Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- type DatabaseI
- type ExtraOption
- type ExtraOptions
- type RWMemstore
- func (c *RWMemstore) Add(key []byte, value []byte) error
- func (c *RWMemstore) Contains(key []byte) bool
- func (c *RWMemstore) Delete(key []byte) error
- func (c *RWMemstore) DeleteIfExists(key []byte) error
- func (c *RWMemstore) EstimatedSizeInBytes() uint64
- func (c *RWMemstore) Flush(opts ...sstables.WriterOption) error
- func (c *RWMemstore) Get(key []byte) ([]byte, error)
- func (c *RWMemstore) SStableIterator() sstables.SSTableIteratorI
- func (c *RWMemstore) Size() int
- func (c *RWMemstore) Tombstone(key []byte) error
- func (c *RWMemstore) Upsert(key []byte, value []byte) error
- type SSTableManager
Constants ¶
const CompactionFinishedSuccessfulFileName = "compaction_successful"
const DefaultCompactionInterval = 5 * time.Second
const DefaultCompactionMaxSizeBytes uint64 = 5 * 1024 * 1024 * 1024 // 5gb
const MemStoreMaxSizeBytes uint64 = 1024 * 1024 * 1024 // 1gb
const NumSSTablesToTriggerCompaction int = 10
const SSTableCompactionPathPrefix = SSTablePrefix + "_compaction"
const SSTablePattern = SSTablePrefix + "_%015d"
const SSTablePrefix = "sstable"
const WriteAheadFolder = "wal"
Variables ¶
var AlreadyClosed = errors.New("database is already closed")
var EmptyKeyValue = errors.New("neither empty keys nor values are allowed")
var NotFound = errors.New("NotFound")
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewSimpleDB ¶
func NewSimpleDB(basePath string, extraOptions ...ExtraOption) (*DB, error)
NewSimpleDB creates a new db that requires a directory that exist, it can be empty in case of existing databases. The error in case it doesn't exist can be checked using normal os package functions like os.IsNotExist(err)
type DatabaseI ¶
type DatabaseI interface { recordio.OpenClosableI // Get returns the value for the given key. If there is no value for the given // key it will return NotFound as the error and an empty string value. Otherwise // the error will contain any other usual io error that can be expected. Get(key string) (string, error) // Put adds the given value for the given key. If this key already exists, it will // overwrite the already existing value with the given one. // Unfortunately this method does not support empty keys and values, that will immediately return an error. Put(key, value string) error // Delete will delete the value for the given key. It will ignore when a key does not exist in the database. // Underneath it will be tombstoned, which still store it and make it not retrievable through this interface. Delete(key string) error }
type ExtraOption ¶
type ExtraOption func(options *ExtraOptions)
func CompactionFileThreshold ¶
func CompactionFileThreshold(n int) ExtraOption
CompactionFileThreshold tells how often SSTables are being compacted, this is measured in the number of SSTables. The default is 10, which in turn will compact into a single SSTable.
func CompactionMaxSizeBytes ¶
func CompactionMaxSizeBytes(n uint64) ExtraOption
CompactionMaxSizeBytes tells whether an SSTable is considered for compaction. SSTables over the given threshold will not be compacted any further. Default is 5GB in DefaultCompactionMaxSizeBytes.
func CompactionRunInterval ¶
func CompactionRunInterval(interval time.Duration) ExtraOption
CompactionRunInterval configures how often the compaction ticker tries to compact sstables. By default it's every DefaultCompactionInterval.
func DisableAsyncWAL ¶
func DisableAsyncWAL() ExtraOption
DisableAsyncWAL will turn off the asynchronous WAL writes, which should give consistent, but slower results.
func DisableCompactions ¶
func DisableCompactions() ExtraOption
DisableCompactions will disable the compaction process from running. Default is enabled.
func MemstoreSizeBytes ¶
func MemstoreSizeBytes(n uint64) ExtraOption
MemstoreSizeBytes controls the size of the memstore, after this limit is hit the memstore will be written to disk. Default is 1 GiB.
type ExtraOptions ¶
type ExtraOptions struct {
// contains filtered or unexported fields
}
type RWMemstore ¶
type RWMemstore struct {
// contains filtered or unexported fields
}
the RW memstore contains two memstores, one for reading, one for writing. the one that writes takes precedence over the read store (for the same key).
func (*RWMemstore) Contains ¶
func (c *RWMemstore) Contains(key []byte) bool
func (*RWMemstore) Delete ¶
func (c *RWMemstore) Delete(key []byte) error
func (*RWMemstore) DeleteIfExists ¶
func (c *RWMemstore) DeleteIfExists(key []byte) error
func (*RWMemstore) EstimatedSizeInBytes ¶
func (c *RWMemstore) EstimatedSizeInBytes() uint64
func (*RWMemstore) Flush ¶
func (c *RWMemstore) Flush(opts ...sstables.WriterOption) error
func (*RWMemstore) SStableIterator ¶
func (c *RWMemstore) SStableIterator() sstables.SSTableIteratorI
func (*RWMemstore) Size ¶
func (c *RWMemstore) Size() int
func (*RWMemstore) Tombstone ¶
func (c *RWMemstore) Tombstone(key []byte) error
type SSTableManager ¶
type SSTableManager struct {
// contains filtered or unexported fields
}
func NewSSTableManager ¶
func NewSSTableManager(cmp skiplist.KeyComparator, dbLock *sync.RWMutex, basePath string) *SSTableManager