kv

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound             = errors.New("oxia: key not found")
	MaxSnapshotChunkSize int64 = 1024 * 1024 // bytes

)
View Source
var DefaultFactoryOptions = &FactoryOptions{
	DataDir:     "data",
	CacheSizeMB: 100,
	InMemory:    false,
}
View Source
var ErrBadVersionId = errors.New("oxia: bad version id")
View Source
var (
	OxiaSlashSpanComparer = &pebble.Comparer{
		Compare:            compareWithSlash,
		Equal:              pebble.DefaultComparer.Equal,
		AbbreviatedKey:     pebble.DefaultComparer.AbbreviatedKey,
		FormatKey:          pebble.DefaultComparer.FormatKey,
		FormatValue:        pebble.DefaultComparer.FormatValue,
		Separator:          pebble.DefaultComparer.Separator,
		Split:              pebble.DefaultComparer.Split,
		Successor:          pebble.DefaultComparer.Successor,
		ImmediateSuccessor: pebble.DefaultComparer.ImmediateSuccessor,
		Name:               "oxia-slash-spans",
	}
)

Functions

func GetStorageEntry

func GetStorageEntry(batch WriteBatch, key string) (*proto.StorageEntry, error)

Types

type DB

type DB interface {
	io.Closer

	ProcessWrite(b *proto.WriteRequest, commitOffset int64, timestamp uint64, updateOperationCallback UpdateOperationCallback) (*proto.WriteResponse, error)
	Get(request *proto.GetRequest) (*proto.GetResponse, error)
	List(request *proto.ListRequest) (KeyIterator, error)
	ReadCommitOffset() (int64, error)

	ReadNextNotifications(ctx context.Context, startOffset int64) ([]*proto.NotificationBatch, error)

	UpdateTerm(newTerm int64) error
	ReadTerm() (term int64, err error)

	Snapshot() (Snapshot, error)

	// Delete and close the database and all its files
	Delete() error
}

func NewDB

func NewDB(namespace string, shardId int64, factory Factory, notificationRetentionTime time.Duration, clock common.Clock) (DB, error)

type Factory added in v0.3.0

type Factory interface {
	io.Closer

	NewKV(namespace string, shardId int64) (KV, error)

	NewSnapshotLoader(namespace string, shardId int64) (SnapshotLoader, error)
}

func NewPebbleKVFactory

func NewPebbleKVFactory(options *FactoryOptions) (Factory, error)

type FactoryOptions added in v0.3.0

type FactoryOptions struct {
	DataDir     string
	CacheSizeMB int64

	// Create a pure in-memory database. Used for unit-tests
	InMemory bool
}

type KV

type KV interface {
	io.Closer

	NewWriteBatch() WriteBatch

	Get(key string) ([]byte, io.Closer, error)

	KeyRangeScan(lowerBound, upperBound string) (KeyIterator, error)
	KeyRangeScanReverse(lowerBound, upperBound string) (ReverseKeyIterator, error)

	RangeScan(lowerBound, upperBound string) (KeyValueIterator, error)

	Snapshot() (Snapshot, error)

	Flush() error

	Delete() error
}

type KeyIterator

type KeyIterator interface {
	io.Closer

	Valid() bool
	Key() string
	Next() bool
}

type KeyValueIterator

type KeyValueIterator interface {
	KeyIterator

	Value() ([]byte, error)
}

type Pebble

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

func (*Pebble) Close

func (p *Pebble) Close() error

func (*Pebble) Delete

func (p *Pebble) Delete() error

func (*Pebble) Flush

func (p *Pebble) Flush() error

func (*Pebble) Get

func (p *Pebble) Get(key string) ([]byte, io.Closer, error)

func (*Pebble) KeyRangeScan

func (p *Pebble) KeyRangeScan(lowerBound, upperBound string) (KeyIterator, error)

func (*Pebble) KeyRangeScanReverse

func (p *Pebble) KeyRangeScanReverse(lowerBound, upperBound string) (ReverseKeyIterator, error)

func (*Pebble) NewWriteBatch

func (p *Pebble) NewWriteBatch() WriteBatch

