Go · Collections

Collections

import "github.com/unum-cloud/ustore" 1.0.0-rc.1 · 084197c4

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/ustore/go/collections.md' | claude -p "How would this fit my code?"

Collections are created under a name and the modality they hold, resolved by name once and addressed by CollectionID from then on, and a database holds none until one is created. A name starting with _ is refused with StatusInvalidArgument, as the engines keep their own system collections there. CollectionFind answers the identifier and modality of every name in a batch, and CollectionList every collection with its name. CollectionDrop empties a collection of its pairs or values with DropPairs or DropValues, or drops it whole with DropCollection. Every batch verb takes a Collections: a bare CollectionID serves every task, and Each names one per task.

people, err := database.CollectionCreate("people", ustore.ModalityBlobs)
found, err := database.CollectionFind(ustore.TapeOf("people", "places"), arena)
id, modality, ok := found.Get(0)
values, err := database.BlobsRead(ustore.Each{people, places}, []ustore.Key{ada, ada}, arena, nil)
err = database.CollectionDrop(people, ustore.DropCollection)

API

Types

ArenaDescriptionArenaDescription is where an arena's outputs live, which decides whether Go code may read them, laid out as ustore_arena_description_t.
db.go:924 ↗
type ArenaDescription struct {
    Residency Residency
    Device int32
    Vendor GPUVendor
    VendorOrdinal int32
    HostAccess HostAccess
}

Fields

ResidencyResidencyResidency is ResidencyRam for host pages and ResidencyVram for one device's memory.
Deviceint32Device is the ordinal of the GPU holding the outputs, as GPUDevices lists it, or -1 for host pages.
VendorGPUVendorVendor is the vendor whose memory it is, as GPUDevices reports it, GPUVendorUnknown for host pages.
VendorOrdinalint32VendorOrdinal is the vendor's own device number, which Arrow and DLPack name, or -1 for host pages.
HostAccessHostAccessHostAccess is whether Go code may read the outputs, as it may host, pinned, managed and Apple's shared memory.
CapabilitiesCapabilities is the set of features an engine reports, one bit each.
db.go:332 ↗
type Capabilities int32

Values

CapabilitiesTransactionsCapabilitiesTransactions means the engine supports transactions.
CapabilitiesSnapshotsCapabilitiesSnapshots means the engine supports snapshots.
CapabilitiesSavesSnapshotsCapabilitiesSavesSnapshots means the engine writes a snapshot out as a database of its own.
CollectionsCollections names the collection of every task in a batch: a CollectionID the whole batch shares, or Each, one per task.
db.go:149 ↗
type Collections interface {
    // contains filtered or unexported methods
}
CompactConfigCompactConfig carries the optional arguments of DatabaseOn.Compact.
db.go:1173 ↗
type CompactConfig struct {
    Plan *CompactPlan
    Progress ProgressCallback
}

Fields

Plan*CompactPlanPlan keeps a compaction live across calls on an executor; nil runs it to its end.
ProgressProgressCallbackProgress is called at every barrier of every phase, and may cancel at that barrier.
CompactPlanCompactPlan is a compaction kept live across calls: the handle the library opens on the first call naming it, and where the last such call stopped.
db.go:1166 ↗
type CompactPlan struct {
    Phase PhaseProgress
    // contains filtered or unexported fields
}

It opens only on an executor, and continues or finishes on any host executor, while its database stays open until the finish.

Fields

PhasePhaseProgressPhase is where the last call naming the plan stopped, PhaseDone once the compaction ended.
DatabaseDescriptionDatabaseDescription is what DatabaseOn.Describe reports, laid out as ustore_database_description_t.
db.go:1077 ↗
type DatabaseDescription struct {
    Capabilities Capabilities
    Engine Engine
    Isolation Isolation
    CPUClass CPUClass
    Keys uint64
    MemoryBytes uint64
    DiskBytes uint64
    UnpinnedStagingBytes uint64
    RequestsAcrossRegisteredSlots uint64
    CommitConflictsLimit uint64
}

Fields

CapabilitiesCapabilitiesCapabilities are the features the engine supports.
EngineEngineEngine is the engine serving the database.
IsolationIsolationIsolation is how transactions see each other.
CPUClassCPUClassCPUClass is the class the engine's calls run as, picked at open.
Keysuint64Keys counts the keys across every collection.
MemoryBytesuint64MemoryBytes is the memory the engine holds for the data.
DiskBytesuint64DiskBytes is what the files of the database take on disk.
UnpinnedStagingBytesuint64UnpinnedStagingBytes is the NVMe engine's io_uring arena the locked-memory cap refused to pin, so each request pins its own.
RequestsAcrossRegisteredSlotsuint64RequestsAcrossRegisteredSlots counts the requests the NVMe engine sent unpinned while its arena was pinned, as each crossed a gibibyte of it.
CommitConflictsLimituint64CommitConflictsLimit is the conflicts a commit of the database's own absorbs before it fails, as its open named or derived them, on the RAM and NVMe engines, and zero elsewhere.
TypeCollectionIDCollectionID identifies a collection: a UUIDv7 its create mints once and never reuses.1
db.go:123 ↗
type CollectionID [16]byte

The zero value names none.

StringString renders the identifier as a lowercase dashed UUID.
db.go:126 ↗
func (collection CollectionID) String() string
StructCollectionListCollectionList is every collection a call listed into its arena, readable until the arena serves another call.4
db.go:1445 ↗
type CollectionList struct {
    // contains filtered or unexported fields
}
IDID reports the identifier of collection index.
db.go:1457 ↗
func (list CollectionList) ID(index uint) CollectionID
LenLen reports how many collections the call listed.
db.go:1454 ↗
func (list CollectionList) Len() uint
ModalityModality reports what collection index holds.
db.go:1464 ↗
func (list CollectionList) Modality(index uint) Modality
NameName views the name of collection index in the arena.
db.go:1471 ↗
func (list CollectionList) Name(index uint) []byte
EnumDropModeDropMode is what a drop or a clear removes.2
db.go:308 ↗
type DropMode int32

Values

DropCollectionDropCollection removes the collection with everything it holds.
DropPairsDropPairs removes every key and value, keeping the collection.
DropValuesDropValues empties every value, keeping its key.
DropModeFromNameDropModeFromName reads a drop mode back from the spelling DropMode.String renders.
db.go:325 ↗
func DropModeFromName(name string) (DropMode, error)
StringString renders the drop mode as the library spells it.
db.go:320 ↗
func (mode DropMode) String() string
StructFoundCollectionsFoundCollections is what a lookup of names found, in the order of the names, readable until the arena serves another call.2
db.go:1514 ↗
type FoundCollections struct {
    // contains filtered or unexported fields
}
GetGet reports the collection name index addresses and what it holds, and false when no collection carries the name.
db.go:1527 ↗
func (found FoundCollections) Get(
    index uint,
) (CollectionID, Modality, bool)
LenLen reports how many names the call looked up.
db.go:1523 ↗
func (found FoundCollections) Len() uint
TypeKeyKey identifies a value within one collection: sixteen bytes, ordered as their bytes.3
db.go:101 ↗
type Key [16]byte

An integer spells as its 128-bit big-endian bytes, so keys made from integers order as the integers.

KeyFromUint64KeyFromUint64 spells an integer as its 128-bit big-endian bytes.
db.go:112 ↗
func KeyFromUint64(value uint64) Key
KeysViewFromArrowKeysViewFromArrow views the 16-byte keys of a fixed_size_binary(16) column in place, tagged arrow.uuid or not, viewing the column's buffers.
db.go:71 ↗
func KeysViewFromArrow(
    schema *ArrowSchema,
    array *ArrowArray,
) ([]Key, error)
StringString renders the key as a lowercase dashed UUID.
db.go:119 ↗
func (key Key) String() string
EnumModalityModality is what a collection holds, recorded beside its name so that a verb of another kind is refused.3
db.go:186 ↗
type Modality int32

Values

ModalityBlobsModalityBlobs holds binary values of blobs.h.
ModalityDocsModalityDocs holds JSON documents of docs.h.
ModalityGraphModalityGraph holds vertices and their edges of graph.h.
ModalityStringsModalityStrings holds values keyed by strings of strings.h.
ModalityPagesModalityPages holds structured pages of pages.h.
ModalityFromNameModalityFromName reads a modality back from the spelling Modality.String renders.
db.go:213 ↗
func ModalityFromName(name string) (Modality, error)
CompiledCompiled reports whether this build serves collections of the modality; creating one it omits answers StatusUnsupported.
db.go:208 ↗
func (modality Modality) Compiled() bool
StringString renders the modality as the library spells it.
db.go:202 ↗
func (modality Modality) String() string
EnumPhasePhase is the kind of work a plan is doing, shared by every long operation.2
types.go:193 ↗
type Phase int32

Values

PhaseNonePhaseNone means no plan, or one that has not started.
PhaseFlushPhaseFlush writes what memory holds to storage.
PhaseMergePhaseMerge merges or vacuums the stored versions one unit at a time.
PhaseReclaimPhaseReclaim frees what no reader reaches any more.
PhaseDonePhaseDone means the plan ran to its end, and nothing is pending.
PhaseFromNamePhaseFromName reads a phase back from the spelling Phase.String renders.
types.go:212 ↗
func PhaseFromName(name string) (Phase, error)
StringString renders the phase as the library spells it.
types.go:209 ↗
func (phase Phase) String() string

Constants

KeyUnknownKeyUnknown is the key that stands for no key, every bit of it set, the start of a descending walk over a whole collection.
db.go:105 ↗
var KeyUnknown = Key{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}