Skip to main content

HexastoreScan

Trait HexastoreScan 

Source
pub trait HexastoreScan:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn scan_pattern(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        omitted: u8,
        verdict_wanted: bool,
    ) -> impl Future<Output = Result<ScanPage, Status>> + Send;
    fn count_pattern(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        merge_default_graph: bool,
    ) -> impl Future<Output = Result<u64, Status>> + Send;
    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: Option<&GraphFilter>,
        iri_only_head: bool,
    ) -> impl Future<Output = Result<Vec<DomainScanHit>, Status>> + Send;
    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: Option<&GraphFilter>,
        iri_only_head: bool,
        merge_default_graph: bool,
        mode: DomainCountMode,
    ) -> impl Future<Output = Result<Vec<DomainScanCountHit>, Status>> + Send;
    fn scan_axis_head(
        &self,
        permutation: IndexPermutation,
        snapshot: SnapshotId,
        limit: u64,
        start_after_term: Option<&EncodedTerm>,
        graph_name: Option<&EncodedTerm>,
        graph_filter: Option<&GraphFilter>,
        iri_only_head: bool,
        head_prefixes: &[Vec<u8>],
    ) -> impl Future<Output = Result<Vec<EncodedTerm>, Status>> + Send;
    fn count_axis_heads(
        &self,
        permutation: IndexPermutation,
        snapshot: SnapshotId,
        graph_name: Option<&EncodedTerm>,
        graph_filter: Option<&GraphFilter>,
        iri_only_head: bool,
    ) -> impl Future<Output = Result<u64, Status>> + Send;
    fn scan_axis_head_counts(
        &self,
        permutation: IndexPermutation,
        snapshot: SnapshotId,
        limit: u64,
        start_after_term: Option<&EncodedTerm>,
        graph_name: Option<&EncodedTerm>,
        graph_filter: Option<&GraphFilter>,
        iri_only_head: bool,
    ) -> impl Future<Output = Result<Vec<AxisHeadCountHit>, Status>> + Send;

    // Provided methods
    fn scan_pattern_with_comparisons(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        comparisons: &[SlotComparison],
        omitted: u8,
        verdict_wanted: bool,
    ) -> impl Future<Output = Result<ScanPage, Status>> + Send { ... }
    fn scan_pattern_stream(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        omitted: u8,
        verdict_wanted: bool,
    ) -> impl Future<Output = Result<QuadPageStream, Status>> + Send { ... }
    fn scan_pattern_stream_with_comparisons(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        comparisons: &[SlotComparison],
        omitted: u8,
        verdict_wanted: bool,
    ) -> impl Future<Output = Result<QuadPageStream, Status>> + Send { ... }
    fn scan_pattern_detached(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        omitted: u8,
        verdict_wanted: bool,
    ) -> JoinHandle<Result<(Vec<EncodedQuad>, Option<ScanExhaustion>), Status>> { ... }
    fn scan_pattern_detached_with_comparisons(
        &self,
        axis: PartitionAxis,
        pattern: &EncodedTriplePattern,
        snapshot: SnapshotId,
        limit: u64,
        permutation: Option<IndexPermutation>,
        filter: Option<&BroadcastFilter>,
        graph_filter: Option<&GraphFilter>,
        start_after: Option<&EncodedQuad>,
        merge_default_graph: bool,
        iri_only: IriOnlyMask,
        comparisons: &[SlotComparison],
        omitted: u8,
        verdict_wanted: bool,
    ) -> JoinHandle<Result<(Vec<EncodedQuad>, Option<ScanExhaustion>), Status>> { ... }
}
Expand description

Scan a pattern on one hexastore axis, as of a snapshot.

Clients are cheap handles (Clone = refcount bump over shared channels) and may be moved across threads, which is what lets callers detach work: Self::scan_pattern_detached clones the client into a spawned task and returns a handle the caller can await while doing other work.

Required Methods§

Source

fn scan_pattern( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, omitted: u8, verdict_wanted: bool, ) -> impl Future<Output = Result<ScanPage, Status>> + Send

Encoded rows matching pattern; limit of 0 is unlimited.

permutation selects the axis-local index (None lets the partition choose via EncodedTriplePattern::best_permutation).

