Documentation ¶
Index ¶
- Constants
- Variables
- type BloomFilter
- func (bf *BloomFilter) Add(item []byte)
- func (*BloomFilter) Descriptor() ([]byte, []int)deprecated
- func (x *BloomFilter) GetBitset() []bool
- func (x *BloomFilter) GetSize() int64
- func (*BloomFilter) ProtoMessage()
- func (x *BloomFilter) ProtoReflect() protoreflect.Message
- func (x *BloomFilter) Reset()
- func (x *BloomFilter) String() string
- func (bf *BloomFilter) Test(item []byte) bool
- type Command
- type EntrySize
- type Index
- type IndexEntry
- type KVPair
- type LSMTree
- type Memtable
- func (m *Memtable) Clear()
- func (m *Memtable) Delete(key string)
- func (m *Memtable) Get(key string) *MemtableEntry
- func (m *Memtable) GetEntries() []*MemtableEntry
- func (m *Memtable) Len() int
- func (m *Memtable) Put(key string, value []byte)
- func (m *Memtable) RangeScan(startKey string, endKey string) []*MemtableEntry
- func (m *Memtable) SizeInBytes() int64
- type MemtableEntry
- func (*MemtableEntry) Descriptor() ([]byte, []int)deprecated
- func (x *MemtableEntry) GetCommand() Command
- func (x *MemtableEntry) GetKey() string
- func (x *MemtableEntry) GetTimestamp() int64
- func (x *MemtableEntry) GetValue() []byte
- func (*MemtableEntry) ProtoMessage()
- func (x *MemtableEntry) ProtoReflect() protoreflect.Message
- func (x *MemtableEntry) Reset()
- func (x *MemtableEntry) String() string
- type SSTable
- type SSTableIterator
- type WALEntry
- func (*WALEntry) Descriptor() ([]byte, []int)deprecated
- func (x *WALEntry) GetCommand() Command
- func (x *WALEntry) GetKey() string
- func (x *WALEntry) GetTimestamp() int64
- func (x *WALEntry) GetValue() []byte
- func (*WALEntry) ProtoMessage()
- func (x *WALEntry) ProtoReflect() protoreflect.Message
- func (x *WALEntry) Reset()
- func (x *WALEntry) String() string
Constants ¶
const ( SSTableFilePrefix = "sstable_" WALDirectorySuffix = "_wal" )
Variables ¶
var ( Command_name = map[int32]string{ 0: "PUT", 1: "DELETE", 2: "WRITE_SST", } Command_value = map[string]int32{ "PUT": 0, "DELETE": 1, "WRITE_SST": 2, } )
Enum value maps for Command.
var File_serialization_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶
type BloomFilter struct { Bitset []bool `protobuf:"varint,1,rep,packed,name=bitset,proto3" json:"bitset,omitempty"` Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*BloomFilter) Add ¶
func (bf *BloomFilter) Add(item []byte)
Add adds an item to the Bloom filter.
func (*BloomFilter) Descriptor
deprecated
func (*BloomFilter) Descriptor() ([]byte, []int)
Deprecated: Use BloomFilter.ProtoReflect.Descriptor instead.
func (*BloomFilter) GetBitset ¶
func (x *BloomFilter) GetBitset() []bool
func (*BloomFilter) GetSize ¶
func (x *BloomFilter) GetSize() int64
func (*BloomFilter) ProtoMessage ¶
func (*BloomFilter) ProtoMessage()
func (*BloomFilter) ProtoReflect ¶
func (x *BloomFilter) ProtoReflect() protoreflect.Message
func (*BloomFilter) Reset ¶
func (x *BloomFilter) Reset()
func (*BloomFilter) String ¶
func (x *BloomFilter) String() string
func (*BloomFilter) Test ¶
func (bf *BloomFilter) Test(item []byte) bool
Test checks if an item might be in the Bloom filter.
type Command ¶
type Command int32
func (Command) Descriptor ¶
func (Command) Descriptor() protoreflect.EnumDescriptor
func (Command) EnumDescriptor
deprecated
func (Command) Number ¶
func (x Command) Number() protoreflect.EnumNumber
func (Command) Type ¶
func (Command) Type() protoreflect.EnumType
type Index ¶
type Index struct { Entries []*IndexEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` // contains filtered or unexported fields }
func (*Index) Descriptor
deprecated
func (*Index) GetEntries ¶
func (x *Index) GetEntries() []*IndexEntry
func (*Index) ProtoMessage ¶
func (*Index) ProtoMessage()
func (*Index) ProtoReflect ¶
func (x *Index) ProtoReflect() protoreflect.Message
type IndexEntry ¶
type IndexEntry struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` // contains filtered or unexported fields }
func (*IndexEntry) Descriptor
deprecated
func (*IndexEntry) Descriptor() ([]byte, []int)
Deprecated: Use IndexEntry.ProtoReflect.Descriptor instead.
func (*IndexEntry) GetKey ¶
func (x *IndexEntry) GetKey() string
func (*IndexEntry) GetOffset ¶
func (x *IndexEntry) GetOffset() int64
func (*IndexEntry) ProtoMessage ¶
func (*IndexEntry) ProtoMessage()
func (*IndexEntry) ProtoReflect ¶
func (x *IndexEntry) ProtoReflect() protoreflect.Message
func (*IndexEntry) Reset ¶
func (x *IndexEntry) Reset()
func (*IndexEntry) String ¶
func (x *IndexEntry) String() string
type LSMTree ¶
type LSMTree struct {
// contains filtered or unexported fields
}
func Open ¶
Opens an LSMTree. If the directory does not exist, it will be created. directory: The directory where the SSTables will be stored. maxMemtableSize: The maximum size of the memtable in bytes before it is flushed to an SSTable. runRecovery: If true, the LSMTree will recover from the WAL on startup. On startup, the LSMTree will load all the SSTables handles (if any) from disk into memory.
func (*LSMTree) Get ¶
Get the value for a given key from the LSMTree. Returns nil if the key is not found. This function will first look in the memtable, then in the SSTables.
type Memtable ¶
type Memtable struct {
// contains filtered or unexported fields
}
In-memory table that supports writes, reads, deletes, and range scans.
func (*Memtable) Get ¶
func (m *Memtable) Get(key string) *MemtableEntry
Retrieve a value from the Memtable. Not thread-safe.
func (*Memtable) GetEntries ¶
func (m *Memtable) GetEntries() []*MemtableEntry
Generates serializable list of memtable entries in sorted order for SSTable. Not thread-safe.
func (*Memtable) Len ¶
Get the number of entries in the Memtable. Includes tombstones. Not thread-safe.
func (*Memtable) RangeScan ¶
func (m *Memtable) RangeScan(startKey string, endKey string) []*MemtableEntry
Range scan the Memtable, inclusive of startKey and endKey. Not thread-safe.
func (*Memtable) SizeInBytes ¶
Get the size of the Memtable in bytes. Not thread-safe.
type MemtableEntry ¶
type MemtableEntry struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Command Command `protobuf:"varint,2,opt,name=command,proto3,enum=grpcapi.Command" json:"command,omitempty"` Value []byte `protobuf:"bytes,3,opt,name=value,proto3,oneof" json:"value,omitempty"` Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
func (*MemtableEntry) Descriptor
deprecated
func (*MemtableEntry) Descriptor() ([]byte, []int)
Deprecated: Use MemtableEntry.ProtoReflect.Descriptor instead.
func (*MemtableEntry) GetCommand ¶
func (x *MemtableEntry) GetCommand() Command
func (*MemtableEntry) GetKey ¶
func (x *MemtableEntry) GetKey() string
func (*MemtableEntry) GetTimestamp ¶
func (x *MemtableEntry) GetTimestamp() int64
func (*MemtableEntry) GetValue ¶
func (x *MemtableEntry) GetValue() []byte
func (*MemtableEntry) ProtoMessage ¶
func (*MemtableEntry) ProtoMessage()
func (*MemtableEntry) ProtoReflect ¶
func (x *MemtableEntry) ProtoReflect() protoreflect.Message
func (*MemtableEntry) Reset ¶
func (x *MemtableEntry) Reset()
func (*MemtableEntry) String ¶
func (x *MemtableEntry) String() string
type SSTable ¶
type SSTable struct {
// contains filtered or unexported fields
}
func OpenSSTable ¶
Opens an SSTable file for reading and returns a handle to it.
func SerializeToSSTable ¶
func SerializeToSSTable(messages []*MemtableEntry, filename string) (*SSTable, error)
Writes a list of MemtableKeyValue to a file in SSTable format. Format of the file is: 1. Bloom filter size (OffsetSize) 2. Bloom filter data (BloomFilter Protobuf) 3. Index size (OffsetSize) 4. Index data (Index Protobuf) 5. Entries data
The entries data is written in as: 1. Size of the entry (OffsetSize) 2. Entry data (MemtableEntry Protobuf)
func (*SSTable) Front ¶
func (s *SSTable) Front() *SSTableIterator
Returns an iterator for the SSTable. The iterator is positioned at the beginning of the SSTable.
func (*SSTable) Get ¶
func (s *SSTable) Get(key string) (*MemtableEntry, error)
Reads the value for a given key from the SSTable. Returns nil if the key is not found.
func (*SSTable) GetEntries ¶
func (s *SSTable) GetEntries() ([]*MemtableEntry, error)
GetEntries returns all the values in the SSTable.
type SSTableIterator ¶
type SSTableIterator struct { Value *MemtableEntry // Current entry // contains filtered or unexported fields }
func (*SSTableIterator) Next ¶
func (i *SSTableIterator) Next() *SSTableIterator
Returns the next entry in the SSTable. Returns nil if there are no more entries.
type WALEntry ¶
type WALEntry struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Command Command `protobuf:"varint,2,opt,name=command,proto3,enum=grpcapi.Command" json:"command,omitempty"` Value []byte `protobuf:"bytes,3,opt,name=value,proto3,oneof" json:"value,omitempty"` Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
func (*WALEntry) Descriptor
deprecated
func (*WALEntry) GetCommand ¶
func (*WALEntry) GetTimestamp ¶
func (*WALEntry) ProtoMessage ¶
func (*WALEntry) ProtoMessage()
func (*WALEntry) ProtoReflect ¶
func (x *WALEntry) ProtoReflect() protoreflect.Message