world_block

package
v0.53.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeadChangeCountLimit = 5
	NodeChangeCountLimit = 2048
)

Variables

View Source
var (
	WorldChangeType_name = map[int32]string{
		0: "WorldChange_INVALID",
		1: "WorldChange_OBJECT_SET",
		2: "WorldChange_OBJECT_INC_REV",
		3: "WorldChange_OBJECT_DELETE",
		4: "WorldChange_OBJECT_RENAME",
		5: "WorldChange_GRAPH_SET",
		6: "WorldChange_GRAPH_DELETE",
	}
	WorldChangeType_value = map[string]int32{
		"WorldChange_INVALID":        0,
		"WorldChange_OBJECT_SET":     1,
		"WorldChange_OBJECT_INC_REV": 2,
		"WorldChange_OBJECT_DELETE":  3,
		"WorldChange_OBJECT_RENAME":  4,
		"WorldChange_GRAPH_SET":      5,
		"WorldChange_GRAPH_DELETE":   6,
	}
)

Enum value maps for WorldChangeType.

Functions

func ApplyWorldChangeToKeyFilters

func ApplyWorldChangeToKeyFilters(b *filters.KeyFiltersBuilder, ch *WorldChange)

ApplyWorldChangeToKeyFilters applies the world change to the key filter builder.

func BuildMockObject

func BuildMockObject(ctx context.Context, ws world.WorldState, objKey string) (world.ObjectState, error)

BuildMockObject builds a mock object in a world.

func NewChangeLogLLBlock

func NewChangeLogLLBlock() block.Block

NewChangeLogLLBlock constructs a new ChangeLogLL block.

func NewChangeLogLLSubBlockCtor

func NewChangeLogLLSubBlockCtor(r **ChangeLogLL) block.SubBlockCtor

NewChangeLogLLSubBlockCtor returns the sub-block constructor.

func NewEngineTxObjectIterator

func NewEngineTxObjectIterator(
	e *EngineTx,
	ctx context.Context,
	prefix string,
	reversed bool,
) *engineTxObjectIterator

NewEngineTxObjectIterator constructs a new engine tx object iterator.

func NewMockObjectBlock

func NewMockObjectBlock() block.Block

NewMockObjectBlock constructs a new mock object block.

func NewObjectBlock

func NewObjectBlock() block.Block

NewObjectBlock constructs a new object block.

func NewObjectIterator

func NewObjectIterator(w *WorldState, ctx context.Context, prefix string, reversed bool) *objectIterator

NewObjectIterator constructs a new object iterator.

func NewWorldBlock

func NewWorldBlock() block.Block

NewWorldBlock constructs a new world state block.

func NewWorldChangeBlock

func NewWorldChangeBlock() block.Block

NewWorldChangeBlock is the world change block constructor.

func NewWorldChangeLLBlock

func NewWorldChangeLLBlock() block.Block

NewWorldChangeLLBlock constructs a new WorldChangeLL block.

func NewWorldChangeSet

func NewWorldChangeSet(v *[]*WorldChange, bcs *block.Cursor) *sbset.SubBlockSet

NewWorldChangeSet builds a new world change set container.

bcs should be located at the world change set sub-block.

func NewWorldChangeSubBlockCtor

func NewWorldChangeSubBlockCtor(r **WorldChange) block.SubBlockCtor

NewWorldChangeSubBlockCtor returns the sub-block constructor.

func UnmarshalMockObject

func UnmarshalMockObject(ctx context.Context, bcs *block.Cursor) (*block_mock.Example, error)

UnmarshalMockObject unmarshals a block from a block cursor.

Types

type ChangeLogEntry added in v0.52.0

type ChangeLogEntry struct {
	Seqno      uint64
	ChangeType WorldChangeType
	TotalSize  uint32
	Changes    []*WorldChange
}

ChangeLogEntry is one linked-list entry plus its expanded change batch.

func ReadChangeLogEntries added in v0.52.0

func ReadChangeLogEntries(
	ctx context.Context,
	access world.AccessWorldStateFunc,
	opts ChangeLogReadOptions,
) ([]*ChangeLogEntry, error)

ReadChangeLogEntries reads recent changelog entries from a World storage accessor.

func ReadChangeLogEntriesFromCursor added in v0.52.0

func ReadChangeLogEntriesFromCursor(
	ctx context.Context,
	rootBcs *block.Cursor,
	opts ChangeLogReadOptions,
) ([]*ChangeLogEntry, error)

ReadChangeLogEntriesFromCursor reads recent changelog entries from a cursor at the World root.

type ChangeLogLL

type ChangeLogLL struct {

	// Seqno is the world sequence number after this changeset is applied.
	Seqno uint64 `protobuf:"varint,1,opt,name=seqno,proto3" json:"seqno,omitempty"`
	// PrevRef is the reference to the previous change.
	// If seqno <= 1, this must be empty.
	PrevRef *block1.BlockRef `protobuf:"bytes,2,opt,name=prev_ref,json=prevRef,proto3" json:"prevRef,omitempty"`
	// ChangeBatch is the world change batch linked-list first node.
	// Linked-list is used to reduce the size of changelog entries.
	// The HEAD of the ChangeLogLL is limited to 5 embedded changes.
	// The nodes of the ChangeLogLL are limited to 2048 entries (~512KiB).
	ChangeBatch *WorldChangeLL `protobuf:"bytes,3,opt,name=change_batch,json=changeBatch,proto3" json:"changeBatch,omitempty"`
	// ChangeType is the type of change applied.
	// If there are multiple changes, they will all be of this type.
	ChangeType WorldChangeType `protobuf:"varint,4,opt,name=change_type,json=changeType,proto3" json:"changeType,omitempty"`
	// KeyFilters contains filters to quickly check if a key was affected.
	// Bloom capacity is the object key count before changes are applied.
	// Bloom capacity: min 64 (38bytes), max 500k (300KiB).
	// Bloom false-negative rate 0%, false-positive rate ~10%.
	// Key prefix false-negative rate depends on common prefix of ops.
	// Should be used as a changelog filter for watchers.
	// If change_batch.prev_ref is empty, this field will also be empty.
	KeyFilters *filters.KeyFilters `protobuf:"bytes,5,opt,name=key_filters,json=keyFilters,proto3" json:"keyFilters,omitempty"`
	// contains filtered or unexported fields
}

ChangeLogLL is a world change log linked-list entry. The size of a ChangeLogLL entry is capped to 1MiB, targeting 512KiB.

func AppendChangeLogLL

func AppendChangeLogLL(
	ctx context.Context,
	storeKeyCount uint64,
	nextBcs *block.Cursor,
	prevBcs *block.Cursor,
	worldChangesBcs []*block.Cursor,
) (*ChangeLogLL, error)

AppendChangeLogLL appends world changes to the ChangeLogLL, respecting the given limits for most recent (HEAD) and linked-list node change counts. nextBcs should point to the location to write the HEAD WorldChangeLL. prevBcs should point to the previous *WorldChangeLL. prevBcs can be nil to indicate a brand-new linked list. if prevBcs is a sub-block, it will be detached before it is referenced prevBcs and nextBcs can be the same block cursor, if both are sub-block all world changes must have the same change type Returns the latest HEAD block and sets it into nextBcs.

func UnmarshalChangeLogLL

func UnmarshalChangeLogLL(ctx context.Context, bcs *block.Cursor) (*ChangeLogLL, error)

UnmarshalChangeLogLL unmarshals a world change ll from a cursor. If empty, returns nil, nil

func (*ChangeLogLL) ApplyBlockRef

func (w *ChangeLogLL) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*ChangeLogLL) ApplySubBlock

func (w *ChangeLogLL) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*ChangeLogLL) BlockAliasIdentity added in v0.52.0

func (w *ChangeLogLL) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for ChangeLogLL.

func (*ChangeLogLL) Clone

func (w *ChangeLogLL) Clone() *ChangeLogLL

Clone clones the changelog ll object. Note: references the same ChangeBatch object. Note: clones the KeyFilters object.

func (*ChangeLogLL) CloneMessageVT

func (m *ChangeLogLL) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*ChangeLogLL) CloneVT

func (m *ChangeLogLL) CloneVT() *ChangeLogLL

func (*ChangeLogLL) EqualMessageVT

func (this *ChangeLogLL) EqualMessageVT(thatMsg any) bool

