use of org.janusgraph.graphdb.tinkerpop.optimize.QueryInfo in project janusgraph by JanusGraph.
the class JanusGraphStep method buildGlobalGraphCentricQuery.
public GraphCentricQuery buildGlobalGraphCentricQuery() {
if (ids == null || ids.length > 0) {
return null;
}
if (globalQuery != null) {
return globalQuery;
}
if (hasLocalContainers.isEmpty()) {
Map<List<HasContainer>, QueryInfo> containers = new LinkedHashMap<>();
containers.put(new ArrayList<>(), new QueryInfo(new ArrayList<>(), 0, BaseQuery.NO_LIMIT));
hasLocalContainers.put(null, containers);
}
tx = JanusGraphTraversalUtil.getTx(traversal);
globalQuery = buildGlobalGraphCentricQuery(tx, queryProfiler);
return globalQuery;
}
use of org.janusgraph.graphdb.tinkerpop.optimize.QueryInfo in project janusgraph by JanusGraph.
the class JanusGraphStep method addLocalHasContainersConvertingAndPContainers.
@Override
public List<HasContainer> addLocalHasContainersConvertingAndPContainers(TraversalParent parent, List<HasContainer> unconvertedHasContainers) {
List<HasContainer> localHasContainers = new ArrayList<>(unconvertedHasContainers.size());
for (HasContainer hasContainer : unconvertedHasContainers) {
localHasContainers.add(JanusGraphPredicateUtils.convert(hasContainer));
}
Map<List<HasContainer>, QueryInfo> hasContainers = hasLocalContainers.computeIfAbsent(parent.asStep().getId(), k -> new LinkedHashMap<>());
hasContainers.put(localHasContainers, new QueryInfo(new ArrayList<>(), 0, BaseQuery.NO_LIMIT));
return localHasContainers;
}
use of org.janusgraph.graphdb.tinkerpop.optimize.QueryInfo in project janusgraph by JanusGraph.
the class JanusGraphStep method addLocalHasContainersSplittingAndPContainers.
@Override
public List<HasContainer> addLocalHasContainersSplittingAndPContainers(TraversalParent parent, Iterable<HasContainer> hasContainers) {
List<HasContainer> localHasContainers = new ArrayList<>();
for (HasContainer hasContainer : hasContainers) {
HasStepFolder.splitAndP(localHasContainers, hasContainer);
}
Map<List<HasContainer>, QueryInfo> containers = hasLocalContainers.computeIfAbsent(parent.asStep().getId(), k -> new LinkedHashMap<>());
containers.put(localHasContainers, new QueryInfo(new ArrayList<>(), 0, BaseQuery.NO_LIMIT));
return localHasContainers;
}
use of org.janusgraph.graphdb.tinkerpop.optimize.QueryInfo in project janusgraph by JanusGraph.
the class JanusGraphStep method buildGlobalGraphCentricQuery.
private GraphCentricQuery buildGlobalGraphCentricQuery(final JanusGraphTransaction tx, final QueryProfiler globalQueryProfiler) {
Integer limit = null;
for (Map<List<HasContainer>, QueryInfo> containers : hasLocalContainers.values()) {
for (QueryInfo queryInfo : containers.values()) {
if (queryInfo.getLowLimit() > 0 || orders.isEmpty() && !queryInfo.getOrders().isEmpty()) {
return null;
}
final int currentHighLimit = queryInfo.getHighLimit();
if (limit == null) {
limit = currentHighLimit;
} else if (currentHighLimit < highLimit && !limit.equals(currentHighLimit)) {
return null;
}
}
}
final JanusGraphQuery query = tx.query();
for (Map<List<HasContainer>, QueryInfo> lc : hasLocalContainers.values()) {
List<JanusGraphQuery> localQueries = new ArrayList<>(lc.size());
for (final List<HasContainer> localContainers : lc.keySet()) {
final JanusGraphQuery localQuery = tx.query();
addConstraint(localQuery, localContainers);
localQueries.add(localQuery);
}
query.or(localQueries);
}
for (final OrderEntry order : orders) query.orderBy(order.key, order.order);
query.limit(Math.min(limit, highLimit));
return buildGraphCentricQuery(query, globalQueryProfiler);
}
Aggregations