luci: go.chromium.org/luci/common/data/treapstore Index | Files

package treapstore

import "go.chromium.org/luci/common/data/treapstore"

Package treapstore is a lightweight append-only in-memory key-value store built on top a treap (tree + heap) implementation.

treapstore is specifically focused on supporting the in-memory datastore implementation at "go.chromium.org/gae/impl/memory".

Index

Package Files

store.go

type Collection Uses

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

Collection is a collection of Items.

Collections belonging to read/write Store instances are, themselves, read/write. Collections belonging to Snapshot instances are read-only.

A Collection's zero value is a valid read-only empty Collection, which is not terribly useful.

func (*Collection) Delete Uses

func (c *Collection) Delete(i gtreap.Item)

Delete deletes an item from the Collection, if such an item exists.

func (*Collection) Get Uses

func (c *Collection) Get(i gtreap.Item) gtreap.Item

Get returns the item in the Store that matches i, or nil if no such item exists.

func (*Collection) IsReadOnly Uses

func (c *Collection) IsReadOnly() bool

IsReadOnly returns true if this Collection is read-only.

func (*Collection) Iterator Uses

func (c *Collection) Iterator(pivot gtreap.Item) *gtreap.Iterator

Iterator returns an iterator over the Collection, starting at the supplied pivot item.

func (*Collection) Max Uses

func (c *Collection) Max() gtreap.Item

Max returns the largest item in the collection.

func (*Collection) Min Uses

func (c *Collection) Min() gtreap.Item

Min returns the smallest item in the collection.

func (*Collection) Name Uses

func (c *Collection) Name() string

Name returns this Collection's name.

func (*Collection) Put Uses

func (c *Collection) Put(i gtreap.Item)

Put adds an item to the Store.

If the Store is read-only, Put will panic.

func (*Collection) VisitAscend Uses

func (c *Collection) VisitAscend(pivot gtreap.Item, visitor gtreap.ItemVisitor)

VisitAscend traverses the Collection ascendingly, invoking visitor for each visited item.

If visitor returns false, iteration will stop prematurely.

VisitAscend is a more efficient traversal than using an Iterator, and is useful in times when entry-by-entry iteration is not required.

type Store Uses

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

Store is a general-purpose concurrently-accessible copy-on-write store built on top of the github.com/steveyen/gtreap treap (tree + heap) implementation.

A Store is composed of a series of named Collection instances, each of which can hold data elements.

A Store is created by calling New, and is initially in a read/write mode. Derivative Stores can be created by calling a Store's Snapshot capability. These Stores will be read-only, meaning their collections and those collections' data data may only be accessed, not modified.

A Store's zero value is a valid read-only empty Store, but is not terribly useful.

func New Uses

func New() *Store

New creates a new read/write Store.

func (*Store) CreateCollection Uses

func (s *Store) CreateCollection(name string, compare gtreap.Compare) *Collection

CreateCollection returns a Collection with the specified name. If the collection already exists, or if s is read-only, CreateCollection will panic.

func (*Store) GetCollection Uses

func (s *Store) GetCollection(name string) *Collection

GetCollection returns the Collection with the specified name. If no such Collection exists, GetCollection will return nil.

func (*Store) GetCollectionNames Uses

func (s *Store) GetCollectionNames() []string

GetCollectionNames returns the names of the Collections in this Store, sorted alphabetically.

func (*Store) IsReadOnly Uses

func (s *Store) IsReadOnly() bool

IsReadOnly returns true if this Store is read-only.

func (*Store) Snapshot Uses

func (s *Store) Snapshot() *Store

Snapshot creates a read-only copy of the Store and all of its Collection instances. Because a Store is copy-on-write, this is a cheap operation.

Package treapstore imports 5 packages (graph) and is imported by 5 packages. Updated 2018-08-21. Refresh now. Tools for package owners.