Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- type DatabaseI
- type ExtraOption
- func CompactionFileThreshold(n int) ExtraOption
- func CompactionMaxSizeBytes(n uint64) ExtraOption
- func CompactionRunInterval(interval time.Duration) ExtraOption
- func DisableCompactions() ExtraOption
- func EnableAsyncWAL() ExtraOption
- func EnableDirectIOWAL() ExtraOption
- func MemstoreSizeBytes(n uint64) ExtraOption
- func ReadBufferSizeBytes(n uint64) ExtraOption
- func WriteBufferSizeBytes(n uint64) 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 DefaultReadBufferSizeBytes uint64 = 4 * 1024 * 1024 // 4Mb
const DefaultWriteBufferSizeBytes uint64 = 4 * 1024 * 1024 // 4Mb
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 ErrAlreadyClosed = errors.New("database is already closed")
var ErrAlreadyOpen = errors.New("database is already open")
var ErrEmptyKeyValue = errors.New("neither empty keys nor values are allowed")
var ErrNotFound = errors.New("ErrNotFound")
var ErrNotOpenedYet = errors.New("database has not been opened yet, please call Open() first")
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 ErrNotFound 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 stores it and makes 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 DisableCompactions ¶
func DisableCompactions() ExtraOption
DisableCompactions will disable the compaction process from running. Default is enabled.
func EnableAsyncWAL ¶ added in v1.4.0
func EnableAsyncWAL() ExtraOption
EnableAsyncWAL will turn on the asynchronous WAL writes, which should give faster writes at the expense of safety.
func EnableDirectIOWAL ¶ added in v1.4.0
func EnableDirectIOWAL() ExtraOption
EnableDirectIOWAL will turn on the WAL writes using DirectIO, which should give faster aligned block writes and less cache churn.
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.
func ReadBufferSizeBytes ¶ added in v1.6.2
func ReadBufferSizeBytes(n uint64) ExtraOption
ReadBufferSizeBytes is the read buffer size for all buffer used by simple db.
func WriteBufferSizeBytes ¶ added in v1.6.2
func WriteBufferSizeBytes(n uint64) ExtraOption
WriteBufferSizeBytes is the write buffer size for all buffer used by simple db.
type ExtraOptions ¶
type ExtraOptions struct {
// contains filtered or unexported fields
}
type RWMemstore ¶
type RWMemstore struct {
// contains filtered or unexported fields
}
RWMemstore 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.Comparator[[]byte], dbLock *sync.RWMutex, basePath string) *SSTableManager