filter (Phase 9b) pushes a broadcast allow-list for one unbound slot. graph_filter is residual G membership. Compute allow-lists map to graph_filter_allow = true; block-lists (including {DefaultGraph} for unbound GRAPH ?g) map to false. Omitted/None is an empty block-list (block nothing). An empty allow-list is skip-RPC on compute. merge_default_graph asks storage to emit each S/P/O once and rewrite G to DefaultGraph (SPARQL default-graph RDF merge). start_after is then exclusive on that triple (any G), not one logical quad. start_after is an exclusive resume cursor (logical quad, not versioned key). With a filter, concatenation order is filter.terms: earlier terms are skipped, the matching term resumes at the cursor, later terms scan from the start of their prefix.

Returns the page plus the walk’s own [ScanExhaustion] verdict — the server-side fact that replaces the short-page inference (rows.len() < limit cannot distinguish “stopped at the limit” from “ran out, exactly at the limit”).

verdict_wanted is the consumer’s declaration that a FULL page will be followed by another request, and therefore that the walk should spend look-ahead work reporting an honest terminal verdict at exact limit boundaries: true keeps the walk running past a full page until the next emitting row proves more data (Limited) or the key range ends (terminal verdict); false stops at the limit’th row, and the response carries no verdict at all — the field is left unset, even when the walk’s fact was free to know. Callers whose demand equals their whole remaining interest (an ASK / one-shot slice: no follow-up request can exist) pass false so the walk never scans past its last delivered row. Inert when limit == 0 (a drain never fills its page).

Source

fn count_pattern( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, merge_default_graph: bool, ) -> impl Future<Output = Result<u64, Status>> + Send

Count matching quads without returning rows; limit of 0 is unlimited.

Same routing arguments as Self::scan_pattern. The partition walks the prefix locally and returns a single integer.

Source

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: Option<&GraphFilter>, iri_only_head: bool, ) -> impl Future<Output = Result<Vec<DomainScanHit>, Status>> + Send

Constrained domain scan: distinct slot-1 head terms under each slot-0 constraint of permutation (POSG predicates→objects, SPOG subjects→predicates, SOPG subjects→objects, OPSG objects→predicates).

A permutation not owned by the serving partition returns UNIMPLEMENTED. limit of 0 is unlimited; the exclusive resume cursor is (start_after_constraint, start_after_term). G is existence-only: a head term is emitted when any visible Put quad satisfies the graph window, and the graph slot is never returned.

Source

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: Option<&GraphFilter>, iri_only_head: bool, merge_default_graph: bool, mode: DomainCountMode, ) -> impl Future<Output = Result<Vec<DomainScanCountHit>, Status>> + Send

Constrained domain count scan: run lengths of slot-1 head terms under each slot-0 constraint of permutation — the same constraint/head families and cursor semantics as Self::scan_domain, but the graph window applies per row (a head in n graphs of the window counts n) unless merge_default_graph is set. Merge counts distinct S/P/O prefixes and seeks past extra G. Zero-count runs are not emitted, and each hit carries the multiplicity of its (constraint, head) pair.

Source

fn scan_axis_head( &self, permutation: IndexPermutation, snapshot: SnapshotId, limit: u64, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter: Option<&GraphFilter>, iri_only_head: bool, head_prefixes: &[Vec<u8>], ) -> impl Future<Output = Result<Vec<EncodedTerm>, Status>> + Send

Bare axis head scan: distinct slot-0 head terms of the whole CF for permutation (SPOG subjects, PSOG predicates, OPSG objects, TSG classes). No anchor terms; same graph-window semantics and exclusive single-term cursor as Self::scan_domain. head_prefixes are opaque seek-union byte ranges: when non-empty, only heads whose encoded bytes start with one of them are visited (empty = unfiltered).

Source

fn count_axis_heads( &self, permutation: IndexPermutation, snapshot: SnapshotId, graph_name: Option<&EncodedTerm>, graph_filter: Option<&GraphFilter>, iri_only_head: bool, ) -> impl Future<Output = Result<u64, Status>> + Send

Axis head count, TOTAL mode: the number of distinct slot-0 head terms of the whole CF for permutation.

Source

fn scan_axis_head_counts( &self, permutation: IndexPermutation, snapshot: SnapshotId, limit: u64, start_after_term: Option<&EncodedTerm>, graph_name: Option<&EncodedTerm>, graph_filter: Option<&GraphFilter>, iri_only_head: bool, ) -> impl Future<Output = Result<Vec<AxisHeadCountHit>, Status>> + Send

Axis head count, PER_HEAD mode: per-head distinct slot-1 counts, paged at head boundaries with an exclusive resume cursor.

Provided Methods§

Source

