encoding

package
v1.0.0-alpha.43 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidId = uint32(0)
)

Functions

func ByteToUInt16

func ByteToUInt16(b []byte) uint16

func ByteToUInt32

func ByteToUInt32(b []byte) uint32

func UInt16ToByte

func UInt16ToByte(v uint16) []byte

func UInt32ToByte

func UInt32ToByte(v uint32) []byte

Types

type DefaultMDNameRegistry

type DefaultMDNameRegistry struct{}

DefaultMDNameRegistry provides the names of the subspaces used by the metadata package for managing dictionary encoded values, counters and schemas.

func (*DefaultMDNameRegistry) EncodingSubspaceName

func (d *DefaultMDNameRegistry) EncodingSubspaceName() []byte

func (*DefaultMDNameRegistry) ReservedSubspaceName

func (d *DefaultMDNameRegistry) ReservedSubspaceName() []byte

func (*DefaultMDNameRegistry) SchemaSubspaceName

func (d *DefaultMDNameRegistry) SchemaSubspaceName() []byte

type MDNameRegistry

type MDNameRegistry interface {
	// ReservedSubspaceName is the name of the table(subspace) where all the counters are stored.
	ReservedSubspaceName() []byte

	// EncodingSubspaceName is the name of the table(subspace) which is used by the dictionary encoder to store all the
	// dictionary encoded values.
	EncodingSubspaceName() []byte

	// SchemaSubspaceName (the schema subspace) will be storing the actual schema of the user for a collection. The schema subspace will
	// look like below
	//    ["schema", 0x01, x, 0x01, 0x03, "created", 0x01] => {"title": "t1", properties: {"a": int}, primary_key: ["a"]}
	//
	//  where,
	//    - schema is the keyword for this table.
	//    - 0x01 is the schema subspace version
	//    - x is the value assigned for the namespace
	//    - 0x01 is the value for the database.
	//    - 0x03 is the value for the collection.
	//    - "created" is keyword.
	//
	SchemaSubspaceName() []byte
}

MDNameRegistry provides the names of the internal tables(subspaces) maintained by the metadata package. The interface helps in creating test tables for these structures.

type MetadataDictionary

type MetadataDictionary struct {
	MDNameRegistry
	// contains filtered or unexported fields
}

MetadataDictionary is used to replace variable length strings to their corresponding codes to allocateAndSave it. Compression is achieved by replacing long strings with a simple 4byte representation.

func NewMetadataDictionary

func NewMetadataDictionary(mdNameRegistry MDNameRegistry) *MetadataDictionary

func (*MetadataDictionary) CreateCollection

func (k *MetadataDictionary) CreateCollection(ctx context.Context, tx transaction.Tx, collection string, namespaceId uint32, dbId uint32) (uint32, error)

func (*MetadataDictionary) CreateDatabase

func (k *MetadataDictionary) CreateDatabase(ctx context.Context, tx transaction.Tx, dbName string, namespaceId uint32) (uint32, error)

func (*MetadataDictionary) CreateIndex

func (k *MetadataDictionary) CreateIndex(ctx context.Context, tx transaction.Tx, indexName string, namespaceId uint32, dbId uint32, collId uint32) (uint32, error)

func (*MetadataDictionary) DropCollection

func (k *MetadataDictionary) DropCollection(ctx context.Context, tx transaction.Tx, collection string, namespaceId uint32, dbId uint32, existingId uint32) error

func (*MetadataDictionary) DropDatabase

func (k *MetadataDictionary) DropDatabase(ctx context.Context, tx transaction.Tx, dbName string, namespaceId uint32, existingId uint32) error

DropDatabase will remove the "created" entry from the encoding subspace and will add a "dropped" entry with the same value.

func (*MetadataDictionary) DropIndex

func (k *MetadataDictionary) DropIndex(ctx context.Context, tx transaction.Tx, indexName string, namespaceId uint32, dbId uint32, collId uint32, existingId uint32) error

