materializer

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSQLBytes             = 256 << 10
	MaxSQLStatements        = 64
	MaxSQLArgs              = 999
	MaxReturningRows        = 10_000
	MaxResultBytes          = 16 << 20
	MaxMutationResultBytes  = 1 << 20
	MaxCellBytes            = 1 << 20
	MaxGraphReachableDepth  = 64
	MaxGraphReachableEdges  = 1_000_000
	MaxGraphPropertyIndexes = 64
)
View Source
const MaxGraphStreamRecords = 1_000

Variables

View Source
var (
	ErrGraphResourceLimit  = errors.New("graph resource limit exceeded")
	ErrReadVersionMismatch = errors.New("read version mismatch")
)

Functions

func NormalizeSQLArgs

func NormalizeSQLArgs(args []any) ([]any, error)

NormalizeSQLArgs converts JSON numbers into database/sql argument types.

func ValidateGraphCommand

func ValidateGraphCommand(command types.GraphCommand) error

ValidateGraphCommand keeps replicated Cypher deterministic and bounded.

func ValidateGraphCommandAdmission added in v0.9.1

func ValidateGraphCommandAdmission(command types.GraphCommand) error

ValidateGraphCommandAdmission rejects commands that LatticeDB can silently partially execute. Apply-time validation stays stable for committed-log replay.

func ValidateGraphReachableRequest added in v0.10.0

func ValidateGraphReachableRequest(request types.GraphReachableRequest) error

func ValidateSQLCommand

func ValidateSQLCommand(command types.SQLCommand) error

ValidateSQLCommand validates the replicated SQL trust boundary.

Types

type CheckpointFile

type CheckpointFile struct {
	Role CheckpointRole
	Path string
}

type CheckpointRole

type CheckpointRole string
const (
	CheckpointSQLite    CheckpointRole = "sqlite"
	CheckpointGraphData CheckpointRole = "graph-data"
)

type Materializer

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

Materializer applies decided values to SQLite. Uses single writer, multiple readers pattern like Hiqlite.

func Open

func Open(dbPath string, readerCount int, idempotencyWindow ...uint64) (*Materializer, error)

Open opens or creates a materializer.

func (*Materializer) Apply

func (m *Materializer) Apply(ctx context.Context, slot uint64, value []byte) error

Apply applies one decided value.

func (*Materializer) ApplyBatch

func (m *Materializer) ApplyBatch(ctx context.Context, decisions []quepaxa.DecidedValue) error

ApplyBatch materializes a contiguous decision page with one SQLite commit.

func (*Materializer) CheckpointFilesAt

func (m *Materializer) CheckpointFilesAt(ctx context.Context) ([]CheckpointFile, uint64, func(), error)

CheckpointFilesAt captures fixed-role database files without packaging them.

func (*Materializer) Close

func (m *Materializer) Close() error

Close closes all connections.

func (*Materializer) ConfigureLocalGraphNodePropertyIndexes added in v0.10.0

func (m *Materializer) ConfigureLocalGraphNodePropertyIndexes(indexes []types.GraphNodePropertyIndex) error

ConfigureLocalGraphNodePropertyIndexes declares node-local derived indexes. The declaration is retained and reconciled after materializer replacement.

func (*Materializer) GraphMutationReceipt

func (m *Materializer) GraphMutationReceipt(_ context.Context, requestID string) (types.MutationReceipt, bool, error)

func (*Materializer) GraphQuery

func (m *Materializer) GraphQuery(ctx context.Context, cypher string, args map[string]any) (types.GraphCommandResult, error)

func (*Materializer) GraphReachable added in v0.9.0

GraphReachable traverses one immutable LatticeDB read transaction. Nodes which fail NodeLabel or NodeFilters are neither returned nor expanded.

func (*Materializer) GraphReadStream

func (m *Materializer) GraphReadStream(ctx context.Context, stream string, afterSequence uint64, limit uint, wait time.Duration) ([]types.GraphStreamRecord, uint64, error)

func (*Materializer) GraphRequestMatches

func (m *Materializer) GraphRequestMatches(_ context.Context, command types.GraphCommand) (bool, error)

func (*Materializer) GraphStreamOffset

func (m *Materializer) GraphStreamOffset(ctx context.Context, stream, consumer string) (uint64, bool, uint64, error)

func (*Materializer) Health

func (m *Materializer) Health(ctx context.Context) error

Health check

func (*Materializer) KVGet

func (m *Materializer) KVGet(ctx context.Context, key string, now time.Time) ([]byte, bool, error)

KVGet reads a non-expired value from the local materialized state.