fn scan_pattern_with_comparisons( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, comparisons: &[SlotComparison], omitted: u8, verdict_wanted: bool, ) -> impl Future<Output = Result<ScanPage, Status>> + Send

Self::scan_pattern with slot comparison pushdown.

comparisons is a conjunction of slot OP term constraints (SlotComparison, S/P/O only) that the partition evaluates on the encoded term before a row reaches the sink. The partition drops only rows the comparison provably fails; every row it cannot decide is kept for the compute-side FILTER, which remains authoritative. An empty list is exactly Self::scan_pattern, including its verdict and page-limit accounting (the limit counts post-comparison rows).

The default evaluates nothing and delegates to Self::scan_pattern: a transport that does not understand the list still returns correct rows, because the compute-side FILTER stays in the plan and remains authoritative — the list is a read reduction, not a correctness requirement. Production transports (the gRPC client and the in-process standalone adapter) override this to actually apply it.

Source

fn scan_pattern_stream( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, omitted: u8, verdict_wanted: bool, ) -> impl Future<Output = Result<QuadPageStream, Status>> + Send

Storage-driven drain of pattern as a QuadPageStream.

Same routing arguments and semantics as Self::scan_pattern (limit of 0 is unlimited, start_after positions the first page), but the implementation keeps streaming pages until the prefix is exhausted (or limit rows have been emitted). Used by the fetch service whenever compute cannot prove the result set fits in one gRPC message (unbounded drains whose bound proof failed, and window demands above crate::query::tunables::MAX_UNARY_SCAN_QUADS); unary callers keep using Self::scan_pattern for demands within that ceiling.

The default adapts a unary implementation to the stream protocol’s own frame shapes (scan_page_as_wire_frames): a completed walk arrives as one verdict-less data frame plus the empty terminal frame carrying its verdict, and a limit stop keeps Limited on the single frame. Correct for in-process transports with no message-size ceiling; over-gRPC clients override it with the ScanPatternStream RPC.

Source

fn scan_pattern_stream_with_comparisons( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, comparisons: &[SlotComparison], omitted: u8, verdict_wanted: bool, ) -> impl Future<Output = Result<QuadPageStream, Status>> + Send

Self::scan_pattern_stream with slot comparison pushdown.

Same request semantics as Self::scan_pattern_with_comparisons; each delivered frame carries the rows that survived the partition’s comparison evaluation, and the verdict/paging rules are the stream protocol’s.

The default evaluates nothing and delegates to Self::scan_pattern_stream, keeping the transport’s own frame protocol. As with the unary fallback, the rows are correct without the comparison — only the read reduction is lost. Production transports override this to carry the list.

Source

fn scan_pattern_detached( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, omitted: u8, verdict_wanted: bool, ) -> JoinHandle<Result<(Vec<EncodedQuad>, Option<ScanExhaustion>), Status>>

Fetch up to limit rows in a detached task that owns a clone of the client; the returned handle completes with the rows and the walk’s verdict once the task finishes.

Exists for the aggregation executor’s pipelined loop: the caller holds the handle while folding the previous page, so the fetch overlaps compute instead of serializing after it. The transport follows the same rule as the engine’s bounded scans — demands at or under scan_batch take one unary message, larger demands open the storage-driven stream and drain exactly limit rows (the stream is closed on completion or on drop, which cancels the partition side).

The verdict is last-read: the unary branch carries the page’s own verdict; the stream branch carries the last frame’s — a full drain that purchased the verdict ends on its terminal frame, a drain that broke at the limit holds the last verdict it read (None on a mid-walk frame, Limited on a limit-stop flush), never a terminal claim it did not see.

Source

fn scan_pattern_detached_with_comparisons( &self, axis: PartitionAxis, pattern: &EncodedTriplePattern, snapshot: SnapshotId, limit: u64, permutation: Option<IndexPermutation>, filter: Option<&BroadcastFilter>, graph_filter: Option<&GraphFilter>, start_after: Option<&EncodedQuad>, merge_default_graph: bool, iri_only: IriOnlyMask, comparisons: &[SlotComparison], omitted: u8, verdict_wanted: bool, ) -> JoinHandle<Result<(Vec<EncodedQuad>, Option<ScanExhaustion>), Status>>

Self::scan_pattern_detached with slot comparison pushdown.

Same task and transport choice as the unfiltered sibling; a non-empty list rides whichever transport the demand selects. The pipelined aggregation loop uses this path, so a filtered aggregate scan must come through here rather than the unfiltered wrapper.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§