hyperdb

package module
v0.0.0-...-8f16c74 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2016 License: MIT Imports: 3 Imported by: 0

README

hyperdb

License - MIT Circle CI Build Status

Multidimensional object store.

Documentation

Index

Constants

View Source
const DefaultDataFileName = "hyper.db"

DefaultDataFileName is the default file name of the database file.

Variables

View Source
var (
	// ErrCannotCloseNilDB is an error returned when attempted to close nil database.
	ErrCannotCloseNilDB = errors.New("attempted to close nil database")
	// ErrCannotCloseNilBoltDB is an error returned when attempted to close nil Bolt database.
	ErrCannotCloseNilBoltDB = errors.New("attempted to close nil Bolt database")
)

Functions

This section is empty.

Types

type Attribute

type Attribute interface {
	GetType() string
	GetName() string
	GetValue() []byte
}

Attribute is a set property of an object that needs to be indexed in the db to be easily findable.

type AttributeBase

type AttributeBase struct {
	Type  string
	Name  string
	Value []byte
}

AttributeBase is a naive hyperdb implementation of the Attribute interface.

func (AttributeBase) GetName

func (ab AttributeBase) GetName() string

GetName returns the name of the AttributeBase object.

func (AttributeBase) GetType

func (ab AttributeBase) GetType() string

GetType returns the type of the AttributeBase object.

func (AttributeBase) GetValue

func (ab AttributeBase) GetValue() []byte

GetValue returns the value of the AttributeBase object.

type DB

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

DB represents a collection of objects with multitude of attributes, that can be retrieved based all possible dimensions.

func Open

func Open(path string) (*DB, error)

Open creates and opens a database at the given path. If the file doesn't exist, it is created automatically.

func (*DB) Close

func (db *DB) Close() error

Close closes the database.

func (*DB) Get

func (db *DB) Get(searchCriteria string) ([]string, error)

Get looks up the ids of the objects that fit the search criteria and returns them to the client.

func (*DB) Put

func (db *DB) Put(obj HyperObject) (string, error)

Put adds an object to the database if it does not exist, or updates existing entries based on the new object definition. The function returns unique id of the object stored in hyperdb that can later be used to update or remove object in/from the namespace.

func (*DB) Remove

func (db *DB) Remove(uid string) error

Remove removes passed object from the database based on the unique id of the object.

type HyperObject

type HyperObject interface {
	// GetId returns a unique ID of the object the hyperdb client wants to
	// use as a reference for the object. If 0 is returned, hyperdb assigns its
	// own ID.
	GetID() string
	// GetAttributes returns a slice of all the attributes of the object.
	GetAttributes() []Attribute
}

HyperObject is an interface expected to be implemented by the objects that are about to be stored in the hyperdb.

type HyperObjectBase

type HyperObjectBase struct {
	ID         string
	Attributes []Attribute
}

HyperObjectBase is a built-in naive implementation of the HyperObject interface.

func (HyperObjectBase) GetAttributes

func (hob HyperObjectBase) GetAttributes() []Attribute

func (HyperObjectBase) GetID

func (hob HyperObjectBase) GetID() string

Jump to

Keyboard shortcuts

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