Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrEmptyKeys = errors.New("empty keys under store builder")
)
View Source
var (
ErrKeyNotExist = errors.New("key not exist in kv table")
)
for testing
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder interface { // FileNumber returns file name for store builder FileNumber() FileNumber // Add puts k/v pair init sst file write buffer // NOTICE: key must key in sort by desc Add(key uint32, value []byte) error // StreamWriter returns a writer for streaming writing data StreamWriter() StreamWriter // MinKey returns min key in store MinKey() uint32 // MaxKey returns max key in store MaxKey() uint32 // Size returns the length of store file Size() uint32 // Count returns the number of k/v pairs contained in the store Count() uint64 // Abandon abandons current store build for some reason Abandon() error // Close closes sst file write buffer Close() error }
Builder represents sst file builder
func NewStoreBuilder ¶
func NewStoreBuilder(fileNumber FileNumber, fileName string) (Builder, error)
NewStoreBuilder creates store builder instance for building store file
type Cache ¶
type Cache interface { // GetReader returns store reader from cache, create new reader if not exist. GetReader(family string, fileName string) (Reader, error) // ReleaseReaders releases reader after read completed. ReleaseReaders(readers []Reader) // Evict evicts file reader from cache. Evict(fileName string) // Cleanup cleans the expired reader from cache. Cleanup() // Close cleans cache data after closing reader resource firstly. Close() error }
Cache caches table readers.
type FileNumber ¶
type FileNumber int64
FileNumber represents sst file number
func (FileNumber) Int64 ¶
func (i FileNumber) Int64() int64
Int64 returns the int64 value of file number
type Iterator ¶
type Iterator interface { // HasNext returns if the iteration has more element. // It returns false if the iterator is exhausted. HasNext() bool // Key returns the key of the current key/value pair Key() uint32 // Value returns the value of the current key/value pair Value() []byte }
Iterator iterates over a store's key/value pairs in key order.
func NewMergedIterator ¶
NewMergedIterator create merged iterator for multi iterators
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func (*LRUCache) Purge ¶
func (c *LRUCache) Purge(fn func(entry *cacheEntry))
Purge is used to completely clear the cache.
type Reader ¶
type Reader interface { // Path returns the file path. Path() string // FileName returns the file name of reader. FileName() string // Get returns value for giving key, // if key not exist, return nil, ErrKeyNotExist. Get(key uint32) ([]byte, error) // Iterator iterates over a store's key/value pairs in key order. Iterator() Iterator // Close closes reader, release related resources. Close() error }
Reader represents reader which reads k/v pair from store file.
type StreamWriter ¶
type StreamWriter interface { // Prepare the writer with specified key // Resets the size and checksum Prepare(key uint32) // Writer writes buffer into the underlying file io.Writer // Size returns total written size of Write // Prepare will resets it to zero. Size() uint32 // CRC32CheckSum returns a IEEE checksum of written bytes CRC32CheckSum() uint32 // Commit marks the key/value pair has been written Commit() error }
StreamWriter writes multi buffer into the builder continuously Call Prepare, Write, Commit in order. sw.Prepare(1) sw.Write(...) sw.Write(...) sw.Commit()
Click to show internal directories.
Click to hide internal directories.