tuplecodec

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATABASE_ID = "database_id"
	TABLE_ID    = "table_id"
)
View Source
const (
	SystemTenantID uint64 = 1

	//holding the schema of the descriptor table
	InternalDatabaseID uint64 = 0

	//holding the schema of the table
	InternalDescriptorTableID uint64 = 0

	InternalDescriptorTable_parentID_ID        = 0
	InternalDescriptorTable_id_ID              = 1
	InternalDescriptorTable_name_ID            = 2
	InternalDescriptorTable_desc_ID            = 3
	PrimaryIndexID                      uint32 = 1

	//holding the epochgced table
	InternalAsyncGCTableID          uint64 = 1
	InternalAsyncGCTable_epoch_ID          = 0
	InternalAsyncGCTable_dbID_ID           = 1
	InternalAsyncGCTable_tableID_ID        = 2
	InternalAsyncGCTable_desc_ID           = 3

	//user table id offset
	UserTableIDOffset uint64 = 3
)
View Source
const (
	INT64         = "int64"
	UINT64        = "uint64"
	FLOAT64       = "FLOAT64"
	STRING        = "string"
	TYPE_DATE     = "types.Date"
	TYPE_DATETIME = "types.Datetime"
)
View Source
const (
	SERIAL_TYPE_NULL     byte = 0
	SERIAL_TYPE_STRING   byte = SERIAL_TYPE_NULL + 1
	SERIAL_TYPE_BYTES    byte = SERIAL_TYPE_STRING + 1
	SERIAL_TYPE_BOOL     byte = SERIAL_TYPE_BYTES + 1
	SERIAL_TYPE_INT8     byte = SERIAL_TYPE_BOOL + 1
	SERIAL_TYPE_INT16    byte = SERIAL_TYPE_INT8 + 1
	SERIAL_TYPE_INT32    byte = SERIAL_TYPE_INT16 + 1
	SERIAL_TYPE_INT64    byte = SERIAL_TYPE_INT32 + 1
	SERIAL_TYPE_UINT8    byte = SERIAL_TYPE_INT64 + 1
	SERIAL_TYPE_UINT16   byte = SERIAL_TYPE_UINT8 + 1
	SERIAL_TYPE_UINT32   byte = SERIAL_TYPE_UINT16 + 1
	SERIAL_TYPE_UINT64   byte = SERIAL_TYPE_UINT32 + 1
	SERIAL_TYPE_FLOAT32  byte = SERIAL_TYPE_UINT64 + 1
	SERIAL_TYPE_FLOAT64  byte = SERIAL_TYPE_FLOAT32 + 1
	SERIAL_TYPE_DATE     byte = SERIAL_TYPE_FLOAT64 + 1
	SERIAL_TYPE_DATETIME byte = SERIAL_TYPE_DATE + 1
	SERIAL_TYPE_UNKNOWN  byte = 255
)

Variables

View Source
var (
	InternalDatabaseDesc = &descriptor.DatabaseDesc{
		ID:           uint32(InternalDatabaseID),
		Name:         "system",
		Update_time:  0,
		Create_epoch: math.MaxUint64,
		Is_deleted:   false,
		Drop_epoch:   0,
	}
	InternalDescriptorTableDesc = &descriptor.RelationDesc{
		ID:                uint32(InternalDescriptorTableID),
		Name:              "descriptor",
		Update_time:       0,
		Next_attribute_id: 4,
		Attributes: []descriptor.AttributeDesc{
			{
				ID:                0,
				Name:              "parentID",
				Ttype:             orderedcodec.VALUE_TYPE_UINT64,
				TypesType:         toTypesType(types.T_uint64),
				Is_null:           false,
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     true,
				Comment:           "the parent ID of the table and database",
			},
			{
				ID:                1,
				Name:              "ID",
				Ttype:             orderedcodec.VALUE_TYPE_UINT64,
				TypesType:         toTypesType(types.T_uint64),
				Is_null:           false,
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     true,
				Comment:           "the ID of the table and the database",
			},
			{
				ID:                2,
				Name:              "Name",
				Ttype:             orderedcodec.VALUE_TYPE_STRING,
				TypesType:         toTypesType(types.T_varchar),
				Is_null:           false,
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     false,
				Comment:           "the name of the table and the database",
			},
			{
				ID:                3,
				Name:              "desc",
				Ttype:             orderedcodec.VALUE_TYPE_BYTES,
				TypesType:         toTypesType(types.T_varchar),
				Is_null:           false,
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     false,
				Comment:           "the serialized bytes of the descriptor of the table and the database",
			},
		},
		IDependsOnRelations:     nil,
		RelationsDependsOnMe:    nil,
		Next_attribute_group_id: 0,
		AttributeGroups:         nil,
		Primary_index: descriptor.IndexDesc{
			Name:      "primary",
			ID:        PrimaryIndexID,
			Is_unique: true,
			Attributes: []descriptor.IndexDesc_Attribute{
				{
					Name:      "parentID",
					ID:        0,
					Type:      orderedcodec.VALUE_TYPE_UINT64,
					TypesType: toTypesType(types.T_uint64),
				},
				{
					Name:      "ID",
					ID:        1,
					Type:      orderedcodec.VALUE_TYPE_UINT64,
					TypesType: toTypesType(types.T_uint64),
				},
			},
		},
		Next_index_id:     2,
		Indexes:           nil,
		Create_sql:        "hard code",
		Create_time:       0,
		Drop_time:         0,
		Create_epoch:      math.MaxUint64,
		Is_deleted:        false,
		Drop_epoch:        0,
		Max_access_epoch:  0,
		Table_options:     nil,
		Partition_options: nil,
	}

	InternalAsyncGCTableDesc = &descriptor.RelationDesc{
		ID:                uint32(InternalAsyncGCTableID),
		Name:              "asyncgc",
		Update_time:       0,
		Next_attribute_id: 0,
		Attributes: []descriptor.AttributeDesc{
			{
				ID:                0,
				Name:              "epoch",
				Ttype:             orderedcodec.VALUE_TYPE_UINT64,
				TypesType:         toTypesType(types.T_uint64),
				Is_null:           false,
				Default_value:     "",
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     true,
				Comment:           "epoch when the delete happens",
				References:        nil,
				Constrains:        nil,
			},
			{
				ID:                1,
				Name:              "dbID",
				Ttype:             orderedcodec.VALUE_TYPE_UINT64,
				TypesType:         toTypesType(types.T_uint64),
				Is_null:           false,
				Default_value:     "",
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     true,
				Comment:           "the dbID that the table belongs to",
				References:        nil,
				Constrains:        nil,
			},
			{
				ID:                2,
				Name:              "tableID",
				Ttype:             orderedcodec.VALUE_TYPE_UINT64,
				TypesType:         toTypesType(types.T_uint64),
				Is_null:           false,
				Default_value:     "the tableID to be dropped",
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     true,
				Comment:           "",
				References:        nil,
				Constrains:        nil,
			},
			{
				ID:                3,
				Name:              "desc",
				Ttype:             orderedcodec.VALUE_TYPE_BYTES,
				TypesType:         toTypesType(types.T_varchar),
				Default:           engine.DefaultExpr{},
				Is_null:           false,
				Default_value:     "",
				Is_hidden:         false,
				Is_auto_increment: false,
				Is_unique:         false,
				Is_primarykey:     false,
				Comment:           "the descriptor of the table dropped",
				References:        nil,
				Constrains:        nil,
			},
		},
		IDependsOnRelations:     nil,
		RelationsDependsOnMe:    nil,
		Next_attribute_group_id: 0,
		AttributeGroups:         nil,
		Primary_index: descriptor.IndexDesc{
			Name:      "primary",
			ID:        PrimaryIndexID,
			Is_unique: true,
			Attributes: []descriptor.IndexDesc_Attribute{
				{
					Name:      "epoch",
					ID:        0,
					Type:      orderedcodec.VALUE_TYPE_UINT64,
					TypesType: toTypesType(types.T_uint64),
				},
				{
					Name:      "dbID",
					ID:        1,
					Type:      orderedcodec.VALUE_TYPE_UINT64,
					TypesType: toTypesType(types.T_uint64),
				},
				{
					Name:      "tableID",
					ID:        2,
					Type:      orderedcodec.VALUE_TYPE_UINT64,
					TypesType: toTypesType(types.T_uint64),
				},
			},
			Impilict_attributes:  nil,
			Composite_attributes: nil,
			Store_attributes:     nil,
			Key_encoding_type:    0,
			Value_encoding_type:  0,
		},
		Next_index_id:     0,
		Indexes:           nil,
		Create_sql:        "",
		Create_time:       0,
		Drop_time:         0,
		Create_epoch:      math.MaxUint64,
		Is_deleted:        false,
		Drop_epoch:        0,
		Max_access_epoch:  0,
		Table_options:     nil,
		Partition_options: nil,
	}
)
View Source
var ES errorStorage
View Source
var (
	ErrorIsNotShards = errors.New("it is not the shards")
)