func (*ChangeLogLL) EqualVT

func (this *ChangeLogLL) EqualVT(that *ChangeLogLL) bool

func (*ChangeLogLL) GetBlockRefCtor

func (w *ChangeLogLL) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*ChangeLogLL) GetBlockRefs

func (w *ChangeLogLL) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*ChangeLogLL) GetChangeBatch

func (x *ChangeLogLL) GetChangeBatch() *WorldChangeLL

func (*ChangeLogLL) GetChangeType

func (x *ChangeLogLL) GetChangeType() WorldChangeType

func (*ChangeLogLL) GetKeyFilters

func (x *ChangeLogLL) GetKeyFilters() *filters.KeyFilters

func (*ChangeLogLL) GetPrevRef

func (x *ChangeLogLL) GetPrevRef() *block1.BlockRef

func (*ChangeLogLL) GetSeqno

func (x *ChangeLogLL) GetSeqno() uint64

func (*ChangeLogLL) GetSubBlockCtor

func (w *ChangeLogLL) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*ChangeLogLL) GetSubBlocks

func (w *ChangeLogLL) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*ChangeLogLL) IsEmpty

func (w *ChangeLogLL) IsEmpty() bool

IsEmpty checks if the world change is empty.

func (*ChangeLogLL) IsNil

func (w *ChangeLogLL) IsNil() bool

IsNil returns if the object is nil.

func (*ChangeLogLL) MarshalBlock

func (w *ChangeLogLL) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*ChangeLogLL) MarshalJSON

func (x *ChangeLogLL) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ChangeLogLL to JSON.

func (*ChangeLogLL) MarshalProtoJSON

func (x *ChangeLogLL) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the ChangeLogLL message to JSON.

func (*ChangeLogLL) MarshalProtoText

func (x *ChangeLogLL) MarshalProtoText() string

func (*ChangeLogLL) MarshalToSizedBufferVT

func (m *ChangeLogLL) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*ChangeLogLL) MarshalToVT

func (m *ChangeLogLL) MarshalToVT(dAtA []byte) (int, error)

func (*ChangeLogLL) MarshalVT

func (m *ChangeLogLL) MarshalVT() (dAtA []byte, err error)

func (*ChangeLogLL) ProtoMessage

func (*ChangeLogLL) ProtoMessage()

func (*ChangeLogLL) Reset

func (x *ChangeLogLL) Reset()

func (*ChangeLogLL) SizeVT

func (m *ChangeLogLL) SizeVT() (n int)

func (*ChangeLogLL) String

func (x *ChangeLogLL) String() string

func (*ChangeLogLL) UnmarshalBlock

func (w *ChangeLogLL) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*ChangeLogLL) UnmarshalJSON

func (x *ChangeLogLL) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the ChangeLogLL from JSON.

func (*ChangeLogLL) UnmarshalProtoJSON

func (x *ChangeLogLL) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the ChangeLogLL message from JSON.

func (*ChangeLogLL) UnmarshalVT

func (m *ChangeLogLL) UnmarshalVT(dAtA []byte) error

type ChangeLogReadOptions added in v0.52.0

type ChangeLogReadOptions struct {
	// Limit is the maximum number of ChangeLogLL entries to return. Zero means
	// no explicit limit.
	Limit uint64
	// AfterSeqno stops traversal before entries at or below this seqno.
	AfterSeqno uint64
}

ChangeLogReadOptions bounds changelog traversal.

type CommitFn

type CommitFn func(ctx context.Context, baseRef, nref *bucket.ObjectRef) error

CommitFn is a function to call with the updated root before confirming it. Should be used to write the updated state back to storage. Note: engine rmtx is locked while cb is called, do not block or call engine funcs! If an error is returned the change will be rolled back. Do not change the nrootBcs during this call.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the world engine instance. Uses short-lived block graph transactions internally. Reads are against latest state; read txs don't lock. Re-tries transaction operations if the underlying transaction is discarded mid-way through. Maintains two WorldState objects: one for readers, one for writer.

func NewEngine

func NewEngine(
	ctx context.Context,
	le *logrus.Entry,
	root *bucket_lookup.Cursor,
	lookupOp world.LookupOp,
	commitFn CommitFn,
	verbose bool,
	opts ...EngineOption,
) (*Engine, error)

NewEngine constructs a new world engine. commitFn can be nil.

func (*Engine) AccessWorldState

func (e *Engine) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref Bucket ID is empty, uses the same bucket + volume as the world. The lookup cursor will be released after cb returns.

NOTE: this is the implementation of AccessWorldState for the world/block engine.

func (*Engine) AdoptRootRefFromWatch added in v0.52.0

func (e *Engine) AdoptRootRefFromWatch(ctx context.Context, ref *bucket.ObjectRef) error

AdoptRootRefFromWatch updates the root from an advisory coordinator watch only when no local write transaction is active. bbolt emits generation events for intermediate block writes before the durable World head is updated; watch adoption must not roll an in-flight local writer back to the previous head.

func (*Engine) BuildStorageCursor

func (e *Engine) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

BuildStorageCursor builds a cursor to the world storage with an empty ref. The cursor should be released independently of the WorldState. Be sure to call Release on the cursor when done.

func (*Engine) Close added in v0.51.7

func (e *Engine) Close() error

Close releases root cursors and active transaction state owned by the engine.

func (*Engine) ForkBlockTransaction

func (e *Engine) ForkBlockTransaction(ctx context.Context, write bool) (*Tx, error)

ForkBlockTransaction forks the transaction at the current state.

func (*Engine) GetGCJournalEntries

func (e *Engine) GetGCJournalEntries() uint64

GetGCJournalEntries returns the number of pending GC journal entries. Safe to call concurrently. Returns 0 if the read tx or journal is not initialized.

func (*Engine) GetRootRef

func (e *Engine) GetRootRef() *bucket.ObjectRef

GetRootRef gets the current root cursor reference.

func (*Engine) GetSeqno

func (e *Engine) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current seqno of the world state. This is also the sequence number of the most recent change. Initializes at 0 for initial world state.

func (*Engine) NewBlockEngineTransaction

func (e *Engine) NewBlockEngineTransaction(ctx context.Context, write bool) (*EngineTx, error)

NewBlockEngineTransaction returns the world-block specific EngineTx type.

func (*Engine) NewTransaction

func (e *Engine) NewTransaction(ctx context.Context, write bool) (world.Tx, error)

NewTransaction returns a new transaction against the store. Indicate write if the transaction will not be read-only. Always call Discard() after you are done with the transaction. Check GetReadOnly, might not return a write tx if write=true.

func (*Engine) SetRootRef

func (e *Engine) SetRootRef(ctx context.Context, ref *bucket.ObjectRef) error

SetRootRef updates the root cursor to point to a new reference. Re-creates the internal read transaction with the updated state. Cancels any ongoing write tx (to be re-created against new state). Can return an error to indicate validation failure.

func (*Engine) Sync added in v0.52.0

func (e *Engine) Sync(ctx context.Context) (bool, error)

Sync fences durable storage and advances the durable world head.

The fence is ordered: first the block barrier makes every block written so far durable, then the durable head is advanced to the current in-memory root via commitFn. Ordering matters because a head that names not-yet-durable blocks is the crash window this fence closes.

In the single-writer path (no write coordinator) the per-commit path defers the durable head, so this is where it advances. In coordinator mode the head is already published per commit, so the head advance here is a no-op and only the block barrier runs.

func (*Engine) WaitSeqno

func (e *Engine) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the seqno of the world state to be >= value. Returns the seqno when the condition is reached. If value == 0, this might return immediately unconditionally.

type EngineOption added in v0.52.0

type EngineOption func(*Engine)

EngineOption configures optional Engine integrations.

func WithDeferredDurability added in v0.52.0

func WithDeferredDurability() EngineOption

WithDeferredDurability enables single-writer deferred durability: block writes and the durable head advance batch in memory until Sync. It is the IC-3 hot-path fence and has no effect when a write coordinator is configured.

func WithWriteCoordinator added in v0.52.0

func WithWriteCoordinator(
	coordinator coord.Coordinator,
	scope coord.Scope,
	keyPrefix []byte,
	refreshHead func(context.Context) (*bucket.ObjectRef, error),
) EngineOption

WithWriteCoordinator requires write transactions to acquire a coordinator lease and refresh the durable World head before mutation.

