use of org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer in project titan by thinkaurelius.
the class TitanPropertiesStep method makeQuery.
private <Q extends BaseVertexQuery> Q makeQuery(Q query) {
String[] keys = getPropertyKeys();
query.keys(keys);
for (HasContainer condition : hasContainers) {
query.has(condition.getKey(), TitanPredicate.Converter.convert(condition.getBiPredicate()), condition.getValue());
}
for (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 HasStepFolder method foldInIds.
static void foldInIds(final HasStepFolder janusgraphStep, final Traversal.Admin<?, ?> traversal) {
Step<?, ?> currentStep = janusgraphStep.getNextStep();
while (true) {
if (currentStep instanceof HasContainerHolder) {
final HasContainerHolder hasContainerHolder = (HasContainerHolder) currentStep;
final GraphStep graphStep = (GraphStep) janusgraphStep;
// HasContainer collection that we get back is immutable so we keep track of which containers
// need to be deleted after they've been folded into the JanusGraphStep and then remove them from their
// step using HasContainer.removeHasContainer
final List<HasContainer> removableHasContainers = new ArrayList<>();
final Set<String> stepLabels = currentStep.getLabels();
hasContainerHolder.getHasContainers().forEach(hasContainer -> {
if (GraphStep.processHasContainerIds(graphStep, hasContainer)) {
stepLabels.forEach(janusgraphStep::addLabel);
// this has container is no longer needed because its ids will be folded into the JanusGraphStep
removableHasContainers.add(hasContainer);
}
});
if (!removableHasContainers.isEmpty()) {
removableHasContainers.forEach(hasContainerHolder::removeHasContainer);
}
// if all has containers have been removed, the current step can be removed
if (hasContainerHolder.getHasContainers().isEmpty()) {
traversal.removeStep(currentStep);
}
} else if (currentStep instanceof IdentityStep) {
// do nothing, has no impact
} else if (currentStep instanceof NoOpBarrierStep) {
// do nothing, has no impact
} else {
break;
}
currentStep = currentStep.getNextStep();
}
}
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) {
String[] keys = getPropertyKeys();
query.keys(keys);
for (HasContainer condition : hasContainers) {
query.has(condition.getKey(), JanusGraphPredicate.Converter.convert(condition.getBiPredicate()), condition.getValue());
}
for (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 (HasContainer condition : hasContainers) {
query.has(condition.getKey(), JanusGraphPredicate.Converter.convert(condition.getBiPredicate()), condition.getValue());
}
for (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 unipop by unipop-graph.
the class IndexPropertySchema method toPredicates.
@Override
public PredicatesHolder toPredicates(PredicatesHolder predicatesHolder) {
if (predicatesHolder.getClause().equals(PredicatesHolder.Clause.Abort))
return null;
Set<Object> values = schema.getValues(predicatesHolder);
Set<String> indices = values.size() > 0 ? values.stream().map(Object::toString).collect(Collectors.toSet()) : Collections.singleton(defaultIndex);
return PredicatesHolderFactory.predicate(new HasContainer(getKey(), P.within(indices)));
}
Aggregations