Skip to main content

MemoryStorage

Struct MemoryStorage 

Source
pub struct MemoryStorage { /* private fields */ }
Expand description

In-memory hexastore backend keyed like RocksDB (lexicographic BTree maps).

Implementations§

Source§

impl MemoryStorage

Source

pub fn new(axis: PartitionAxis) -> Self

Create an empty in-memory store for axis.

Source

pub fn axis(&self) -> PartitionAxis

Partition axis this store owns.

Source

pub fn insert_quad(&mut self, quad: &Quad) -> Result<(), StorageError>

Insert a quad version into both axis-local indexes.

Defaults (commit_ts = 0, op = Put, visibility = 0) keep existing callers working until compute assigns real timestamps.

Source

pub fn insert_quad_version( &mut self, quad: &Quad, commit_ts: CommitTs, op: StorageOp, visibility: VisibilityLabel, ) -> Result<(), StorageError>

Insert a versioned hexastore record (Put or Delete).

Source

pub fn insert_encoded_quad_version( &mut self, encoded: &EncodedQuad, commit_ts: CommitTs, op: StorageOp, visibility: VisibilityLabel, ) -> Result<(), StorageError>

Insert an already-encoded quad version (partition-service write path).

Source

pub fn apply_prepared_puts( &mut self, puts: &[HexastorePut], ) -> Result<(), StorageError>

Apply pre-encoded index puts into the in-memory BTreeMaps.

Empty puts is a no-op. Caller encodes keys via crate::prepare_hexastore_puts. Does not update the named-graph catalog; use Self::apply_prepared_puts_with_catalog on the S-axis write path.

Source

pub fn apply_prepared_puts_with_catalog( &mut self, puts: &[HexastorePut], catalog: &[CatalogPut], ) -> Result<(), StorageError>

Apply hexastore index puts and catalog puts together.

Source

pub fn catalog_puts_for_insert( &self, graphs: &[(EncodedTerm, CommitTs)], ) -> Result<Vec<CatalogPut>, StorageError>

Prefix-seek the catalog for each graph and stage Present when missing or Dropped.

Source

pub fn add_named_graph( &mut self, graph: &EncodedTerm, commit_ts: CommitTs, ) -> Result<(), StorageError>

Insert an empty named graph (or recreate after Dropped) at commit_ts.

Source

pub fn list_named_graphs( &self, snapshot: SnapshotId, ) -> Result<Vec<EncodedTerm>, StorageError>

Named graphs whose newest in-snapshot catalog version is Present.

Includes empty graphs. Never includes the RDF default graph.

Source

pub fn rebuild_named_graph_catalog( &mut self, ) -> Result<CatalogRebuildStats, StorageError>

Rebuild the named-graph catalog from all SPOG versions (S axis only).

Source

pub fn visit_index_versions( &self, permutation: IndexPermutation, visit: impl FnMut(&EncodedQuad, CommitTs, StorageOp) -> Result<(), StorageError>, ) -> Result<(), StorageError>

Walk every versioned key in an axis-local index (no MVCC collapse).

Source

pub fn flush_memtables(&self) -> Result<(), StorageError>

Flush MemTables to SST — no-op for the in-memory backend.

Source

pub fn scan_pattern( &self, pattern: &EncodedTriplePattern, snapshot: SnapshotId, ) -> Result<Vec<EncodedQuad>, StorageError>

Scan an encoded pattern as of snapshot.

For each logical quad, returns the newest version with commit_ts <= snapshot whose op is StorageOp::Put. Visibility labels are stored but not enforced yet.

Source

pub fn scan_pattern_in( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, ) -> Result<Vec<EncodedQuad>, StorageError>

Scan pattern through an explicitly chosen axis-local index.

Returns StorageError::PermutationNotOwned when permutation belongs to another partition axis.

Source

pub fn scan_pattern_page( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, start_after: Option<&EncodedQuad>, graph_filter: GByteFilter, merge_default_graph: bool, iri_only: IriOnlyMask, ) -> Result<ScanPage, StorageError>

Prefix scan with the full matcher semantics: residual graph_filter membership, merge_default_graph whole-triple collapse (rows return with G rewritten to DefaultGraph), the exclusive start_after cursor, and iri_only segment pushdown all run inside the RowMatcher on raw key bytes. limit counts post-filter matches (0 = unlimited) — one continuous pass, no decoded pre-filter chunking.