type EngineTx

type EngineTx struct {
	// contains filtered or unexported fields
}

EngineTx is an engine transaction wrapping the Tx object. returned by e.NewTransaction

func (*EngineTx) AccessCayleyGraph

func (e *EngineTx) AccessCayleyGraph(ctx context.Context, write bool, cb func(ctx context.Context, h world.CayleyHandle) error) error

AccessCayleyGraph calls a callback with a temporary Cayley graph handle. All accesses of the handle should complete before returning cb. Try to make access (queries) as short as possible. Write operations will fail if the store is read-only.

func (*EngineTx) AccessWorldState

func (e *EngineTx) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, returns empty cursor in the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*EngineTx) ApplyWorldOp

func (e *EngineTx) ApplyWorldOp(
	ctx context.Context,
	op world.Operation,
	opSender peer.ID,
) (uint64, bool, error)

ApplyWorldOp applies a batch operation at the world level. The handling of the operation is operation-type specific. Returns the seqno following the operation execution. If nil is returned for the error, implies success.

func (*EngineTx) BuildStorageCursor

func (e *EngineTx) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

BuildStorageCursor builds a cursor to the world storage with an empty ref. The cursor should be released independently of the WorldState. Be sure to call Release on the cursor when done.

func (*EngineTx) Commit

func (e *EngineTx) Commit(ctx context.Context) error

Commit commits the transaction to storage. Can return an error to indicate tx failure. If not write, returns ErrNotWrite.

func (*EngineTx) CommitBlockTransaction

func (e *EngineTx) CommitBlockTransaction(ctx context.Context) (*bucket.ObjectRef, error)

CommitBlockTransaction implements Commit but additionally returns the updated ObjectRef. Commit commits the transaction to storage. Can return an error to indicate tx failure. If not write, returns ErrNotWrite.

func (*EngineTx) CreateObject

func (e *EngineTx) CreateObject(ctx context.Context, key string, rootRef *bucket.ObjectRef) (world.ObjectState, error)

CreateObject creates a object with a key and initial root ref. Returns ErrObjectExists if the object already exists.

func (*EngineTx) DeleteGraphObject

func (e *EngineTx) DeleteGraphObject(ctx context.Context, value string) error

DeleteGraphObject deletes all quads with Subject or Object set to value. May also remove objects with <predicate> or <value> set to the value.

func (*EngineTx) DeleteGraphQuad

func (e *EngineTx) DeleteGraphQuad(ctx context.Context, q world.GraphQuad) error

DeleteGraphQuad deletes a quad from the graph store. Note: if quad did not exist, returns nil.

func (*EngineTx) DeleteObject

func (e *EngineTx) DeleteObject(ctx context.Context, key string) (bool, error)

DeleteObject deletes an object and associated graph quads by ID. Calls DeleteGraphObject internally. Returns false, nil if not found.

func (*EngineTx) Discard

func (e *EngineTx) Discard()

Discard cancels the transaction. If called after Commit, does nothing. Cannot return an error. Can be called unlimited times.

func (*EngineTx) Fork

func (e *EngineTx) Fork(ctx context.Context) (world.WorldState, error)

Fork forks the current world state into a completely separate world state.

Creates a new block transaction.

func (*EngineTx) GarbageCollect

func (e *EngineTx) GarbageCollect(ctx context.Context) error

GarbageCollect sweeps unreferenced nodes from the GC ref graph. Only valid on writable EngineTx instances with GC enabled.

func (*EngineTx) GetObject

func (e *EngineTx) GetObject(ctx context.Context, key string) (world.ObjectState, bool, error)

GetObject looks up an object by key. Returns nil, false if not found.

func (*EngineTx) GetObjectRootRefsBatch added in v0.51.7

func (e *EngineTx) GetObjectRootRefsBatch(ctx context.Context, keys []string) ([]*world.ObjectRootRef, error)

GetObjectRootRefsBatch returns object root refs for object keys.

func (*EngineTx) GetReadOnly

func (e *EngineTx) GetReadOnly() bool

GetReadOnly returns if the state is read-only.

func (*EngineTx) GetSeqno

func (e *EngineTx) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current seqno of the world state. This is also the sequence number of the most recent change. Initializes at 0 for initial world state. Note: this contains the seqno of the tx if this is a transaction.

func (*EngineTx) HasObject added in v0.53.0

func (e *EngineTx) HasObject(ctx context.Context, key string) (bool, error)

HasObject reports whether an object exists at key. It routes through the transaction like GetObject, so a write transaction can answer from its transaction-local object memo.

func (*EngineTx) IterateObjects

func (e *EngineTx) IterateObjects(ctx context.Context, prefix string, reversed bool) world.ObjectIterator

IterateObjects returns an iterator with the given object key prefix. The prefix is NOT clipped from the output keys. Keys are returned in sorted order. Must call Next() or Seek() before valid. Call Close when done with the iterator. Any init errors will be available via the iterator's Err() method.

func (*EngineTx) LookupGraphQuads

func (e *EngineTx) LookupGraphQuads(ctx context.Context, filter world.GraphQuad, limit uint32) ([]world.GraphQuad, error)

LookupGraphQuads searches for graph quads in the store.

func (*EngineTx) LookupGraphQuadsBatch added in v0.51.7

func (e *EngineTx) LookupGraphQuadsBatch(ctx context.Context, filters []world.GraphQuad, limitPerFilter uint32) ([][]world.GraphQuad, error)

LookupGraphQuadsBatch searches for graph quads for each filter in one transaction operation.

func (*EngineTx) QueryGraphPath added in v0.51.6

func (e *EngineTx) QueryGraphPath(ctx context.Context, query *world.GraphPathQuery) (*world.GraphPathQueryResult, error)

QueryGraphPath executes a bounded graph traversal.

func (*EngineTx) RenameObject

func (e *EngineTx) RenameObject(ctx context.Context, oldKey, newKey string, descendants bool) (world.ObjectState, error)

RenameObject renames an object key and updates associated graph quads.

func (*EngineTx) SetGraphQuad

func (e *EngineTx) SetGraphQuad(ctx context.Context, q world.GraphQuad) error

SetGraphQuad sets a quad in the graph store. Subject: must be an existing object IRI: <object-key> Predicate: a predicate string, e.x. IRI: <ref> Object: an existing object IRI: <object-key> If already exists, returns nil.

func (*EngineTx) Sync added in v0.52.0

func (e *EngineTx) Sync(ctx context.Context) (bool, error)

Sync fences durable storage and advances the durable head via the engine.

func (*EngineTx) WaitSeqno

func (e *EngineTx) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the seqno of the world state to be >= value. Returns the seqno when the condition is reached. If value == 0, this might return immediately unconditionally. Note: this waits for the engine seqno, not the pending tx seqno.

type EngineTxObjectState

type EngineTxObjectState struct {
	// contains filtered or unexported fields
}

EngineTxObjectState is an ObjectState handle attached to a EngineTx.

func (*EngineTxObjectState) AccessWorldState

func (t *EngineTxObjectState) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, will default to the object RootRef. If the ref Bucket ID is empty, uses the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*EngineTxObjectState) ApplyObjectOp

func (t *EngineTxObjectState) ApplyObjectOp(
	ctx context.Context,
	op world.Operation,
	opSender peer.ID,
) (uint64, bool, error)

ApplyObjectOp applies a batch operation at the object level. The handling of the operation is operation-type specific. Returns the revision following the operation execution. If nil is returned for the error, implies success.

func (*EngineTxObjectState) GetKey

func (t *EngineTxObjectState) GetKey() string

GetKey returns the key this state object is for.

func (*EngineTxObjectState) GetRootRef

GetRootRef returns the root reference of the object.

func (*EngineTxObjectState) IncrementRev

func (t *EngineTxObjectState) IncrementRev(ctx context.Context) (uint64, error)

IncrementRev increments the revision of the object. Returns the new latest revision.

func (*EngineTxObjectState) SetRootRef

func (t *EngineTxObjectState) SetRootRef(ctx context.Context, nref *bucket.ObjectRef) (uint64, error)

SetRootRef changes the root reference of the object.

func (*EngineTxObjectState) WaitRev

func (t *EngineTxObjectState) WaitRev(
	ctx context.Context,
	rev uint64,
	ignoreNotFound bool,
) (uint64, error)