Functions

func BeginCpuProfile

func BeginCpuProfile(cpu string) *os.File

func BeginTime

func BeginTime() time.Time

func ConvertAttributeDescIntoTypesType

func ConvertAttributeDescIntoTypesType(attrs []*descriptor.AttributeDesc) ([]string, []*engine.AttributeDef)

func EndCpuProfile

func EndCpuProfile(cpuf *os.File)

func EndTime

func EndTime(s time.Time, info string)

func EngineTypeToTpeType

func EngineTypeToTpeType(t *types.Type) orderedcodec.ValueType

func FillBatch

func FillBatch(lines [][]string, batchData *batch.Batch)

func GetDeleteFlag

func GetDeleteFlag(bat *batch.Batch) bool

judge the operation is delete or insert, true for delete, false for insert

func GetRow

func GetRow(writeCtx interface{}, bat *batch.Batch, row []interface{}, j int) error

func GetRowID

func GetRowID(nodeID uint64) uint64

func InitColIndex

func InitColIndex(indexWriteCtx *WriteContext, bat *batch.Batch)

func IsValid

func IsValid(r Range) bool

IsValid check the Range is valid or not. It is different the IsValid above. IsValid here can accept the nil for the startKey and endKey

func MakeAttributes

func MakeAttributes(ts ...types.T) ([]string, []*engine.AttributeDef)

func MakeBatch

func MakeBatch(batchSize int, attrName []string, cols []*engine.AttributeDef) *batch.Batch

MakeBatch allocates a batch for test

func MarshalDatabaseDesc

func MarshalDatabaseDesc(desc *descriptor.DatabaseDesc) ([]byte, error)

MarshalDatabaseDesc encods the relationDesc into the bytes

func MarshalRelationDesc

func MarshalRelationDesc(desc *descriptor.RelationDesc) ([]byte, error)

MarshalRelationDesc encods the relationDesc into the bytes

func MaxUint64

func MaxUint64(a, b uint64) uint64

func Min

func Min(a, b int) int

func ParseFloat

func ParseFloat(actualData []byte, bitSize int) (interface{}, error)

func ParseInterge

func ParseInterge(actualData []byte, base int, bitSize int, flag bool) (interface{}, error)

func SerializeVectorForBatch

func SerializeVectorForBatch(bat *batch.Batch) error

func TpeTypeToEngineType

func TpeTypeToEngineType(Ttype orderedcodec.ValueType) types.Type

func TruncateBatch

func TruncateBatch(bat *batch.Batch, batchSize, needLen int)

func Uint64ToString

func Uint64ToString(v uint64) string

func UnmarshalDatabaseDesc

func UnmarshalDatabaseDesc(data []byte) (*descriptor.DatabaseDesc, error)

UnmarshalDatabaseDesc decodes the bytes into the databaseDesc

func UnmarshalRelationDesc

func UnmarshalRelationDesc(data []byte) (*descriptor.RelationDesc, error)

UnmarshalRelationDesc decodes the bytes into the relationDesc

Types

type AttributeMap

type AttributeMap struct {
	// contains filtered or unexported fields
}

func (*AttributeMap) Append

func (am *AttributeMap) Append(id, positionInValue, positionInBatch int)

func (*AttributeMap) BuildPositionInDecodedItemArray

func (am *AttributeMap) BuildPositionInDecodedItemArray()

func (*AttributeMap) Get

func (am *AttributeMap) Get(i int) (int, int, int, int)

func (*AttributeMap) GetAttributeAtSortedIndex

func (am *AttributeMap) GetAttributeAtSortedIndex(i int) int

func (*AttributeMap) Length

func (am *AttributeMap) Length() int

type AttributeStateForWrite

type AttributeStateForWrite struct {
	PositionInBatch int

	//true - the attribute value should be generated.
	//false - the attribute value got from the batch.
	NeedGenerated bool

	AttrDesc descriptor.AttributeDesc

	//the value for the attribute especially for
	//the implicit primary key
	ImplicitPrimaryKey interface{}
}

type BatchAdapter

type BatchAdapter struct {
	// contains filtered or unexported fields
}

BatchAdapter for convenient access to the batch

func NewBatchAdapter

func NewBatchAdapter(bat *batch.Batch) *BatchAdapter

