use of com.baidu.hugegraph.backend.query.Query in project incubator-hugegraph by apache.
the class HugeTraverser method edgesOfVertex.
private Iterator<Edge> edgesOfVertex(Id source, EdgeStep edgeStep, boolean mustAllSK) {
Id[] edgeLabels = edgeStep.edgeLabels();
Query query = GraphTransaction.constructEdgesQuery(source, edgeStep.direction(), edgeLabels);
ConditionQuery filter = null;
if (mustAllSK) {
this.fillFilterBySortKeys(query, edgeLabels, edgeStep.properties());
} else {
filter = (ConditionQuery) query.copy();
this.fillFilterByProperties(filter, edgeStep.properties());
}
query.capacity(Query.NO_CAPACITY);
if (edgeStep.limit() != NO_LIMIT) {
query.limit(edgeStep.limit());
}
Iterator<Edge> edges = this.graph().edges(query);
if (filter != null) {
ConditionQuery finalFilter = filter;
edges = new FilterIterator<>(edges, (e) -> {
return finalFilter.test((HugeEdge) e);
});
}
return edgeStep.skipSuperNodeIfNeeded(edges);
}
use of com.baidu.hugegraph.backend.query.Query in project incubator-hugegraph by apache.
the class HugeGraphStep method makeQuery.
private Query makeQuery(HugeGraph graph, HugeType type) {
Query query = null;
if (this.hasContainers.isEmpty()) {
// Query all
query = new Query(type);
} else {
ConditionQuery q = new ConditionQuery(type);
query = TraversalUtil.fillConditionQuery(q, this.hasContainers, graph);
}
query = this.injectQueryInfo(query);
return query;
}
use of com.baidu.hugegraph.backend.query.Query in project incubator-hugegraph by apache.
the class HugeGraphStep method verticesCount.
private long verticesCount() {
if (!this.hasIds()) {
HugeGraph graph = TraversalUtil.getGraph(this);
Query query = this.makeQuery(graph, HugeType.VERTEX);
return graph.queryNumber(query).longValue();
}
return IteratorUtils.count(this.vertices());
}
use of com.baidu.hugegraph.backend.query.Query in project incubator-hugegraph by apache.
the class HugeGraphStep method vertices.
private Iterator<E> vertices() {
LOG.debug("HugeGraphStep.vertices(): {}", this);
HugeGraph graph = TraversalUtil.getGraph(this);
// g.V().hasId(EMPTY_LIST) will set ids to null
if (this.ids == null) {
return QueryResults.emptyIterator();
}
if (this.hasIds()) {
return TraversalUtil.filterResult(this.hasContainers, graph.vertices(this.ids));
}
Query query = this.makeQuery(graph, HugeType.VERTEX);
@SuppressWarnings("unchecked") Iterator<E> result = (Iterator<E>) graph.vertices(query);
return result;
}
use of com.baidu.hugegraph.backend.query.Query in project incubator-hugegraph by apache.
the class HugeVariables method queryAllVariableVertices.
private Iterator<Vertex> queryAllVariableVertices() {
GraphTransaction tx = this.params.graphTransaction();
Query query = this.createVariableQuery(null);
Iterator<Vertex> vertices = tx.queryVertices(query);
return vertices;
}
Aggregations