lm2

package module
v2.0.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2018 License: BSD-3-Clause Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lm2 CircleCI GoDoc

lm2 (listmap2) is an ordered key-value storage library.

It provides

  • Ordered key-value data model
  • Append-only modifications
  • Fully durable, atomic writes
  • Cursors with snapshot reads

Because it is append-only, records are never actually deleted. You will have to rewrite a collection to reclaim space.

License

BSD (see LICENSE)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDoesNotExist is returned when a collection's data file
	// doesn't exist.
	ErrDoesNotExist = errors.New("lm2: does not exist")
	// ErrInternal is returned when the internal state of the collection
	// is invalid. The collection should be closed and reopened.
	ErrInternal = errors.New("lm2: internal error")
)

Functions

This section is empty.

Types

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

Collection represents an ordered linked list map.

func NewCollection

func NewCollection(file string, cacheSize int) (*Collection, error)

NewCollection creates a new collection with a data file at file. cacheSize represents the size of the collection cache.

func OpenCollection

func OpenCollection(file string, cacheSize int) (*Collection, error)

OpenCollection opens a collection with a data file at file. cacheSize represents the size of the collection cache. ErrDoesNotExist is returned if file does not exist.

func (*Collection) Close

func (c *Collection) Close()

Close closes a collection and all of its resources.

func (*Collection) Compact

func (c *Collection) Compact() error

Compact rewrites a collection to clean up deleted records and optimize data layout on disk. NOTE: The collection is closed after compaction, so you'll have to reopen it.

func (*Collection) CompactFunc

func (c *Collection) CompactFunc(f func(key, value string) (string, string, bool)) error

CompactFunc compacts with a custom compaction function. f is called with each key-value pair, and it should return the new key and value for that record if they should be changed, and whether to keep the record. Returning false will skip the record. NOTE: The collection is closed after compaction, so you'll have to reopen it.

func (*Collection) Destroy added in v1.2.1

func (c *Collection) Destroy() error

Destroy closes the collection and removes its associated data files.

func (*Collection) NewCursor

func (c *Collection) NewCursor() (*Cursor, error)

NewCursor returns a new cursor with a snapshot view of the current collection state.

func (*Collection) Stats added in v1.0.0

func (c *Collection) Stats() Stats

Stats returns collection statistics.

func (*Collection) Update

func (c *Collection) Update(wb *WriteBatch) (int64, error)

Update atomically and durably applies a WriteBatch (a set of updates) to the collection. It returns the new version (on success) and an error.

func (*Collection) Version added in v0.1.3

func (c *Collection) Version() int64

Version returns the last committed version.

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

Cursor represents a snapshot cursor.

func (*Cursor) Err added in v1.4.0

func (c *Cursor) Err() error

Err returns the error encountered during iteration, if any.

func (*Cursor) Key

func (c *Cursor) Key() string

Key returns the key of the current record. It returns an empty string if the cursor is not valid.

func (*Cursor) Next

func (c *Cursor) Next() bool

Next moves the cursor to the next record. It returns true if it lands on a valid record.

func (*Cursor) Seek

func (c *Cursor) Seek(key string)

Seek positions the cursor at the last key less than or equal to the provided key.

func (*Cursor) Valid

func (c *Cursor) Valid() bool

Valid returns true if the cursor's Key() and Value() methods can be called. It returns false if the cursor isn't at a valid record position.

func (*Cursor) Value

func (c *Cursor) Value() string

Value returns the value of the current record. It returns an empty string if the cursor is not valid.

type Stats added in v1.0.0

type Stats struct {
	RecordsWritten uint64
	RecordsRead    uint64
	CacheHits      uint64
	CacheMisses    uint64
}

Stats holds collection statistics.

type WriteBatch

type WriteBatch struct {
	// contains filtered or unexported fields
}

WriteBatch represents a set of modifications.

func NewWriteBatch

func NewWriteBatch() *WriteBatch

NewWriteBatch returns a new WriteBatch.

func (*WriteBatch) Delete

func (wb *WriteBatch) Delete(key string)

Delete marks a key for deletion.

func (*WriteBatch) Set

func (wb *WriteBatch) Set(key, value string)

Set adds key => value to the WriteBatch. Note: If a key is passed to Delete and Set, then the Set will be ignored.

Directories

Path Synopsis
cmd
lm2util command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL