Go · Platform Notes

Platform Notes

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/platform-notes.md' | claude -p "How would this fit my code?"

§ Engines

DatabaseInitRam starts an empty database in memory alone, DatabaseOpenRam serves a directory as one image, DatabaseOpenRocksdb, DatabaseOpenLeveldb and DatabaseOpenNvme serve a directory in place, and DatabaseViewRocksdb and DatabaseViewNvme serve one read-only, refusing every change with StatusReadOnly. Close writes nothing to disk, so On(executor).Flush() makes commits with DurabilityBuffered durable before it. Describe reports the engine, the isolation, the CPU class picked and the sizes the engine estimates, Clear empties every collection at once, and Compact reclaims space through the phases its engine runs, where a CompactPlan keeps a stopped compaction open until CompactPlanFinish. The RAM engine always links, and build tags mirror the Cargo features for the others: ustore_rocksdb links librocksdb, and on Linux liburing beside it, and ustore_leveldb links libleveldb. Build the archive with the matching USTORE_WITH_* options and point CGO_LDFLAGS at the directory holding the engine archives too, as the lib/ of a prefix CMake installed with USTORE_INSTALL does; the NVMe engine links nothing more.

go build -tags ustore_rocksdb,ustore_leveldb ./...

With those tags, a scratch database in memory and a RocksDB directory open side by side, and either one describes, clears and compacts through the same calls:

scratch, err := ustore.DatabaseInitRam(&ustore.DatabaseInitRamConfig{Isolation: ustore.IsolationSnapshot})
people, err := ustore.DatabaseOpenRocksdb("/var/lib/people", nil)
description, err := people.Describe()
err = people.Clear(ustore.DropValues) // keeps every key, emptying its value
err = people.Compact(nil)            // reclaims what overwritten and removed data still takes

§ Left Unbound

  • Deferred opens, transaction and snapshot inits, resets, cursor inits, cursor pulls and ingests: these block whatever receiver they are called on.
  • The progress of a cursor pull, and the lengths a read writes beside its values, which the tape’s offsets carry.
  • Batches of strings through an accessor: every input batch is a Tape.
  • Exporting strided keys, like the columns of edges, through KeysViewToArrow, which takes dense keys alone.

§ Design

  • The receiver makes the completion a type, not a flag. Each verb is written once over its parent, and the parent decides what compiles: only a transaction commits, only the head clears and compacts, and nothing writes through a snapshot.
  • Inputs cross as they lie. Keys, edges and tapes are pinned in place for the call, and a collection or a role the whole batch shares crosses from the call’s own frame, so nothing is staged on the way in.
  • One pinned frame per call. It holds the outcome, the argument structure, the fixed-width inputs and the result, and TestCallsAllocateOnlyTheirFrames pins the budgets below.
  • No life of its own. The binding starts no goroutines, takes no locks and keeps no counts or queues, and releasing a Deferred rides Wait, Close or the collector, each of which waits for the call to be final first.
PathGoRust
Blocking call1 frame0
Refusal before the call1 Error1 error
Deferred submit and wait4: frame, Deferred, 2 in AddCleanup0
Each callback1 handle0

API

Types

PagesImportConfigPagesImportConfig carries the optional arguments of DatabaseOn.PagesImport.
db.go:74 ↗
type PagesImportConfig struct {
    Encoding PageEncoding
    Durability Durability
    Progress ProgressCallback
}

Fields

EncodingPageEncodingEncoding is the encoding of the markup.
DurabilityDurabilityDurability is how durable the edits are once the call finishes at the head.
ProgressProgressCallbackProgress reports the pages parsed, and may cancel the call.
PagesInsertConfigPagesInsertConfig carries the optional arguments of DatabaseOn.PagesInsert.
db.go:128 ↗
type PagesInsertConfig struct {
    Elements []Key
    Parents []Key
    Anchors []Key
    Encoding PageEncoding
    Durability Durability
}

Fields

Elements[]KeyElements are the keys to give the inserted elements, one per task, or keys minted for each when empty.
Parents[]KeyParents are the elements the fragments land under, one per task, the zero key for the root, or the root for every one when empty.
Anchors[]KeyAnchors are the siblings after which the fragments land, one per task, the zero key for the front, or the front for every one when empty.
EncodingPageEncodingEncoding is the encoding of the fragments.
DurabilityDurabilityDurability is how durable the edits are once the call finishes at the head.
PagesMoveConfigPagesMoveConfig carries the optional arguments of DatabaseOn.PagesMove.
db.go:261 ↗
type PagesMoveConfig struct {
    Parents []Key
    Anchors []Key
    Durability Durability
}

Fields

Parents[]KeyParents are the elements the moved elements land under, one per task, the zero key for the root.
Anchors[]KeyAnchors are the siblings after which the moved elements land, one per task, the zero key for the front.
DurabilityDurabilityDurability is how durable the edits are once the call finishes at the head.
PagesReadConfigPagesReadConfig carries the optional arguments of DatabaseOn.PagesRead.
db.go:446 ↗
type PagesReadConfig struct {
    Elements []Key
    OutputsEncoding PageEncoding
}

Fields

Elements[]KeyElements are the elements to render with their subtrees, one per key, the zero key for the whole page, or whole pages when empty.
OutputsEncodingPageEncodingOutputsEncoding is the encoding the renderings are converted into.
PagesRemoveConfigPagesRemoveConfig carries the optional arguments of DatabaseOn.PagesRemove.
db.go:208 ↗
type PagesRemoveConfig struct {
    Elements []Key
    EndKeys []Key
    Durability Durability
}

Fields

Elements[]KeyElements are the elements to remove with their subtrees, one per task.
EndKeys[]KeyEndKeys turn every key into the inclusive start of a range of whole pages ending before its end key, one per task, which leaves Elements empty.
DurabilityDurabilityDurability is how durable the edits are once the call finishes at the head.
PagesScanConfigPagesScanConfig carries the optional arguments of DatabaseOn.PagesScan.
db.go:502 ↗
type PagesScanConfig struct {
    StartKeys []Key
    EndKeys []Key
    Direction ScanDirection
    Filter string
    Predicate Admitter
    Mode ScanMode
    Progress ProgressCallback
}

Fields

StartKeys[]KeyStartKeys are the inclusive starts of the scans, one per task, or the first page in Direction when empty.
EndKeys[]KeyEndKeys are the keys every scan stops before, one per task, or no bound when empty.
DirectionScanDirectionDirection is which way every scan goes from its start.
FilterstringFilter is the expression every listed page matches, shared by every scan.
PredicateAdmitterPredicate admits or passes over the listed keys.
ModeScanModeMode is in what order the keys come.
ProgressProgressCallbackProgress reports the scans finished, and may cancel the call.
StructInsertedInserted is the key every inserted element ended up with, minted or given, readable until the arena serves another call.1
pages.go:146 ↗
type Inserted struct {
    // contains filtered or unexported fields
}
KeysKeys views the keys of the inserted elements in the arena, one per fragment.
pages.go:153 ↗
func (inserted Inserted) Keys() []Key
EnumPageEncodingPageEncoding is the encoding a page or a fragment is imported from or rendered into.2
pages.go:42 ↗
type PageEncoding int32

Values

PageEncodingHTMLPageEncodingHTML is HTML, not yet imported.
PageEncodingXMLPageEncodingXML is XML, with every element and attribute kept as written.
PageEncodingMarkdownPageEncodingMarkdown is Markdown, not yet imported.
PageEncodingTextPageEncodingText is the text of every run in document order, with structure dropped.
PageEncodingJSONPageEncodingJSON is the element tree as JSON, not yet imported.
PageEncodingFromNamePageEncodingFromName reads an encoding back from the spelling PageEncoding.String renders.
pages.go:63 ↗
func PageEncodingFromName(name string) (PageEncoding, error)
StringString renders the encoding as the library spells it.
pages.go:58 ↗
func (encoding PageEncoding) String() string