Documentation ¶
Index ¶
- Constants
- Variables
- func CalcCRC(d []byte) uint32
- func LevelText(level logLevel) string
- func Search(pattern string, input []byte) (bool, error)
- type DebugEntry
- type LSMConfig
- type LSMTree
- func (lsm *LSMTree) Close() error
- func (lsm *LSMTree) Del(k string) error
- func (lsm *LSMTree) FlushToSSTableAndCycleWAL(memt *mtbl.RBTree) error
- func (lsm *LSMTree) Get(k string) ([]byte, error)
- func (lsm *LSMTree) GetBatch(keys ...string) (*binary.Batch, error)
- func (lsm *LSMTree) GetLinear(k string) ([]byte, error)
- func (lsm *LSMTree) Has(k string) bool
- func (lsm *LSMTree) Put(k string, v []byte) error
- func (lsm *LSMTree) PutBatch(batch *binary.Batch) error
- func (lsm *LSMTree) Scan(direction int, iter func(e *binary.Entry) bool) error
- func (lsm *LSMTree) Stats() (*LSMTreeStats, error)
- func (lsm *LSMTree) Sync() error
- type LSMTreeStats
- type Logger
- type ScanDirection
Constants ¶
const ( SizeKB = 1<<10 - 1 SizeMB = 1<<20 - 1 Size64KB = math.MaxUint16 Size4GB = math.MaxUint32 )
const ( LevelDebug logLevel = iota LevelInfo LevelWarn LevelError LevelFatal LevelOff )
const ( ScanNewToOld int = sstable.ScanNewToOld ScanOldToNew int = sstable.ScanOldToNew )
Variables ¶
var ( ErrKeyNotFound = errors.New("lsmt: key not found") ErrFoundTombstone = errors.New("lsmt: found tombstone or empty value") ErrDeleted = ErrFoundTombstone ErrNotFound = errors.New("lsmt: not found") ErrIncompleteSet = errors.New("lsmt: incomplete batch or set") ErrFlushThreshold = errors.New("lsmt: flush threshold has been reached") ErrBadKey = errors.New("lsmt: bad key") ErrKeyTooLarge = errors.New("lsmt: key too large") ErrBadValue = errors.New("lsmt: bad value") ErrValueTooLarge = errors.New("lsmt: value too large") ErrBadChecksum = errors.New("lsmt: bad checksum") )
var Tombstone = []byte(nil)
Functions ¶
Types ¶
type DebugEntry ¶ added in v1.7.0
func NewDebugEntry ¶ added in v1.7.0
func NewDebugEntry(k string, v []byte) *DebugEntry
func (*DebugEntry) IsOK ¶ added in v1.7.0
func (de *DebugEntry) IsOK(entry *DebugEntry) bool
type LSMConfig ¶ added in v1.3.1
type LSMConfig struct { BaseDir string // base directory SyncOnWrite bool // perform sync every time an entry is written LoggingLevel logLevel // enable logging FlushThreshold int64 // mem-table flush threshold BloomFilterSize uint // specify the bloom filter size MaxKeySize int64 // the max allowed key size MaxValueSize int64 // the maximum allowed value size }
LSMConfig holds configuration settings for an LSMTree instance
func DefaultConfig ¶ added in v1.7.0
type LSMTree ¶
type LSMTree struct {
// contains filtered or unexported fields
}
LSMTree is an LSMTree
func OpenLSMTree ¶
OpenLSMTree opens or creates an LSMTree instance.
func (*LSMTree) Del ¶
Del takes a key and overwrites the record with a tomstone or a 'deleted' or nil entry. It leaves the key in the LSMTree so that future table versions can properly merge.
func (*LSMTree) FlushToSSTableAndCycleWAL ¶ added in v1.7.0
func (*LSMTree) Get ¶
Get takes a key and attempts to find a match in the LSMTree. If a match cannot be found Get returns a nil value and ErrNotFound. Get first checks the bloom filter, then the mem-table. If it is still not found it attempts to do a binary search on the for the key in the ss-index and if that yields no result it will try to find the entry by doing a linear search of the ss-table itself.
func (*LSMTree) GetBatch ¶ added in v1.5.0
GetBatch attempts to find entries matching the keys provided. If a matching entry is found, it is added to the batch that is returned. If a matching entry cannot be found it is simply skipped and not added to the batch. GetBatch will return a nil error if all the matching entries were found. If it found some but not all, GetBatch will return ErrIncompleteSet along with the batch of entries that it could find. If it could not find any matches at all, the batch will be nil and GetBatch will return an ErrNotFound
func (*LSMTree) GetLinear ¶ added in v1.7.0
GetLinear takes a key and attempts to find a match in the LSMTree. If a match cannot be found Get returns a nil value and ErrNotFound. Get first checks the bloom filter, then the mem-table. If it is still not found [this is where it differs from Get] it attempts to do a linear search directly of the ss-table itself. It can be a bit quicker [if you know that your data is not memory resident.]
func (*LSMTree) Has ¶ added in v1.4.0
Has returns a boolean signaling weather or not the key is in the LSMTree. It should be noted that in some cases this may return a false positive, but it should never return a false negative.
func (*LSMTree) Put ¶
Put takes a key and a value and adds them to the LSMTree. If the entry already exists, it should overwrite the old entry.
func (*LSMTree) PutBatch ¶ added in v1.3.1
PutBatch takes a batch of entries and adds all of them at one time. It acts a bit like a transaction. If you have a configuration option of SyncOnWrite: true it will be disabled temporarily and the batch will sync at the end of all the writes. This is to give a slight performance advantage. It should be worth noting that very large batches may have an impact on performance and may also cause frequent ss-table flushes which may result in fragmentation.
func (*LSMTree) Scan ¶ added in v1.7.0
Scan takes a scan direction and an iteration function and scans the ss-tables in the provided direction (young to old, or old to young) and provides you with a pointer to each entry during iteration. *It should be noted that modification of the entry pointer has unknown effects.
func (*LSMTree) Stats ¶ added in v1.6.0
func (lsm *LSMTree) Stats() (*LSMTreeStats, error)
type LSMTreeStats ¶ added in v1.6.0
type LSMTreeStats struct { Config *LSMConfig `json:"config,omitempty"` MtEntries int `json:"mt_entries,omitempty"` MtSize int64 `json:"mt_size,omitempty"` BfEntries int `json:"bf_entries,omitempty"` BfSize int64 `json:"bf_size,omitempty"` }
func (*LSMTreeStats) JSON ¶ added in v1.6.0
func (s *LSMTreeStats) JSON() (string, error)
func (*LSMTreeStats) String ¶ added in v1.6.0
func (s *LSMTreeStats) String() string
type ScanDirection ¶ added in v1.7.0
type ScanDirection = sstable.ScanDirection