WaitRev waits until the object rev is >= the specified. Returns ErrObjectNotFound if the object is deleted. If ignoreNotFound is set, waits for the object to exist. Returns the new rev.

type MockObject

type MockObject = block_mock.Example

MockObject is the mock object block.

type Object

type Object struct {

	// Key is the unique Object key.
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// RootRef is the block ref to the root of the object structure.
	// Note: Object type is not stored. Type data is stored in the Graph, inline, or not at all.
	RootRef *bucket.ObjectRef `protobuf:"bytes,2,opt,name=root_ref,json=rootRef,proto3" json:"rootRef,omitempty"`
	// Rev is the revision nonce of the object.
	// Incremented when a transaction is applied to the object.
	// Incremented when root_ref is changed (SetRootRef).
	// Incremented when adding or removing a graph quad referencing Object.
	Rev uint64 `protobuf:"varint,3,opt,name=rev,proto3" json:"rev,omitempty"`
	// contains filtered or unexported fields
}

Object is an atomic unit for a object in a World graph.

func NewObject

func NewObject(key string, rootRef *bucket.ObjectRef) *Object

NewObject constructs a new Object block from a key and root ref.

A nil root ref is normalized to an empty ObjectRef so that an object created with no explicit root carries an empty root sub-block, identical to one created with an explicit empty ref. Readers that strictly decode the object root (the SQL store opener) then see an empty root rather than a missing sub-block that decodes as the wrong block type.

func UnmarshalObject

func UnmarshalObject(ctx context.Context, bcs *block.Cursor) (*Object, error)

UnmarshalObject unmarshals a Object block from a cursor. If empty, returns nil, nil

func (*Object) ApplySubBlock

func (o *Object) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Object) Clone

func (o *Object) Clone() *Object

Clone clones the Object.

func (*Object) CloneMessageVT

func (m *Object) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Object) CloneVT

func (m *Object) CloneVT() *Object

func (*Object) DecodedBlockCacheTypeKey added in v0.51.7

func (o *Object) DecodedBlockCacheTypeKey() string

DecodedBlockCacheTypeKey returns the decoded-block cache type key.

func (*Object) EqualMessageVT

func (this *Object) EqualMessageVT(thatMsg any) bool

func (*Object) EqualVT

func (this *Object) EqualVT(that *Object) bool

func (*Object) GetKey

func (x *Object) GetKey() string

func (*Object) GetRev

func (x *Object) GetRev() uint64

func (*Object) GetRootRef

func (x *Object) GetRootRef() *bucket.ObjectRef

func (*Object) GetSubBlockCtor

func (o *Object) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Object) GetSubBlocks

func (o *Object) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Object) MarshalBlock

func (o *Object) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Object) MarshalJSON

func (x *Object) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Object to JSON.

func (*Object) MarshalProtoJSON

func (x *Object) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Object message to JSON.

func (*Object) MarshalProtoText

func (x *Object) MarshalProtoText() string

func (*Object) MarshalToSizedBufferVT

func (m *Object) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Object) MarshalToVT

func (m *Object) MarshalToVT(dAtA []byte) (int, error)

func (*Object) MarshalVT

func (m *Object) MarshalVT() (dAtA []byte, err error)

func (*Object) ProtoMessage

func (*Object) ProtoMessage()

func (*Object) Reset

func (x *Object) Reset()

func (*Object) SizeVT

func (m *Object) SizeVT() (n int)

func (*Object) String

func (x *Object) String() string

func (*Object) UnmarshalBlock

func (o *Object) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Object) UnmarshalJSON

func (x *Object) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Object from JSON.

func (*Object) UnmarshalProtoJSON

func (x *Object) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Object message from JSON.

func (*Object) UnmarshalVT

func (m *Object) UnmarshalVT(dAtA []byte) error

type ObjectState

type ObjectState struct {
	// contains filtered or unexported fields
}

ObjectState implements the ObjectState interface attached to block cursor.

func NewObjectState

func NewObjectState(ctx context.Context, w *WorldState, bcs *block.Cursor) (*ObjectState, error)

NewObjectState constructs a new ObjectState from a block cursor and world state.

func (*ObjectState) AccessWorldState

func (o *ObjectState) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, will default to the object RootRef. If the ref Bucket ID is empty, uses the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*ObjectState) ApplyObjectOp

func (o *ObjectState) ApplyObjectOp(
	rctx context.Context,
	op world.Operation,
	opSender peer.ID,
) (uint64, bool, error)

ApplyObjectOp applies a batch operation at the object level. The handling of the operation is operation-type specific. Returns the revision following the operation execution. If nil is returned for the error, implies success.

func (*ObjectState) GetKey

func (o *ObjectState) GetKey() string

GetKey returns the key this state object is for.

func (*ObjectState) GetRoot

func (o *ObjectState) GetRoot(ctx context.Context) (*Object, error)

GetRoot unmarshals root from the block cursor

func (*ObjectState) GetRootRef

func (o *ObjectState) GetRootRef(ctx context.Context) (*bucket.ObjectRef, uint64, error)

GetRootRef returns the root reference of the object.

func (*ObjectState) IncrementRev

func (o *ObjectState) IncrementRev(ctx context.Context) (uint64, error)

IncrementRev increments the revision of the object. Returns the new latest revision.

func (*ObjectState) SetRootRef

func (o *ObjectState) SetRootRef(ctx context.Context, nref *bucket.ObjectRef) (uint64, error)

SetRootRef changes the root reference of the object.

func (*ObjectState) WaitRev

func (o *ObjectState) WaitRev(
	ctx context.Context,
	rev uint64,
	ignoreNotFound bool,
) (uint64, error)

WaitRev waits until the object rev is >= the specified. Returns ErrObjectNotFound if the object is deleted. If ignoreNotFound is set, waits for the object to exist. Returns the new rev.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx implements the hydra world transaction interface. uses a mutex for concurrent-safe calls

func NewTx

func NewTx(state *WorldState) *Tx

NewTx constructs a new transaction from a world state. Guards the calls with a RWMutex (concurrency safe). Prevents operations after the Tx was discarded or committed.

func (*Tx) AccessCayleyGraph

func (t *Tx) AccessCayleyGraph(ctx context.Context, write bool, cb func(ctx context.Context, h world.CayleyHandle) error) error

AccessCayleyGraph calls a callback with a temporary Cayley graph handle. All accesses of the handle should complete before returning cb. Try to make access (queries) as short as possible. Write operations will fail if the store is read-only.

func (*Tx) AccessWorldState

func (t *Tx) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, returns empty cursor in the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*Tx) ApplyWorldOp

func (t *Tx) ApplyWorldOp(
	ctx context.Context,
	op world.Operation,
	opSender peer.ID,
) (uint64, bool, error)

ApplyWorldOp applies a batch operation at the world level. The handling of the operation is operation-type specific. Returns the seqno following the operation execution. If nil is returned for the error, implies success.

func (*Tx) BuildStorageCursor

func (t *Tx) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

BuildStorageCursor builds a cursor to the world storage with an empty ref. The cursor should be released independently of the WorldState. Be sure to call Release on the cursor when done.

func (*Tx) Commit

func (t *Tx) Commit(ctx context.Context) error

Commit commits the transaction to storage. Can return an error to indicate tx failure.

func (*Tx) CommitBlockTransaction

func (t *Tx) CommitBlockTransaction(ctx context.Context) (*block.BlockRef, error)

CommitBlockTransaction implements Commit but additionally returns the updated BlockRef. Commit commits the transaction to storage. Can return an error to indicate tx failure.

func (*Tx) CreateObject

func (t *Tx) CreateObject(ctx context.Context, key string, rootRef *bucket.ObjectRef) (world.ObjectState, error)

CreateObject creates a object with a key and initial root ref. Returns ErrObjectExists if the object already exists.

func (*Tx) DeleteGraphObject

func (t *Tx) DeleteGraphObject(ctx context.Context, value string) error

DeleteGraphObject deletes all quads with Subject or Object set to value. May also remove objects with <predicate> or <value> set to the value.

func (*Tx) DeleteGraphQuad

func (t *Tx) DeleteGraphQuad(ctx context.Context, q world.GraphQuad) error

DeleteGraphQuad deletes a quad from the graph store. Note: if quad did not exist, returns nil.

func (*Tx) DeleteObject

func (t *Tx) DeleteObject(ctx context.Context, key string) (bool, error)

