Documentation ¶
Index ¶
Constants ¶
const HeaderSize = 16
HeaderSize describes the general offset in a segment until the data starts, it is composed of 2 bytes for level, 2 bytes for version, 2 bytes for secondary index count, 2 bytes for strategy, 8 bytes for the pointer to the index part
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskTree ¶
type DiskTree struct {
// contains filtered or unexported fields
}
DiskTree is a read-only wrapper around a marshalled index search tree, which can be used for reading, but cannot change the underlying structure. It is thus perfectly suited as an index for an (immutable) LSM disk segment, but pretty much useless for anything else
func NewDiskTree ¶
func (*DiskTree) AllKeys ¶
AllKeys is a relatively expensive operation as it basically does a full disk read of the index. It is meant for one of operations, such as initializing a segment where we need access to all keys, e.g. to build a bloom filter. This should not run at query time.
The binary tree is traversed in Level-Order so keys have no meaningful order. Do not use this method if an In-Order traversal is required, but only for use cases who don't require a specific order, such as building a bloom filter.
func (*DiskTree) QuantileKeys ¶ added in v1.25.11
QuantileKeys returns a list of keys that roughly represent the quantiles of the tree. This can be very useful to bootstrap parallel cursors over the segment that are more or less evenly distributed.
This method uses the natural shape of the tree to determine the distribution of the keys. This is a performance-accuracy trade-off. It does not guarantee perfect distribution, but it is fairly cheap to obtain as most runs will only need to go a few levels deep – even on massive trees.
The number of keys returned is not guaranteed to be exactly q, in most cases returns more keys. This is because in a real-life application you would likely aggregate across multiple segments. Similarly keys are not returned in any specific order, as the assumption is that post-processing will be done when keys are aggregated across multiple segments.
The two guarantees you get are:
- If there are at least q keys in the tree, you will get at least q keys, most likely more
- If there are less than q keys in the tree, you will get all keys.
type Header ¶ added in v1.18.0
type Header struct { Level uint16 Version uint16 SecondaryIndices uint16 Strategy Strategy IndexStart uint64 }
func (*Header) PrimaryIndex ¶ added in v1.18.0
func (*Header) SecondaryIndex ¶ added in v1.18.0
type Key ¶ added in v1.18.0
Key is a helper struct that can be used to build the key nodes for the segment index. It contains the primary key and an arbitrary number of secondary keys, as well as valueStart and valueEnd indicator. Those are used to find the correct payload for each key.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}