func (*BatchAdapter) ForEachTuple

func (ba *BatchAdapter) ForEachTuple(callbackCtx interface{},
	callback func(callbackCtx interface{}, tuple Tuple) error) error

ForEachTuple process every row with callback function in the batch

type CompactValueLayoutSerializer

type CompactValueLayoutSerializer struct {
	Serializer ValueSerializer
	// contains filtered or unexported fields
}

CompactValueLayoutSerializer defines a compact layout of the value

The Layout of the value: | The Control Byte(first byte) | The Column Group (option) | The Attributes Storage Section | | | Attributes Offset Section | Attributes Section | | The count of Attributes | Attribute Offset Array | Attribute 1 Format, Attribute 2 Format,.... | | Attribute 1 offset, Attribute 2 offset,...|

The layout of the Attribute X Format: | The Value Type(first byte) | Attribute X's ID (option) | The serialized bytes of the Attribute X |

Control Byte : bit7:0-primary index;1-secondary index。 bit6: 0-no column group; 1-has column group。 bit5: 0-The Attribute X Format does not have Attribute ID;1-The Attribute X Format has Attribute ID bit4~bit3 : used in secondary index bit0~bit2: the offset of the Attributes Offset Section

func (*CompactValueLayoutSerializer) Deserialize

func (cvls *CompactValueLayoutSerializer) Deserialize(data []byte, amForValue *AttributeMap) ([]byte, []*orderedcodec.DecodedItem, []*ValueDecodedItem, error)

func (*CompactValueLayoutSerializer) GetPositionsOfAttributesInTheValue

func (cvls *CompactValueLayoutSerializer) GetPositionsOfAttributesInTheValue(tableDesc *descriptor.RelationDesc, indexDesc *descriptor.IndexDesc) map[uint32]int

func (*CompactValueLayoutSerializer) Serialize

func (cvls *CompactValueLayoutSerializer) Serialize(out []byte, ctx *ValueLayoutContext) ([]byte, error)

Serialize serializes the tuple Now we just consider the primary index

type ComputationHandlerImpl

type ComputationHandlerImpl struct {
	// contains filtered or unexported fields
}

func NewComputationHandlerImpl

func NewComputationHandlerImpl(dh descriptor.DescriptorHandler, kv KVHandler, tch *TupleCodecHandler, serial ValueSerializer, ih index.IndexHandler, epoch *EpochHandler, parallelReader bool, multiNode bool) *ComputationHandlerImpl

func (*ComputationHandlerImpl) CreateDatabase

func (chi *ComputationHandlerImpl) CreateDatabase(epoch uint64, dbName string, typ int) (uint64, error)

func (*ComputationHandlerImpl) CreateTable

func (chi *ComputationHandlerImpl) CreateTable(epoch, dbId uint64, tableDesc *descriptor.RelationDesc) (uint64, error)

func (*ComputationHandlerImpl) DropDatabase

func (chi *ComputationHandlerImpl) DropDatabase(epoch uint64, dbName string) error

func (*ComputationHandlerImpl) DropTable

func (chi *ComputationHandlerImpl) DropTable(epoch, dbId uint64, tableName string) (uint64, error)

func (*ComputationHandlerImpl) DropTableByDesc

func (chi *ComputationHandlerImpl) DropTableByDesc(epoch, dbId uint64, tableDesc *descriptor.RelationDesc) (uint64, error)

func (*ComputationHandlerImpl) GetDatabase

func (chi *ComputationHandlerImpl) GetDatabase(dbName string) (*descriptor.DatabaseDesc, error)

func (*ComputationHandlerImpl) GetNodesHoldTheTable

func (chi *ComputationHandlerImpl) GetNodesHoldTheTable(dbId uint64, desc *descriptor.RelationDesc) (engine.Nodes, interface{}, error)

func (*ComputationHandlerImpl) GetTable

func (chi *ComputationHandlerImpl) GetTable(dbId uint64, name string) (*descriptor.RelationDesc, error)

func (*ComputationHandlerImpl) ListDatabases

func (chi *ComputationHandlerImpl) ListDatabases() ([]*descriptor.DatabaseDesc, error)

func (*ComputationHandlerImpl) ListTables

func (chi *ComputationHandlerImpl) ListTables(dbId uint64) ([]*descriptor.RelationDesc, error)

func (*ComputationHandlerImpl) MultiNode

func (chi *ComputationHandlerImpl) MultiNode() bool

func (*ComputationHandlerImpl) ParallelReader

func (chi *ComputationHandlerImpl) ParallelReader() bool

func (*ComputationHandlerImpl) Read

func (chi *ComputationHandlerImpl) Read(readCtx interface{}) (*batch.Batch, error)

func (*ComputationHandlerImpl) RemoveDeletedTable

func (chi *ComputationHandlerImpl) RemoveDeletedTable(epoch uint64) (int, error)

func (*ComputationHandlerImpl) Write

func (chi *ComputationHandlerImpl) Write(writeCtx interface{}, bat *batch.Batch) error

type ConciseSerializer

type ConciseSerializer struct {
}

func (*ConciseSerializer) DeserializeValue

func (cs *ConciseSerializer) DeserializeValue(data []byte) ([]byte, *orderedcodec.DecodedItem, error)

func (*ConciseSerializer) SerializeValue

func (cs *ConciseSerializer) SerializeValue(data []byte, value interface{}) ([]byte, *orderedcodec.EncodedItem, error)

type CubeKV

type CubeKV struct {
	Cube driver.CubeDriver
	// contains filtered or unexported fields
}

func NewCubeKV

func NewCubeKV(cd driver.CubeDriver, limit uint64, tpeDedupSetBatchTimeout time.Duration, tpeDedupSetBatchTryCount int, tpeScanTimeout time.Duration, tpeScanTryCount int) (*CubeKV, error)

func (*CubeKV) DedupSet

func (ck *CubeKV) DedupSet(key TupleKey, value TupleValue) error

func (*CubeKV) DedupSetBatch

func (ck *CubeKV) DedupSetBatch(keys []TupleKey, values []TupleValue) error

func (*CubeKV) Delete

func (ck *CubeKV) Delete(key TupleKey) error

func (*CubeKV) DeleteWithPrefix

func (ck *CubeKV) DeleteWithPrefix(prefix TupleKey) error

func (*CubeKV) Get

func (ck *CubeKV) Get(key TupleKey) (TupleValue, error)

Get gets the value of the key. If the key does not exist, it returns the null

func (*CubeKV) GetBatch

func (ck *CubeKV) GetBatch(keys []TupleKey) ([]TupleValue, error)

