Documentation ¶
Index ¶
- Constants
- type Config
- type DB
- func (db *DB) CompactNTables(n int) error
- func (db *DB) Delete(key string) error
- func (db *DB) Get(key string) (string, bool)
- func (db *DB) GetCompactableFiles() []string
- func (db *DB) GetDirectory() string
- func (db *DB) GetSSTableIndex(filename string) int
- func (db *DB) GetTableSize() int
- func (db *DB) MergeFiles(f1, f2 string) error
- func (db *DB) Put(key, val string) error
- func (db *DB) Run() error
- func (db *DB) Stop() error
- type WRequest
Constants ¶
const MaxMemSize int64 = 1024 * 256
256 kb
const MaxSSTableSize int64 = 1024 * 1014 * 24
24 mb
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config represents different parameters to change te default behaviour of the database
func DefaultConfiguration ¶
func DefaultConfiguration() *Config
DefaultConfiguration returns a database config that has some default values
type DB ¶
type DB struct { Alive bool MEM *mem.MEM SSTables []*sstable.SSTable MEMQueue []*mem.MEM // contains filtered or unexported fields }
DB represents the database as a whole.
func (*DB) CompactNTables ¶
compactNTables combines the last n sstables.
func (*DB) Delete ¶
Delete has almost exactly the same functionality as read, but instead we set the value of the key to a TombstoneValue which just corresponds to a string where the first character is a null-byte. We cannot remove the key from the in-memory table since it might reside in the queue or sstable. The key will be ultimately deleted when sstable compaction happens.
func (*DB) Get ¶
Get tries to find the wanted key from the in-memory table, and if not found checks it then checks the queue for the value. If the value is not found in the queue, check the sstables. If the value corresponds to a TombstoneValue return a invalid key since the key was "deleted".
func (*DB) GetCompactableFiles ¶
GetCompactableFiles returns all of the files in the SSTable directory that are small enough.
func (*DB) GetDirectory ¶
GetDirectory returns the directory in which all of the files are stored.
func (*DB) GetSSTableIndex ¶
GetSSTableIndex returns the index of the sstable with a given filename
func (*DB) GetTableSize ¶
GetTableSize returns the amount of sstables indexed
func (*DB) MergeFiles ¶
func (*DB) Put ¶
Put writes a value into the in-memory table and also checks if the amount of items in the in-memory table exceeds the amount specified in the database configuation. If the number is exceeded, add the in-memory table to the start of the queue.