db

package
v0.0.0-...-89416fd Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV[K, V any] interface {
	Get(k K) (V, bool)
	Range(func(k K, v V) bool)
	Remove(k K) (V, bool)
	Set(k K, v V)
}

type KeyRange

type KeyRange struct {
	Start []byte
	End   []byte
	Limit int
}

func (*KeyRange) String

func (kr *KeyRange) String() string

type KeyValue

type KeyValue struct {
	Key   json.RawMessage `json:"key"`
	Value json.RawMessage `json:"value"`
}

func (*KeyValue) Valid

func (kv *KeyValue) Valid() bool

type Query

type Query struct {
	Header   QueryHeader
	KeyRange KeyRange
	Key      []byte
	Value    []byte
	Values   []KeyValue
	// contains filtered or unexported fields
}

func NewAddTableQuery

func NewAddTableQuery(ctx context.Context, db []byte) (*Query, chan QueryResponse)

func NewBatchSetValueQuery

func NewBatchSetValueQuery(ctx context.Context, db []byte, values []KeyValue) (*Query, chan QueryResponse)

func NewGetValueQuery

func NewGetValueQuery(ctx context.Context, db []byte, key []byte) (*Query, chan QueryResponse)

func NewLoadFromFileQuery

func NewLoadFromFileQuery(ctx context.Context, db []byte, filename []byte) (*Query, chan QueryResponse)

func NewQuery

func NewQuery(ctx context.Context, outbox chan QueryResponse) *Query

func NewSetValueQuery

func NewSetValueQuery(ctx context.Context, db, key, value []byte) (*Query, chan QueryResponse)

func (*Query) Context

func (m *Query) Context() context.Context

func (*Query) Done

func (m *Query) Done(r QueryResponse)

func (*Query) GetResponse

func (m *Query) GetResponse() *QueryResponse

func (*Query) String

func (m *Query) String() string

type QueryHeader

type QueryHeader struct {
	DataDir   []byte
	TableName []byte
	Opts      *TableOpts
	FileName  []byte
	Inst      QueryInstruction
}

type QueryInstruction

type QueryInstruction int
const (
	AddTable QueryInstruction = iota
	BatchSetValue
	Count
	GetValue
	GetRange
	Load
	Print
	Range
	SetValue
)

func (QueryInstruction) String

func (i QueryInstruction) String() string

type QueryResponse

type QueryResponse struct {
	Key         []byte
	Value       []byte
	RangeValues [][][]byte
	Stats       QueryStats
	Success     bool
}

type QueryStats

type QueryStats struct {
	Count uint
}

type Table

type Table interface {
	Get(k []byte) ([]byte, bool)
	Set(k, v []byte) error
	Scan(s, e []byte) ([][][]byte, bool)
	ScanWithLimit(s, e []byte, l int) ([][][]byte, bool)
	Range(func(k, v []byte) bool)
	Print()
	Connect() error
	Count() uint64
	Close()
}

func New

func New(opts *TableOpts) Table

type TableOpts

type TableOpts struct {
	TableName []byte
	DataDir   []byte
	InMemory  bool
	WalMode   bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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