func (*CubeKV) GetKVType

func (ck *CubeKV) GetKVType() KVType

func (*CubeKV) GetRange

func (ck *CubeKV) GetRange(startKey TupleKey, endKey TupleKey) ([]TupleValue, error)

func (*CubeKV) GetRangeWithLimit

func (ck *CubeKV) GetRangeWithLimit(startKey TupleKey, endKey TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*CubeKV) GetRangeWithPrefixLimit

func (ck *CubeKV) GetRangeWithPrefixLimit(startKey TupleKey, endKey TupleKey, prefix TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*CubeKV) GetShardsWithPrefix

func (ck *CubeKV) GetShardsWithPrefix(prefix TupleKey) (interface{}, error)

func (*CubeKV) GetShardsWithRange

func (ck *CubeKV) GetShardsWithRange(startKey TupleKey, endKey TupleKey) (interface{}, error)

func (*CubeKV) GetWithPrefix

func (ck *CubeKV) GetWithPrefix(prefixOrStartkey TupleKey, prefixLen int, prefixEnd []byte, needKeyOnly bool, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*CubeKV) NextID

func (ck *CubeKV) NextID(typ string) (uint64, error)

func (*CubeKV) Set

func (ck *CubeKV) Set(key TupleKey, value TupleValue) error

func (*CubeKV) SetBatch

func (ck *CubeKV) SetBatch(keys []TupleKey, values []TupleValue) error

type CubeShards

type CubeShards struct {
	Shards []metapb.Shard `json:"shards"`
}

func (CubeShards) String

func (cs CubeShards) String() string

type DefaultValue

type DefaultValue struct {
	ValueType string      `json:"value_type"`
	Value     interface{} `json:"value,string"`
}

type DefaultValueLayoutSerializer

type DefaultValueLayoutSerializer struct {
	Serializer ValueSerializer
}

DefaultValueLayoutSerializer defines a default layout of the value

The Layout of the value:

The attributes in the value keep the same order as they defined in the relation.

| Attribute1,Attribute2,... |

func (*DefaultValueLayoutSerializer) Deserialize

func (dvls *DefaultValueLayoutSerializer) Deserialize(data []byte, amForValue *AttributeMap) ([]byte, []*orderedcodec.DecodedItem, []*ValueDecodedItem, error)

func (*DefaultValueLayoutSerializer) GetPositionsOfAttributesInTheValue

func (dvls *DefaultValueLayoutSerializer) GetPositionsOfAttributesInTheValue(tableDesc *descriptor.RelationDesc, indexDesc *descriptor.IndexDesc) map[uint32]int

func (*DefaultValueLayoutSerializer) Serialize

func (dvls *DefaultValueLayoutSerializer) Serialize(out []byte, ctx *ValueLayoutContext) ([]byte, error)

type DefaultValueSerializer

type DefaultValueSerializer struct{}

func (*DefaultValueSerializer) DeserializeValue

func (dvs *DefaultValueSerializer) DeserializeValue(data []byte) ([]byte, *orderedcodec.DecodedItem, error)

DeserializeValue deserializes the data

func (*DefaultValueSerializer) SerializeValue

func (dvs *DefaultValueSerializer) SerializeValue(data []byte, value interface{}) ([]byte, *orderedcodec.EncodedItem, error)

SerializeValue serializes the value with json

type DescriptorHandlerImpl

type DescriptorHandlerImpl struct {
	// contains filtered or unexported fields
}

func NewDescriptorHandlerImpl

func NewDescriptorHandlerImpl(codec *TupleCodecHandler,
	kv KVHandler,
	vs ValueSerializer,
	limit uint64) *DescriptorHandlerImpl

func (*DescriptorHandlerImpl) DeleteDatabaseDescByID

func (dhi *DescriptorHandlerImpl) DeleteDatabaseDescByID(dbID uint64) error

func (*DescriptorHandlerImpl) DeleteRelationDescByID

func (dhi *DescriptorHandlerImpl) DeleteRelationDescByID(parentID uint64, tableID uint64) error

func (*DescriptorHandlerImpl) GetValuesWithPrefix

func (dhi *DescriptorHandlerImpl) GetValuesWithPrefix(parentID uint64, callbackCtx interface{}, callback func(callbackCtx interface{}, dis []*orderedcodec.DecodedItem) ([]byte, error)) ([]byte, error)

getValueByName gets the value for the key by the name

func (*DescriptorHandlerImpl) ListRelationDescFromAsyncGC

func (dhi *DescriptorHandlerImpl) ListRelationDescFromAsyncGC(epoch uint64) ([]descriptor.EpochGCItem, error)

func (*DescriptorHandlerImpl) LoadDatabaseDescByID

func (dhi *DescriptorHandlerImpl) LoadDatabaseDescByID(dbID uint64) (*descriptor.DatabaseDesc, error)

func (*DescriptorHandlerImpl) LoadDatabaseDescByName

func (dhi *DescriptorHandlerImpl) LoadDatabaseDescByName(name string) (*descriptor.DatabaseDesc, error)

func (*DescriptorHandlerImpl) LoadRelationDescByID

func (dhi *DescriptorHandlerImpl) LoadRelationDescByID(parentID uint64, tableID uint64) (*descriptor.RelationDesc, error)

func (*DescriptorHandlerImpl) LoadRelationDescByName

func (dhi *DescriptorHandlerImpl) LoadRelationDescByName(parentID uint64, name string) (*descriptor.RelationDesc, error)

func (*DescriptorHandlerImpl) MakePrefixWithEpochAndDBIDAndTableID

func (dhi *DescriptorHandlerImpl) MakePrefixWithEpochAndDBIDAndTableID(
	dbID uint64, tableID uint64, indexID uint64,
	gcEpoch uint64, gcDbID uint64, gcTableID uint64) (TupleKey, *orderedcodec.EncodedItem)

MakePrefixWithEpochAndDBIDAndTableID makes the prefix(tenantID,dbID,tableID,indexID,delEpoch,delDbID,delTableID)

func (*DescriptorHandlerImpl) MakePrefixWithOneExtraID

func (dhi *DescriptorHandlerImpl) MakePrefixWithOneExtraID(dbID uint64, tableID uint64, indexID uint64, extraID uint64) ([]byte, *orderedcodec.EncodedItem)

MakePrefixWithParentID makes the prefix(tenantID,dbID,tableID,indexID,parentID)

func (*DescriptorHandlerImpl) StoreDatabaseDescByID

func (dhi *DescriptorHandlerImpl) StoreDatabaseDescByID(dbID uint64, dbDesc *descriptor.DatabaseDesc) error

