compton

package module
v0.0.0-...-85a7822 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

Compton

A library that provides embeddable, lightweight database engine.

Compile protobuf files

protoc --go_out=paths=source_relative:. ./types/*/*.proto

License

Licensed under the Apache License

Authors

Copyright(c) 2022 Fred Chien fred@brobridge.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatabaseExistsAlready = errors.New("Database exists already")
	ErrNotFoundDatabase      = errors.New("Not found database")
)
View Source
var (
	ErrNotFoundRecord = errors.New("Not found record")
	ErrNotFoundEntry  = errors.New("Not found entry")
)
View Source
var (
	MetaDataKeyPrefix = []byte("m_")
	RecordKeyPrefix   = []byte("r_")
)
View Source
var (
	ErrNotFoundTable = errors.New("Not found table")
)

Functions

func BytesToFloat64

func BytesToFloat64(data []byte) float64

func BytesToInt64

func BytesToInt64(data []byte) int64

func BytesToString

func BytesToString(b []byte) string

func BytesToUint64

func BytesToUint64(data []byte) uint64

func Float64ToBytes

func Float64ToBytes(n float64) []byte

func Int64ToBytes

func Int64ToBytes(n int64) []byte

func StrToBytes

func StrToBytes(s string) []byte

func Uint64ToBytes

func Uint64ToBytes(n uint64) []byte

Types

type Compton

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

func NewCompton

func NewCompton(options *Options) (*Compton, error)

func (*Compton) Close

func (ct *Compton) Close()

func (*Compton) CreateDatabase

func (ct *Compton) CreateDatabase(dbName string) (*Database, error)

func (*Compton) DropDatabase

func (ct *Compton) DropDatabase(dbName string) error

func (*Compton) GetDatabase

func (ct *Compton) GetDatabase(dbName string) (*Database, error)

type Cursor

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

func (*Cursor) Close

func (cur *Cursor) Close() error

func (*Cursor) EOF

func (cur *Cursor) EOF() bool

func (*Cursor) GetData

func (cur *Cursor) GetData() []byte

func (*Cursor) GetKey

func (cur *Cursor) GetKey() []byte

func (*Cursor) GetRecord

func (cur *Cursor) GetRecord() *record_type.Record

func (*Cursor) Next

func (cur *Cursor) Next() bool

type Database

type Database struct {
	Name string
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(compton *Compton, dbName string) (*Database, error)

func (*Database) Close

func (db *Database) Close()

func (*Database) CreateTable

func (db *Database) CreateTable(name string) (*Table, error)

func (*Database) Drop

func (db *Database) Drop() error

func (*Database) DropTable

func (db *Database) DropTable(name string) error

func (*Database) GetTable

func (db *Database) GetTable(name string) (*Table, error)

type ListOptions

type ListOptions struct {
	Prefix           []byte
	WithoutRawPrefix bool
}

type Merger

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

func (*Merger) Finish

func (m *Merger) Finish(includesBase bool) ([]byte, io.Closer, error)

func (*Merger) MergeNewer

func (m *Merger) MergeNewer(value []byte) error

func (*Merger) MergeOlder

func (m *Merger) MergeOlder(value []byte) error

func (*Merger) SetHandler

func (m *Merger) SetHandler(fn func(origin []byte, newValue []byte) []byte)

type Options

type Options struct {
	DatabasePath string
}

func NewOptions

func NewOptions() *Options

type Table

type Table struct {
	Database *Database
	Db       *pebble.DB
	Path     string
	Name     string
	Merge    func([]byte, []byte) []byte
	// contains filtered or unexported fields
}

func NewTable

func NewTable(db *Database, name string) *Table

func (*Table) Close

func (table *Table) Close() error

func (*Table) DeleteMeta

func (table *Table) DeleteMeta(key []byte) error

func (*Table) DeleteRecord

func (table *Table) DeleteRecord(key []byte) error

func (*Table) Drop

func (table *Table) Drop() error

func (*Table) Get

func (table *Table) Get(key []byte) ([]byte, error)

func (*Table) GetMetaBytes

func (table *Table) GetMetaBytes(key []byte) ([]byte, error)

func (*Table) GetMetaFloat64

func (table *Table) GetMetaFloat64(key []byte) (float64, error)

func (*Table) GetMetaInt64

func (table *Table) GetMetaInt64(key []byte) (int64, error)

func (*Table) GetMetaString

func (table *Table) GetMetaString(key []byte) (string, error)

func (*Table) GetMetaUint64

func (table *Table) GetMetaUint64(key []byte) (uint64, error)

func (*Table) GetRecord

func (table *Table) GetRecord(pkey []byte) (*record_type.Record, error)

func (*Table) ListMeta

func (table *Table) ListMeta(key []byte) (*Cursor, error)

func (*Table) ListRecords

func (table *Table) ListRecords(targetPrimaryKey []byte, opts *ListOptions) (*Cursor, error)

func (*Table) ModifyRecord

func (table *Table) ModifyRecord(pkey []byte, newRecord *record_type.Record) error

func (*Table) Open

func (table *Table) Open() error

func (*Table) SetMetaBytes

func (table *Table) SetMetaBytes(key []byte, value []byte) error

func (*Table) SetMetaFloat64

func (table *Table) SetMetaFloat64(key []byte, value float64) error

func (*Table) SetMetaInt64

func (table *Table) SetMetaInt64(key []byte, value int64) error

func (*Table) SetMetaString

func (table *Table) SetMetaString(key []byte, value string) error

func (*Table) SetMetaUint64

func (table *Table) SetMetaUint64(key []byte, value uint64) error

func (*Table) Write

func (table *Table) Write(key []byte, data []byte) error

func (*Table) WriteRecord

func (table *Table) WriteRecord(pkey []byte, r *record_type.Record) error

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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