Documentation ¶
Index ¶
- type PebbleBucket
- func (bucket *PebbleBucket) Close() (err error)
- func (bucket *PebbleBucket) Cursor(ctx context.Context) (buckets.IBucketCursor, error)
- func (bucket *PebbleBucket) Delete(key string) (err error)
- func (bucket *PebbleBucket) Get(key string) (doc []byte, err error)
- func (bucket *PebbleBucket) GetMultiple(keys []string) (docs map[string][]byte, err error)
- func (bucket *PebbleBucket) ID() string
- func (bucket *PebbleBucket) Info() (info *buckets.BucketStoreInfo)
- func (bucket *PebbleBucket) Set(key string, doc []byte) error
- func (bucket *PebbleBucket) SetMultiple(docs map[string][]byte) (err error)
- type PebbleCursor
- func (cursor *PebbleCursor) BucketID() string
- func (cursor *PebbleCursor) Context() context.Context
- func (cursor *PebbleCursor) First() (key string, value []byte, valid bool)
- func (cursor *PebbleCursor) Last() (key string, value []byte, valid bool)
- func (cursor *PebbleCursor) Next() (key string, value []byte, valid bool)
- func (cursor *PebbleCursor) NextN(steps uint) (docs map[string][]byte, itemsRemaining bool)
- func (cursor *PebbleCursor) Prev() (key string, value []byte, valid bool)
- func (cursor *PebbleCursor) PrevN(steps uint) (docs map[string][]byte, itemsRemaining bool)
- func (cursor *PebbleCursor) Release()
- func (cursor *PebbleCursor) Seek(searchKey string) (key string, value []byte, valid bool)
- type PebbleStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PebbleBucket ¶
type PebbleBucket struct {
// contains filtered or unexported fields
}
PebbleBucket represents a transactional bucket using Pebble Buckets are not supported in Pebble so these are simulated by prefixing all keys with "{bucketID}$" Each write operation is its own transaction.
func NewPebbleBucket ¶
func NewPebbleBucket(clientID, bucketID string, pebbleDB *pebble.DB) *PebbleBucket
NewPebbleBucket creates a new bucket
clientID is the owner of the buck for logging bucketID identifies the bucket pebbleDB backend storage
func (*PebbleBucket) Cursor ¶
func (bucket *PebbleBucket) Cursor(ctx context.Context) (buckets.IBucketCursor, error)
Cursor provides an iterator for the bucket using a pebble iterator with prefix bounds
optional name for use by application
func (*PebbleBucket) Delete ¶
func (bucket *PebbleBucket) Delete(key string) (err error)
Delete removes the key-value pair from the bucket store
func (*PebbleBucket) Get ¶
func (bucket *PebbleBucket) Get(key string) (doc []byte, err error)
Get returns the document for the given key
func (*PebbleBucket) GetMultiple ¶
func (bucket *PebbleBucket) GetMultiple(keys []string) (docs map[string][]byte, err error)
GetMultiple returns a batch of documents with existing keys
func (*PebbleBucket) Info ¶
func (bucket *PebbleBucket) Info() (info *buckets.BucketStoreInfo)
Info returns bucket information FIXME: Unable to determine the number of records in a bucket (or even in the DB)
func (*PebbleBucket) Set ¶
func (bucket *PebbleBucket) Set(key string, doc []byte) error
Set sets a document with the given key
func (*PebbleBucket) SetMultiple ¶
func (bucket *PebbleBucket) SetMultiple(docs map[string][]byte) (err error)
SetMultiple sets multiple documents in a batch update
type PebbleCursor ¶
type PebbleCursor struct {
// contains filtered or unexported fields
}
func NewPebbleCursor ¶
func NewPebbleCursor(ctx context.Context, clientID, bucketID string, bucketPrefix string, iterator *pebble.Iterator) *PebbleCursor
NewPebbleCursor create a pebble storage iterator cursor for a pebble bucket
ctx holds cursor context, for example additional application filters clientID owner bucketID the cursor iterates bucketPrefix iterator is pebble's iterator
func (*PebbleCursor) BucketID ¶
func (cursor *PebbleCursor) BucketID() string
func (*PebbleCursor) Context ¶
func (cursor *PebbleCursor) Context() context.Context
Context returns the cursor application context
func (*PebbleCursor) First ¶
func (cursor *PebbleCursor) First() (key string, value []byte, valid bool)
First moves the cursor to the first item
func (*PebbleCursor) Last ¶
func (cursor *PebbleCursor) Last() (key string, value []byte, valid bool)
Last moves the cursor to the last item
func (*PebbleCursor) Next ¶
func (cursor *PebbleCursor) Next() (key string, value []byte, valid bool)
Next iterates to the next key from the current cursor
func (*PebbleCursor) NextN ¶
func (cursor *PebbleCursor) NextN(steps uint) (docs map[string][]byte, itemsRemaining bool)
NextN increases the cursor position N times and return the encountered key-value pairs
func (*PebbleCursor) Prev ¶
func (cursor *PebbleCursor) Prev() (key string, value []byte, valid bool)
Prev iterations to the previous key from the current cursor
type PebbleStore ¶
type PebbleStore struct {
// contains filtered or unexported fields
}
PebbleStore implements the IBucketStore API using the embedded CockroachDB pebble database
The following benchmark are made using BucketBench_test.go Performance is stellar! Fast, efficient data storage and low memory usage compared to the others. Estimates are made using a i5-4570S @2.90GHz cpu. Document size is 100 bytes.
Create&commit bucket, no data changes (fast since pebbles doesn't use transactions for this)
Dataset 1K, 0.1 us/op Dataset 10K, 0.1 us/op Dataset 100K 0.1 us/op Dataset 1M 0.1 us/op
Get bucket 1 record
Dataset 1K, 1.0 us/op Dataset 10K, 1.6 us/op Dataset 100K 1.6 us/op Dataset 1M 3.2 us/op
Set bucket 1 record
Dataset 1K, 2.2 us/op Dataset 10K, 2.2 us/op Dataset 100K 2.5 us/op Dataset 1M 3.0 us/op Dataset 10M 40 us/op
Seek, 1 record
Dataset 1K, 5 us/op Dataset 10K, 3 us/op Dataset 100K 3 us/op Dataset 1M 14 us/op Dataset 10M 144 us/op
See https://pkg.go.dev/github.com/cockroachdb/pebble for Pebble's documentation.
func NewPebbleStore ¶
func NewPebbleStore(clientID, storeDirectory string) *PebbleStore
NewPebbleStore creates a storage database with bucket support.
clientID that owns the database storeDirectory is the directory (not file) holding the database
func (*PebbleStore) Close ¶
func (store *PebbleStore) Close() error