DeleteObject deletes an object and associated graph quads by ID. Calls DeleteGraphObject internally. Returns false, nil if not found.

func (*Tx) Discard

func (t *Tx) Discard()

Discard cancels the transaction. If called after Commit, does nothing. Cannot return an error. Can be called unlimited times.

func (*Tx) Fork

func (t *Tx) Fork(ctx context.Context) (world.WorldState, error)

Fork forks the current tx into a completely separate tx.

Creates a new block transaction.

func (*Tx) GetObject

func (t *Tx) GetObject(ctx context.Context, key string) (world.ObjectState, bool, error)

GetObject looks up an object by key. Returns nil, false if not found.

func (*Tx) GetObjectRootRefsBatch added in v0.51.7

func (t *Tx) GetObjectRootRefsBatch(ctx context.Context, keys []string) ([]*world.ObjectRootRef, error)

GetObjectRootRefsBatch returns object root refs for object keys.

func (*Tx) GetReadOnly

func (t *Tx) GetReadOnly() bool

GetReadOnly returns if the tx is read-only.

func (*Tx) GetSeqno

func (t *Tx) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current seqno of the world state. This is also the sequence number of the most recent change. Initializes at 0 for initial world state.

func (*Tx) HasObject added in v0.53.0

func (t *Tx) HasObject(ctx context.Context, key string) (bool, error)

HasObject reports whether an object exists at key. It takes the write lock because a miss may populate the underlying state's transaction-local object memo, which the single-threaded state does not guard on its own.

func (*Tx) IterateObjects

func (t *Tx) IterateObjects(ctx context.Context, prefix string, reversed bool) world.ObjectIterator

IterateObjects returns an iterator with the given object key prefix. The prefix is NOT clipped from the output keys. Keys are returned in sorted order. Must call Next() or Seek() before valid. Call Close when done with the iterator. Any init errors will be available via the iterator's Err() method.

func (*Tx) LookupGraphQuads

func (t *Tx) LookupGraphQuads(ctx context.Context, filter world.GraphQuad, limit uint32) ([]world.GraphQuad, error)

LookupGraphQuads searches for graph quads in the store.

func (*Tx) LookupGraphQuadsBatch added in v0.51.7

func (t *Tx) LookupGraphQuadsBatch(ctx context.Context, filters []world.GraphQuad, limitPerFilter uint32) ([][]world.GraphQuad, error)

LookupGraphQuadsBatch searches for graph quads for each filter in one locked read.

func (*Tx) QueryGraphPath added in v0.51.6

func (t *Tx) QueryGraphPath(ctx context.Context, query *world.GraphPathQuery) (*world.GraphPathQueryResult, error)

QueryGraphPath executes a bounded graph traversal.

func (*Tx) RenameObject

func (t *Tx) RenameObject(ctx context.Context, oldKey, newKey string, descendants bool) (world.ObjectState, error)

RenameObject renames an object key and updates associated graph quads.

func (*Tx) SetGraphQuad

func (t *Tx) SetGraphQuad(ctx context.Context, q world.GraphQuad) error

SetGraphQuad sets a quad in the graph store. Subject: must be an existing object IRI: <object-key> Predicate: a predicate string, e.x. IRI: <ref> Object: an existing object IRI: <object-key> If already exists, returns nil.

func (*Tx) Sync added in v0.52.0

func (t *Tx) Sync(ctx context.Context) (bool, error)

Sync fences the block writes made through this tx's world state durable.

func (*Tx) WaitSeqno

func (t *Tx) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the seqno of the world state to be >= value. Returns the seqno when the condition is reached. If value == 0, this might return immediately unconditionally.

type TxObjectState

type TxObjectState struct {
	// contains filtered or unexported fields
}

TxObjectState is an Object attached to a Tx. Concurrent safe guarded by rmtx on the Tx.

func NewTxObjectState

func NewTxObjectState(t *Tx, key string, o world.ObjectState) *TxObjectState

NewTxObjectState returns a new Object wrapped with a tx.

func (*TxObjectState) AccessWorldState

func (t *TxObjectState) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, will default to the object RootRef. If the ref Bucket ID is empty, uses the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*TxObjectState) ApplyObjectOp

func (t *TxObjectState) ApplyObjectOp(ctx context.Context, op world.Operation, opSender peer.ID) (uint64, bool, error)

ApplyObjectOp applies a batch operation at the object level. The handling of the operation is operation-type specific. Returns the revision following the operation execution. If nil is returned for the error, implies success.

func (*TxObjectState) GetKey

func (t *TxObjectState) GetKey() string

GetKey returns the key this state object is for.

func (*TxObjectState) GetRootRef

func (t *TxObjectState) GetRootRef(ctx context.Context) (*bucket.ObjectRef, uint64, error)

GetRootRef returns the root reference of the object.

func (*TxObjectState) IncrementRev

func (t *TxObjectState) IncrementRev(ctx context.Context) (uint64, error)

IncrementRev increments the revision of the object. Returns the new latest revision.

func (*TxObjectState) SetRootRef

func (t *TxObjectState) SetRootRef(ctx context.Context, nref *bucket.ObjectRef) (uint64, error)

SetRootRef changes the root reference of the object.

func (*TxObjectState) WaitRev

func (t *TxObjectState) WaitRev(
	ctx context.Context,
	rev uint64,
	ignoreNotFound bool,
) (uint64, error)

WaitRev waits until the object rev is >= the specified. Returns ErrObjectNotFound if the object is deleted. If ignoreNotFound is set, waits for the object to exist. Returns the new rev.

type World

type World struct {

	// ObjectKeyValue is the key/value tree of objects.
	// Key: string
	// Value: cid.BlockRef -> Object
	ObjectKeyValue *block.KeyValueStore `protobuf:"bytes,1,opt,name=object_key_value,json=objectKeyValue,proto3" json:"objectKeyValue,omitempty"`
	// GraphKeyValue is the key/value tree storing the graph.
	// k/v structure managed by cayley graph kvtx implementation
	// Value: cid.BlockRef -> Quad
	GraphKeyValue *block.KeyValueStore `protobuf:"bytes,2,opt,name=graph_key_value,json=graphKeyValue,proto3" json:"graphKeyValue,omitempty"`
	// LastChange is the current head of the changelog linked list.
	// If seqno == 0, this field is empty.
	LastChange *ChangeLogLL `protobuf:"bytes,3,opt,name=last_change,json=lastChange,proto3" json:"lastChange,omitempty"`
	// LastChangeDisable indicates the changelog is disabled for this world.
	// If set, last_change will be empty, except for the seqno field.
	// NOTE: the seqno field will not be empty on LastChange.
	LastChangeDisable bool `protobuf:"varint,4,opt,name=last_change_disable,json=lastChangeDisable,proto3" json:"lastChangeDisable,omitempty"`
	// GcGraph is the gc reference graph key/value store.
	// Stores gc/ref quads for garbage collection of unreferenced blocks.
	GcGraph *block.KeyValueStore `protobuf:"bytes,5,opt,name=gc_graph,json=gcGraph,proto3" json:"gcGraph,omitempty"`
	// GcJournal is the deferred GC journal key/value store.
	// Stores pending ref edge batches that are reconciled into gc_graph later.
	GcJournal *block.KeyValueStore `protobuf:"bytes,6,opt,name=gc_journal,json=gcJournal,proto3" json:"gcJournal,omitempty"`
	// contains filtered or unexported fields
}

World contains a key/value Object store, and a graph database with quads <subject, predicate, object, value>. Optionally a 2D changelog is used for efficient change detection without needing to download every change.

func NewWorld

func NewWorld(disableChangelog bool) *World

NewWorld constructs a new empty world.

func UnmarshalWorld

func UnmarshalWorld(ctx context.Context, bcs *block.Cursor) (*World, error)

UnmarshalWorld unmarshals a world block from a cursor. If empty, returns nil, nil

func (*World) ApplySubBlock

func (w *World) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*World) CloneMessageVT

func (m *World) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*World) CloneVT

func (m *World) CloneVT() *World

func (*World) DecodedBlockCacheTypeKey added in v0.51.7

func (w *World) DecodedBlockCacheTypeKey() string

DecodedBlockCacheTypeKey returns the decoded-block cache type key.

func (*World) EqualMessageVT

func (this *World) EqualMessageVT(thatMsg any) bool

