Class ImpulseQueryBuilder<R>
java.lang.Object
org.impulsegraph.api.ImpulseQueryBuilder<R>
- Type Parameters:
R- Expected return type of the query pipeline result.
Fluent builder for constructing immutable
ImpulseGraphQuery AST
pipelines.
Constructs canonical ImpScheme (.impscm) AST programs (ScmProgram)
containing CSR/CSC walks, SIMD vector filtering, CEL predicate evaluation,
compile-time parameter binding, set operations, fixed and convergent loop
iterations, and domain reductions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classExtended domain opcodes wrapper. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for creating an uninitialized QueryBuilder. -
Method Summary
Modifier and TypeMethodDescriptionappendStep(ImpScmNode step) bindParameter(String name, Object value) Bind a named parameter value (e.g.bindParameters(Map<String, Object> params) Bind multiple named parameters for compile-time substitution.<T> ImpulseGraphQuery<T> collect(ReturnType returnType) Terminal collect step: materialize final result in the requested return type format.<T> ImpulseGraphQuery<T> <T> ImpulseGraphQuery<T> <T> ImpulseGraphQuery<T> static StringexportAst(ImpScmNode ast) Format AST steps pipeline into a human-readable ImpScheme S-expression text representation.extended()Access point for domain-specific extended opcodes (Powergrid island detection, ReBAC, motifs).Filter active candidate node set with an embedded CEL expression.filterNodeAttribute(String attributeName, String op, double value) Filter active candidate node set by comparing a node attribute against a numeric threshold.filterWithCel(String celExpr) Filter active candidate node set with an embedded CEL expression.Returns the map of bound parameters configured on this builder.getSteps()Define the input seed entity type and argument type for the query pipeline.projectExpression(String nodeAttribute, String operator, String edgeAttribute) Project an arithmetic combination of node and edge attributes onto the active candidate frontier.projectState(String projectionExpr) Apply in-domain state projections on the active frontier.<T> ImpulseGraphQuery<T> Terminal step: argmax reduction over projected values (returns Node ID).<T> ImpulseGraphQuery<T> Terminal step: argmin reduction over projected values (returns Node ID).<T> ImpulseGraphQuery<T> Terminal step: average reduction over projected values.<T> ImpulseGraphQuery<T> Early termination reducer: returns as soon as the first matching projected node/attribute value is found.<T> ImpulseGraphQuery<T> Terminal step: max reduction over projected values.<T> ImpulseGraphQuery<T> Terminal step: min reduction over projected values.<T> ImpulseGraphQuery<T> Terminal step: sum reduction over projected values.repeat(int count, Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn) repeat(Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn, int count) Repeat a sub-query pipeline a fixed number of times.repeatUntilStable(Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn) Repeat a sub-query pipeline until candidate set generation converges (reaches a fixed point).vectorRerank(float[] queryVector, int attrId, int metric) Append a vector rerank step (`OP_VECTOR_RERANK_DOT`) over the active frontier.Walk both outgoing (CSR) and incoming (CSC) edges over the relation name.walkBothUnion(String... relationNames) Walk both outgoing and incoming edges across the union of multiple relation names.Add a CSR forward edge walk step over the specified relation name.walkEdgeFiltered(String relationName, String filterLabel) Add a filtered CSR edge walk step over the relation name matching a specific label.walkEdgeFilteredAttribute(String relationName, String attributeName, String op, double value) Add a filtered CSR edge walk step based on numeric edge attribute comparison.walkEdgeWithCel(String relationName, String celExpr) Add a filtered CSR edge walk step with an embedded CEL expression.walkEdgeWithState(String relationName, String stateProjections) Walk forward along a specific edge relation, applying state projections.walkInUnion(String... relationNames) Walk incoming edges across the union of multiple relation names.walkOutUnion(String... relationNames) Walk outgoing edges across the union of multiple relation names.walkReverse(String relationName) Add a reverse (CSC) edge walk step over the relation name.walkReverseWithCel(String relationName, String celExpr) Add a reverse (CSC) edge walk step with an embedded CEL expression.walkTarget(String relationName) Walk to target relation domain nodes.
-
Constructor Details
-
ImpulseQueryBuilder
public ImpulseQueryBuilder()Default constructor for creating an uninitialized QueryBuilder.
-
-
Method Details
-
input
Define the input seed entity type and argument type for the query pipeline.- Parameters:
entityType- Name of input entity domain (e.g. "USER", "Bus", "Load")argType- Argument type format (e.g.ArgType.SINGLE_NODE,ArgType.ROARING_BITSET)- Returns:
- This builder instance for method chaining
-
bindParameter
Bind a named parameter value (e.g. "@P1", "FRUIT" or "@minVoltage", 0.95) for compile-time substitution.- Parameters:
name- Parameter name (e.g. "@P1", "@threshold")value- Bound parameter value (String, Long, Double, Boolean, etc.)- Returns:
- This builder instance for method chaining
-
bindParameters
Bind multiple named parameters for compile-time substitution.- Parameters:
params- Map of parameter name to value bindings- Returns:
- This builder instance for method chaining
-
getParameters
-
walkEdge
Add a CSR forward edge walk step over the specified relation name.- Parameters:
relationName- Name of edge relation (e.g. "userToGroup", "Branch")- Returns:
- This builder instance for method chaining
-
walkEdgeWithState
Walk forward along a specific edge relation, applying state projections. -
projectState
Apply in-domain state projections on the active frontier. -
walkEdgeWithCel
Add a filtered CSR edge walk step with an embedded CEL expression.- Parameters:
relationName- Name of edge relation (e.g. "Branch", "in_section")celExpr- CEL predicate expression (e.g."edge.status == 1 && edge.rate_a >= @minRating")- Returns:
- This builder instance for method chaining
-
filterWithCel
Filter active candidate node set with an embedded CEL expression.- Parameters:
celExpr- CEL predicate expression (e.g."node.vm < @minVoltage || node.vm > @maxVoltage")- Returns:
- This builder instance for method chaining
-
filter
Filter active candidate node set with an embedded CEL expression. -
walkEdgeFiltered
Add a filtered CSR edge walk step over the relation name matching a specific label.- Parameters:
relationName- Name of edge relationfilterLabel- Attribute or edge filter label- Returns:
- This builder instance for method chaining
-
walkTarget
Walk to target relation domain nodes.- Parameters:
relationName- Target edge relation name- Returns:
- This builder instance for method chaining
-
walkReverse
Add a reverse (CSC) edge walk step over the relation name.- Parameters:
relationName- Name of edge relation- Returns:
- This builder instance for method chaining
-
walkBoth
Walk both outgoing (CSR) and incoming (CSC) edges over the relation name. -
walkOutUnion
Walk outgoing edges across the union of multiple relation names. -
walkInUnion
Walk incoming edges across the union of multiple relation names. -
walkBothUnion
Walk both outgoing and incoming edges across the union of multiple relation names. -
vectorRerank
Append a vector rerank step (`OP_VECTOR_RERANK_DOT`) over the active frontier. -
walkReverseWithCel
Add a reverse (CSC) edge walk step with an embedded CEL expression.- Parameters:
relationName- Name of edge relationcelExpr- CEL expression- Returns:
- This builder instance for method chaining
-
repeat
public ImpulseQueryBuilder<R> repeat(Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn, int count) Repeat a sub-query pipeline a fixed number of times.- Parameters:
stepFn- Sub-builder lambda configuring loop body stepscount- Fixed loop iteration count- Returns:
- This builder instance for method chaining
-
repeat
public ImpulseQueryBuilder<R> repeat(int count, Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn) -
repeatUntilStable
public ImpulseQueryBuilder<R> repeatUntilStable(Function<ImpulseQueryBuilder<R>, ImpulseQueryBuilder<R>> stepFn) Repeat a sub-query pipeline until candidate set generation converges (reaches a fixed point).- Parameters:
stepFn- Sub-builder lambda configuring loop body steps- Returns:
- This builder instance for method chaining
-
walkEdgeFilteredAttribute
public ImpulseQueryBuilder<R> walkEdgeFilteredAttribute(String relationName, String attributeName, String op, double value) Add a filtered CSR edge walk step based on numeric edge attribute comparison.- Parameters:
relationName- Name of edge relationattributeName- Edge attribute nameop- Comparison operator (e.g.">","==","<=")value- Threshold double value- Returns:
- This builder instance for method chaining
-
filterNodeAttribute
Filter active candidate node set by comparing a node attribute against a numeric threshold.- Parameters:
attributeName- Node attribute nameop- Comparison operator (e.g. ">", "==")value- Threshold double value- Returns:
- This builder instance for method chaining
-
projectExpression
public ImpulseQueryBuilder<R> projectExpression(String nodeAttribute, String operator, String edgeAttribute) Project an arithmetic combination of node and edge attributes onto the active candidate frontier.- Parameters:
nodeAttribute- Node attribute nameoperator- Math operator (e.g. "*", "+")edgeAttribute- Edge attribute name- Returns:
- This builder instance for method chaining
-
reduceSum
Terminal step: sum reduction over projected values.- Type Parameters:
T- Expected scalar result type (Double)- Returns:
- Immutable compiled query object
-
reduceArgMax
Terminal step: argmax reduction over projected values (returns Node ID).- Type Parameters:
T- Expected scalar result type (Integer)- Returns:
- Immutable compiled query object
-
reduceArgMin
Terminal step: argmin reduction over projected values (returns Node ID).- Type Parameters:
T- Expected scalar result type (Integer)- Returns:
- Immutable compiled query object
-
reduceMax
Terminal step: max reduction over projected values.- Type Parameters:
T- Expected scalar result type (Double)- Returns:
- Immutable compiled query object
-
reduceMin
Terminal step: min reduction over projected values.- Type Parameters:
T- Expected scalar result type (Double)- Returns:
- Immutable compiled query object
-
reduceAvg
Terminal step: average reduction over projected values.- Type Parameters:
T- Expected scalar result type (Double)- Returns:
- Immutable compiled query object
-
reduceFirst
Early termination reducer: returns as soon as the first matching projected node/attribute value is found.- Type Parameters:
T- Expected scalar result type- Returns:
- Immutable compiled query object
-
extended
Access point for domain-specific extended opcodes (Powergrid island detection, ReBAC, motifs).- Returns:
- ExtendedOps wrapper object
-
collect
Terminal collect step: materialize final result in the requested return type format.- Type Parameters:
T- Expected return type class- Parameters:
returnType- Requested result format (e.g.ReturnType.ROARING_BITSET,ReturnType.NODE_ARRAY)- Returns:
- Immutable compiled query object
-
collectBitSet
-
collectRoaringBitset
-
collectArray
-
collectCount
-
getEntityType
-
getInputArgType
-
getSteps
-
appendStep
-
exportAst
Format AST steps pipeline into a human-readable ImpScheme S-expression text representation.
-