kv

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseObject = HeaderType('D')
	SchemaObject   = HeaderType('S')
	DocumentObject = HeaderType('O')
	IndexObject    = HeaderType('I')
)
View Source
const (
	PrimaryIndex   = IndexType(1)
	SecondaryIndex = IndexType(2)
)
View Source
const (
	CBOR = DocumentType(1)
)
View Source
const (
	V1 = Version(1)
)

Variables

View Source
var DatabaseKeyHeader = [2]byte{byte(DatabaseObject), byte(byte(CBOR) | headerByteFromVersion(V1))}
View Source
var DocumentKeyHeader = [2]byte{byte(DocumentObject), byte(byte(CBOR) | headerByteFromVersion(V1))}
View Source
var (
	ErrNotExist = errors.New("not exist")
)
View Source
var PrimaryIndexHeader = [2]byte{byte(IndexObject), byte(byte(PrimaryIndex) | headerByteFromVersion(V1))}
View Source
var SchemaKeyHeader = [2]byte{byte(SchemaObject), byte(byte(CBOR) | headerByteFromVersion(V1))}
View Source
var SecondaryIndexHeader = [2]byte{byte(IndexObject), byte(byte(SecondaryIndex) | headerByteFromVersion(V1))}

Functions

func NewObjectNotExistError

func NewObjectNotExistError(v any) error

Types

type Database

type Database interface {
	// Name returns the unique name.
	Name() string
	// Transact begin a new transaction.
	Transact(write bool) (Transaction, error)
}

Database represents a database interface.

type DocumentType

type DocumentType byte

type HeaderType

type HeaderType byte

type IndexType

type IndexType byte

type Key

type Key = document.Key

Key represents an object key.

func NewKeyWith

func NewKeyWith(header KeyHeader, key Key) Key

NewKeyWith returns a new key from the specified header and key elements.

type KeyHeader

type KeyHeader [2]byte

KeyHeader represents a header for any keys.

func (KeyHeader) Bytes

func (header KeyHeader) Bytes() []byte

func (KeyHeader) DocumentType

func (header KeyHeader) DocumentType() DocumentType

func (KeyHeader) IndexType

func (header KeyHeader) IndexType() IndexType

func (KeyHeader) Type

func (header KeyHeader) Type() HeaderType

func (KeyHeader) Version

func (header KeyHeader) Version() Version

type Object

type Object struct {
	Key   Key
	Value []byte
}

Object represents a key-value object.

func (*Object) KeyBytes

func (obj *Object) KeyBytes() ([]byte, error)

type ResultSet

type ResultSet interface {
	// Next moves the cursor forward next object from its current position.
	Next() bool
	// Object returns an object in the current position.
	Object() *Object
}

ResultSet represents a result set which includes query execution results.

type Store

type Store interface {
	// CreateDatabase creates a new database.
	CreateDatabase(name string) error
	// GetDatabase retruns the specified database.
	GetDatabase(name string) (Database, error)
	// RemoveDatabase removes the specified database.
	RemoveDatabase(name string) error
}

Store represents a store interface.

type Transaction

type Transaction interface {
	// Set stores a key-value object. If the key already holds some value, it is overwritten.
	Set(obj *Object) error
	// Get returns a key-value object of the specified key.
	Get(key Key) (*Object, error)
	// GetRange returns a result set of the specified key.
	GetRange(key Key) (ResultSet, error)
	// Remove removes the specified key-value object.
	Remove(key Key) error
	// Commit commits this transaction.
	Commit() error
	// Cancel cancels this transaction.
	Cancel() error
}

Transaction represents a transaction interface.

type Version

type Version byte

Jump to

Keyboard shortcuts

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