Skip to main content

GraphProjectionSpec

Struct GraphProjectionSpec 

Source
pub struct GraphProjectionSpec {
    pub node_labels: Vec<String>,
    pub edge_types: Vec<String>,
    pub weight_property: Option<String>,
    pub include_reverse: bool,
    pub node_properties: Vec<String>,
    pub edge_properties: Vec<String>,
    pub project_all: bool,
}
Expand description

Selects which subgraph an AlgorithmHost::project call materializes.

Naming node_labels / edge_types scopes the projection to exactly those. Leaving BOTH empty means “the whole graph”, but that is only honored when Self::project_all is true — otherwise the projection fails loud (G9), so an unscoped projection can never silently pull in unrelated labels (e.g. a coexisting search tree) and corrupt an index-keyed kernel. weight_property names an edge property to expose through GraphView::out_weight; include_reverse requests inbound adjacency (GraphView::in_neighbors).

Fields§

§node_labels: Vec<String>

Vertex labels to include; empty (with Self::project_all) selects every label.

§edge_types: Vec<String>

Edge types to include; empty (with Self::project_all) selects every type.

§weight_property: Option<String>

Edge property surfaced as the traversal weight, if any.

§include_reverse: bool

Whether to also build inbound adjacency.

§node_properties: Vec<String>

Vertex properties to materialize into per-vertex [V] tensors the guest reads by name via gc.node_property (issue #151).

§edge_properties: Vec<String>

Edge properties to materialize into per-edge [E] tensors the guest reads by name via gc.edge_property (issue #151).

§project_all: bool

Deliberate opt-in to projecting the whole graph when neither node_labels nor edge_types is named (G9). With both empty and this false, AlgorithmHost::project fails loud instead of silently pulling in every schema label/edge-type. First-party providers set this to preserve the ergonomic whole-graph default; guest loaders must pass projectAll: true in their config to project everything on purpose.

Implementations§

Source§

impl GraphProjectionSpec

Source

pub const CONFIG_KEYS: &'static [&'static str]

Keys that mark a trailing CALL argument as a projection-config object (a “graphRef”) rather than a guest algorithm argument. Covers the Native knobs, the P2 property-tensor knobs, and the P3 Cypher/Named graphRef knobs so the trailing object is stripped from the guest’s arguments consistently across every projection mode.

Source

pub const QUERY_CONFIG_KEYS: &'static [&'static str]

Keys that mark a config object as a Cypher/Named graphRef rather than a Native label/edge-type scoping object.

Single-sourced so the query layer’s graphRef sniffing and the per-scope parsing below cannot drift: a scope routed to the Native storage scan when it names a Cypher query would silently project the wrong graph.

Source

pub fn from_config_object(cfg: &Map<String, Value>) -> Self

Parses the Native-mode projection knobs from a guest/procedure config object. This is the single source of truth for nodeLabels / edgeTypes (accepting the relationshipTypes alias) / weightProperty / includeReverse — the native providers and all four guest loaders funnel through it so the knob names cannot drift.

includeReverse defaults to true (inbound adjacency is built unless the caller opts out), matching the graphRef contract in uni-algo and keeping In-direction kernels (WCC / k-core / HITS) working. Unknown keys are ignored and malformed values fall back to the field default: this is a best-effort projection hint, not a strict schema.

Source

pub fn is_query_graph_ref(cfg: &Map<String, Value>) -> bool

Whether a config object names a Cypher/Named projection.

Source

pub fn scopes_from_config_object( cfg: &Map<String, Value>, ) -> Result<Vec<GraphScopeSpec>, String>

Parses the scopes map into pre-declared named projections.

A guest that needs more than one view of the store declares them at the CALL site rather than projecting on demand, because projection is the one thing a guest must not be able to trigger in a loop:

CALL myplugin.compare([], {
  nodeLabels: ['Cell'], edgeTypes: ['ADJ'],
  scopes: {
    agg:  {nodeLabels: ['Cell'], edgeTypes: ['AGGREGATES']},
    flow: {nodeQuery: 'MATCH (c:Cell) RETURN id(c) AS id'}
  }
})

The outer object stays the primary projection — the one emit keys its nodeId column to. Each scope value is parsed by the same Self::from_config_object, so every Native knob works per scope; a scope bearing a Cypher/Named key is carried through verbatim for the resolver instead.

§Errors

Returns a message naming the offending scope when scopes is not an object, a scope name is empty, a scope value is not an object, or a scope is named graph (which would shadow the primary handle’s own accessor).

Source

pub fn reject_scopes( cfg: &Map<String, Value>, algorithm: &str, ) -> Result<(), FnError>

Rejects a scopes map on an algorithm that does not consume one.

scopes joined Self::CONFIG_KEYS so a scopes-only object is stripped from the guest’s positional arguments. That stripping applies to every algorithm, but only the guest loader adapters build the declared projections — so without this a first-party provider would accept a scopes map, project nothing, and run as if it had never been asked. Silently ignoring a projection the caller asked for is the same failure the unscoped-projection change (G9) made loud; this keeps it loud.

§Errors

Returns 0x86E naming algorithm when cfg carries a non-empty scopes.

Source

pub fn take_config_from_args( args: &mut Vec<Value>, ) -> Option<Map<String, Value>>

Like Self::take_from_args but also returns the raw config object.

Self::take_from_args discards the object after parsing, which is fine for the Native knobs but loses scopes (whose values must be re-parsed per scope, and whose Cypher entries must survive verbatim).

Source

pub fn take_from_args(args: &mut Vec<Value>) -> Option<Self>

If the last element of args is a JSON object bearing at least one Self::CONFIG_KEYS key, removes it from args and returns the parsed Native spec; otherwise leaves args untouched and returns None.

The Native-spec half of the “trailing object is the projection config” convention. The guest loaders now go through ProjectionPlan, which needs the raw object to parse scopes; this remains for callers that want only the Native knobs. Both share Self::take_config_from_args, so the recognition rule cannot drift. In P3 Cypher/Named mode the returned Native spec is empty (the query/name keys are unknown to Self::from_config_object) and is ignored by the bridge in favor of the pre-built projection — but the object is still stripped here so it never reaches the guest function.

Trait Implementations§

Source§

impl Clone for GraphProjectionSpec

Source§

fn clone(&self) -> GraphProjectionSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphProjectionSpec

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for GraphProjectionSpec

Source§

fn default() -> GraphProjectionSpec

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PluginState for T
where T: Send + Sync + 'static,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more