Documentation
¶
Index ¶
- Variables
- func WithMerge[T any](fn func(value, delta T) T) func(*option[T])
- 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(value map[string]any) error
- func (c *Collection) CreateIndex(indexName, columnName string, fn func(r Reader) bool) error
- func (c *Collection) CreateSortIndex(indexName, columnName string) error
- func (c *Collection) CreateTrigger(triggerName, columnName string, fn func(r Reader)) 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) DropTrigger(triggerName 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) 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 Options
- type Reader
- type Row
- 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) Index() uint32
- 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) MergeFloat32(columnName string, value float32)
- func (r Row) MergeFloat64(columnName string, value float64)
- func (r Row) MergeInt(columnName string, value int)
- func (r Row) MergeInt16(columnName string, value int16)
- func (r Row) MergeInt32(columnName string, value int32)
- func (r Row) MergeInt64(columnName string, value int64)
- func (r Row) MergeRecord(columnName string, delta encoding.BinaryMarshaler) error
- func (r Row) MergeString(columnName string, value string)
- func (r Row) MergeUint(columnName string, value uint)
- func (r Row) MergeUint16(columnName string, value uint16)
- func (r Row) MergeUint32(columnName string, value uint32)
- func (r Row) MergeUint64(columnName string, value uint64)
- func (r Row) Record(columnName string) (any, 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) SetMany(value map[string]any) error
- func (r Row) SetRecord(columnName string, value encoding.BinaryMarshaler) error
- func (r Row) SetString(columnName string, value string)
- func (r Row) SetTTL(ttl time.Duration) (until time.Time)
- 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) rwAny
- func (txn *Txn) Ascend(sortIndexName string, fn func(idx uint32)) error
- func (txn *Txn) Bool(columnName string) rwBool
- 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) rwEnum
- func (txn *Txn) Float32(columnName string) rwFloat32
- func (txn *Txn) Float64(columnName string) rwFloat64
- func (txn *Txn) Index() uint32
- func (txn *Txn) Insert(fn func(Row) error) (uint32, error)
- func (txn *Txn) InsertKey(key string, fn func(Row) error) error
- func (txn *Txn) Int(columnName string) rwInt
- func (txn *Txn) Int16(columnName string) rwInt16
- func (txn *Txn) Int32(columnName string) rwInt32
- func (txn *Txn) Int64(columnName string) rwInt64
- func (txn *Txn) Key() rwKey
- 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) Record(columnName string) rwRecord
- func (txn *Txn) String(columnName string) rwString
- func (txn *Txn) TTL() rwTTL
- func (txn *Txn) Uint(columnName string) rwUint
- func (txn *Txn) Uint16(columnName string) rwUint16
- func (txn *Txn) Uint32(columnName string) rwUint32
- func (txn *Txn) Uint64(columnName string) rwUint64
- 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) WithUnion(columns ...string) *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 ¶
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(value map[string]any) error
CreateColumnsOf registers a set of columns that are present in the target map.
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 data column. The index function will be applied on the values of the column whenever a new row is added or updated.
func (*Collection) CreateSortIndex ¶ added in v0.3.0
func (c *Collection) CreateSortIndex(indexName, columnName string) error
CreateSortIndex creates a sorted index column with a specified name which depends on a given data column.
func (*Collection) CreateTrigger ¶ added in v0.2.3
func (c *Collection) CreateTrigger(triggerName, columnName string, fn func(r Reader)) error
CreateTrigger creates an trigger column with a specified name which depends on a given column. The trigger function will be applied on the values of the column whenever a new row is added, updated or deleted.
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) DropTrigger ¶ added in v0.2.3
func (c *Collection) DropTrigger(triggerName string) error
DropTrigger removes the trigger column with the specified name. If the trigger 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) 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
func ForRecord ¶ added in v0.2.0
func ForRecord[T recordType](new func() T, opts ...func(*option[T])) Column
ForRecord creates a new column that contains a type marshaled into/from binary. It requires a constructor for the type as well as optional merge function. If merge function is set to nil, "overwrite" strategy will be used.
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 { IsUpsert() bool IsDelete() bool Index() uint32 String() string Bytes() []byte 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) MergeFloat32 ¶ added in v0.2.0
MergeFloat32 atomically merges a delta into float32 value at a particular column
func (Row) MergeFloat64 ¶ added in v0.2.0
MergeFloat64 atomically merges a delta into float64 value at a particular column
func (Row) MergeInt ¶ added in v0.2.0
MergeInt atomically merges a delta into int value at a particular column
func (Row) MergeInt16 ¶ added in v0.2.0
MergeInt16 atomically merges a delta into int16 value at a particular column
func (Row) MergeInt32 ¶ added in v0.2.0
MergeInt32 atomically merges a delta into int32 value at a particular column
func (Row) MergeInt64 ¶ added in v0.2.0
MergeInt64 atomically merges a delta into int64 value at a particular column
func (Row) MergeRecord ¶ added in v0.2.0
func (r Row) MergeRecord(columnName string, delta encoding.BinaryMarshaler) error
MergeRecord merges a record value at a particular column
func (Row) MergeString ¶ added in v0.2.0
MergeString merges a string value at a particular column
func (Row) MergeUint ¶ added in v0.2.0
MergeUint atomically merges a delta into uint value at a particular column
func (Row) MergeUint16 ¶ added in v0.2.0
MergeUint16 atomically merges a delta into uint16 value at a particular column
func (Row) MergeUint32 ¶ added in v0.2.0
MergeUint32 atomically merges a delta into uint32 value at a particular column
func (Row) MergeUint64 ¶ added in v0.2.0
MergeUint64 atomically merges a delta into uint64 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
func (Row) SetRecord ¶ added in v0.2.0
func (r Row) SetRecord(columnName string, value encoding.BinaryMarshaler) error
SetRecord stores a record 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) Ascend ¶ added in v0.3.0
Ascend through a given SortedIndex and returns each offset remaining in the transaction's index
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) 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() rwTTL
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.
func (*Txn) WithUnion ¶ added in v0.2.0
WithUnion computes a union between all given indexes, and then applies the result to the txn index.