Source

pub fn scan_pattern_page_with_comparisons( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, start_after: Option<&EncodedQuad>, graph_filter: GByteFilter, merge_default_graph: bool, iri_only: IriOnlyMask, mask: &ComparisonMask, ) -> Result<ScanPage, StorageError>

Self::scan_pattern_page with compiled slot comparisons applied inside the walk, before a row reaches the page.

Source

pub fn count_pattern_impl( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, graph_filter: GByteFilter, merge_default_graph: bool, ) -> Result<u64, StorageError>

Count matching rows with the full matcher semantics — same graph_filter / merge_default_graph / cursor contract as Self::scan_pattern_page, counting raw KeyRows without decoding any term. limit counts post-filter matches (0 = unlimited).

Source

pub fn count_pattern_best_permutation( &self, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, ) -> Result<u64, StorageError>

Count matching quads visible at snapshot without collecting rows.

limit of 0 is unlimited; a positive limit stops the iterator once that many matches have been counted.

Source

pub fn count_pattern_in( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, ) -> Result<u64, StorageError>

Count pattern through an explicitly chosen axis-local index.

Returns StorageError::PermutationNotOwned when permutation belongs to another partition axis. limit of 0 is unlimited.

Source

pub fn scan_pattern_page_allow_list( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, start_after: Option<&EncodedQuad>, allow_list_slot: QuadSlot, allow_terms: &[EncodedTerm], graph_filter: GByteFilter, merge_default_graph: bool, iri_only: IriOnlyMask, ) -> Result<Option<ScanPage>, StorageError>

Allow-list prefix scan with the full matcher semantics per tight prefix: residual graph_filter membership and merge_default_graph collapse (rows return with G rewritten to DefaultGraph) run inside each prefix’s matcher. limit counts post-filter matches (0 = unlimited). Returns None when slot does not extend permutation.

Source

pub fn scan_pattern_page_allow_list_with_comparisons( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, start_after: Option<&EncodedQuad>, allow_list_slot: QuadSlot, allow_terms: &[EncodedTerm], graph_filter: GByteFilter, merge_default_graph: bool, iri_only: IriOnlyMask, mask: &ComparisonMask, ) -> Result<Option<ScanPage>, StorageError>

Self::scan_pattern_page_allow_list with compiled slot comparisons applied inside each tight prefix’s walk.

Source

pub fn scan_domain( &self, permutation: IndexPermutation, constraints: &[EncodedTerm], snapshot: SnapshotId, limit: u64, start_after_constraint: Option<&EncodedTerm>, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter_terms: &[EncodedTerm], graph_filter_allow: bool, iri_only_head: bool, ) -> Result<Vec<DomainScanHit>, StorageError>

Domain scan: distinct slot-1 head terms under each slot-0 constraint on permutation. Axis-local only. Twin of crate::rocksdb::RocksDbStorage::scan_domain. iri_only_head rejects non-NamedNode heads (FILTER(isIRI) pushdown).

Source

pub fn scan_domain_counts( &self, permutation: IndexPermutation, constraints: &[EncodedTerm], snapshot: SnapshotId, limit: u64, start_after_constraint: Option<&EncodedTerm>, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter_terms: &[EncodedTerm], graph_filter_allow: bool, iri_only_head: bool, merge_default_graph: bool, mode: DomainCountMode, ) -> Result<Vec<DomainScanCountHit>, StorageError>

Domain count scan: run lengths of slot-1 head terms under each slot-0 constraint on permutation. Axis-local only. Twin of crate::rocksdb::RocksDbStorage::scan_domain_counts and of Self::scan_domain — same visibility semantics (per-logical-quad MVCC collapse, op == Put, graph window, iri_only_head), but the walk iterates every key of the constraint prefix instead of seeking past runs. What one increment represents is mode — see DomainCountMode. With merge_default_graph set the walk seeks past extra G per counted triple, which makes Rows coincide with DistinctTerms. Runs with zero visible rows are not emitted. limit counts emitted triples (0 = unlimited).

Source

