Documentation ¶
Index ¶
- Constants
- func Add(bloomFilter *pb.BloomFilter, key []byte)
- func Contains(bloomFilter *pb.BloomFilter, key []byte) bool
- func MarshalEntry(pb proto.Message) []byte
- func UnmarshalEntry(bytes []byte, entry protoreflect.ProtoMessage)
- type EntrySize
- type KVPair
- type LSMTree
- type Memtable
- func (m *Memtable) Clear()
- func (m *Memtable) Delete(key string)
- func (m *Memtable) GenerateEntries() []*pb.LSMEntry
- func (m *Memtable) Get(key string) *pb.LSMEntry
- func (m *Memtable) Len() int
- func (m *Memtable) Put(key string, value []byte)
- func (m *Memtable) RangeScan(startKey, endKey string) []*pb.LSMEntry
- func (m *Memtable) SizeInBytes() int64
- type SSTable
- type SSTableIterator
Constants ¶
const ( BloomFilterSize = 1000000 // 1 million bits. InitialOffset = 0 // Initial offset for the data entries. SSTableFilePrefix = "sstable_" // Prefix for SSTable files. WALDirectorySuffix = "_wal" // Suffix for WAL directory. MaxLevels = 6 // Maximum number of levels in the LSM tree. WALMaxFileSize = 128000 // 128 KB WALMaxSegments = 1000 // Maximum number of WAL segments. )
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(bloomFilter *pb.BloomFilter, key []byte) bool
Check if key is in the BloomFilter
func MarshalEntry ¶
MarshalEntry marshals any proto message into a byte slice and panics if there is an error.
func UnmarshalEntry ¶
func UnmarshalEntry(bytes []byte, entry protoreflect.ProtoMessage)
UnmarshalEntry unmarshals the data into the entry and panics if there is an error.
Types ¶
type LSMTree ¶
type LSMTree struct {
// contains filtered or unexported fields
}
type Memtable ¶
type Memtable struct {
// contains filtered or unexported fields
}
Memtable is a memory table that supports fast writes, reads, deletes, and range scans. It uses a skip list as the underlying data structure to store key-value pairs.
func (*Memtable) Clear ¶
func (m *Memtable) Clear()
Clear resets the memtable to an empty state. Not Thread-Safe Implementation.
func (*Memtable) GenerateEntries ¶
GenerateEntries returns a serializable list of memtable entries in sorted order. Not Thread-Safe Implementation.
func (*Memtable) Get ¶
Get retrieves a value for a given key from the memtable, Not Thread-Safe Implementation.
func (*Memtable) Put ¶
Put inserts a key-value pair into the memtable, Not Thread-Safe Implementation.
func (*Memtable) RangeScan ¶
RangeScan returns all key-value pairs in the memtable within the given key range, Not Thread-Safe Implementation. The startKey is inclusive, and the endKey is inclusive.
func (*Memtable) SizeInBytes ¶
SizeInBytes returns the size of the memtable in bytes. Not Thread-Safe Implementation.
type SSTable ¶
type SSTable struct {
// contains filtered or unexported fields
}
func OpenSSTable ¶
OpenSSTable opens an SSTable file and returns an SSTable object for reading.
func SerializeToSSTable ¶
Writes a list of MemtableKeyValue entires to file in SSTable format. The format of the SSTable file is as follows: 1. Bloom filter size (OffsetSize) 2. Bloom filter data (BloomFilter ProtoBuf) 3. Index size (OffsetSize) 4. Index data (Index ProtoBuf) 5. Data entries
The data entries are written in the following format: 1. Size of the entry (OffsetSize) 2. Entry data (LSMEntry ProtoBuf)
func (*SSTable) Front ¶
func (s *SSTable) Front() *SSTableIterator
Front returns an Iterator for the SSTable. The iterator is positioned at the first entry in the SSTable.
func (*SSTable) Get ¶
Get returns the value/ for the given key from the SSTable. Returns nil if the key is not found.
func (*SSTable) GetEntries ¶
GetEntries returns all the entries in the SSTable.
type SSTableIterator ¶
type SSTableIterator struct { Value *pb.LSMEntry // current entry. // contains filtered or unexported fields }
SSTableIterator is an iterator for SSTable
func (*SSTableIterator) Next ¶
func (it *SSTableIterator) Next() *SSTableIterator
Next returns the next entry in the SSTable. Returns nil if there are no more entries.