StoreDatabaseDescByID saves the descriptor. It will overwrite the exists one.

func (*DescriptorHandlerImpl) StoreDatabaseDescByName

func (dhi *DescriptorHandlerImpl) StoreDatabaseDescByName(name string, dbDesc *descriptor.DatabaseDesc) error

func (*DescriptorHandlerImpl) StoreRelationDescByID

func (dhi *DescriptorHandlerImpl) StoreRelationDescByID(parentID uint64, tableID uint64, tableDesc *descriptor.RelationDesc) error

StoreRelationDescByID saves the descriptor. It will overwrite the exists one.

func (*DescriptorHandlerImpl) StoreRelationDescByName

func (dhi *DescriptorHandlerImpl) StoreRelationDescByName(parentID uint64, name string, tableDesc *descriptor.RelationDesc) error

func (*DescriptorHandlerImpl) StoreRelationDescIntoAsyncGC

func (dhi *DescriptorHandlerImpl) StoreRelationDescIntoAsyncGC(epoch uint64, dbID uint64, desc *descriptor.RelationDesc) error

type EpochHandler

type EpochHandler struct {
	// contains filtered or unexported fields
}

func (*EpochHandler) GetEpoch

func (eh *EpochHandler) GetEpoch() uint64

func (*EpochHandler) RemoveDeletedTable

func (eh *EpochHandler) RemoveDeletedTable(epoch uint64) (int, error)

func (*EpochHandler) SetEpoch

func (eh *EpochHandler) SetEpoch(e uint64)

type FlatSerializer

type FlatSerializer struct {
}

func (*FlatSerializer) DeserializeValue

func (fs *FlatSerializer) DeserializeValue(data []byte) ([]byte, *orderedcodec.DecodedItem, error)

func (*FlatSerializer) SerializeValue

func (fs *FlatSerializer) SerializeValue(data []byte, value interface{}) ([]byte, *orderedcodec.EncodedItem, error)

type IDPool

type IDPool struct {
	// contains filtered or unexported fields
}

type IndexHandlerImpl

type IndexHandlerImpl struct {
	PBKV *pebble.Storage
	// contains filtered or unexported fields
}

func (*IndexHandlerImpl) DeleteFromIndex

func (ihi *IndexHandlerImpl) DeleteFromIndex(writeCtx interface{}, bat *batch.Batch) error

func (*IndexHandlerImpl) DeleteFromTable

func (ihi *IndexHandlerImpl) DeleteFromTable(writeCtx interface{}, bat *batch.Batch) error

func (*IndexHandlerImpl) DumpReadFromIndex

func (ihi *IndexHandlerImpl) DumpReadFromIndex(readCtx interface{}) (*batch.Batch, int, error)

func (*IndexHandlerImpl) ReadFromIndex

func (ihi *IndexHandlerImpl) ReadFromIndex(readCtx interface{}) (*batch.Batch, int, error)

func (*IndexHandlerImpl) UpdateIntoIndex

func (ihi *IndexHandlerImpl) UpdateIntoIndex(writeCtx interface{}, bat *batch.Batch) error

func (*IndexHandlerImpl) WriteIntoIndex

func (ihi *IndexHandlerImpl) WriteIntoIndex(writeCtx interface{}, bat *batch.Batch) error

func (*IndexHandlerImpl) WriteIntoTable

func (ihi *IndexHandlerImpl) WriteIntoTable(table *descriptor.RelationDesc, writeCtx interface{}, bat *batch.Batch) error

type KVHandler

