public abstract class Fragment extends Object
A fragment is composed of four things:
Variable names refer to Graql variables. Some of these variable names may be randomly-generated UUIDs, such as for castings.
A Fragment is usually contained in a EquivalentFragmentSet, which contains multiple fragments describing
the different directions the traversal can be followed in, with different starts and ends.
A gremlin traversal is created from a Query by appending together fragments in order of priority, one from
each EquivalentFragmentSet describing the Query.
| Type | Property and Description |
|---|---|
abstract VarProperty |
var
Get the corresponding property
|
| Modifier and Type | Field and Description |
|---|---|
static double |
SHARD_LOAD_FACTOR |
| Constructor and Description |
|---|
Fragment() |
| Modifier and Type | Method and Description |
|---|---|
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,? extends org.apache.tinkerpop.gremlin.structure.Element> |
applyTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,? extends org.apache.tinkerpop.gremlin.structure.Element> traversal,
GraknTx graph,
Collection<Var> vars,
Var currentVar) |
boolean |
canOperateOnEdges()
Indicates whether the fragment can be used on an
Edge as well as
a Vertex. |
Set<Var> |
dependencies() |
Set<Weighted<DirectedEdge<Node>>> |
directedEdges(Map<NodeId,Node> nodes,
Map<Node,Map<Node,Fragment>> edges)
Convert the fragment to a set of weighted edges for query planning
|
Var |
end() |
double |
fragmentCost()
Get the cost for executing the fragment.
|
Fragment |
getInverse() |
Optional<Long> |
getShardCount(GraknTx tx) |
boolean |
hasFixedFragmentCost()
If a fragment has fixed cost, the traversal is done using index.
|
abstract double |
internalFragmentCost() |
boolean |
isStartingFragment()
A starting fragment is a fragment that can start a traversal.
|
abstract String |
name()
The name of the fragment
|
void |
setAccurateFragmentCost(double fragmentCost) |
abstract Var |
start() |
String |
toString() |
Fragment |
transform(Map<Var,ConceptId> transform) |
abstract VarProperty |
varProperty()
Get the corresponding property
|
Set<Var> |
vars()
Get all variables in the fragment including the start and end (if present)
|
@Nullable public abstract VarProperty varProperty
public static final double SHARD_LOAD_FACTOR
public Fragment transform(Map<Var,ConceptId> transform)
transform - map defining id transform var -> new id@Nullable public abstract VarProperty varProperty()
public abstract Var start()
@Nullable public Var end()
public Set<Var> dependencies()
public Set<Weighted<DirectedEdge<Node>>> directedEdges(Map<NodeId,Node> nodes, Map<Node,Map<Node,Fragment>> edges)
nodes - all nodes in the queryedges - a mapping from edge(child, parent) to its corresponding fragmentpublic final org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,? extends org.apache.tinkerpop.gremlin.structure.Element> applyTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,? extends org.apache.tinkerpop.gremlin.structure.Element> traversal,
GraknTx graph,
Collection<Var> vars,
@Nullable
Var currentVar)
traversal - the traversal to extend with this Fragmentgraph - the graph to execute the traversal onpublic abstract String name()
public boolean isStartingFragment()
public double fragmentCost()
public void setAccurateFragmentCost(double fragmentCost)
public abstract double internalFragmentCost()
public boolean hasFixedFragmentCost()
public Fragment getInverse()
public boolean canOperateOnEdges()
Edge as well as
a Vertex.public final Set<Var> vars()
Copyright © 2018 Grakn Labs Ltd. All rights reserved.