Search in sources :

Example 1 with AndCondition

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;
}
Also used : AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) HashSet(java.util.HashSet) AndCondition(org.apache.atlas.repository.graphdb.tinkerpop.query.expr.AndCondition)

Example 2 with AndCondition

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;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) HashSet(java.util.HashSet) AndCondition(org.apache.atlas.repository.graphdb.tinkerpop.query.expr.AndCondition)

Aggregations

HashSet (java.util.HashSet)2 AndCondition (org.apache.atlas.repository.graphdb.tinkerpop.query.expr.AndCondition)2 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)1 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)1