Documentation ¶
Index ¶
- Constants
- func NewMergeIterator(iters []y.Iterator, reverse bool) y.Iterator
- type Builder
- type CompressionType
- type ConcatIterator
- type Iterator
- func (itr *Iterator) Close() error
- func (itr *Iterator) Key() []byte
- func (itr *Iterator) Next()
- func (itr *Iterator) Rewind()
- func (itr *Iterator) Seek(key []byte)
- func (itr *Iterator) Valid() bool
- func (itr *Iterator) Value() (ret y.ValueStruct)
- func (itr *Iterator) ValueCopy() (ret y.ValueStruct)
- type MergeIterator
- type Table
- type TableInterface
Constants ¶
const ( KB = 1024 MB = KB * 1024 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used in building a table.
func NewTableBuilder ¶
func NewTableBuilder(stream streamclient.StreamClient, ct CompressionType) *Builder
NewTableBuilder makes a new TableBuilder.
func (*Builder) Add ¶
func (b *Builder) Add(key []byte, value y.ValueStruct)
Add adds a key-value pair to the block.
func (*Builder) Close ¶
func (b *Builder) Close()
Close closes the TableBuilder, FinishAll will close go routine and wait
func (*Builder) FinishAll ¶
func (b *Builder) FinishAll(headExtentID uint64, headOffset uint32, seqNum uint64, discards map[uint64]int64, memorySize uint64) (uint64, uint32, error)
Finish finishes the table by appending the index.
The table structure looks like +---------+------------+-----------+---------------+ | Block 1 | Block 2 | Block 3 | Block 4 | +---------+------------+-----------+---------------+ | Block 5 | Block 6 | Block ... | Block N | +---------+------------+-----------+---------------+ | MetaBlock | +---------+------------+-----------+---------------+
return metablock position(extentID, offset, error) tailExtentID和tailOffset表示当前commitLog对应的结尾, 在打开commitlog后, 从(tailExtentID, tailOffset)开始的 block读数据, 生成mt
func (*Builder) FinishBlock ¶
func (b *Builder) FinishBlock()
Structure of Block. +-------------------+---------------------+--------------------+--------------+------------------+ | Entry1 | Entry2 | Entry3 | Entry4 | Entry5 | +-------------------+---------------------+--------------------+--------------+------------------+ | Entry6 | ... | ... | ... | EntryN | +-------------------+---------------------+--------------------+--------------+------------------+ | Block Meta(contains list of offsets used| Block Meta Size | | | | to perform binary search in the block) | (4 Bytes) | | | +-----------------------------------------+--------------------+--------------+------------------+
In case the data is encrypted, the "IV" is added to the end of the block.
type CompressionType ¶
type CompressionType uint32
const ( None CompressionType = 0 Snappy CompressionType = 1 ZSTD CompressionType = 2 )
type ConcatIterator ¶
type ConcatIterator struct {
// contains filtered or unexported fields
}
ConcatIterator concatenates the sequences defined by several iterators. (It only works with TableIterators, probably just because it's faster to not be so generic.)
func NewConcatIterator ¶
func NewConcatIterator(tbls []*Table, reversed bool) *ConcatIterator
NewConcatIterator creates a new concatenated iterator
func (*ConcatIterator) Seek ¶
func (s *ConcatIterator) Seek(key []byte)
Seek brings us to element >= key if reversed is false. Otherwise, <= key.
func (*ConcatIterator) Value ¶
func (s *ConcatIterator) Value() y.ValueStruct
Value implements y.Interface
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is an iterator for a Table.
func (*Iterator) Value ¶
func (itr *Iterator) Value() (ret y.ValueStruct)
Value follows the y.Iterator interface
func (*Iterator) ValueCopy ¶
func (itr *Iterator) ValueCopy() (ret y.ValueStruct)
ValueCopy copies the current value and returns it as decoded ValueStruct.
type MergeIterator ¶
type MergeIterator struct {
// contains filtered or unexported fields
}
MergeIterator merges multiple iterators. NOTE: MergeIterator owns the array of iterators and is responsible for closing them.
func (*MergeIterator) Key ¶
func (mi *MergeIterator) Key() []byte
Key returns the key associated with the current iterator.
func (*MergeIterator) Next ¶
func (mi *MergeIterator) Next()
Next returns the next element. If it is the same as the current key, ignore it.
func (*MergeIterator) Rewind ¶
func (mi *MergeIterator) Rewind()
Rewind seeks to first element (or last element for reverse iterator).
func (*MergeIterator) Seek ¶
func (mi *MergeIterator) Seek(key []byte)
Seek brings us to element with key >= given key.
func (*MergeIterator) Valid ¶
func (mi *MergeIterator) Valid() bool
Valid returns whether the MergeIterator is at a valid element.
func (*MergeIterator) Value ¶
func (mi *MergeIterator) Value() y.ValueStruct
Value returns the value associated with the iterator.
type Table ¶
type Table struct { utils.SafeMutex // Stores the total size of key-values in skiplist. EstimatedSize uint64 Loc pspb.Location //saved address in rowStream LastSeq uint64 //all data before [vpExtentID, vpOffset] is in rowStream. log replay starts from [vpExtentID, vpOffset] VpExtentID uint64 VpOffset uint32 //extentID => discard count Discards map[uint64]int64 CompressionType CompressionType CompressedSize uint32 UncompressedSize uint32 // contains filtered or unexported fields }
func OpenTable ¶
func OpenTable(streamReader streamclient.StreamClient, extentID uint64, offset uint32) (*Table, error)
func (*Table) DoesNotHave ¶
func (*Table) FirstOccurrence ¶
func (*Table) MidKey ¶
the first key of the block with a zero-based index of (n) / 2, where the total number of table is n
func (*Table) NewIterator ¶
NewIterator returns a new iterator of the Table