Documentation ¶
Index ¶
- Constants
- Variables
- func LogableStore() (CacheableKVStore, ShowOpser)
- type BTreeCacheWrap
- func (b BTreeCacheWrap) CacheWrap() KVCacheWrap
- func (b BTreeCacheWrap) Delete(key []byte) error
- func (b BTreeCacheWrap) Discard()
- func (b BTreeCacheWrap) Get(key []byte) ([]byte, error)
- func (b BTreeCacheWrap) Has(key []byte) (bool, error)
- func (b BTreeCacheWrap) Iterator(start, end []byte) (Iterator, error)
- func (b BTreeCacheWrap) NewBatch() Batch
- func (b BTreeCacheWrap) ReverseIterator(start, end []byte) (Iterator, error)
- func (b BTreeCacheWrap) Set(key, value []byte) error
- func (b BTreeCacheWrap) Write() error
- type BTreeCacheable
- type Batch
- type CacheableKVStore
- type CommitID
- type CommitKVStore
- type EmptyKVStore
- func (e EmptyKVStore) Delete(key []byte) error
- func (e EmptyKVStore) Get(key []byte) ([]byte, error)
- func (e EmptyKVStore) Has(key []byte) (bool, error)
- func (e EmptyKVStore) Iterator(start, end []byte) (Iterator, error)
- func (e EmptyKVStore) NewBatch() Batch
- func (e EmptyKVStore) ReverseIterator(start, end []byte) (Iterator, error)
- func (e EmptyKVStore) Set(key, value []byte) error
- type Iterator
- type KVCacheWrap
- type KVStore
- type Model
- type NonAtomicBatch
- type Op
- type ReadOnlyKVStore
- type Recorder
- type SetDeleter
- type ShowOpser
- type SliceIterator
- type TestStoreConstructor
- type TestSuite
Constants ¶
const ( // DefaultFreeListSize is the size we hold for free node in btree DefaultFreeListSize = btree.DefaultFreeListSize )
Variables ¶
var Pair = weave.Pair
Pair is an alias to function in root package
Functions ¶
func LogableStore ¶ added in v0.11.2
func LogableStore() (CacheableKVStore, ShowOpser)
LogableStore will return a store, along with insight into all operations that were run on it
Types ¶
type BTreeCacheWrap ¶
type BTreeCacheWrap struct {
// contains filtered or unexported fields
}
BTreeCacheWrap places a btree cache over a KVStore
func NewBTreeCacheWrap ¶
func NewBTreeCacheWrap(kv ReadOnlyKVStore, batch Batch, free *btree.FreeList) BTreeCacheWrap
NewBTreeCacheWrap initializes a BTree to cache around this kv store. Use ReadOnlyKVStore to emphasize that all writes must go through the Batch.
free may be nil, but set to an existing list to reuse it for memory savings
func (BTreeCacheWrap) CacheWrap ¶
func (b BTreeCacheWrap) CacheWrap() KVCacheWrap
CacheWrap layers another BTree on top of this one. Don't change horses in mid-stream....
Uses NonAtomicBatch as it is only backed by another in-memory batch
func (BTreeCacheWrap) Delete ¶
func (b BTreeCacheWrap) Delete(key []byte) error
Delete deletes from the BTree and to the batch
func (BTreeCacheWrap) Discard ¶
func (b BTreeCacheWrap) Discard()
Discard invalidates this CacheWrap and releases all data
TODO: currently noop....leave it to the garbage collector
func (BTreeCacheWrap) Get ¶
func (b BTreeCacheWrap) Get(key []byte) ([]byte, error)
Get reads from btree if there, else backing store
func (BTreeCacheWrap) Has ¶
func (b BTreeCacheWrap) Has(key []byte) (bool, error)
Has reads from btree if there, else backing store
func (BTreeCacheWrap) Iterator ¶
func (b BTreeCacheWrap) Iterator(start, end []byte) (Iterator, error)
Iterator over a domain of keys in ascending order. Combines results from btree and backing store
func (BTreeCacheWrap) NewBatch ¶
func (b BTreeCacheWrap) NewBatch() Batch
NewBatch returns a non-atomic batch that eventually may write to our cachewrap
func (BTreeCacheWrap) ReverseIterator ¶
func (b BTreeCacheWrap) ReverseIterator(start, end []byte) (Iterator, error)
ReverseIterator over a domain of keys in descending order. Combines results from btree and backing store
func (BTreeCacheWrap) Set ¶
func (b BTreeCacheWrap) Set(key, value []byte) error
Set writes to the BTree and to the batch
func (BTreeCacheWrap) Write ¶
func (b BTreeCacheWrap) Write() error
Write syncs with the underlying store. And then cleans up
type BTreeCacheable ¶
type BTreeCacheable struct {
KVStore
}
BTreeCacheable adds a simple btree-based CacheWrap strategy to a KVStore
func (BTreeCacheable) CacheWrap ¶
func (b BTreeCacheable) CacheWrap() KVCacheWrap
CacheWrap returns a BTreeCacheWrap that can be later written to this store, or rolled back
type CacheableKVStore ¶
type CacheableKVStore = weave.CacheableKVStore
CacheableKVStore is an alias to interface in root package
func MemStore ¶
func MemStore() CacheableKVStore
MemStore returns a simple implementation useful for tests. There is no persistence here....
type CommitKVStore ¶
type CommitKVStore = weave.CommitKVStore
CommitKVStore is an alias to interface in root package
type EmptyKVStore ¶
type EmptyKVStore struct{}
EmptyKVStore never holds any data, used as a base layer to test caching
func (EmptyKVStore) Get ¶
func (e EmptyKVStore) Get(key []byte) ([]byte, error)
Get always returns nil
func (EmptyKVStore) Has ¶
func (e EmptyKVStore) Has(key []byte) (bool, error)
Has always returns false
func (EmptyKVStore) Iterator ¶
func (e EmptyKVStore) Iterator(start, end []byte) (Iterator, error)
Iterator is always empty
func (EmptyKVStore) NewBatch ¶
func (e EmptyKVStore) NewBatch() Batch
NewBatch returns a batch that can write to this tree later
func (EmptyKVStore) ReverseIterator ¶
func (e EmptyKVStore) ReverseIterator(start, end []byte) (Iterator, error)
ReverseIterator is always empty
type KVCacheWrap ¶
type KVCacheWrap = weave.KVCacheWrap
KVCacheWrap is an alias to interface in root package
type KVStore ¶
KVStore is an alias to interface in root package
func NewRecordingStore ¶ added in v0.2.1
NewRecordingStore initializes a recording store wrapping this base store, using cached alternative if possible
We need to expose this optional functionality through the interface wrapper so downstream components (like Savepoint) can use reflection to CacheWrap.
type NonAtomicBatch ¶
type NonAtomicBatch struct {
// contains filtered or unexported fields
}
NonAtomicBatch just piles up ops and executes them later on the underlying store. Can be used when there is no better option (for in-memory stores).
func NewNonAtomicBatch ¶
func NewNonAtomicBatch(out SetDeleter) *NonAtomicBatch
NewNonAtomicBatch creates an empty batch to be later written to the KVStore
func (*NonAtomicBatch) Delete ¶
func (b *NonAtomicBatch) Delete(key []byte) error
Delete adds a delete operation to the batch
func (*NonAtomicBatch) Set ¶
func (b *NonAtomicBatch) Set(key, value []byte) error
Set adds a set operation to the batch
func (*NonAtomicBatch) ShowOps ¶ added in v0.11.2
func (b *NonAtomicBatch) ShowOps() []Op
ShowOps is instrumentation for testing, it returns a copy of the internal Ops list
func (*NonAtomicBatch) Write ¶
func (b *NonAtomicBatch) Write() error
Write writes all the ops to the underlying store and resets
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op is either set or delete
func (Op) Apply ¶
func (o Op) Apply(out SetDeleter) error
Apply performs the stored operation on a writable store
type ReadOnlyKVStore ¶
type ReadOnlyKVStore = weave.ReadOnlyKVStore
ReadOnlyKVStore is an alias to interface in root package
type Recorder ¶ added in v0.2.1
Recorder interface is implemented by anything returned from NewRecordingStore
type SetDeleter ¶
type SetDeleter = weave.SetDeleter
SetDeleter is an alias to interface in root package
type ShowOpser ¶ added in v0.11.2
type ShowOpser interface {
ShowOps() []Op
}
ShowOpser returns an ordered list of all operations performed
type SliceIterator ¶
type SliceIterator struct {
// contains filtered or unexported fields
}
SliceIterator wraps an Iterator over a slice of models
TODO: make this private and only expose Iterator interface????
func NewSliceIterator ¶
func NewSliceIterator(data []Model) *SliceIterator
NewSliceIterator creates a new Iterator over this slice
func (*SliceIterator) Next ¶
func (s *SliceIterator) Next() (key, value []byte, err error)
func (*SliceIterator) Release ¶ added in v0.17.0
func (s *SliceIterator) Release()
Release releases the Iterator.
type TestStoreConstructor ¶ added in v0.17.0
type TestStoreConstructor func() (base CacheableKVStore, cleanup func())
type TestSuite ¶ added in v0.17.0
type TestSuite struct {
// contains filtered or unexported fields
}
* TestSuite provides many methods that can be called in package-specific test code. We just customize the store being tested (pass in constructor), the rest of the logic is generic to the KVStore interface.
This is intended in particular to remove duplication between btree_test.go and iavl/adapter_test.go, but can be used for any implementation of KVStore.
func NewTestSuite ¶ added in v0.17.0
func NewTestSuite(constructor TestStoreConstructor) *TestSuite
func (*TestSuite) AssertGetHas ¶ added in v0.17.0
func (*TestSuite) CacheConflicts ¶ added in v0.17.0
CacheConflicts checks that we can handle overwriting values and deleting underlying values
func (*TestSuite) FuzzIterator ¶ added in v0.17.0
FuzzIterator makes sure the basic iterator works. Includes random deletes, but not nested iterators.
func (*TestSuite) GetSet ¶ added in v0.17.0
GetSet does basic sanity checks on our cache
Other tests should handle deletes, setting same value, iterating over ranges, and general fuzzing
func (*TestSuite) IteratorWithConflicts ¶ added in v0.17.0
IteratorWithConflicts covers some specific test cases that arose during fuzzing the iterators.