type KVHandler interface {
	GetKVType() KVType

	// NextID gets the next id of the type
	NextID(typ string) (uint64, error)

	// Set writes the key-value (overwrite)
	Set(key TupleKey, value TupleValue) error

	// SetBatch writes the batch of key-value (overwrite)
	SetBatch(keys []TupleKey, values []TupleValue) error

	// DedupSet writes the key-value. It will fail if the key exists
	DedupSet(key TupleKey, value TupleValue) error

	// DedupSetBatch writes the batch of keys-values. It will fail if there is one key exists
	DedupSetBatch(keys []TupleKey, values []TupleValue) error

	// Delete deletes the key
	Delete(key TupleKey) error

	// DeleteWithPrefix keys with the prefix
	DeleteWithPrefix(prefix TupleKey) error

	// Get gets the value of the key
	Get(key TupleKey) (TupleValue, error)

	// GetBatch gets the values of the keys
	GetBatch(keys []TupleKey) ([]TupleValue, error)

	// GetRange gets the values among the range [startKey,endKey).
	GetRange(startKey TupleKey, endKey TupleKey) ([]TupleValue, error)

	// GetRangeWithLimit gets the values from the startKey with limit
	//return parameters:
	//[][]byte : return keys
	//[][]byte : return values
	//bool: true - the scanner accomplished in all shards.
	//[]byte : the start key for the next scan. If last parameter is false, this parameter is nil.
	GetRangeWithLimit(startKey TupleKey, endKey TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

	GetRangeWithPrefixLimit(startKey TupleKey, endKey TupleKey, prefix TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

	// GetWithPrefix gets the values of the prefix with limit.
	// The prefixLen denotes the prefix[:prefixLen] is the real prefix.
	// When we invoke GetWithPrefix several times, the prefix is the real
	// prefix in the first time. But from the second time, the prefix is the
	// last key in previous results of the GetWithPrefix.
	//return parameters:
	//[][]byte : return keys
	//[][]byte : return values
	//bool: true - the scanner accomplished in all shards.
	//[]byte : the start key for the next scan. If last parameter is false, this parameter is nil.
	GetWithPrefix(prefixOrStartkey TupleKey, prefixLen int, prefixEnd []byte, needKeyOnly bool, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

	// GetShardsWithRange get the shards that holds the range [startKey,endKey)
	GetShardsWithRange(startKey TupleKey, endKey TupleKey) (interface{}, error)

	// GetShardsWithPrefix get the shards that holds the keys with prefix
	GetShardsWithPrefix(prefix TupleKey) (interface{}, error)
}

type KVType

type KVType int
const (
	KV_MEMORY KVType = iota
	KV_CUBE   KVType = iota + 1
)

type MemoryItem

type MemoryItem struct {
	// contains filtered or unexported fields
}

func NewMemoryItem

func NewMemoryItem(key TupleKey, value TupleValue) *MemoryItem

func (*MemoryItem) Less

func (m *MemoryItem) Less(than btree.Item) bool

type MemoryKV

type MemoryKV struct {
	// contains filtered or unexported fields
}

MemoryKV for test

func NewMemoryKV

func NewMemoryKV() *MemoryKV

func (*MemoryKV) DedupSet

func (m *MemoryKV) DedupSet(key TupleKey, value TupleValue) error

func (*MemoryKV) DedupSetBatch

func (m *MemoryKV) DedupSetBatch(keys []TupleKey, values []TupleValue) error

func (*MemoryKV) Delete

func (m *MemoryKV) Delete(key TupleKey) error

func (*MemoryKV) DeleteWithPrefix

func (m *MemoryKV) DeleteWithPrefix(prefix TupleKey) error

func (*MemoryKV) Get

func (m *MemoryKV) Get(key TupleKey) (TupleValue, error)

func (*MemoryKV) GetBatch

func (m *MemoryKV) GetBatch(keys []TupleKey) ([]TupleValue, error)

func (*MemoryKV) GetKVType

func (m *MemoryKV) GetKVType() KVType

func (*MemoryKV) GetRange

func (m *MemoryKV) GetRange(startKey TupleKey, endKey TupleKey) ([]TupleValue, error)

func (*MemoryKV) GetRangeWithLimit

func (m *MemoryKV) GetRangeWithLimit(startKey TupleKey, endKey TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*MemoryKV) GetRangeWithPrefixLimit

func (m *MemoryKV) GetRangeWithPrefixLimit(startKey TupleKey, endKey TupleKey, prefix TupleKey, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*MemoryKV) GetShardsWithPrefix

func (m *MemoryKV) GetShardsWithPrefix(prefix TupleKey) (interface{}, error)

func (*MemoryKV) GetShardsWithRange

func (m *MemoryKV) GetShardsWithRange(startKey TupleKey, endKey TupleKey) (interface{}, error)

func (*MemoryKV) GetWithPrefix

func (m *MemoryKV) GetWithPrefix(prefixOrStartkey TupleKey, prefixLen int, prefixEnd []byte, needKeyOnly bool, limit uint64) ([]TupleKey, []TupleValue, bool, TupleKey, error)

func (*MemoryKV) NextID

func (m *MemoryKV) NextID(typ string) (uint64, error)

func (*MemoryKV) PrintKeys

func (m *MemoryKV) PrintKeys()

func (*MemoryKV) Set

func (m *MemoryKV) Set(key TupleKey, value TupleValue) error

func (*MemoryKV) SetBatch

func (m *MemoryKV) SetBatch(keys []TupleKey, values []TupleValue) error

type ParallelReaderContext

type ParallelReaderContext struct {
	ID int

	//index in shard info
	ShardIndex int

	//the startKey of the shard
	ShardStartKey []byte

	//the endKey of the shard
	ShardEndKey []byte

	//the next scan key of the shard
	ShardNextScanKey []byte

	//scan end key for the shard
	ShardScanEndKey []byte

	//finished ?
	CompleteInShard bool

	ReadCnt int

	CountOfWithoutPrefix int
}

for parallel readers

func (*ParallelReaderContext) Reset

func (prc *ParallelReaderContext) Reset()

func (*ParallelReaderContext) Set

func (prc *ParallelReaderContext) Set(id, shardIndex int)

func (*ParallelReaderContext) SetShardInfo

func (prc *ParallelReaderContext) SetShardInfo(shardStartKey, shardEndKey, nextScanKeyInShard, scanEndKeyInShard []byte)

func (ParallelReaderContext) String

func (prc ParallelReaderContext) String() string

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range for [startKey, endKey)

func (Range) Contain

func (r Range) Contain(key TupleKey) bool

Contain checks the key in the range

func (Range) ContainRange

func (r Range) ContainRange(another Range) bool

Contain check the range contains the another range.

func (Range) Equal

func (r Range) Equal(another Range) bool

Equal checks the range is equal to the another range.

func (Range) Intersect

func (r Range) Intersect(another Range) Range

Intersect gets the intersected range.

func (Range) IsValid

func (r Range) IsValid() bool

func (Range) Merge

func (r Range) Merge(another Range) Range

Merge merges two ranges

func (Range) Overlap

func (r Range) Overlap(another Range) bool

Overlap checks the range overlaps or not.

type ReadContext

type ReadContext struct {
	//target database,table and index
	DbDesc    *descriptor.DatabaseDesc
	TableDesc *descriptor.RelationDesc
	IndexDesc *descriptor.IndexDesc

	//the attributes to be read
	ReadAttributesNames []string

	//the attributes for the read
	ReadAttributeDescs []*descriptor.AttributeDesc

	ParallelReader bool

	MultiNode bool

	//for test
	ReadCount int

	ParallelReaderContext

	SingleReaderContext

	DumpData bool // dumpData flag

	Opt *batch.DumpOption
}

func (*ReadContext) AddReadCount

func (rc *ReadContext) AddReadCount() int

type RowColumnConverter

type RowColumnConverter interface {
	GetTupleFromBatch(bat *batch.Batch, rowID int) (Tuple, error)

	GetTuplesFromBatch(bat *batch.Batch) (Tuples, error)

	//FillBatchFromDecodedIndexKey fills the batch at row i with the data from the decoded key
	//the attributeID are wanted attribute.
	FillBatchFromDecodedIndexKey(index *descriptor.IndexDesc,
		columnGroupID uint64, attributes []*orderedcodec.DecodedItem,
		am *AttributeMap, bat *batch.Batch, rowIndex int) error

	//FillBatchFromDecodedIndexValue fills the batch at row i with the data from the decoded value
	//the attributeID are wanted attribute.
	FillBatchFromDecodedIndexValue(index *descriptor.IndexDesc,
		columnGroupID uint64, attributes []*orderedcodec.DecodedItem,
		am *AttributeMap, bat *batch.Batch, rowIndex int) error

	FillBatchFromDecodedIndexValue2(index *descriptor.IndexDesc,
		columnGroupID uint64, attributes []*ValueDecodedItem,
		am *AttributeMap, bat *batch.Batch, rowIndex int) error

	//FillBatchFromDecodedIndexKeyValue fills the batch at row i with the data from the decoded key and value
	//the attributeID are wanted attribute.
	FillBatchFromDecodedIndexKeyValue(index *descriptor.IndexDesc,
		columnGroupID uint64,
		keyAttributes []*orderedcodec.DecodedItem,
		valueAttributes []*orderedcodec.DecodedItem,
		amForKey *AttributeMap, amForValue *AttributeMap,
		bat *batch.Batch, rowIndex int) error
}

type RowColumnConverterImpl

type RowColumnConverterImpl struct{}

func (*RowColumnConverterImpl) FillBatchFromDecodedIndexKey

func (tbi *RowColumnConverterImpl) FillBatchFromDecodedIndexKey(
	index *descriptor.IndexDesc,
	columnGroupID uint64,
	attributes []*orderedcodec.DecodedItem,
	am *AttributeMap,
	bat *batch.Batch,
	rowIdx int) error

func (*RowColumnConverterImpl) FillBatchFromDecodedIndexKeyValue

func (tbi *RowColumnConverterImpl) FillBatchFromDecodedIndexKeyValue(
	index *descriptor.IndexDesc,
	columnGroupID uint64,
	keyAttributes []*orderedcodec.DecodedItem,
	valueAttributes []*orderedcodec.DecodedItem,
	amForKey *AttributeMap, amForValue *AttributeMap,
	bat *batch.Batch,
	rowIdx int) error

func (*RowColumnConverterImpl) FillBatchFromDecodedIndexValue

func (tbi *RowColumnConverterImpl) FillBatchFromDecodedIndexValue(
	index *descriptor.IndexDesc,
	columnGroupID uint64,
	attributes []*orderedcodec.DecodedItem,
	am *AttributeMap,
	bat *batch.Batch,
	rowIdx int) error

func (*RowColumnConverterImpl) FillBatchFromDecodedIndexValue2

func (tbi *RowColumnConverterImpl) FillBatchFromDecodedIndexValue2(index *descriptor.IndexDesc,
	columnGroupID uint64, attributes []*ValueDecodedItem,
	am *AttributeMap, bat *batch.Batch, rowIdx int) error

func (*RowColumnConverterImpl) GetTupleFromBatch

func (tbi *RowColumnConverterImpl) GetTupleFromBatch(bat *batch.Batch, rowID int) (Tuple, error)

func (*RowColumnConverterImpl) GetTuplesFromBatch

func (tbi *RowColumnConverterImpl) GetTuplesFromBatch(bat *batch.Batch) (Tuples, error)

type SerializerType

type SerializerType int
const (
	ST_JSON    SerializerType = iota
	ST_CONCISE SerializerType = iota + 1
	ST_FLAT    SerializerType = iota + 2
)

type ShardInfo

type ShardInfo struct {
	// contains filtered or unexported fields
}

func (ShardInfo) GetEndKey

func (si ShardInfo) GetEndKey() []byte

func (ShardInfo) GetShardID

func (si ShardInfo) GetShardID() uint64

func (ShardInfo) GetShardNode

func (si ShardInfo) GetShardNode() ShardNode

func (ShardInfo) GetStartKey

func (si ShardInfo) GetStartKey() []byte

func (ShardInfo) GetStatistics

func (si ShardInfo) GetStatistics() metapb.ShardStats

type ShardNode

type ShardNode struct {
	//the address of the store of the leader replica of the shard
	Addr string
	//the id of the store of the leader replica of the shard
	StoreID uint64
	//the bytes of the id
	StoreIDbytes string
	//shards the node will read
	Shards CubeShards
}

type Shards

type Shards struct {
	// contains filtered or unexported fields
}

func (Shards) GetShardInfos

func (s Shards) GetShardInfos() []ShardInfo

func (Shards) GetShardNodes

func (s Shards) GetShardNodes() []ShardNode

func (*Shards) SetShardInfos

func (s *Shards) SetShardInfos(infos []ShardInfo)

func (*Shards) SetShardNodes

func (s *Shards) SetShardNodes(nodes []ShardNode)

type SingleReaderContext

type SingleReaderContext struct {
	//true -- the scanner has scanned all shards
	CompleteInAllShards bool

	//for prefix scan in next time
	PrefixForScanKey []byte

	//the length of the prefix
	LengthOfPrefixForScanKey int

	PrefixEnd []byte
}

type Tuple

type Tuple interface {
	GetAttributeCount() (uint32, error)

	GetAttribute(colIdx uint32) (types.Type, string, error)

	IsNull(colIdx uint32) (bool, error)

	GetValue(colIdx uint32) (interface{}, error)

	GetInt(colIdx uint32) (int, error)
}

Tuple denotes the row of the relation

type TupleBatchImpl

type TupleBatchImpl struct {
	// contains filtered or unexported fields
}

func NewTupleBatchImpl

func NewTupleBatchImpl(bat *batch.Batch, row []interface{}) *TupleBatchImpl

func (*TupleBatchImpl) GetAttribute

func (tbi *TupleBatchImpl) GetAttribute(colIdx uint32) (types.Type, string, error)

func (*TupleBatchImpl) GetAttributeCount

func (tbi *TupleBatchImpl) GetAttributeCount() (uint32, error)

func (*TupleBatchImpl) GetInt

func (tbi *TupleBatchImpl) GetInt(colIdx uint32) (int, error)

func (*TupleBatchImpl) GetValue

func (tbi *TupleBatchImpl) GetValue(colIdx uint32) (interface{}, error)

func (*TupleBatchImpl) IsNull

func (tbi *TupleBatchImpl) IsNull(colIdx uint32) (bool, error)

type TupleCodecHandler

type TupleCodecHandler struct {
	// contains filtered or unexported fields
}

func NewTupleCodecHandler

func NewTupleCodecHandler(tenantID uint64) *TupleCodecHandler

func (*TupleCodecHandler) GetDecoder

func (tch *TupleCodecHandler) GetDecoder() *TupleKeyDecoder

func (*TupleCodecHandler) GetEncoder

func (tch *TupleCodecHandler) GetEncoder() *TupleKeyEncoder

type TupleKey

type TupleKey []byte

func SuccessorOfKey

func SuccessorOfKey(key TupleKey) TupleKey

SuccessorOfKey gets the successor of the key. Carefully, key can not be changed.

func SuccessorOfPrefix

func SuccessorOfPrefix(prefix TupleKey) TupleKey

SuccessorOfPrefix gets the successor of the prefix

func (TupleKey) Compare

func (tk TupleKey) Compare(another TupleKey) int

Compare compares the key with another key

func (TupleKey) Equal

func (tk TupleKey) Equal(another TupleKey) bool

Equal decides the key is equal to another key

func (TupleKey) IsPredecessor

func (tk TupleKey) IsPredecessor(another TupleKey) bool

IsPredecessor decides the is the predecessor of the another key

func (TupleKey) Less

func (tk TupleKey) Less(another TupleKey) bool

Less decides the key is less than another key

type TupleKeyDecoder

type TupleKeyDecoder struct {
	// contains filtered or unexported fields
}

func NewTupleKeyDecoder

func NewTupleKeyDecoder(tenantID uint64) *TupleKeyDecoder

func (*TupleKeyDecoder) DecodeDatabasePrefix

func (tkd *TupleKeyDecoder) DecodeDatabasePrefix(key TupleKey) (TupleKey, *orderedcodec.DecodedItem, error)

DecodeDatabasePrefix decodes database ID and returns the rest.

func (*TupleKeyDecoder) DecodeIndexPrefix

func (tkd *TupleKeyDecoder) DecodeIndexPrefix(key TupleKey) (TupleKey, []*orderedcodec.DecodedItem, error)

DecodeIndexPrefix decodes database ID, table ID and index ID and returns the rest.

func (*TupleKeyDecoder) DecodePrimaryIndexKey

func (tkd *TupleKeyDecoder) DecodePrimaryIndexKey(key TupleKey, index *descriptor.IndexDesc) (TupleKey, []*orderedcodec.DecodedItem, error)

DecodePrimaryIndexKey decodes fields of the primary index and returns the rest. The dbID,tableID and Index ID have been decoded.

func (*TupleKeyDecoder) DecodePrimaryIndexValue

func (tkd *TupleKeyDecoder) DecodePrimaryIndexValue(value TupleValue, index *descriptor.IndexDesc, columnGroupID uint64, serializer ValueSerializer) (TupleValue, []*orderedcodec.DecodedItem, error)

DecodePrimaryIndexValue decodes the values of the primary index and return the rest. Now,it decodes all tuple.

func (*TupleKeyDecoder) DecodeTablePrefix

func (tkd *TupleKeyDecoder) DecodeTablePrefix(key TupleKey) (TupleKey, []*orderedcodec.DecodedItem, error)

DecodeTablePrefix decodes table ID and returns the rest.

func (*TupleKeyDecoder) GetTenantPrefix

func (tkd *TupleKeyDecoder) GetTenantPrefix() TupleKey

func (*TupleKeyDecoder) SkipTenantPrefix

func (tkd *TupleKeyDecoder) SkipTenantPrefix(key TupleKey) (TupleKey, error)

SkipTenantPrefix skips the tenant prefix wanted and returns the rest.

type TupleKeyEncoder

type TupleKeyEncoder struct {
	// contains filtered or unexported fields
}

func NewTupleKeyEncoder

func NewTupleKeyEncoder(tenantID uint64) *TupleKeyEncoder

func (*TupleKeyEncoder) EncodeDatabasePrefix

func (tke *TupleKeyEncoder) EncodeDatabasePrefix(prefix TupleKey, dbID uint64) (TupleKey, *orderedcodec.EncodedItem)

EncodeDatabasePrefix encodes the database prefix

func (*TupleKeyEncoder) EncodeIndexPrefix

func (tke *TupleKeyEncoder) EncodeIndexPrefix(prefix TupleKey, dbID uint64, tableID, indexID uint64) (TupleKey, *orderedcodec.EncodedItem)

EncodeIndexPrefix encodes the index prefix

func (*TupleKeyEncoder) EncodePrimaryIndexKey

func (tke *TupleKeyEncoder) EncodePrimaryIndexKey(prefix TupleKey,
	index *descriptor.IndexDesc,
	columnGroupID uint64,
	tuple Tuple) (TupleKey, *orderedcodec.EncodedItem, error)

EncodePrimaryIndexKey encodes the tuple into bytes. The prefix has the tenantID,dbID,tableID,IndexID.

func (*TupleKeyEncoder) EncodePrimaryIndexValue

func (tke *TupleKeyEncoder) EncodePrimaryIndexValue(prefix TupleValue,
	index *descriptor.IndexDesc,
	columnGroupID uint64,
	tuple Tuple,
	serializer ValueSerializer) (TupleValue, *orderedcodec.EncodedItem, error)

EncodePrimaryIndexValue encodes the tuple into bytes

func (*TupleKeyEncoder) EncodeTablePrefix

func (tke *TupleKeyEncoder) EncodeTablePrefix(prefix TupleKey, dbID uint64, tableID uint64) (TupleKey, *orderedcodec.EncodedItem)

EncodeTablePrefix encodes the table prefix

func (*TupleKeyEncoder) EncodeTenantPrefix

func (tke *TupleKeyEncoder) EncodeTenantPrefix(prefix TupleKey, tenantID uint64) (TupleKey, *orderedcodec.EncodedItem)

EncodeTenantPrefix encodes the tenant prefix

func (*TupleKeyEncoder) GetTenantPrefix

func (tke *TupleKeyEncoder) GetTenantPrefix() TupleKey

type TupleValue

type TupleValue []byte

type Tuples

type Tuples []Tuple

type ValueDecodedItem

type ValueDecodedItem struct {
	OffsetInUndecodedKey     int    //the position in undecoded bytes
	RawBytes                 []byte //the byte that holds the item
	BytesCountInUndecodedKey int    //the count of bytes in undecoded bytes
	ID                       uint32 //the attribute id
	// contains filtered or unexported fields
}

ValueDecodedItem for value deserialization

func (*ValueDecodedItem) DecodeValue

func (vdi *ValueDecodedItem) DecodeValue() (*orderedcodec.DecodedItem, error)

type ValueLayoutContext

type ValueLayoutContext struct {
	TableDesc *descriptor.RelationDesc
	IndexDesc *descriptor.IndexDesc

	//write control for the attribute
	AttributeStates []AttributeStateForWrite
	Tuple           Tuple
	Fields          []interface{}

	ColumnGroup uint64
}

type ValueLayoutSerializer

type ValueLayoutSerializer interface {
	Serialize(out []byte, ctx *ValueLayoutContext) ([]byte, error)
	Deserialize(data []byte, amForValue *AttributeMap) ([]byte, []*orderedcodec.DecodedItem, []*ValueDecodedItem, error)
	GetPositionsOfAttributesInTheValue(tableDesc *descriptor.RelationDesc, indexDesc *descriptor.IndexDesc) map[uint32]int
}

ValueLayoutSerializer defines the layout of the value serialization

type ValueSerializer

type ValueSerializer interface {
	SerializeValue(data []byte, value interface{}) ([]byte, *orderedcodec.EncodedItem, error)

	DeserializeValue(data []byte) ([]byte, *orderedcodec.DecodedItem, error)
}

ValueSerializer for serializing the value Stateless is better

type WriteContext

type WriteContext struct {
	//target database,table and index
	DbDesc    *descriptor.DatabaseDesc
	TableDesc *descriptor.RelationDesc
	IndexDesc *descriptor.IndexDesc

	//write control for the attribute
	AttributeStates []AttributeStateForWrite

	//the attributes need to be written
	BatchAttrs []descriptor.AttributeDesc

	NodeID uint64
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package mock_tuplecodec is a generated GoMock package.
Package mock_tuplecodec is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL