use of org.apache.atlas.repository.graphdb.tinkerpop.query.expr.AndCondition in project atlas by apache.
the class TinkerpopGraphQuery method edges.
@Override
public Iterable<AtlasEdge<V, E>> edges(int offset, int limit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing: " + queryCondition);
}
Preconditions.checkArgument(offset >= 0, "Offset must be non-negative");
Preconditions.checkArgument(limit >= 0, "Limit must be non-negative");
// Compute the overall result by combining the results of all the AndConditions (nested within OR) together.
Set<AtlasEdge<V, E>> result = new HashSet<>();
long resultIdx = 0;
for (AndCondition andExpr : queryCondition.getAndTerms()) {
if (result.size() == limit) {
break;
}
NativeTinkerpopGraphQuery<V, E> andQuery = andExpr.create(getQueryFactory());
for (AtlasEdge<V, E> edge : andQuery.edges(offset + limit)) {
if (resultIdx >= offset) {
result.add(edge);
if (result.size() == limit) {
break;
}
}
resultIdx++;
}
}
return result;
}
use of org.apache.atlas.repository.graphdb.tinkerpop.query.expr.AndCondition in project atlas by apache.
the class TinkerpopGraphQuery method vertices.
@Override
public Iterable<AtlasVertex<V, E>> vertices(int offset, int limit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing: " + queryCondition);
}
Preconditions.checkArgument(offset >= 0, "Offset must be non-negative");
Preconditions.checkArgument(limit >= 0, "Limit must be non-negative");
// Compute the overall result by combining the results of all the AndConditions (nested within OR) together.
Set<AtlasVertex<V, E>> result = new HashSet<>();
long resultIdx = 0;
for (AndCondition andExpr : queryCondition.getAndTerms()) {
if (result.size() == limit) {
break;
}
NativeTinkerpopGraphQuery<V, E> andQuery = andExpr.create(getQueryFactory());
for (AtlasVertex<V, E> vertex : andQuery.vertices(offset + limit)) {
if (resultIdx >= offset) {
result.add(vertex);
if (result.size() == limit) {
break;
}
}
resultIdx++;
}
}
return result;
}
Aggregations