engineccl

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeMultiIterator

func MakeMultiIterator(iters []engine.SimpleIterator) engine.SimpleIterator

MakeMultiIterator creates an iterator that multiplexes engine.SimpleIterators. The caller is responsible for closing the passed iterators after closing the returned multiIterator.

If two iterators have an entry with exactly the same key and timestamp, the one with a higher index in this constructor arg is preferred. The other is skipped.

func NewMemSSTIterator added in v1.1.0

func NewMemSSTIterator(data []byte) (engine.SimpleIterator, error)

NewMemSSTIterator returns a SimpleIterator for a leveldb format sstable in memory. It's compatible with sstables output by engine.RocksDBSstFileWriter, which means the keys are CockroachDB mvcc keys and they each have the RocksDB trailer (of seqno & value type).

func NewSSTIterator added in v1.1.0

func NewSSTIterator(path string) (engine.SimpleIterator, error)

NewSSTIterator returns a SimpleIterator for a leveldb formatted sstable on disk. It's compatible with sstables output by engine.RocksDBSstFileWriter, which means the keys are CockroachDB mvcc keys and they each have the RocksDB trailer (of seqno & value type).

func VerifyBatchRepr

func VerifyBatchRepr(
	repr []byte, start, end engine.MVCCKey, nowNanos int64,
) (enginepb.MVCCStats, error)

VerifyBatchRepr asserts that all keys in a BatchRepr are between the specified start and end keys and computes the enginepb.MVCCStats for it.

Types

type MVCCIncrementalIterator

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

MVCCIncrementalIterator iterates over the diff of the key range [startKey,endKey) and time range (startTime,endTime]. If a key was added or modified between startTime and endTime, the iterator will position at the most recent version (before or at endTime) of that key. If the key was most recently deleted, this is signalled with an empty value.

Note: The endTime is inclusive to be consistent with the non-incremental iterator, where reads at a given timestamp return writes at that timestamp. The startTime is then made exclusive so that iterating time 1 to 2 and then 2 to 3 will only return values with time 2 once. An exclusive start time would normally make it difficult to scan timestamp 0, but CockroachDB uses that as a sentinel for key metadata anyway.

Expected usage:

iter := NewMVCCIncrementalIterator(e, startTime, endTime)
defer iter.Close()
for iter.Seek(startKey); ; iter.Next() {
    ok, err := iter.Valid()
    if !ok { ... }
    [code using iter.Key() and iter.Value()]
}
if err := iter.Error(); err != nil {
  ...
}

func NewMVCCIncrementalIterator

func NewMVCCIncrementalIterator(
	e engine.Reader, startTime, endTime hlc.Timestamp,
) *MVCCIncrementalIterator

NewMVCCIncrementalIterator creates an MVCCIncrementalIterator with the specified engine and time range.

func (*MVCCIncrementalIterator) Close

func (i *MVCCIncrementalIterator) Close()

Close frees up resources held by the iterator.

func (*MVCCIncrementalIterator) Key

Key returns the current key.

func (*MVCCIncrementalIterator) Next

func (i *MVCCIncrementalIterator) Next()

Next advances the iterator to the next key/value in the iteration. After this call, Valid() will be true if the iterator was not positioned at the last key.

func (*MVCCIncrementalIterator) NextKey added in v1.1.0

func (i *MVCCIncrementalIterator) NextKey()

NextKey advances the iterator to the next MVCC key. This operation is distinct from Next which advances to the next version of the current key or the next key if the iterator is currently located at the last version for a key.

func (*MVCCIncrementalIterator) Seek added in v1.1.0

func (i *MVCCIncrementalIterator) Seek(startKey engine.MVCCKey)

Seek advances the iterator to the first key in the engine which is >= the provided key.

func (*MVCCIncrementalIterator) UnsafeKey

func (i *MVCCIncrementalIterator) UnsafeKey() engine.MVCCKey

UnsafeKey returns the same key as Key, but the memory is invalidated on the next call to {Next,Reset,Close}.

func (*MVCCIncrementalIterator) UnsafeValue

func (i *MVCCIncrementalIterator) UnsafeValue() []byte

UnsafeValue returns the same value as Value, but the memory is invalidated on the next call to {Next,Reset,Close}.

func (*MVCCIncrementalIterator) Valid

func (i *MVCCIncrementalIterator) Valid() (bool, error)

Valid must be called after any call to Reset(), Next(), or similar methods. It returns (true, nil) if the iterator points to a valid key (it is undefined to call Key(), Value(), or similar methods unless Valid() has returned (true, nil)). It returns (false, nil) if the iterator has moved past the end of the valid range, or (false, err) if an error has occurred. Valid() will never return true with a non-nil error.

func (*MVCCIncrementalIterator) Value

func (i *MVCCIncrementalIterator) Value() []byte

Value returns the current value as a byte slice.

Jump to

Keyboard shortcuts

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