func (*World) EqualVT

func (this *World) EqualVT(that *World) bool

func (*World) GetGcGraph

func (x *World) GetGcGraph() *block.KeyValueStore

func (*World) GetGcJournal

func (x *World) GetGcJournal() *block.KeyValueStore

func (*World) GetGraphKeyValue

func (x *World) GetGraphKeyValue() *block.KeyValueStore

func (*World) GetLastChange

func (x *World) GetLastChange() *ChangeLogLL

func (*World) GetLastChangeDisable

func (x *World) GetLastChangeDisable() bool

func (*World) GetObjectKeyValue

func (x *World) GetObjectKeyValue() *block.KeyValueStore

func (*World) GetSubBlockCtor

func (w *World) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*World) GetSubBlocks

func (w *World) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*World) MarshalBlock

func (w *World) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*World) MarshalJSON

func (x *World) MarshalJSON() ([]byte, error)

MarshalJSON marshals the World to JSON.

func (*World) MarshalProtoJSON

func (x *World) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the World message to JSON.

func (*World) MarshalProtoText

func (x *World) MarshalProtoText() string

func (*World) MarshalToSizedBufferVT

func (m *World) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*World) MarshalToVT

func (m *World) MarshalToVT(dAtA []byte) (int, error)

func (*World) MarshalVT

func (m *World) MarshalVT() (dAtA []byte, err error)

func (*World) ProtoMessage

func (*World) ProtoMessage()

func (*World) Reset

func (x *World) Reset()

func (*World) SizeVT

func (m *World) SizeVT() (n int)

func (*World) String

func (x *World) String() string

func (*World) UnmarshalBlock

func (w *World) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*World) UnmarshalJSON

func (x *World) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the World from JSON.

func (*World) UnmarshalProtoJSON

func (x *World) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the World message from JSON.

func (*World) UnmarshalVT

func (m *World) UnmarshalVT(dAtA []byte) error

type WorldChange

type WorldChange struct {

	// ChangeType is the type of change this is.
	ChangeType WorldChangeType `protobuf:"varint,1,opt,name=change_type,json=changeType,proto3" json:"changeType,omitempty"`
	// Key is the associated key of the change.
	// May be a key prefix, depending on change type.
	// If a rename transaction, this is the old key.
	// If a Graph transaction, this will be empty.
	Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// Quad is the associated graph quad of the change.
	// If a Object transaction, this will be empty.
	Quad *quad.Quad `protobuf:"bytes,3,opt,name=quad,proto3" json:"quad,omitempty"`
	// TransactionRef is the reference to the associated transaction.
	// This is transparent to the core World code.
	TransactionRef *block1.BlockRef `protobuf:"bytes,4,opt,name=transaction_ref,json=transactionRef,proto3" json:"transactionRef,omitempty"`
	// ObjectRef is the reference to the associated Object block.
	// Empty for graph operations.
	ObjectRef *block1.BlockRef `protobuf:"bytes,5,opt,name=object_ref,json=objectRef,proto3" json:"objectRef,omitempty"`
	// PrevObjectRef is the reference to the associated previous Object block.
	// If set, this will be the old object.
	// If deleted, this will be the object just before deletion.
	// Empty for graph operations.
	PrevObjectRef *block1.BlockRef `protobuf:"bytes,6,opt,name=prev_object_ref,json=prevObjectRef,proto3" json:"prevObjectRef,omitempty"`
	// ObjectRev is the updated revision of the Object.
	// If a Graph transaction, this will be empty.
	ObjectRev uint64 `protobuf:"varint,7,opt,name=object_rev,json=objectRev,proto3" json:"objectRev,omitempty"`
	// NewKey is the new key for a rename transaction.
	NewKey string `protobuf:"bytes,8,opt,name=new_key,json=newKey,proto3" json:"newKey,omitempty"`
	// contains filtered or unexported fields
}

WorldChange is an entry in the changelog. A transaction may convert into multiple changes.

func UnmarshalWorldChange

func UnmarshalWorldChange(ctx context.Context, bcs *block.Cursor) (*WorldChange, error)

UnmarshalWorldChange unmarshals a world change from a cursor. If empty, returns nil, nil

func (*WorldChange) ApplyBlockRef

func (w *WorldChange) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*WorldChange) BlockAliasIdentity added in v0.52.0

func (w *WorldChange) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for WorldChange.

func (*WorldChange) CloneMessageVT

func (m *WorldChange) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WorldChange) CloneVT

func (m *WorldChange) CloneVT() *WorldChange

func (*WorldChange) EqualMessageVT

func (this *WorldChange) EqualMessageVT(thatMsg any) bool

func (*WorldChange) EqualVT

func (this *WorldChange) EqualVT(that *WorldChange) bool

func (*WorldChange) GetBlockRefCtor

func (w *WorldChange) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*WorldChange) GetBlockRefs

func (w *WorldChange) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*WorldChange) GetChangeType

func (x *WorldChange) GetChangeType() WorldChangeType

func (*WorldChange) GetKey

func (x *WorldChange) GetKey() string

func (*WorldChange) GetNewKey

func (x *WorldChange) GetNewKey() string

func (*WorldChange) GetObjectRef

func (x *WorldChange) GetObjectRef() *block1.BlockRef

func (*WorldChange) GetObjectRev

func (x *WorldChange) GetObjectRev() uint64

func (*WorldChange) GetPrevObjectRef

func (x *WorldChange) GetPrevObjectRef() *block1.BlockRef

func (*WorldChange) GetQuad

func (x *WorldChange) GetQuad() *quad.Quad

func (*WorldChange) GetTransactionRef

func (x *WorldChange) GetTransactionRef() *block1.BlockRef

func (*WorldChange) IsEmpty

func (w *WorldChange) IsEmpty() bool

IsEmpty checks if the world change is empty.

func (*WorldChange) IsNil

func (w *WorldChange) IsNil() bool

IsNil returns if the object is nil.

func (*WorldChange) MarshalBlock

func (w *WorldChange) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*WorldChange) MarshalJSON

func (x *WorldChange) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WorldChange to JSON.

func (*WorldChange) MarshalProtoJSON

func (x *WorldChange) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WorldChange message to JSON.

func (*WorldChange) MarshalProtoText

func (x *WorldChange) MarshalProtoText() string

func (*WorldChange) MarshalToSizedBufferVT

func (m *WorldChange) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WorldChange) MarshalToVT

func (m *WorldChange) MarshalToVT(dAtA []byte) (int, error)

func (*WorldChange) MarshalVT

func (m *WorldChange) MarshalVT() (dAtA []byte, err error)

func (*WorldChange) ProtoMessage

func (*WorldChange) ProtoMessage()

func (*WorldChange) Reset

func (x *WorldChange) Reset()

func (*WorldChange) SizeVT

func (m *WorldChange) SizeVT() (n int)

func (*WorldChange) String

func (x *WorldChange) String() string

func (*WorldChange) UnmarshalBlock

func (w *WorldChange) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*WorldChange) UnmarshalJSON

func (x *WorldChange) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WorldChange from JSON.

func (*WorldChange) UnmarshalProtoJSON

func (x *WorldChange) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WorldChange message from JSON.

func (*WorldChange) UnmarshalVT

func (m *WorldChange) UnmarshalVT(dAtA []byte) error

type WorldChangeLL

