github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/tables/factory.go (about)

     1  // Copyright 2021 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package tables
    16  
    17  import (
    18  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog"
    19  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/dbutils"
    20  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/data"
    21  )
    22  
    23  type DataFactory struct {
    24  	dir string
    25  	rt  *dbutils.Runtime
    26  }
    27  
    28  func NewDataFactory(
    29  	rt *dbutils.Runtime, dir string,
    30  ) *DataFactory {
    31  	return &DataFactory{
    32  		dir: dir,
    33  		rt:  rt,
    34  	}
    35  }
    36  
    37  func (factory *DataFactory) MakeTableFactory() catalog.TableDataFactory {
    38  	return func(meta *catalog.TableEntry) data.Table {
    39  		return newTable(meta, factory.rt)
    40  	}
    41  }
    42  
    43  func (factory *DataFactory) MakeObjectFactory() catalog.ObjectDataFactory {
    44  	return func(meta *catalog.ObjectEntry) data.Object {
    45  		if meta.IsAppendable() {
    46  			return newAObject(meta, factory.rt)
    47  		} else {
    48  			return newObject(meta, factory.rt)
    49  		}
    50  	}
    51  }
    52  
    53  func (factory *DataFactory) MakeTombstoneFactory() catalog.TombstoneFactory {
    54  	return DefaultTOmbstoneFactory
    55  }