Documentation
¶
Index ¶
- Variables
- type Collection
- func (c *Collection) Close() error
- func (c *Collection) Count() (count int)
- func (c *Collection) CreateColumn(columnName string, column Column) error
- func (c *Collection) CreateColumnsOf(object Object) error
- func (c *Collection) CreateIndex(indexName, columnName string, fn func(r Reader) bool) error
- func (c *Collection) DeleteAt(idx uint32) (deleted bool)
- func (c *Collection) DeleteKey(key string) error
- func (c *Collection) DropColumn(columnName string)
- func (c *Collection) DropIndex(indexName string) error
- func (c *Collection) Insert(fn func(Row) error) (index uint32, err error)
- func (c *Collection) InsertKey(key string, fn func(Row) error) error
- func (c *Collection) InsertObject(obj Object) (index uint32)
- func (c *Collection) InsertObjectWithTTL(obj Object, ttl time.Duration) (index uint32)
- func (c *Collection) Query(fn func(txn *Txn) error) error
- func (c *Collection) QueryAt(idx uint32, fn func(Row) error) error
- func (c *Collection) QueryKey(key string, fn func(Row) error) error
- func (c *Collection) Replay(change commit.Commit) error
- func (c *Collection) Restore(snapshot io.Reader) error
- func (c *Collection) Snapshot(dst io.Writer) error
- func (c *Collection) UpsertKey(key string, fn func(Row) error) error
- type Column
- type Numeric
- type Object
- type Options
- type Reader
- type Row
- func (r Row) AddFloat32(columnName string, value float32)
- func (r Row) AddFloat64(columnName string, value float64)
- func (r Row) AddInt(columnName string, value int)
- func (r Row) AddInt16(columnName string, value int16)
- func (r Row) AddInt32(columnName string, value int32)
- func (r Row) AddInt64(columnName string, value int64)
- func (r Row) AddUint(columnName string, value uint)
- func (r Row) AddUint16(columnName string, value uint16)
- func (r Row) AddUint32(columnName string, value uint32)
- func (r Row) AddUint64(columnName string, value uint64)
- func (r Row) Any(columnName string) (any, bool)
- func (r Row) Bool(columnName string) bool
- func (r Row) Enum(columnName string) (v string, ok bool)
- func (r Row) Float32(columnName string) (v float32, ok bool)
- func (r Row) Float64(columnName string) (float64, bool)
- func (r Row) Int(columnName string) (v int, ok bool)
- func (r Row) Int16(columnName string) (v int16, ok bool)
- func (r Row) Int32(columnName string) (v int32, ok bool)
- func (r Row) Int64(columnName string) (v int64, ok bool)
- func (r Row) Key() (v string, ok bool)
- func (r Row) SetAny(columnName string, value interface{})
- func (r Row) SetBool(columnName string, value bool)
- func (r Row) SetEnum(columnName string, value string)
- func (r Row) SetFloat32(columnName string, value float32)
- func (r Row) SetFloat64(columnName string, value float64)
- func (r Row) SetInt(columnName string, value int)
- func (r Row) SetInt16(columnName string, value int16)
- func (r Row) SetInt32(columnName string, value int32)
- func (r Row) SetInt64(columnName string, value int64)
- func (r Row) SetKey(key string)
- func (r Row) SetString(columnName string, value string)
- func (r Row) SetTTL(ttl time.Duration)
- func (r Row) SetUint(columnName string, value uint)
- func (r Row) SetUint16(columnName string, value uint16)
- func (r Row) SetUint32(columnName string, value uint32)
- func (r Row) SetUint64(columnName string, value uint64)
- func (r Row) String(columnName string) (v string, ok bool)
- func (r Row) TTL() (time.Duration, bool)
- func (r Row) Uint(columnName string) (v uint, ok bool)
- func (r Row) Uint16(columnName string) (v uint16, ok bool)
- func (r Row) Uint32(columnName string) (v uint32, ok bool)
- func (r Row) Uint64(columnName string) (v uint64, ok bool)
- type Textual
- type Txn
- func (txn *Txn) Any(columnName string) anyWriter
- func (txn *Txn) Bool(columnName string) boolWriter
- func (txn *Txn) Count() int
- func (txn *Txn) DeleteAll()
- func (txn *Txn) DeleteAt(index uint32) bool
- func (txn *Txn) DeleteKey(key string) error
- func (txn *Txn) Enum(columnName string) enumSlice
- func (txn *Txn) Float32(columnName string) float32Writer
- func (txn *Txn) Float64(columnName string) float64Writer
- func (txn *Txn) Insert(fn func(Row) error) (uint32, error)
- func (txn *Txn) InsertKey(key string, fn func(Row) error) error
- func (txn *Txn) InsertObject(object Object) (uint32, error)
- func (txn *Txn) InsertObjectWithTTL(object Object, ttl time.Duration) (uint32, error)
- func (txn *Txn) Int(columnName string) intWriter
- func (txn *Txn) Int16(columnName string) int16Writer
- func (txn *Txn) Int32(columnName string) int32Writer
- func (txn *Txn) Int64(columnName string) int64Writer
- func (txn *Txn) Key() keySlice
- func (txn *Txn) QueryAt(index uint32, f func(Row) error) (err error)
- func (txn *Txn) QueryKey(key string, fn func(Row) error) error
- func (txn *Txn) Range(fn func(idx uint32)) error
- func (txn *Txn) String(columnName string) stringWriter
- func (txn *Txn) TTL() ttlWriter
- func (txn *Txn) Uint(columnName string) uintWriter
- func (txn *Txn) Uint16(columnName string) uint16Writer
- func (txn *Txn) Uint32(columnName string) uint32Writer
- func (txn *Txn) Uint64(columnName string) uint64Writer
- func (txn *Txn) Union(columns ...string) *Txn
- func (txn *Txn) UpsertKey(key string, fn func(Row) error) error
- func (txn *Txn) With(columns ...string) *Txn
- func (txn *Txn) WithFloat(column string, predicate func(v float64) bool) *Txn
- func (txn *Txn) WithInt(column string, predicate func(v int64) bool) *Txn
- func (txn *Txn) WithString(column string, predicate func(v string) bool) *Txn
- func (txn *Txn) WithUint(column string, predicate func(v uint64) bool) *Txn
- func (txn *Txn) WithValue(column string, predicate func(v interface{}) bool) *Txn
- func (txn *Txn) Without(columns ...string) *Txn
Constants ¶
This section is empty.
Variables ¶
var ( ForString = makeStrings ForFloat32 = makeFloat32s ForFloat64 = makeFloat64s ForInt = makeInts ForInt16 = makeInt16s ForInt32 = makeInt32s ForInt64 = makeInt64s ForUint = makeUints ForUint16 = makeUint16s ForUint32 = makeUint32s ForUint64 = makeUint64s ForBool = makeBools ForEnum = makeEnum ForKey = makeKey )
Various column constructor functions for a specific types.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection represents a collection of objects in a columnar format
func NewCollection ¶
func NewCollection(opts ...Options) *Collection
NewCollection creates a new columnar collection.
func (*Collection) Close ¶
func (c *Collection) Close() error
Close closes the collection and clears up all of the resources.
func (*Collection) Count ¶
func (c *Collection) Count() (count int)
Count returns the total number of elements in the collection.
func (*Collection) CreateColumn ¶
func (c *Collection) CreateColumn(columnName string, column Column) error
CreateColumn creates a column of a specified type and adds it to the collection.
func (*Collection) CreateColumnsOf ¶
func (c *Collection) CreateColumnsOf(object Object) error
CreateColumnsOf registers a set of columns that are present in the target object.
func (*Collection) CreateIndex ¶
func (c *Collection) CreateIndex(indexName, columnName string, fn func(r Reader) bool) error
CreateIndex creates an index column with a specified name which depends on a given column. The index function will be applied on the values of the column whenever a new row is added or updated.
func (*Collection) DeleteAt ¶
func (c *Collection) DeleteAt(idx uint32) (deleted bool)
DeleteAt attempts to delete an item at the specified index for this collection. If the item exists, it marks at as deleted and returns true, otherwise it returns false.
func (*Collection) DeleteKey ¶
func (c *Collection) DeleteKey(key string) error
DeleteKey deletes a row for a given primary key.
func (*Collection) DropColumn ¶
func (c *Collection) DropColumn(columnName string)
DropColumn removes the column (or an index) with the specified name. If the column with this name does not exist, this operation is a no-op.
func (*Collection) DropIndex ¶
func (c *Collection) DropIndex(indexName string) error
DropIndex removes the index column with the specified name. If the index with this name does not exist, this operation is a no-op.
func (*Collection) Insert ¶
func (c *Collection) Insert(fn func(Row) error) (index uint32, err error)
Insert executes a mutable cursor transactionally at a new offset.
func (*Collection) InsertKey ¶
func (c *Collection) InsertKey(key string, fn func(Row) error) error
InsertKey inserts a row given its corresponding primary key.
func (*Collection) InsertObject ¶
func (c *Collection) InsertObject(obj Object) (index uint32)
InsertObject adds an object to a collection and returns the allocated index.
func (*Collection) InsertObjectWithTTL ¶
func (c *Collection) InsertObjectWithTTL(obj Object, ttl time.Duration) (index uint32)
InsertObjectWithTTL adds an object to a collection, sets the expiration time based on the specified time-to-live and returns the allocated index.
func (*Collection) Query ¶
func (c *Collection) Query(fn func(txn *Txn) error) error
Query creates a transaction which allows for filtering and iteration over the columns in this collection. It also allows for individual rows to be modified or deleted during iteration (range), but the actual operations will be queued and executed after the iteration.
func (*Collection) QueryAt ¶
func (c *Collection) QueryAt(idx uint32, fn func(Row) error) error
QueryAt jumps at a particular offset in the collection, sets the cursor to the provided position and executes given callback fn.
func (*Collection) QueryKey ¶
func (c *Collection) QueryKey(key string, fn func(Row) error) error
QueryKey queries/updates a row given its corresponding primary key.
func (*Collection) Replay ¶
func (c *Collection) Replay(change commit.Commit) error
Replay replays a commit on a collection, applying the changes.
func (*Collection) Restore ¶
func (c *Collection) Restore(snapshot io.Reader) error
Restore restores the collection from the underlying snapshot reader. This operation should be called before any of transactions, right after initialization.
type Column ¶
type Column interface { Grow(idx uint32) Apply(commit.Chunk, *commit.Reader) Value(idx uint32) (interface{}, bool) Contains(idx uint32) bool Index(commit.Chunk) bitmap.Bitmap Snapshot(chunk commit.Chunk, dst *commit.Buffer) }
Column represents a column implementation
type Numeric ¶
type Numeric interface { Column LoadFloat64(uint32) (float64, bool) LoadUint64(uint32) (uint64, bool) LoadInt64(uint32) (int64, bool) FilterFloat64(commit.Chunk, bitmap.Bitmap, func(v float64) bool) FilterUint64(commit.Chunk, bitmap.Bitmap, func(v uint64) bool) FilterInt64(commit.Chunk, bitmap.Bitmap, func(v int64) bool) }
Numeric represents a column that stores numbers.
type Options ¶
type Options struct { Capacity int // The initial capacity when creating columns Writer commit.Logger // The writer for the commit log (optional) Vacuum time.Duration // The interval at which the vacuum of expired entries will be done }
Options represents the options for a collection.
type Reader ¶
type Reader interface { Index() uint32 String() string Float() float64 Int() int Uint() uint Bool() bool }
Reader represents a reader cursor for a specific row/column combination.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row represents a cursor at a particular row offest in the transaction.
func (Row) AddFloat32 ¶
AddFloat32 adds delta to a float32 value at a particular column
func (Row) AddFloat64 ¶
AddFloat64 adds delta to a float64 value at a particular column
func (Row) SetFloat32 ¶
SetFloat32 stores a float32 value at a particular column
func (Row) SetFloat64 ¶
SetFloat64 stores a float64 value at a particular column
type Textual ¶
type Textual interface { Column LoadString(uint32) (string, bool) FilterString(commit.Chunk, bitmap.Bitmap, func(v string) bool) }
Textual represents a column that stores strings.
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn represents a transaction which supports filtering and projection.
func (*Txn) DeleteAll ¶
func (txn *Txn) DeleteAll()
DeleteAll marks all of the items currently selected by this transaction for deletion. The actual delete will take place once the transaction is committed.
func (*Txn) DeleteAt ¶
DeleteAt attempts to delete an item at the specified index for this transaction. If the item exists, it marks at as deleted and returns true, otherwise it returns false.
func (*Txn) InsertObject ¶
InsertObject adds an object to a collection and returns the allocated index.
func (*Txn) InsertObjectWithTTL ¶
InsertObjectWithTTL adds an object to a collection, sets the expiration time based on the specified time-to-live and returns the allocated index.
func (*Txn) QueryAt ¶
QueryAt jumps at a particular offset in the collection, sets the cursor to the provided position and executes given callback fn.
func (*Txn) Range ¶
Range selects and iterates over result set. In each iteration step, the internal transaction cursor is updated and can be used by various column accessors.
func (*Txn) TTL ¶
func (txn *Txn) TTL() ttlWriter
TTL returns a read-write accessor for the time-to-live column
func (*Txn) With ¶
With applies a logical AND operation to the current query and the specified index.
func (*Txn) WithFloat ¶
WithFloat filters down the values based on the specified predicate. The column for this filter must be numerical and convertible to float64.
func (*Txn) WithInt ¶
WithInt filters down the values based on the specified predicate. The column for this filter must be numerical and convertible to int64.
func (*Txn) WithString ¶
WithString filters down the values based on the specified predicate. The column for this filter must be a string.
func (*Txn) WithUint ¶
WithUint filters down the values based on the specified predicate. The column for this filter must be numerical and convertible to uint64.