Search in sources :

Example 1 with NoopGremlinQuery

use of org.apache.atlas.util.NoopGremlinQuery in project incubator-atlas by apache.

the class GraphBackedDiscoveryService method parseAndTranslateDsl.

private GremlinQuery parseAndTranslateDsl(String dslQuery, QueryParams queryParams) throws DiscoveryException {
    CompiledQueryCacheKey entry = new CompiledQueryCacheKey(dslQuery, queryParams);
    GremlinQuery gremlinQuery = QueryProcessor.compiledQueryCache().get(entry);
    if (gremlinQuery == null) {
        Expressions.Expression validatedExpression = parseQuery(dslQuery, queryParams);
        //If the final limit is 0, don't launch the query, return with 0 rows
        if (validatedExpression instanceof Expressions.LimitExpression && ((Integer) ((Expressions.LimitExpression) validatedExpression).limit().rawValue()) == 0) {
            gremlinQuery = new NoopGremlinQuery(validatedExpression.dataType());
        } else {
            gremlinQuery = new GremlinTranslator(validatedExpression, graphPersistenceStrategy).translate();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Query = {}", validatedExpression);
                LOG.debug("Expression Tree = {}", validatedExpression.treeString());
                LOG.debug("Gremlin Query = {}", gremlinQuery.queryStr());
            }
        }
        QueryProcessor.compiledQueryCache().put(entry, gremlinQuery);
    }
    return gremlinQuery;
}
Also used : GremlinTranslator(org.apache.atlas.query.GremlinTranslator) NoopGremlinQuery(org.apache.atlas.util.NoopGremlinQuery) CompiledQueryCacheKey(org.apache.atlas.util.CompiledQueryCacheKey) Expressions(org.apache.atlas.query.Expressions) GremlinQuery(org.apache.atlas.query.GremlinQuery) NoopGremlinQuery(org.apache.atlas.util.NoopGremlinQuery)

Aggregations

Expressions (org.apache.atlas.query.Expressions)1 GremlinQuery (org.apache.atlas.query.GremlinQuery)1 GremlinTranslator (org.apache.atlas.query.GremlinTranslator)1 CompiledQueryCacheKey (org.apache.atlas.util.CompiledQueryCacheKey)1 NoopGremlinQuery (org.apache.atlas.util.NoopGremlinQuery)1