pub fn scan_axis_head( &self, permutation: IndexPermutation, snapshot: SnapshotId, limit: u64, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter_terms: &[EncodedTerm], graph_filter_allow: bool, iri_only_head: bool, head_prefixes: &[Vec<u8>], ) -> Result<Vec<EncodedTerm>, StorageError>

Axis head scan: distinct slot-0 head terms of the whole permutation CF. Axis-local only. Twin of crate::rocksdb::RocksDbStorage::scan_axis_head. iri_only_head rejects non-NamedNode heads (FILTER(isIRI) pushdown). With non-empty head_prefixes the walk is a seek-union over those partial head-term byte ranges (opaque bytes; see prepare_head_prefixes for normalization and resume semantics); empty means the unfiltered whole-CF walk.

Source

pub fn max_commit_ts_under_prefixes( &self, permutation: IndexPermutation, head_prefixes: &[Vec<u8>], ) -> Result<u64, StorageError>

Max commit_ts among the versioned keys whose slot-0 head term falls under head_prefixes (normalized like Self::scan_axis_head). Twin of crate::rocksdb::RocksDbStorage::max_commit_ts_under_prefixes: pure suffix scan over the versioned keys, no liveness evaluation — counting superseded/dead versions too only ever overestimates the bound, which is safe (a larger swap ts still sorts ahead of every row it deletes). 0 when no key matches.

Source

pub fn count_axis_heads( &self, permutation: IndexPermutation, snapshot: SnapshotId, graph_name: Option<&EncodedTerm>, graph_filter_terms: &[EncodedTerm], graph_filter_allow: bool, iri_only_head: bool, ) -> Result<u64, StorageError>

Axis head count, TOTAL mode. Twin of crate::rocksdb::RocksDbStorage::count_axis_heads.

Source

pub fn scan_axis_head_counts( &self, permutation: IndexPermutation, snapshot: SnapshotId, limit: u64, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter_terms: &[EncodedTerm], graph_filter_allow: bool, iri_only_head: bool, ) -> Result<Vec<AxisHeadCountHit>, StorageError>

Axis head count, PER_HEAD mode. Twin of crate::rocksdb::RocksDbStorage::scan_axis_head_counts.

Source

pub fn count_pattern_allow_list( &self, permutation: IndexPermutation, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, allow_list_slot: QuadSlot, allow_terms: &[EncodedTerm], graph_filter: GByteFilter, merge_default_graph: bool, ) -> Result<Option<u64>, StorageError>

Count an allow-list scan with the full matcher semantics per tight prefix — residual graph_filter membership and merge_default_graph collapse inside each prefix’s matcher, counting raw KeyRows without decoding any term. limit counts post-filter matches (0 = unlimited). Returns None when slot does not extend permutation.

Source

pub fn apply_geo_puts( &mut self, puts: &[GeoIndexPut], ) -> Result<(), StorageError>

Apply geometry-index postings into the in-memory map (O axis only).

Source

pub fn delete_geo_term(&mut self, term: &[u8]) -> Result<u64, StorageError>

Delete every versioned posting of one encoded geo term (rebuild).

Source

pub fn visit_geo_postings( &self, on_posting: &mut dyn FnMut(&GeoIndexPut) -> Result<(), StorageError>, ) -> Result<(), StorageError>

Visit every posting row, decoded, in key order (read-only; the census/debug surface — see the RocksDb twin for the order contract: the BTreeMap iterates in the same cell-major, newest-version-first order as the CF).

Source

pub fn geo_index_epoch(&self) -> Result<Option<u64>, StorageError>

Rebuild epoch of the geometry index (O axis) — the TRUST decision.

Ok(None) on S/P (no map) and when no epoch was ever stamped: every consumer treats a missing epoch as UNTRUSTED (the flip from the original missing-epoch-trusted default, because geography can be ingested plugin-less, so an empty index is not proof of an empty dataset). None also when the liveness marker is absent or disagrees with the epoch: the postings were wiped without the epoch being re-stamped, so the index is empty-but-“trusted” and must read untrusted instead. A malformed value also reads as None.

Source

pub fn set_geo_index_epoch(&mut self, epoch: u64) -> Result<(), StorageError>

Stamp the rebuild epoch of the geometry index (O axis) together with its liveness marker.

