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;
}
Aggregations