use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer in project sqlg by pietermartin.
the class SqlgUtil method filterSqlgSchemaHasContainers.
/**
* return tables in their schema with their properties, matching the given hasContainers
*
* @param topology
* @param hasContainers
* @param withSqlgSchema do we want the sqlg schema tables too?
* @return
*/
public static Map<String, Map<String, PropertyType>> filterSqlgSchemaHasContainers(Topology topology, List<HasContainer> hasContainers, boolean withSqlgSchema) {
HasContainer fromHasContainer = null;
HasContainer withoutHasContainer = null;
for (HasContainer hasContainer : hasContainers) {
if (hasContainer.getKey().equals(TopologyStrategy.TOPOLOGY_SELECTION_FROM)) {
fromHasContainer = hasContainer;
break;
} else if (hasContainer.getKey().equals(TopologyStrategy.TOPOLOGY_SELECTION_WITHOUT)) {
withoutHasContainer = hasContainer;
break;
}
}
// from and without are mutually exclusive, only one will ever be set.
Map<String, Map<String, PropertyType>> filteredAllTables;
if (fromHasContainer != null) {
filteredAllTables = topology.getAllTablesFrom((Set<TopologyInf>) fromHasContainer.getPredicate().getValue());
} else if (withoutHasContainer != null) {
filteredAllTables = topology.getAllTablesWithout((Set<TopologyInf>) withoutHasContainer.getPredicate().getValue());
} else {
filteredAllTables = topology.getAllTables(withSqlgSchema);
}
return filteredAllTables;
}
use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer in project janusgraph by JanusGraph.
the class JanusGraphPropertiesStep method makeQuery.
private <Q extends BaseVertexQuery> Q makeQuery(Q query) {
final String[] keys = getPropertyKeys();
query.keys(keys);
for (final HasContainer condition : hasContainers) {
query.has(condition.getKey(), JanusGraphPredicateUtils.convert(condition.getBiPredicate()), condition.getValue());
}
for (final OrderEntry order : orders) query.orderBy(order.key, order.order);
if (limit != BaseQuery.NO_LIMIT)
query.limit(limit);
((BasicVertexCentricQueryBuilder) query).profiler(queryProfiler);
return query;
}
use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer in project janusgraph by JanusGraph.
the class JanusGraphVertexStep method makeQuery.
public <Q extends BaseVertexQuery> Q makeQuery(Q query) {
query.labels(getEdgeLabels());
query.direction(getDirection());
for (final HasContainer condition : hasContainers) {
query.has(condition.getKey(), JanusGraphPredicateUtils.convert(condition.getBiPredicate()), condition.getValue());
}
for (final OrderEntry order : orders) query.orderBy(order.key, order.order);
if (limit != BaseQuery.NO_LIMIT)
query.limit(limit);
((BasicVertexCentricQueryBuilder) query).profiler(queryProfiler);
return query;
}
use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer in project janusgraph by JanusGraph.
the class AdjacentVertexFilterOptimizerStrategy method replaceStep.
private void replaceStep(Traversal.Admin<?, ?> traversal, OptimizableQueryType type, TraversalFilterStep originalStep, List<Step> steps) {
// Get the direction in which we filter on the adjacent vertex (or null if not a valid
// adjacency filter)
Direction direction = parseDirection(steps);
P predicate = parsePredicate(type, steps);
// Check that we have a valid direction and a valid vertex filter predicate
if (direction != null && isValidPredicate(type, predicate) && isPreviousStepValid(originalStep, direction)) {
// Now replace the step with a has condition
HasContainer hc = new HasContainer(ImplicitKey.ADJACENT_ID.name(), P.eq(predicate.getValue()));
TraversalHelper.replaceStep(originalStep, new HasStep(traversal, hc), traversal);
}
}
use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer 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;
}
Aggregations