Called by waratah geo rebuild-index and by finish_geo_rebuild after the postings were rewritten: the epoch is the max commit_ts over the geo-contributing version rows the rebuild scanned, and postings stamped at the epoch become visible exactly when the planner starts trusting the index. Both keys are written together — an epoch without its marker is deliberately unreadable as a trust signal (see Self::geo_index_epoch).

Source

pub fn geo_index_epoch_number(&self) -> Result<u64, StorageError>

Raw stored epoch number, ignoring the liveness marker (0 when absent or malformed, 0 on S/P). Twin of crate::rocksdb::RocksDbStorage::geo_index_epoch_number: unlike Self::geo_index_epoch this survives a wipe, so finish_geo_rebuild can floor the new epoch at the previously stamped one.

Source

pub fn geo_scan_candidates( &self, intervals: &[GeoCellInterval], snapshot: SnapshotId, query_envelope: Option<&GeoEnvelope>, limit: u64, state: &mut GeoCandidateState, emit: impl FnMut(&EncodedTerm) -> Result<bool, StorageError>, ) -> Result<(), StorageError>

Skip-seek candidate scan over merged cell-id intervals (O axis).

Twin of the RocksDB walk over a BTree range per interval; the caller-owned GeoCandidateState provides MVCC collapse, the per-stream DISTINCT, and the optional envelope AABB reject.

Source

pub fn apply_replace_pairs( &mut self, pairs: &[ReplacePair], commit_ts: CommitTs, ) -> Result<u64, StorageError>

Apply replace pairs as ONE in-memory batch on this axis (the RocksDB twin; see its doc).

Source

pub fn wipe_geo_index(&mut self) -> Result<u64, StorageError>

Wipe every geo-index posting (O axis; rebuild preamble).

Also drops the LIVENESS marker and only that — the epoch key stays on disk, so geo_index_epoch() reads None (untrusted) for as long as the index is empty, and a rebuild that dies in its walk leaves the planner on the residual geof:* path instead of answering every rewrite from a trusted-but-empty index. finish_geo_rebuild (or set_geo_index_epoch) restores both together.

Source

pub fn apply_temporal_puts( &mut self, puts: &[TemporalIndexPut], ) -> Result<(), StorageError>

Apply temporal-index postings into the in-memory map (O axis only).

Source

pub fn temporal_index_epoch(&self) -> Result<Option<u64>, StorageError>

Rebuild epoch of the temporal index (O axis) — the TRUST decision.

Ok(None) on S/P (no map) and when no epoch was ever stamped (a missing epoch is UNTRUSTED here, unlike geo, because temporal literals predate the plugin and the auto-rebuild stamps before queries serve). None also when the tick-axis ORIGIN version beside the epoch disagrees with TEMPORAL_ORIGIN_VERSION: the origin moved (B56), so postings keyed under the old origin must not be trusted.

Source

pub fn set_temporal_index_epoch( &mut self, epoch: u64, ) -> Result<(), StorageError>

Stamp the rebuild epoch of the temporal index (O axis) together with the tick-axis origin version, so the two cannot diverge: an epoch without a matching origin version is deliberately unreadable as a trust signal (see Self::temporal_index_epoch).

Source

pub fn wipe_temporal_index(&mut self) -> Result<(), StorageError>

Wipe every temporal-index posting (O axis; rebuild preamble).

Source

pub fn temporal_rebuild_terms( &self, ) -> Result<(Vec<EncodedTerm>, CommitTs), StorageError>

Collect the O-axis temporal terms for the rebuild walk.

Twin of the RocksDB walk over the in-memory leading O-permutation map (same object-major byte order). See the RocksDB doc for the per-quad liveness contract (any quad referencing the term with its own-latest version = a visible Put keeps it) and the epoch source.

Source

pub fn temporal_scan_candidates( &self, intervals: &[TemporalCellInterval], snapshot: SnapshotId, predicate: &TemporalQueryPredicate, limit: u64, state: &mut TemporalCandidateState, emit: impl FnMut(&EncodedTerm) -> Result<bool, StorageError>, ) -> Result<(), StorageError>

Skip-seek candidate scan over merged node-key intervals (O axis).

Twin of the RocksDB walk over a BTree range per interval; the caller-owned TemporalCandidateState provides MVCC collapse, the per-stream DISTINCT, and the exact-interval reject.

Trait Implementations§

Source§

impl Debug for MemoryStorage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,