public final class GraphFilter extends Object implements Cloneable, Serializable
GraphComputer
implementations to prune the source graph data being loaded into the OLAP system.
There are two types of filters: a Vertex
filter and an Edge
filter.
The vertex filter is a Traversal
that can only check the id, label, and properties of the vertex.
The edge filter is a Traversal
that starts at the vertex are emits all legal incident edges.
If no vertex filter is provided, then no vertices are filtered. If no edge filter is provided, then no edges are filtered.
The use of a GraphFilter can greatly reduce the amount of data processed by the GraphComputer
.
For instance, for g.V().count()
, there is no reason to load edges, and thus, the edge filter can be bothE().limit(0)
.Modifier and Type | Class and Description |
---|---|
static class |
GraphFilter.Legal
A enum denoting whether a particular result will be allowed or not.
|
Constructor and Description |
---|
GraphFilter() |
GraphFilter(Computer computer) |
Modifier and Type | Method and Description |
---|---|
GraphFilter.Legal |
checkEdgeLegality(Direction direction)
Get the legality of a particular edge direction.
|
GraphFilter.Legal |
checkEdgeLegality(Direction direction,
String label)
Get the legality of a particular edge direction and label.
|
GraphFilter |
clone() |
boolean |
equals(Object object) |
Traversal.Admin<Vertex,Edge> |
getEdgeFilter()
Get the edge filter associated with this graph filter.
|
Set<String> |
getLegallyPositiveEdgeLabels(Direction direction)
For a particular edge directionality, get all the
GraphFilter.Legal.YES or GraphFilter.Legal.MAYBE edge labels. |
Traversal.Admin<Vertex,Vertex> |
getVertexFilter()
Get the vertex filter associated with this graph filter.
|
boolean |
hasEdgeFilter()
Whether an edge filter has been defined.
|
boolean |
hasFilter()
Whether filters have been defined.
|
int |
hashCode() |
boolean |
hasVertexFilter()
Whether a vertex filter has been defined.
|
Iterator<Edge> |
legalEdges(Vertex vertex)
Returns an iterator of legal edges incident to the provided vertex.
|
boolean |
legalVertex(Vertex vertex)
Returns true if the provided vertex meets the vertex-filter criteria.
|
void |
setEdgeFilter(Traversal<Vertex,Edge> edgeFilter)
Set the filter for selecting edges from the source graph.
|
void |
setVertexFilter(Traversal<Vertex,Vertex> vertexFilter)
Set the filter for selecting vertices from the source graph.
|
String |
toString() |
public GraphFilter()
public GraphFilter(Computer computer)
public void setVertexFilter(Traversal<Vertex,Vertex> vertexFilter)
vertexFilter
- The Traversal
that will either let the vertex pass or not.public void setEdgeFilter(Traversal<Vertex,Edge> edgeFilter)
edgeFilter
- The Traversal
that will generate the legal incident edges of the vertex.public boolean legalVertex(Vertex vertex)
vertex
- the vertex to test for legalityGraphFilter.Legal.YES
.public Iterator<Edge> legalEdges(Vertex vertex)
vertex
- the vertex whose legal edges are to be access.GraphFilter.Legal.YES
.public final Traversal.Admin<Vertex,Vertex> getVertexFilter()
public final Traversal.Admin<Vertex,Edge> getEdgeFilter()
public boolean hasFilter()
public boolean hasEdgeFilter()
public boolean hasVertexFilter()
public Set<String> getLegallyPositiveEdgeLabels(Direction direction)
GraphFilter.Legal.YES
or GraphFilter.Legal.MAYBE
edge labels.
If the label set contains null
, then all edge labels for that direction are positively legal.direction
- the direction to get the positively legal edge labels for.public GraphFilter.Legal checkEdgeLegality(Direction direction, String label)
direction
- the direction of the edge.label
- the label of the edge.GraphFilter.Legal
of the arguments.public GraphFilter.Legal checkEdgeLegality(Direction direction)
direction
- the direction of the edge.GraphFilter.Legal
of the edge direction.public GraphFilter clone()
Copyright © 2013–2020 Apache Software Foundation. All rights reserved.