func (*MetadataDictionary) GetCollectionId

func (k *MetadataDictionary) GetCollectionId(ctx context.Context, tx transaction.Tx, collName string, namespaceId uint32, dbId uint32) (uint32, error)

func (*MetadataDictionary) GetCollections

func (k *MetadataDictionary) GetCollections(ctx context.Context, tx transaction.Tx, namespaceId uint32, databaseId uint32) (map[string]uint32, error)

func (*MetadataDictionary) GetDatabaseId

func (k *MetadataDictionary) GetDatabaseId(ctx context.Context, tx transaction.Tx, dbName string, namespaceId uint32) (uint32, error)

func (*MetadataDictionary) GetDatabases

func (k *MetadataDictionary) GetDatabases(ctx context.Context, tx transaction.Tx, namespaceId uint32) (map[string]uint32, error)

func (*MetadataDictionary) GetIndexId

func (k *MetadataDictionary) GetIndexId(ctx context.Context, tx transaction.Tx, indexName string, namespaceId uint32, dbId uint32, collId uint32) (uint32, error)

func (*MetadataDictionary) GetIndexes

func (k *MetadataDictionary) GetIndexes(ctx context.Context, tx transaction.Tx, namespaceId uint32, databaseId uint32, collId uint32) (map[string]uint32, error)

func (*MetadataDictionary) GetNamespaces

func (k *MetadataDictionary) GetNamespaces(ctx context.Context, tx transaction.Tx) (map[string]uint32, error)

func (*MetadataDictionary) ReserveNamespace

func (k *MetadataDictionary) ReserveNamespace(ctx context.Context, tx transaction.Tx, namespace string, id uint32) error

ReserveNamespace is the first step in the encoding and the mapping is passed the caller. As this is the first encoded integer the caller needs to make sure a unique value is assigned to this namespace.

type SchemaSubspace

type SchemaSubspace struct {
	MDNameRegistry
}

SchemaSubspace is used to manage schemas in schema subspace.

func NewSchemaStore

func NewSchemaStore(mdNameRegistry MDNameRegistry) *SchemaSubspace

func (*SchemaSubspace) Delete

func (s *SchemaSubspace) Delete(ctx context.Context, tx transaction.Tx, namespaceId uint32, dbId uint32, collId uint32) error

Delete is to remove schema for a given namespace, database and collection.

func (*SchemaSubspace) Get

func (s *SchemaSubspace) Get(ctx context.Context, tx transaction.Tx, namespaceId uint32, dbId uint32, collId uint32) ([][]byte, []int, error)

Get returns all the version stored for a collection inside a given namespace and database.

func (*SchemaSubspace) GetLatest

func (s *SchemaSubspace) GetLatest(ctx context.Context, tx transaction.Tx, namespaceId uint32, dbId uint32, collId uint32) ([]byte, int, error)

GetLatest returns the latest version stored for a collection inside a given namespace and database.

func (*SchemaSubspace) Put

func (s *SchemaSubspace) Put(ctx context.Context, tx transaction.Tx, namespaceId uint32, dbId uint32, collId uint32, schema []byte, revision int) error

Put is to persist schema for a given namespace, database and collection.

type TestMDNameRegistry

type TestMDNameRegistry struct {
	ReserveSB  string
	EncodingSB string
	SchemaSB   string
}

TestMDNameRegistry is used by tests to inject table names that can be used by tests

func (*TestMDNameRegistry) EncodingSubspaceName

func (d *TestMDNameRegistry) EncodingSubspaceName() []byte

func (*TestMDNameRegistry) ReservedSubspaceName

func (d *TestMDNameRegistry) ReservedSubspaceName() []byte

func (*TestMDNameRegistry) SchemaSubspaceName

func (d *TestMDNameRegistry) SchemaSubspaceName() []byte

Jump to

Keyboard shortcuts

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