func (*Pebble) RangeScan

func (p *Pebble) RangeScan(lowerBound, upperBound string) (KeyValueIterator, error)

func (*Pebble) Snapshot

func (p *Pebble) Snapshot() (Snapshot, error)

type PebbleBatch

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

func (*PebbleBatch) Close

func (b *PebbleBatch) Close() error

func (*PebbleBatch) Commit

func (b *PebbleBatch) Commit() error

func (*PebbleBatch) Count

func (b *PebbleBatch) Count() int

func (*PebbleBatch) Delete

func (b *PebbleBatch) Delete(key string) error

func (*PebbleBatch) DeleteRange

func (b *PebbleBatch) DeleteRange(lowerBound, upperBound string) error

func (*PebbleBatch) Get

func (b *PebbleBatch) Get(key string) ([]byte, io.Closer, error)

func (*PebbleBatch) KeyRangeScan

func (b *PebbleBatch) KeyRangeScan(lowerBound, upperBound string) (KeyIterator, error)

func (*PebbleBatch) Put

func (b *PebbleBatch) Put(key string, value []byte) error

func (*PebbleBatch) Size

func (b *PebbleBatch) Size() int

type PebbleFactory

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

func (*PebbleFactory) Close

func (p *PebbleFactory) Close() error

func (*PebbleFactory) NewKV

func (p *PebbleFactory) NewKV(namespace string, shardId int64) (KV, error)

func (*PebbleFactory) NewSnapshotLoader

func (p *PebbleFactory) NewSnapshotLoader(namespace string, shardId int64) (SnapshotLoader, error)

type PebbleIterator

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

func (*PebbleIterator) Close

func (p *PebbleIterator) Close() error

func (*PebbleIterator) Key

func (p *PebbleIterator) Key() string

func (*PebbleIterator) Next

func (p *PebbleIterator) Next() bool

func (*PebbleIterator) Valid

func (p *PebbleIterator) Valid() bool

func (*PebbleIterator) Value

func (p *PebbleIterator) Value() ([]byte, error)

type PebbleReverseIterator

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

func (*PebbleReverseIterator) Close

func (p *PebbleReverseIterator) Close() error

func (*PebbleReverseIterator) Key

func (p *PebbleReverseIterator) Key() string

func (*PebbleReverseIterator) Prev

func (p *PebbleReverseIterator) Prev() bool

func (*PebbleReverseIterator) Valid

func (p *PebbleReverseIterator) Valid() bool

func (*PebbleReverseIterator) Value

func (p *PebbleReverseIterator) Value() ([]byte, error)

type ReverseKeyIterator

type ReverseKeyIterator interface {
	io.Closer

	Valid() bool
	Key() string
	Prev() bool
}

type Snapshot

type Snapshot interface {
	io.Closer

	BasePath() string

	Valid() bool
	Chunk() (SnapshotChunk, error)
	Next() bool
}

type SnapshotChunk

type SnapshotChunk interface {
	Name() string
	Index() int32
	TotalCount() int32
	Content() []byte
}

type SnapshotLoader

type SnapshotLoader interface {
	io.Closer

	AddChunk(fileName string, chunkIndex int32, chunkCount int32, content []byte) error

	// Complete signals that the snapshot is now complete
	Complete()
}

type UpdateOperationCallback

type UpdateOperationCallback interface {
	OnPut(WriteBatch, *proto.PutRequest, *proto.StorageEntry) (proto.Status, error)
	OnDelete(WriteBatch, string) error
}
var NoOpCallback UpdateOperationCallback = &noopCallback{}

type WriteBatch

type WriteBatch interface {
	io.Closer

	Put(key string, value []byte) error
	Delete(key string) error
	Get(key string) ([]byte, io.Closer, error)

	DeleteRange(lowerBound, upperBound string) error
	KeyRangeScan(lowerBound, upperBound string) (KeyIterator, error)

	// Count is the number of transactions that are currently in the batch
	Count() int

	// Size of all the transactions that are currently in the batch
	Size() int

	Commit() error
}

Jump to

Keyboard shortcuts

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