Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitReadSeeker ¶
func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker
Types ¶
type LimitedReadSeeker ¶
type LimitedReadSeeker struct { R io.ReadSeeker N int64 }
LimitedReadSeeker provides the same interface for io.LimitedReader for types implementing io.ReadSeeker.
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
Segment implements kv.Segment using an SSTable. It uses a contingous body of read-only, ordered, and encoded KVPair's in order to store the contents of a MemoryStore into a more durable long-term format. Internally, it uses a MemoryStore in order to build a sparse index of its stored KVPair's to reduce the amount of IO required to find a key.
func NewSegment ¶
func NewSegment(data io.ReadSeeker, encoder kv.Encoder, index kv.MemoryStore, size int) Segment
func (*Segment) Get ¶
Get searches the underlying SSTable for the given key by first checking the internal index table to locate the approximate position and then reading the contents of the SSTable at that position to find the key.
func (*Segment) LoadIndex ¶
LoadIndex populates the internal index table of the segment by reading the index table data from the internal data stream.
type SegmentBackend ¶
type SegmentBackend struct {
// contains filtered or unexported fields
}
SegmentBackend implements kv.SegmentBackend by providing persistent storage for Segment's using SSTable's stored on the local filesystem.
func NewSegmentBackend ¶
func NewSegmentBackend(root string, encoder kv.Encoder, indexFactor int, storeFactory kv.MemoryStoreFactory) SegmentBackend
func (*SegmentBackend) Get ¶
func (s *SegmentBackend) Get(id kv.SegmentID) (Segment, error)
Get returns the segment with the given SegmentID.
func (*SegmentBackend) New ¶
func (s *SegmentBackend) New(id kv.SegmentID, store kv.MemoryStore) error
New creates a new segment from a MemoryStore and returns its ID.
func (*SegmentBackend) NewWriter ¶
func (s *SegmentBackend) NewWriter(id kv.SegmentID) (kv.SegmentWriter, error)
NewWriter creates a new segment and returns it wrapped in a SegmentWriter.
type SegmentWriter ¶
type SegmentWriter struct {
// contains filtered or unexported fields
}
SegmentWriter implements kv.SegmentWriter for writing SSTable formatted segments to an underlying stream.
func NewSegmentWriter ¶
func NewSegmentWriter(id kv.SegmentID, writer io.WriteCloser, encoder kv.Encoder, table kv.MemoryStore, indexFactor int) SegmentWriter
func (*SegmentWriter) Close ¶
func (s *SegmentWriter) Close() error
Close writes the last written KVPair to the index table and proceeds to encode the index table, writing it along with it's length to the end of the underlying stream before calling Close() on the underlying strema.
func (*SegmentWriter) Write ¶
func (s *SegmentWriter) Write(pair kv.KVPair) (int, error)
Write takes a KVPair and writes it to the underlying stream. An internal count is maintained for the number of writes made and is frequently checked in order to determine if a specific entry should be added to the index table based on the configured index factor. The first and last writes are always added to the index table.