Class GqlRow
GqlExecutor. A row is an immutable value: once built
it cannot be changed, and it never shares mutable state with the arrays, maps or lists it was
built from.
Every binding in a row is addressed by variable index, the position of the
variable in GqlMatchPlan.getVariables(). The seed variable is at index
GqlMatchPlan.getSeedVariableIndex(), and size() equals
GqlMatchPlan.getVariableCount() for the plan that produced the row. Variables whose
names start with GqlMatchPlan.ANON_VAR_PREFIX are anonymous pattern elements. They
occupy an index but are not surfaced to the traversal.
Each index holds at most one kind of binding:
- Scalar: a single graph
Element, read withgetScalar(int). Node variables and non-quantified edge variables are scalars. - Group: an ordered
List<Edge>, read withgetGroup(int). The edge variable of a quantified (variable-length) relationship such as(a)-[r:knows]->{1,3}(b)is a group. The list holds the edges of the walk in pattern order, left to right in theMATCHpattern regardless of which endpoint the walk started from, and is never empty for a matched walk. A group edge variable is a list even when the walk has a single edge.
An index with neither binding is unbound: getScalar(int) and
getGroup(int) both return null, and the variable is omitted from the
traversal result.
Rows have value semantics: two rows are equal when they have the
same size and the same scalar and group bindings at every index.
Executors build rows with of(Element[], Map).
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetGroup(int index) Returns the unmodifiable, ordered edge list bound to the variable index, ornullif the index is unbound or holds a scalar.getScalar(int index) Returns the scalarElementbound to the variable index, ornullif the index is unbound or holds a group.inthashCode()booleanisGroup(int index) Returnstrueif the variable index holds a group (edge list) binding.static GqlRowCreates a row from scalar and group bindings, both keyed by variable index.intsize()Returns the number of variable indices in this row, equal to the length of the scalar array the row was built from.toString()
-
Method Details
-
of
Creates a row from scalar and group bindings, both keyed by variable index.The
scalarsarray is copied, and thegroupsmap and each of its lists are copied into unmodifiable collections, so later changes to the arguments do not affect the row. For an index that is a group, the matchingscalarsslot must benull.- Parameters:
scalars- scalar bindings;scalars[i]is theElementbound to variable indexi, ornull. Its length is the rowsize().groups- group edge-variable bindings from variable index to the ordered edges of the walk; use an empty map when the row has no group variables- Returns:
- the new row
- Throws:
NullPointerException- ifscalars,groups, a key ofgroups, a group list, or an edge in a group list isnullIllegalArgumentException- if a group index is outside[0, scalars.length), the same index also has a non-null scalar binding, or a group list is empty
-
size
public int size()Returns the number of variable indices in this row, equal to the length of the scalar array the row was built from. -
getScalar
Returns the scalarElementbound to the variable index, ornullif the index is unbound or holds a group.- Throws:
IndexOutOfBoundsException- ifindexis outside[0, size())
-
getGroup
Returns the unmodifiable, ordered edge list bound to the variable index, ornullif the index is unbound or holds a scalar.- Throws:
IndexOutOfBoundsException- ifindexis outside[0, size())
-
isGroup
public boolean isGroup(int index) Returnstrueif the variable index holds a group (edge list) binding.- Throws:
IndexOutOfBoundsException- ifindexis outside[0, size())
-
equals
-
hashCode
public int hashCode() -
toString
-