Documentation
¶
Index ¶
- Constants
- Variables
- func CollectionSpecPath(filename string) string
- func FastUUID() string
- func IsCollectionSpecFile(filename string) bool
- func SaveCollectionSpec(spec CollectionSpec) error
- func StartBackgroundFlusher(store stores.Store, interval time.Duration) chan struct{}
- func ValidateDurability(durability string) error
- type Collection
- func NewCollection(name string, store stores.Store) *Collection
- func NewCollectionBase(name string, store stores.Store, rr records.Records[Record]) *Collection
- func NewCollectionConfigured(name string, store stores.Store, rr records.Records[Record], ...) *Collection
- func OpenCollection(filename string) (*Collection, error)
- func OpenCollectionCustom(filename, rawStoreName, wrapStoreName, recordsName string) (*Collection, error)
- func OpenCollectionSpec(spec CollectionSpec) (*Collection, error)
- func (c *Collection) Close() error
- func (c *Collection) Commit(wait bool) error
- func (c *Collection) Count() int64
- func (c *Collection) CreateIndex(name string, options interface{}) error
- func (c *Collection) DataSize() int64
- func (c *Collection) Defaults() map[string]any
- func (c *Collection) Delete(id int64, wait bool) error
- func (c *Collection) DeleteDeferred(id int64) error
- func (c *Collection) DropIndex(name string) error
- func (c *Collection) Durability() string
- func (c *Collection) Filepath() string
- func (c *Collection) FindOne(data interface{}) error
- func (c *Collection) Get(id int64) ([]byte, bool)
- func (c *Collection) Index(name string, options interface{}) error
- func (c *Collection) Insert(jsonData []byte, wait bool) (int64, error)
- func (c *Collection) InsertDeferred(jsonData []byte) (int64, error)
- func (c *Collection) InsertJSON(payload []byte, wait bool) (int64, error)
- func (c *Collection) InsertJSONDeferred(payload []byte) (int64, error)
- func (c *Collection) InsertMap(item map[string]any, wait bool) (int64, error)
- func (c *Collection) InsertMapDeferred(item map[string]any) (int64, error)
- func (c *Collection) ListIndexes() map[string]Index
- func (c *Collection) MaxID() int64
- func (c *Collection) MemorySize() int64
- func (c *Collection) Patch(id int64, patch interface{}, wait bool) error
- func (c *Collection) PatchDeferred(id int64, patch interface{}) ([]byte, error)
- func (c *Collection) Recover() error
- func (c *Collection) Scan() *Rows
- func (c *Collection) SetDefaults(defaults map[string]any) error
- func (c *Collection) SetDurability(durability string)
- func (c *Collection) SetFilepath(filepath string)
- func (c *Collection) SyncIndexes()
- func (c *Collection) Traverse(f func(data []byte))
- func (c *Collection) TraverseIndex(name string, options []byte, f func(id int64, data []byte) bool) error
- func (c *Collection) TraverseRange(from, to int, f func(data []byte))
- func (c *Collection) TraverseRecords(f func(id int64, data []byte) bool)
- func (c *Collection) Update(id int64, data []byte, wait bool) error
- type CollectionSpec
- type CreateIndexCommand
- type DropIndexCommand
- type Index
- type IndexBTreeOptions
- type IndexBtree
- func (b *IndexBtree) Add(id int64, data []byte) error
- func (b *IndexBtree) GetOptions() interface{}
- func (b *IndexBtree) GetType() string
- func (b *IndexBtree) IsUnique() bool
- func (b *IndexBtree) Release(id int64, oldData, newData []byte)
- func (b *IndexBtree) Remove(id int64, data []byte) error
- func (b *IndexBtree) Size() int64
- func (b *IndexBtree) Traverse(optionsData []byte, f func(id int64, data []byte) bool)
- type IndexBtreeTraverse
- type IndexFTS
- func (i *IndexFTS) Add(id int64, data []byte) error
- func (i *IndexFTS) GetOptions() interface{}
- func (i *IndexFTS) GetType() string
- func (i *IndexFTS) IsUnique() bool
- func (i *IndexFTS) Remove(id int64, data []byte) error
- func (i *IndexFTS) Size() int64
- func (i *IndexFTS) Traverse(optionsData []byte, f func(id int64, data []byte) bool)
- type IndexFTSOptions
- type IndexFTSTraverse
- type IndexMap
- func (i *IndexMap) Add(id int64, data []byte) error
- func (i *IndexMap) GetOptions() interface{}
- func (i *IndexMap) GetType() string
- func (i *IndexMap) IsUnique() bool
- func (i *IndexMap) Release(id int64, oldData, newData []byte)
- func (i *IndexMap) Remove(id int64, data []byte) error
- func (i *IndexMap) Size() int64
- func (i *IndexMap) Traverse(optionsData []byte, f func(id int64, data []byte) bool)
- type IndexMapEntry
- type IndexMapOptions
- type IndexMapTraverse
- type IndexPK
- func (idx *IndexPK) Add(id int64, data []byte) error
- func (idx *IndexPK) GetOptions() interface{}
- func (idx *IndexPK) GetType() string
- func (idx *IndexPK) IsUnique() bool
- func (idx *IndexPK) Release(id int64, oldData, newData []byte)
- func (idx *IndexPK) Remove(id int64, data []byte) error
- func (idx *IndexPK) Size() int64
- func (idx *IndexPK) Traverse(optionsData []byte, f func(id int64, data []byte) bool)
- type IndexPKOptions
- type PatchPlan
- type Record
- type RecordsFactory
- type RecordsSpec
- type RowOrdered
- type Rows
- type StoreFactory
- type StoreSpec
- type StoreWrapperFactory
- type StoreWrapperSpec
Constants ¶
const ( StoreBackendDisk = "disk" StoreBackendJSON = "json" StoreBackendCrazy = "crazy" StoreWrapperSnappy = "snappy" StoreWrapperAsync = "async" StoreWrapperFlusher = "flusher" RecordsCorrect = "correct" RecordsFast = "fast" RecordsHyper = "hyper" RecordsTurbo = "turbo" RecordsUltra = "ultra" // DurabilityRelaxed acknowledges a write once it is applied in memory and // queued for the WAL. A crash can lose the most recent writes. DurabilityRelaxed = "relaxed" // DurabilityStrong acknowledges a write only after it is fsynced to disk, // so it survives a process crash or a power loss. DurabilityStrong = "strong" )
Variables ¶
var ( ErrIndexAlreadyExists = errors.New("index already exists") ErrIndexNotFound = errors.New("index not found") ErrIndexType = errors.New("unknown index type") ErrIndexData = errors.New("existing data does not meet the index") )
Errors of the indexes, to check with errors.Is. Their messages say more.
var ErrCollectionClosed = errors.New("collection closed")
var ErrDocumentNotObject = errors.New("document must be a JSON object")
ErrDocumentNotObject rejects a document that is not a JSON object.
var ErrPatchNotObject = errors.New("patch must be a JSON object")
ErrPatchNotObject rejects a patch that is not a JSON object. As a merge patch (RFC 7386) it would replace the whole document with that value.
Functions ¶
func CollectionSpecPath ¶ added in v0.0.18
func IsCollectionSpecFile ¶ added in v0.0.18
func SaveCollectionSpec ¶ added in v0.0.18
func SaveCollectionSpec(spec CollectionSpec) error
func StartBackgroundFlusher ¶ added in v0.0.18
func ValidateDurability ¶ added in v0.0.18
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func NewCollection ¶ added in v0.0.18
func NewCollection(name string, store stores.Store) *Collection
func NewCollectionBase ¶ added in v0.0.18
func NewCollectionConfigured ¶ added in v0.0.18
func OpenCollection ¶
func OpenCollection(filename string) (*Collection, error)
func OpenCollectionCustom ¶ added in v0.0.18
func OpenCollectionCustom(filename, rawStoreName, wrapStoreName, recordsName string) (*Collection, error)
func OpenCollectionSpec ¶ added in v0.0.18
func OpenCollectionSpec(spec CollectionSpec) (*Collection, error)
func (*Collection) Close ¶
func (c *Collection) Close() error
func (*Collection) Commit ¶ added in v0.0.18
func (c *Collection) Commit(wait bool) error
Commit waits until every write previously made by the caller is durable (fsync) when wait is true or the collection has strong durability.
func (*Collection) Count ¶ added in v0.0.13
func (c *Collection) Count() int64
func (*Collection) CreateIndex ¶ added in v0.0.18
func (c *Collection) CreateIndex(name string, options interface{}) error
func (*Collection) DataSize ¶ added in v0.0.18
func (c *Collection) DataSize() int64
DataSize returns the size in bytes of the documents.
func (*Collection) Defaults ¶ added in v0.0.7
func (c *Collection) Defaults() map[string]any
func (*Collection) DeleteDeferred ¶ added in v0.0.18
func (c *Collection) DeleteDeferred(id int64) error
DeleteDeferred deletes without waiting for durability, see Commit.
func (*Collection) DropIndex ¶ added in v0.0.4
func (c *Collection) DropIndex(name string) error
func (*Collection) Durability ¶ added in v0.0.18
func (c *Collection) Durability() string
func (*Collection) Filepath ¶ added in v0.0.18
func (c *Collection) Filepath() string
func (*Collection) FindOne ¶
func (c *Collection) FindOne(data interface{}) error
func (*Collection) Index ¶
func (c *Collection) Index(name string, options interface{}) error
func (*Collection) InsertDeferred ¶ added in v0.0.18
func (c *Collection) InsertDeferred(jsonData []byte) (int64, error)
InsertDeferred inserts without waiting for durability, see Commit.
func (*Collection) InsertJSON ¶ added in v0.0.18
func (c *Collection) InsertJSON(payload []byte, wait bool) (int64, error)
func (*Collection) InsertJSONDeferred ¶ added in v0.0.18
func (c *Collection) InsertJSONDeferred(payload []byte) (int64, error)
InsertJSONDeferred inserts without waiting for durability, see Commit.
func (*Collection) InsertMapDeferred ¶ added in v0.0.18
func (c *Collection) InsertMapDeferred(item map[string]any) (int64, error)
InsertMapDeferred inserts without waiting for durability, see Commit.
func (*Collection) ListIndexes ¶ added in v0.0.18
func (c *Collection) ListIndexes() map[string]Index
func (*Collection) MaxID ¶ added in v0.0.18
func (c *Collection) MaxID() int64
func (*Collection) MemorySize ¶ added in v0.0.18
func (c *Collection) MemorySize() int64
MemorySize estimates the memory taken by the documents.
func (*Collection) Patch ¶ added in v0.0.2
func (c *Collection) Patch(id int64, patch interface{}, wait bool) error
func (*Collection) PatchDeferred ¶ added in v0.0.18
func (c *Collection) PatchDeferred(id int64, patch interface{}) ([]byte, error)
PatchDeferred patches without waiting for durability, see Commit. It returns the document after the patch.
func (*Collection) Recover ¶ added in v0.0.18
func (c *Collection) Recover() error
Recover lee el WAL y reconstruye el estado exacto de la base de datos
func (*Collection) Scan ¶ added in v0.0.18
func (c *Collection) Scan() *Rows
func (*Collection) SetDefaults ¶ added in v0.0.7
func (c *Collection) SetDefaults(defaults map[string]any) error
func (*Collection) SetDurability ¶ added in v0.0.18
func (c *Collection) SetDurability(durability string)
SetDurability sets how writes are acknowledged, see DurabilityStrong.
func (*Collection) SetFilepath ¶ added in v0.0.18
func (c *Collection) SetFilepath(filepath string)
func (*Collection) SyncIndexes ¶ added in v0.0.18
func (c *Collection) SyncIndexes()
func (*Collection) Traverse ¶
func (c *Collection) Traverse(f func(data []byte))
func (*Collection) TraverseIndex ¶ added in v0.0.18
func (*Collection) TraverseRange ¶
func (c *Collection) TraverseRange(from, to int, f func(data []byte))
func (*Collection) TraverseRecords ¶ added in v0.0.18
func (c *Collection) TraverseRecords(f func(id int64, data []byte) bool)
type CollectionSpec ¶ added in v0.0.18
type CollectionSpec struct {
Name string `json:"name"`
Filename string `json:"-"`
Durability string `json:"durability,omitempty"`
Store StoreSpec `json:"storage"`
Records RecordsSpec `json:"records"`
}
func DefaultCollectionSpec ¶ added in v0.0.18
func DefaultCollectionSpec(filename string) CollectionSpec
func LoadCollectionSpec ¶ added in v0.0.18
func LoadCollectionSpec(filename string) (CollectionSpec, bool, error)
type CreateIndexCommand ¶ added in v0.0.3
type DropIndexCommand ¶ added in v0.0.4
type DropIndexCommand struct {
Name string `json:"name"`
}
type IndexBTreeOptions ¶ added in v0.0.3
type IndexBtree ¶ added in v0.0.3
type IndexBtree struct {
Btree *btree.BTreeG[*RowOrdered]
RWmutex *sync.RWMutex
Options *IndexBTreeOptions
// contains filtered or unexported fields
}
func NewIndexBTree ¶ added in v0.0.3
func NewIndexBTree(options *IndexBTreeOptions) *IndexBtree
func (*IndexBtree) GetOptions ¶ added in v0.0.18
func (b *IndexBtree) GetOptions() interface{}
func (*IndexBtree) GetType ¶ added in v0.0.18
func (b *IndexBtree) GetType() string
func (*IndexBtree) IsUnique ¶ added in v0.0.18
func (b *IndexBtree) IsUnique() bool
func (*IndexBtree) Release ¶ added in v0.0.18
func (b *IndexBtree) Release(id int64, oldData, newData []byte)
Release removes the entry of oldData owned by id when newData uses a different key.
func (*IndexBtree) Remove ¶ added in v0.0.18
func (b *IndexBtree) Remove(id int64, data []byte) error
func (*IndexBtree) Size ¶ added in v0.0.18
func (b *IndexBtree) Size() int64
type IndexBtreeTraverse ¶ added in v0.0.3
type IndexFTS ¶ added in v0.0.18
type IndexFTS struct {
Index map[string]map[int64]struct{}
RWmutex *sync.RWMutex
Options *IndexFTSOptions
// contains filtered or unexported fields
}
func NewIndexFTS ¶ added in v0.0.18
func NewIndexFTS(options *IndexFTSOptions) *IndexFTS
func (*IndexFTS) GetOptions ¶ added in v0.0.18
func (i *IndexFTS) GetOptions() interface{}
type IndexFTSOptions ¶ added in v0.0.18
type IndexFTSOptions struct {
Field string `json:"field"`
}
type IndexFTSTraverse ¶ added in v0.0.18
type IndexFTSTraverse struct {
Match string `json:"match"`
}
type IndexMap ¶ added in v0.0.3
type IndexMap struct {
Entries map[string]*IndexMapEntry
RWmutex *sync.RWMutex
Options *IndexMapOptions
// contains filtered or unexported fields
}
func NewIndexMap ¶ added in v0.0.3
func NewIndexMap(options *IndexMapOptions) *IndexMap
func (*IndexMap) GetOptions ¶ added in v0.0.18
func (i *IndexMap) GetOptions() interface{}
type IndexMapEntry ¶ added in v0.0.18
type IndexMapEntry struct {
ID int64
}
type IndexMapOptions ¶ added in v0.0.3
type IndexMapTraverse ¶ added in v0.0.3
type IndexMapTraverse struct {
Value string `json:"value"`
}
type IndexPK ¶ added in v0.0.18
type IndexPK struct {
// contains filtered or unexported fields
}
func NewIndexPK ¶ added in v0.0.18
func NewIndexPK(options *IndexPKOptions) *IndexPK
func (*IndexPK) GetOptions ¶ added in v0.0.18
func (idx *IndexPK) GetOptions() interface{}
func (*IndexPK) Release ¶ added in v0.0.18
Release removes the key of oldData owned by id when newData uses a different key.
type IndexPKOptions ¶ added in v0.0.18
type IndexPKOptions struct {
Paths [][]string `json:"paths"`
}
type PatchPlan ¶ added in v0.0.18
type PatchPlan struct {
Patch interface{}
// contains filtered or unexported fields
}
func CompilePatch ¶ added in v0.0.18
type Record ¶ added in v0.0.18
type Record struct {
Data []byte // El JSON puro
Parsed any // Espacio para caché del JSON parseado (Lazy)
Active bool // true si tiene datos, false si es un hueco
}
Record es la celda de nuestro FlatSlice
type RecordsFactory ¶ added in v0.0.18
type RecordsSpec ¶ added in v0.0.18
type RecordsSpec struct {
Engine string `json:"engine"`
}
type RowOrdered ¶ added in v0.0.3
type RowOrdered struct {
ID int64
Values []interface{}
}
type Rows ¶ added in v0.0.18
type Rows struct {
// contains filtered or unexported fields
}
type StoreSpec ¶ added in v0.0.18
type StoreSpec struct {
Backend string `json:"backend"`
Wrappers []StoreWrapperSpec `json:"wrappers"`
}