Documentation ¶
Overview ¶
Package k4 BSD 3-Clause License
Copyright (c) 2024, Alex Gaetano Padula All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- Constants
- type Iterator
- type K4
- func (k4 *K4) BeginTransaction() *Transaction
- func (k4 *K4) Close() error
- func (k4 *K4) Delete(key []byte) error
- func (k4 *K4) EscalateCompaction() error
- func (k4 *K4) EscalateFlush() error
- func (k4 *K4) Get(key []byte) ([]byte, error)
- func (k4 *K4) GreaterThan(key []byte) (*KeyValueArray, error)
- func (k4 *K4) GreaterThanEq(key []byte) (*KeyValueArray, error)
- func (k4 *K4) LessThan(key []byte) (*KeyValueArray, error)
- func (k4 *K4) LessThanEq(key []byte) (*KeyValueArray, error)
- func (k4 *K4) NGet(key []byte) (*KeyValueArray, error)
- func (k4 *K4) NRange(startKey, endKey []byte) (*KeyValueArray, error)
- func (k4 *K4) Put(key, value []byte, ttl *time.Duration) error
- func (k4 *K4) Range(startKey, endKey []byte) (*KeyValueArray, error)
- func (k4 *K4) RecoverFromWAL() error
- type KV
- type KeyValueArray
- type OPR_CODE
- type Operation
- type SSTable
- type SSTableIterator
- type Transaction
- type WALIterator
Constants ¶
const BACKGROUND_OP_SLEEP = 5 * time.Microsecond // The background sleep time for the background operations
const COMPRESSION_WINDOW_SIZE = 1024 * 32 // The compression window size
const LOG_EXTENSION = ".log" // The log file extension
const SSTABLE_EXTENSION = ".sst" // The SSTable file extension
const TOMBSTONE_VALUE = "$tombstone" // The tombstone value
const WAL_EXTENSION = ".wal" // The write ahead log file extension
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is a structure for an iterator which goes through memtable and sstables. First it goes through the memtable, then once exhausted goes through the sstables from newest to oldest
type K4 ¶
type K4 struct {
// contains filtered or unexported fields
}
K4 is the main structure for the k4 database
func Open ¶
func Open(directory string, memtableFlushThreshold int, compactionInterval int, logging, compress bool, args ...interface{}) (*K4, error)
Open opens a new K4 instance at the specified directory. will reopen the database if it already exists directory - the directory where the database files are stored memtableFlushThreshold - the threshold in bytes for flushing the memtable to disk compactionInterval - the interval in seconds for running compactions logging - whether or not to log to the log file
func (*K4) BeginTransaction ¶
func (k4 *K4) BeginTransaction() *Transaction
BeginTransaction begins a new transaction
func (*K4) EscalateCompaction ¶ added in v2.1.5
EscalateCompaction is a public method to force compaction
func (*K4) EscalateFlush ¶ added in v2.1.5
EscalateFlush is a public method to force flush memtable to queue
func (*K4) GreaterThan ¶
func (k4 *K4) GreaterThan(key []byte) (*KeyValueArray, error)
GreaterThan gets all keys greater than a key from K4 and returns a map of key-value pairs
func (*K4) GreaterThanEq ¶
func (k4 *K4) GreaterThanEq(key []byte) (*KeyValueArray, error)
GreaterThanEq queries keys greater than or equal to a key from K4
func (*K4) LessThan ¶
func (k4 *K4) LessThan(key []byte) (*KeyValueArray, error)
LessThan gets all keys less than a key from K4 and returns a map of key-value pairs
func (*K4) LessThanEq ¶
func (k4 *K4) LessThanEq(key []byte) (*KeyValueArray, error)
LessThanEq queries keys less than or equal to a key from K4
func (*K4) NGet ¶
func (k4 *K4) NGet(key []byte) (*KeyValueArray, error)
NGet gets a key from K4 and returns a map of key-value pairs
func (*K4) NRange ¶
func (k4 *K4) NRange(startKey, endKey []byte) (*KeyValueArray, error)
NRange returns key value pairs not in provided range
func (*K4) Range ¶
func (k4 *K4) Range(startKey, endKey []byte) (*KeyValueArray, error)
Range queries keys in a range from K4
func (*K4) RecoverFromWAL ¶
RecoverFromWAL recovers K4 from a write ahead log
type KV ¶
type KV struct { Key []byte // Binary array of key Value []byte // Binary array of keys value TTL *time.Time // Time to live }
KV mainly used for storage of key value pairs on disk pages we code the KV into a binary format before writing to disk
type Operation ¶
type Operation struct { Op OPR_CODE // Operation code Key []byte // Key for the operation Value []byte // Value for the operation Rollback *Operation // Pointer to the operation that will undo this operation } // fields must be exported for gob
Operation Used for transaction operations and WAL
type SSTable ¶
type SSTable struct {
// contains filtered or unexported fields
}
SSTable is the structure for the SSTable files
type SSTableIterator ¶
type SSTableIterator struct {
// contains filtered or unexported fields
}
SSTableIterator is the structure for the SSTable iterator
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is the structure for the transactions
func (*Transaction) AddOperation ¶
func (txn *Transaction) AddOperation(op OPR_CODE, key, value []byte)
AddOperation adds an operation to a transaction
func (*Transaction) Commit ¶
func (txn *Transaction) Commit(k4 *K4) error
Commit commits a transaction
func (*Transaction) Remove ¶
func (txn *Transaction) Remove(k4 *K4)
Remove removes a transaction from the list of transactions in K4
func (*Transaction) Rollback ¶
func (txn *Transaction) Rollback(k4 *K4) error
Rollback rolls back a transaction (after a commit)
type WALIterator ¶
type WALIterator struct {
// contains filtered or unexported fields
}
WALIterator is the structure for the WAL iterator
Directories ¶
Path | Synopsis |
---|---|
Package cuckoofilter implements a custom cuckoo filter data structure that allows for inserting and looking up keys with associated prefixes.
|
Package cuckoofilter implements a custom cuckoo filter data structure that allows for inserting and looking up keys with associated prefixes. |
Package pager BSD 3-Clause License
|
Package pager BSD 3-Clause License |
Package skiplist BSD 3-Clause License
|
Package skiplist BSD 3-Clause License |