Documentation ¶
Index ¶
- Constants
- Variables
- func Register(reg *Registration)
- func RegisterTestKVDBDriver()
- func RemoveDSNOptions(dsn string, keys ...string) (string, error)
- func RemoveDSNOptionsFromURL(dsnURL *url.URL, keys ...string) *url.URL
- type BatchOp
- type Compressor
- type DSNQuery
- type EmtpyValueEnabler
- type Iterator
- type KV
- type KVStore
- type Key
- type Limit
- type NewStoreFunc
- type NoOpCompressor
- type Option
- type Purgeable
- type PurgeableKVStore
- type ReadOption
- type ReadOptions
- type Registration
- type ReversibleKVStore
- type TestKVDBDriver
- func (t *TestKVDBDriver) BatchDelete(ctx context.Context, keys [][]byte) (err error)
- func (t *TestKVDBDriver) BatchGet(ctx context.Context, keys [][]byte) *Iterator
- func (t *TestKVDBDriver) BatchPrefix(ctx context.Context, prefixes [][]byte, limit int, options ...ReadOption) *Iterator
- func (t *TestKVDBDriver) Close() error
- func (t *TestKVDBDriver) FlushPuts(ctx context.Context) (err error)
- func (t *TestKVDBDriver) Get(ctx context.Context, key []byte) (value []byte, err error)
- func (t *TestKVDBDriver) Prefix(ctx context.Context, prefix []byte, limit int, options ...ReadOption) *Iterator
- func (t *TestKVDBDriver) Put(ctx context.Context, key, value []byte) (err error)
- func (t *TestKVDBDriver) Scan(ctx context.Context, start, exclusiveEnd []byte, limit int, ...) *Iterator
- type TestPurgeableKVDBDriver
- type ZstdCompressor
Constants ¶
const Unlimited = 0
Variables ¶
var (
ErrNotFound = errors.New("not found")
)
var PurgeableMaxBatchSize = 500
Functions ¶
func Register ¶
func Register(reg *Registration)
func RegisterTestKVDBDriver ¶
func RegisterTestKVDBDriver()
func RemoveDSNOptions ¶
RemoveDSNOptions takes a DSN url string and removes from it any query options matching one of the `key` received in parameter.
For example, transforms `kv://path?option1=value&option2=test&option3=any` to `kv://path?option2=test` when passing `option1` and `option3` as the keys.
func RemoveDSNOptionsFromURL ¶
RemoveDSNOptionsFromURL takes a DSN URL and removes from it any query options matching one of the `key` received in parameter.
For example, transforms `kv://path?option1=value&option2=test&option3=any` to `kv://path?option2=test` when passing `option1` and `option3` as the keys.
Types ¶
type BatchOp ¶
type BatchOp struct {
// contains filtered or unexported fields
}
func NewBatchOp ¶
func (*BatchOp) MarshalLogObject ¶
func (b *BatchOp) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*BatchOp) ShouldFlush ¶
func (*BatchOp) WouldFlushNext ¶
WouldFlushNext determines if adding another item with the specified `len(key) + len(value)` would trigger a flush of the batch. This can be used to push a batch preemptively before inserting and item that would make the batch bigger than allowed max size.
type Compressor ¶
type Compressor interface { Compress(in []byte) []byte Decompress(in []byte) ([]byte, error) zapcore.ObjectMarshaler }
func NewCompressor ¶
func NewCompressor(mode string, thresholdInBytes int) (Compressor, error)
type EmtpyValueEnabler ¶
type EmtpyValueEnabler interface {
EnableEmpty()
}
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator can end in any of those scenarios:
- PushError() is called by the db backend
- PushComplete() is called by the db backend and Next() is called by consumer until items channel is empty
- The context given by the consumer is cancelled, notifying the db backend and (hopefully) causing a PushError() to be called with context.Canceled
In any of these cases, the following call to Next() returns false.
Assumptions:
* Next() must never be called again after it returned `false` * No other Push...() function is called PushFinished() or PushError(). * Next(), Item() and Error() are never called concurrently. * PushItem(), PushFinished() and PushError() are never called concurrently. * If the reader wants to finish early, it should close the context to prevent waste
func NewIterator ¶
NewIterator provides a streaming resultset for key/value queries
func (*Iterator) PushFinished ¶
func (it *Iterator) PushFinished()
type KVStore ¶
type KVStore interface { // Put writes to a transaction, which might be flushed from time to time. Call FlushPuts() to ensure all Put entries are properly written to the database. Put(ctx context.Context, key, value []byte) (err error) // FlushPuts takes any pending writes (calls to Put()), and flushes them. FlushPuts(ctx context.Context) (err error) // Get a given key. Returns `kvdb.ErrNotFound` if not found. Get(ctx context.Context, key []byte) (value []byte, err error) // Get a batch of keys. Returns `kvdb.ErrNotFound` the first time a key is not found: not finding a key is fatal and interrupts the resultset from being fetched completely. BatchGet guarantees that Iterator return results in the exact same order as keys BatchGet(ctx context.Context, keys [][]byte) *Iterator Scan(ctx context.Context, start, exclusiveEnd []byte, limit int, options ...ReadOption) *Iterator Prefix(ctx context.Context, prefix []byte, limit int, options ...ReadOption) *Iterator BatchPrefix(ctx context.Context, prefixes [][]byte, limit int, options ...ReadOption) *Iterator BatchDelete(ctx context.Context, keys [][]byte) (err error) // Close the underlying store engine and clear up any resources currently hold // by this instance. // // Once this instance's `Close` method has been called, it's assumed to be terminated // and cannot be reliably used to perform read/write operation on the backing engine. Close() error }
type Key ¶
type Key []byte
func (Key) Next ¶
Next returns the next key in byte-order.
Copied from https://github.com/tikv/client-go/blob/master/key/key.go
func (Key) PrefixNext ¶
PrefixNext returns the next prefix key.
Assume there are keys like:
rowkey1 rowkey1_column1 rowkey1_column2 rowKey2
If we seek 'rowkey1' Next, we will get 'rowkey1_column1'. If we seek 'rowkey1' PrefixNext, we will get 'rowkey2'.
Copied from https://github.com/tikv/client-go/blob/master/key/key.go
type NewStoreFunc ¶
NewStoreFunc is a function for opening a databse.
type NoOpCompressor ¶
type NoOpCompressor struct{}
func NewNoOpCompressor ¶
func NewNoOpCompressor() *NoOpCompressor
func (NoOpCompressor) Compress ¶
func (NoOpCompressor) Compress(in []byte) []byte
func (NoOpCompressor) Decompress ¶
func (NoOpCompressor) Decompress(in []byte) ([]byte, error)
func (NoOpCompressor) MarshalLogObject ¶
func (NoOpCompressor) MarshalLogObject(enc zapcore.ObjectEncoder) error
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithEmptyValue ¶
func WithEmptyValue() Option
type PurgeableKVStore ¶
type PurgeableKVStore struct { KVStore // contains filtered or unexported fields }
func NewPurgeableStore ¶
func NewPurgeableStore(tablePrefix []byte, store KVStore, ttlInBlocks uint64) *PurgeableKVStore
func (*PurgeableKVStore) MarkCurrentHeight ¶
func (s *PurgeableKVStore) MarkCurrentHeight(height uint64)
type ReadOption ¶
type ReadOption interface {
Apply(o *ReadOptions)
}
func KeyOnly ¶
func KeyOnly() ReadOption
type ReadOptions ¶
type ReadOptions struct {
KeyOnly bool
}
type Registration ¶
type Registration struct { Name string // unique name Title string // human-readable name FactoryFunc NewStoreFunc }
type ReversibleKVStore ¶
type ReversibleKVStore interface { ReverseScan(ctx context.Context, start, exclusiveEnd []byte, limit int) *Iterator ReversePrefix(ctx context.Context, prefix []byte, limit int) *Iterator }
ReversibleKVStore is not currently used. Was to be an optimization to avoid writing block numbers twice (to search the timeline), for stores that support reverse scans (unlike Bigtable).
type TestKVDBDriver ¶
type TestKVDBDriver struct {
DSN string
}
func NewTestKVDBDriver ¶
func NewTestKVDBDriver(dsn string) *TestKVDBDriver
func (*TestKVDBDriver) BatchDelete ¶
func (t *TestKVDBDriver) BatchDelete(ctx context.Context, keys [][]byte) (err error)
func (*TestKVDBDriver) BatchGet ¶
func (t *TestKVDBDriver) BatchGet(ctx context.Context, keys [][]byte) *Iterator
func (*TestKVDBDriver) BatchPrefix ¶
func (t *TestKVDBDriver) BatchPrefix(ctx context.Context, prefixes [][]byte, limit int, options ...ReadOption) *Iterator
func (*TestKVDBDriver) Close ¶
func (t *TestKVDBDriver) Close() error
func (*TestKVDBDriver) FlushPuts ¶
func (t *TestKVDBDriver) FlushPuts(ctx context.Context) (err error)
func (*TestKVDBDriver) Prefix ¶
func (t *TestKVDBDriver) Prefix(ctx context.Context, prefix []byte, limit int, options ...ReadOption) *Iterator
func (*TestKVDBDriver) Put ¶
func (t *TestKVDBDriver) Put(ctx context.Context, key, value []byte) (err error)
func (*TestKVDBDriver) Scan ¶
func (t *TestKVDBDriver) Scan(ctx context.Context, start, exclusiveEnd []byte, limit int, options ...ReadOption) *Iterator
type TestPurgeableKVDBDriver ¶
func NewTestPurgeableKVDBDriver ¶
func NewTestPurgeableKVDBDriver(dsn string) *TestPurgeableKVDBDriver
func (*TestPurgeableKVDBDriver) MarkCurrentHeight ¶
func (t *TestPurgeableKVDBDriver) MarkCurrentHeight(height uint64)
type ZstdCompressor ¶
type ZstdCompressor struct {
// contains filtered or unexported fields
}
func NewZstdCompressor ¶
func NewZstdCompressor(thresholdInBytes int) *ZstdCompressor
func (*ZstdCompressor) Compress ¶
func (c *ZstdCompressor) Compress(in []byte) (out []byte)
func (*ZstdCompressor) Decompress ¶
func (c *ZstdCompressor) Decompress(in []byte) ([]byte, error)
func (*ZstdCompressor) MarshalLogObject ¶
func (c *ZstdCompressor) MarshalLogObject(enc zapcore.ObjectEncoder) error