func (*Materializer) KVGetAt

func (m *Materializer) KVGetAt(ctx context.Context, key string, now time.Time) ([]byte, bool, uint64, error)

KVGetAt reads a value and the applied slot from one SQLite snapshot.

func (*Materializer) KVRequestMatches

func (m *Materializer) KVRequestMatches(ctx context.Context, command types.KVCommand) (bool, error)

func (*Materializer) MutationReceipt

func (m *Materializer) MutationReceipt(ctx context.Context, kind types.MutationKind, requestID string) (types.MutationReceipt, bool, error)

func (*Materializer) NotificationDrops

func (m *Materializer) NotificationDrops() uint64

NotificationDrops reports live at-most-once deliveries discarded before delivery, including confirmation failures and saturated queues.

func (*Materializer) NotifyRequestMatches

func (m *Materializer) NotifyRequestMatches(ctx context.Context, command types.NotifyCommand) (bool, error)

NotifyRequestMatches checks whether a request ID is unused or has identical content.

func (*Materializer) Query

func (m *Materializer) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a read query.

func (*Materializer) QueryResult

func (m *Materializer) QueryResult(ctx context.Context, query string, args []any) (types.SQLStatementResult, error)

QueryResult executes a bounded read query and materializes its result.

func (*Materializer) QueryResultAt

func (m *Materializer) QueryResultAt(ctx context.Context, query string, args []any) (types.SQLStatementResult, uint64, error)

QueryResultAt executes a bounded read query and returns its applied slot from the same SQLite snapshot.

func (*Materializer) Restore

func (m *Materializer) Restore(ctx context.Context, data []byte) error

Restore is unavailable for the combined store; use RestoreCheckpoint.

func (*Materializer) RestoreCheckpoint

func (m *Materializer) RestoreCheckpoint(ctx context.Context, files []CheckpointFile) error

RestoreCheckpoint atomically installs the exact fixed-role checkpoint set.

func (*Materializer) RestoreFile

func (m *Materializer) RestoreFile(ctx context.Context, snapshotPath string) error

RestoreFile is unavailable for the combined store; use RestoreCheckpoint.

func (*Materializer) SQLRequestMatches

func (m *Materializer) SQLRequestMatches(ctx context.Context, command types.SQLCommand) (bool, error)

func (*Materializer) SQLRequestResultFingerprint added in v0.9.1

func (m *Materializer) SQLRequestResultFingerprint(ctx context.Context, requestID string, fingerprint [32]byte, wantRows bool) (types.MutationReceipt, types.SQLCommandResult, bool, bool, error)

SQLRequestResultFingerprint returns the retained receipt and row results for an idempotent SQL mutation.

func (*Materializer) SQLRequestStatus added in v0.9.1

func (m *Materializer) SQLRequestStatus(ctx context.Context, command types.SQLCommand) (types.MutationReceipt, bool, bool, error)

SQLRequestStatus returns the retained receipt and fingerprint match.

func (*Materializer) SQLRequestStatusFingerprint added in v0.9.1

func (m *Materializer) SQLRequestStatusFingerprint(ctx context.Context, requestID string, fingerprint [32]byte) (types.MutationReceipt, bool, bool, error)

SQLRequestStatusFingerprint returns the retained receipt for a precomputed fingerprint.

func (*Materializer) Snapshot

func (m *Materializer) Snapshot(ctx context.Context) ([]byte, error)

Snapshot is unavailable for the combined store; use CheckpointFilesAt.

func (*Materializer) SnapshotAt

func (m *Materializer) SnapshotAt(ctx context.Context) ([]byte, uint64, error)

SnapshotAt is unavailable for the combined store; use CheckpointFilesAt.

func (*Materializer) SnapshotTo

func (m *Materializer) SnapshotTo(ctx context.Context, writer io.Writer) (uint64, error)

SnapshotTo is unavailable for the combined store; use CheckpointFilesAt.

func (*Materializer) StateTip

func (m *Materializer) StateTip() uint64

StateTip returns the last slot that changed user-visible state.

func (*Materializer) Subscribe

func (m *Materializer) Subscribe(topic string) (<-chan []byte, func(), error)

Subscribe returns live, bounded, at-most-once notifications for a topic.

func (*Materializer) Tip

func (m *Materializer) Tip() uint64

Tip returns the last applied slot.

func (*Materializer) ValidateTip

func (m *Materializer) ValidateTip(slot uint64, value []byte) error

ValidateTip checks that materialized state agrees with the recovered log.

Jump to

Keyboard shortcuts

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