type WorldChangeLL struct {

	// Height is the index in the batch linked-list.
	// The first change in the set is at height=0.
	Height uint32 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
	// PrevRef is the reference to the previous WorldChangeLL in the linked list.
	// If height == 0, this field must be empty.
	PrevRef *block1.BlockRef `protobuf:"bytes,2,opt,name=prev_ref,json=prevRef,proto3" json:"prevRef,omitempty"`
	// TotalSize is len(changes) + total_size of prev node in list.
	TotalSize uint32 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"totalSize,omitempty"`
	// Changes is the set of changes in the world change batch.
	// Changes are added until the batch reaches the target batch size.
	Changes []*WorldChange `protobuf:"bytes,4,rep,name=changes,proto3" json:"changes,omitempty"`
	// contains filtered or unexported fields
}

WorldChangeLL is a linked-list of world change batches.

func AppendWorldChangeLL

func AppendWorldChangeLL(
	ctx context.Context,
	nextBcs *block.Cursor,
	prevBcs *block.Cursor,
	worldChangesBcs []*block.Cursor,
) (*WorldChangeLL, error)

AppendWorldChangeLL appends a world change set to the list. nextBcs should point to the location to write the new WorldChangeLL. prevBcs should point to the previous *WorldChangeLL. prevBcs can be nil to indicate a brand-new linked list. if prevBcs is a sub-block, it will be detached before it is referenced prevBcs and nextBcs can be the same block cursor, if both are sub-block all world changes must have the same change type if prevBcs is set, it will be checked to ensure same WorldChange type returns the new world change ll node

func UnmarshalWorldChangeLL

func UnmarshalWorldChangeLL(ctx context.Context, bcs *block.Cursor) (*WorldChangeLL, error)

UnmarshalWorldChangeLL unmarshals a world change ll from a cursor. If empty, returns nil, nil

func (*WorldChangeLL) AppendWorldChange

func (w *WorldChangeLL) AppendWorldChange(ch *WorldChange, bcs *block.Cursor) *block.Cursor

AppendWorldChange appends a world change to the batch entry. bcs should be located at WorldChangeLL returns cursor containing ch within the linked-list node returns nil if bcs was nil

func (*WorldChangeLL) ApplyBlockRef

func (w *WorldChangeLL) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*WorldChangeLL) ApplySubBlock

func (w *WorldChangeLL) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*WorldChangeLL) BlockAliasIdentity added in v0.52.0

func (w *WorldChangeLL) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for WorldChangeLL.

func (*WorldChangeLL) CloneMessageVT

func (m *WorldChangeLL) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WorldChangeLL) CloneVT

func (m *WorldChangeLL) CloneVT() *WorldChangeLL

func (*WorldChangeLL) EqualMessageVT

func (this *WorldChangeLL) EqualMessageVT(thatMsg any) bool

func (*WorldChangeLL) EqualVT

func (this *WorldChangeLL) EqualVT(that *WorldChangeLL) bool

func (*WorldChangeLL) GetBlockRefCtor

func (w *WorldChangeLL) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*WorldChangeLL) GetBlockRefs

func (w *WorldChangeLL) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*WorldChangeLL) GetChanges

func (x *WorldChangeLL) GetChanges() []*WorldChange

func (*WorldChangeLL) GetHeight

func (x *WorldChangeLL) GetHeight() uint32

func (*WorldChangeLL) GetPrevRef

func (x *WorldChangeLL) GetPrevRef() *block1.BlockRef

func (*WorldChangeLL) GetSubBlockCtor

func (w *WorldChangeLL) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*WorldChangeLL) GetSubBlocks

func (w *WorldChangeLL) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*WorldChangeLL) GetTotalSize

func (x *WorldChangeLL) GetTotalSize() uint32

func (*WorldChangeLL) IsEmpty

func (w *WorldChangeLL) IsEmpty() bool

IsEmpty checks if the world change is empty.

func (*WorldChangeLL) IsNil

func (w *WorldChangeLL) IsNil() bool

IsNil returns if the object is nil.

func (*WorldChangeLL) MarshalBlock

func (w *WorldChangeLL) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*WorldChangeLL) MarshalJSON

func (x *WorldChangeLL) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WorldChangeLL to JSON.

func (*WorldChangeLL) MarshalProtoJSON

func (x *WorldChangeLL) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WorldChangeLL message to JSON.

func (*WorldChangeLL) MarshalProtoText

func (x *WorldChangeLL) MarshalProtoText() string

func (*WorldChangeLL) MarshalToSizedBufferVT

func (m *WorldChangeLL) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WorldChangeLL) MarshalToVT

func (m *WorldChangeLL) MarshalToVT(dAtA []byte) (int, error)

func (*WorldChangeLL) MarshalVT

func (m *WorldChangeLL) MarshalVT() (dAtA []byte, err error)

func (*WorldChangeLL) ProtoMessage

func (*WorldChangeLL) ProtoMessage()

func (*WorldChangeLL) Reset

func (x *WorldChangeLL) Reset()

func (*WorldChangeLL) SizeVT

func (m *WorldChangeLL) SizeVT() (n int)

func (*WorldChangeLL) String

func (x *WorldChangeLL) String() string

func (*WorldChangeLL) UnmarshalBlock

func (w *WorldChangeLL) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*WorldChangeLL) UnmarshalJSON

func (x *WorldChangeLL) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WorldChangeLL from JSON.

func (*WorldChangeLL) UnmarshalProtoJSON

func (x *WorldChangeLL) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WorldChangeLL message from JSON.

func (*WorldChangeLL) UnmarshalVT

func (m *WorldChangeLL) UnmarshalVT(dAtA []byte) error

func (*WorldChangeLL) Validate

func (w *WorldChangeLL) Validate() error

Validate performs checks on the world change ll block.

type WorldChangeType

type WorldChangeType int32

WorldChangeType is the list of possible change types for the world.

const (
	WorldChangeType_WorldChange_INVALID        WorldChangeType = 0
	WorldChangeType_WorldChange_OBJECT_SET     WorldChangeType = 1
	WorldChangeType_WorldChange_OBJECT_INC_REV WorldChangeType = 2
	WorldChangeType_WorldChange_OBJECT_DELETE  WorldChangeType = 3
	WorldChangeType_WorldChange_OBJECT_RENAME  WorldChangeType = 4
	// WorldChange_GRAPH_SET is fired when setting a graph quad.
	WorldChangeType_WorldChange_GRAPH_SET WorldChangeType = 5
	// WorldChange_GRAPH_DELETE is fired when deleting a graph quad.
	WorldChangeType_WorldChange_GRAPH_DELETE WorldChangeType = 6
)

func (WorldChangeType) Enum

func (x WorldChangeType) Enum() *WorldChangeType

func (WorldChangeType) MarshalJSON

func (x WorldChangeType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WorldChangeType to JSON.

func (WorldChangeType) MarshalProtoJSON

func (x WorldChangeType) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WorldChangeType to JSON.

func (WorldChangeType) MarshalProtoText

func (x WorldChangeType) MarshalProtoText() string

func (WorldChangeType) MarshalText

func (x WorldChangeType) MarshalText() ([]byte, error)

MarshalText marshals the WorldChangeType to text.

func (WorldChangeType) String

func (x WorldChangeType) String() string

func (*WorldChangeType) UnmarshalJSON

func (x *WorldChangeType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WorldChangeType from JSON.

func (*WorldChangeType) UnmarshalProtoJSON

func (x *WorldChangeType) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WorldChangeType from JSON.

func (*WorldChangeType) UnmarshalText

func (x *WorldChangeType) UnmarshalText(b []byte) error

UnmarshalText unmarshals the WorldChangeType from text.

type WorldState

type WorldState struct {
	// contains filtered or unexported fields
}

WorldState implements world state backed by a block graph. Note: GetRoot, WaitSeqno are concurrency safe. Note: all other calls are not concurrency safe. Use Tx if you want a mutex.

func BuildMockWorldState

func BuildMockWorldState(ctx context.Context, le *logrus.Entry, write bool, ocs *bucket_lookup.Cursor, verbose bool) (*WorldState, error)

BuildMockWorldState builds a mock world state.

func BuildWorldStateFromCursor

func BuildWorldStateFromCursor(
	ctx context.Context,
	le *logrus.Entry,
	write bool,
	bls *bucket_lookup.Cursor,
	storage world.WorldStorage,
	lookupOp world.LookupOp,
	verbose bool,
) (*WorldState, error)

BuildWorldStateFromCursor builds a world state from a bucket lookup cursor.

func NewWorldState

func NewWorldState(
	ctx context.Context,
	le *logrus.Entry,
	write bool,
	btx *block.Transaction,
	bcs *block.Cursor,
	store block.StoreOps,
	xfrm block.Transformer,
	onSwept func(context.Context, string) error,
	storage world.WorldStorage,
	lookupOp world.LookupOp,
	verbose bool,
) (*WorldState, error)

NewWorldState constructs a new world handle. btx can be nil to not write during Commit() bcs is located at the root of the world (the World block). if bcs is empty, creates a new empty world. store is the raw block store (for GC wrapping). xfrm is the block transformer (may be nil). onSwept is called per swept node during GC (may be nil). if verbose is true, verbose logging of the graph key/value is enabled.

func (*WorldState) AccessCayleyGraph

func (t *WorldState) AccessCayleyGraph(ctx context.Context, write bool, cb func(ctx context.Context, h world.CayleyHandle) error) error

AccessCayleyGraph calls a callback with a temporary Cayley graph handle. All accesses of the handle should complete before returning cb. Try to make access (queries) as short as possible. Write operations will fail if the store is read-only.

func (*WorldState) AccessWorldState

func (t *WorldState) AccessWorldState(
	ctx context.Context,
	ref *bucket.ObjectRef,
	cb func(*bucket_lookup.Cursor) error,
) error

AccessWorldState builds a bucket lookup cursor with an optional ref. If the ref is empty, returns empty cursor in the same bucket + volume as the world. The lookup cursor will be released after cb returns.

func (*WorldState) ApplyWorldOp

func (t *WorldState) ApplyWorldOp(
	rctx context.Context,
	op world.Operation,
	opSender peer.ID,
) (uint64, bool, error)

ApplyWorldOp applies a batch operation at the world level. The handling of the operation is operation-type specific. Returns the seqno following the operation execution. If nil is returned for the error, implies success.

func (*WorldState) BuildStorageCursor

func (t *WorldState) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

BuildStorageCursor builds a cursor to the world storage with an empty ref. The cursor should be released independently of the WorldState. Be sure to call Release on the cursor when done.

func (*WorldState) Commit

func (t *WorldState) Commit(ctx context.Context) error

Commit commits the current pending changes to the block cursor. updates the WorldState with the new root

func (*WorldState) CreateObject

func (t *WorldState) CreateObject(ctx context.Context, key string, rootRef *bucket.ObjectRef) (world.ObjectState, error)

CreateObject creates a object with a key and initial root ref. Returns ErrObjectExists if the object already exists. Appends a OBJECT_SET change to the changelog.

func (*WorldState) DeleteGraphObject

func (t *WorldState) DeleteGraphObject(ctx context.Context, objKey string) error

DeleteGraphObject deletes all quads with Subject or Object set to value.

func (*WorldState) DeleteGraphQuad

func (t *WorldState) DeleteGraphQuad(ctx context.Context, q world.GraphQuad) error

DeleteGraphQuad deletes a quad from the graph store. Note: if quad did not exist, returns nil.

func (*WorldState) DeleteObject

func (t *WorldState) DeleteObject(ctx context.Context, key string) (bool, error)

DeleteObject deletes an object and associated graph quads by ID. Calls DeleteGraphObject internally. Returns false, nil if not found.

func (*WorldState) Discard

func (t *WorldState) Discard()

Discard discards the resources in the WorldState.

func (*WorldState) Fork

func (t *WorldState) Fork(ctx context.Context) (world.WorldState, error)

Fork forks the current world state into a completely separate world state.

Creates a new block transaction.

func (*WorldState) GarbageCollect

func (t *WorldState) GarbageCollect(ctx context.Context) (*block_gc.Stats, error)

GarbageCollect sweeps unreferenced nodes from the GC ref graph. Only valid on writable WorldState instances with GC enabled. Returns nil stats if GC is not enabled. Reconciles any pending GC journal entries before collecting.

func (*WorldState) GetBcs

func (t *WorldState) GetBcs() *block.Cursor

GetBcs returns the root block cursor.

func (*WorldState) GetGCJournalEntries

func (t *WorldState) GetGCJournalEntries() uint64

GetGCJournalEntries returns the number of pending GC journal entries. Returns 0 if the journal is not initialized.

func (*WorldState) GetObject

func (t *WorldState) GetObject(ctx context.Context, key string) (world.ObjectState, bool, error)

GetObject looks up an object by key. Returns nil, false if not found.

func (*WorldState) GetObjectRootRefsBatch added in v0.51.7

func (t *WorldState) GetObjectRootRefsBatch(ctx context.Context, keys []string) ([]*world.ObjectRootRef, error)

GetObjectRootRefsBatch returns object root refs for object keys.

func (*WorldState) GetReadOnly

func (t *WorldState) GetReadOnly() bool

GetReadOnly returns if the world handle is read-only.

func (*WorldState) GetRefGraph

func (t *WorldState) GetRefGraph() block_gc.RefGraphOps

GetRefGraph returns the GC reference graph, or nil if not initialized.

func (*WorldState) GetRoot

func (t *WorldState) GetRoot(ctx context.Context) (*World, error)

GetRoot builds the Root object from the block cursor.

Concurrency safe.

func (*WorldState) GetRootRef

func (t *WorldState) GetRootRef() *block.BlockRef

GetRootRef returns the current root reference.

func (*WorldState) GetSeqno

func (t *WorldState) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current seqno of the world state. This is also the sequence number of the most recent change. Initializes at 0 for initial world state.

func (*WorldState) HasObject added in v0.53.0

func (t *WorldState) HasObject(ctx context.Context, key string) (bool, error)

HasObject reports whether an object exists at key. It answers from the transaction-local object-existence memo without a storage read when the key is already known to exist, and otherwise checks the object tree, recording a positive result for the rest of the transaction. Positive existence is stable within a transaction snapshot, so read-only states memo it safely; the memo is invalidated when the object is deleted or renamed and reset when the transaction rebuilds or discards its block state.

func (*WorldState) IterateObjects

func (t *WorldState) IterateObjects(ctx context.Context, prefix string, reversed bool) world.ObjectIterator

IterateObjects returns an iterator with the given object key prefix. The prefix is NOT clipped from the output keys. Keys are returned in sorted order. Must call Next() or Seek() before valid. Call Close when done with the iterator. Any init errors will be available via the iterator's Err() method.

func (*WorldState) LookupGraphQuads

func (t *WorldState) LookupGraphQuads(ctx context.Context, filter world.GraphQuad, limit uint32) ([]world.GraphQuad, error)

LookupGraphQuads searches for graph quads in the store.

func (*WorldState) LookupGraphQuadsBatch added in v0.51.7

func (t *WorldState) LookupGraphQuadsBatch(ctx context.Context, filters []world.GraphQuad, limitPerFilter uint32) ([][]world.GraphQuad, error)

LookupGraphQuadsBatch searches for graph quads for each filter in one graph read.

func (*WorldState) QueryGraphPath added in v0.51.6

func (t *WorldState) QueryGraphPath(ctx context.Context, query *world.GraphPathQuery) (*world.GraphPathQueryResult, error)

QueryGraphPath executes a bounded graph traversal.

func (*WorldState) ReconcileGCJournal

func (t *WorldState) ReconcileGCJournal(ctx context.Context) (int, error)

ReconcileGCJournal applies one bounded pending GC journal chunk to the Cayley ref graph. Call during idle periods or forced checkpoints. The caller must commit the world state afterward to persist the reconciled graph and journal cursor.

Returns the number of journal entries applied, or 0 if the journal was empty or GC is not enabled.

func (*WorldState) RenameObject

func (t *WorldState) RenameObject(ctx context.Context, oldKey, newKey string, descendants bool) (world.ObjectState, error)

RenameObject renames an object key and updates associated graph quads.

func (*WorldState) SetBlockTransaction

func (t *WorldState) SetBlockTransaction(ctx context.Context, btx *block.Transaction, bcs *block.Cursor) error

SetBlockTransaction loads the state from the given block transaction and cursor.

The block transaction store is overridden with one wrapped with the GC store ops.

func (*WorldState) SetBufferedStoreSettings

func (t *WorldState) SetBufferedStoreSettings(s *block.BufferedStoreSettings)

SetBufferedStoreSettings overrides the BufferedStore settings used by the underlying block Transaction during Commit. Pass nil to reset to defaults. No-op if the world state has no write transaction.

func (*WorldState) SetGraphQuad

func (t *WorldState) SetGraphQuad(ctx context.Context, q world.GraphQuad) error

SetGraphQuad sets a quad in the graph store. If already exists, returns nil.

func (*WorldState) Sync added in v0.52.0

func (t *WorldState) Sync(ctx context.Context) (bool, error)

Sync fences the block writes made through this state durable. A bare world state fences only its block store; the durable head is advanced by the owning Engine (see Engine.Sync). Returns (true, nil) when there is no store to fence (read-only or coordinator-backed states).

func (*WorldState) WaitSeqno

func (t *WorldState) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the seqno of the world state to be >= value. Returns the seqno when the condition is reached. If value == 0, this might return immediately unconditionally.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL