encoding

package
v1.0.0-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReservedSubspaceKey = []byte("reserved")
	EncodingSubspaceKey = []byte("encoding")
)

subspaces - only reason of not declaring these as consts because tests in different packages can overwrite this.

View Source
var (
	InvalidId = uint32(0)
)
View Source
var (
	SchemaSubspaceKey = []byte("schema")
)

SchemaSubspaceKey (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.
  - 0x01 is the revision of the schema.

Functions

func ByteToUInt32

func ByteToUInt32(b []byte) uint32

func UInt32ToByte

func UInt32ToByte(v uint32) []byte

Types

type DictionaryEncoder

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

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

func NewDictionaryEncoder

func NewDictionaryEncoder() *DictionaryEncoder

func (*DictionaryEncoder) EncodeCollectionAsDropped

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

func (*DictionaryEncoder) EncodeCollectionName

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

func (*DictionaryEncoder) EncodeDatabaseAsDropped

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

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

func (*DictionaryEncoder) EncodeDatabaseName

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

func (*DictionaryEncoder) EncodeIndexAsDropped

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

func (*DictionaryEncoder) EncodeIndexName

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

func (*DictionaryEncoder) GetCollectionId

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

func (*DictionaryEncoder) GetCollections

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

func (*DictionaryEncoder) GetDatabaseId

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

func (*DictionaryEncoder) GetDatabases

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

func (*DictionaryEncoder) GetIndexId

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

func (*DictionaryEncoder) GetIndexes

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

func (*DictionaryEncoder) GetNamespaces

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

func (*DictionaryEncoder) ReserveNamespace

func (k *DictionaryEncoder) 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{}

SchemaSubspace is used to manage schemas in schema subspace.

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.

Jump to

Keyboard shortcuts

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