Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer#getPredicate()
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer#getPredicate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraversalUtil.java From hugegraph with Apache License 2.0 | 6 votes |
public static Condition convHas2Condition(HasContainer has, HugeType type, HugeGraph graph) { P<?> p = has.getPredicate(); E.checkArgument(p != null, "The predicate of has(%s) is null", has); BiPredicate<?, ?> bp = p.getBiPredicate(); Condition condition; if (keyForContainsKeyOrValue(has.getKey())) { condition = convContains2Relation(graph, has); } else if (bp instanceof Compare) { condition = convCompare2Relation(graph, type, has); } else if (bp instanceof RelationType) { condition = convRelationType2Relation(graph, type, has); } else if (bp instanceof Contains) { condition = convIn2Relation(graph, type, has); } else if (p instanceof AndP) { condition = convAnd(graph, type, has); } else if (p instanceof OrP) { condition = convOr(graph, type, has); } else { // TODO: deal with other Predicate throw newUnsupportedPredicate(p); } return condition; }
Example 2
Source File: BaseStrategy.java From sqlg with MIT License | 6 votes |
private boolean isNotWithMultipleColumnValue(HasContainerHolder currentStep) { for (HasContainer h : currentStep.getHasContainers()) { P<?> predicate = h.getPredicate(); //noinspection unchecked if (predicate.getValue() instanceof ZonedDateTime || predicate.getValue() instanceof Period || predicate.getValue() instanceof Duration || (predicate.getValue() instanceof List && containsWithMultipleColumnValue((List<Object>) predicate.getValue())) || (predicate instanceof ConnectiveP && isConnectivePWithMultipleColumnValue((ConnectiveP) h.getPredicate()))) { return false; } } return true; }
Example 3
Source File: BaseStrategy.java From sqlg with MIT License | 6 votes |
private List<HasContainer> optimizeBetween(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof AndP) { AndP<?> andP = (AndP) hasContainer.getPredicate(); List<? extends P<?>> predicates = andP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.gte && predicates.get(1).getBiPredicate() == Compare.lt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
Example 4
Source File: BaseStrategy.java From sqlg with MIT License | 6 votes |
private List<HasContainer> optimizeInside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof AndP) { AndP<?> andP = (AndP) hasContainer.getPredicate(); List<? extends P<?>> predicates = andP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.gt && predicates.get(1).getBiPredicate() == Compare.lt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
Example 5
Source File: BaseStrategy.java From sqlg with MIT License | 6 votes |
private List<HasContainer> optimizeOutside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof OrP) { OrP<?> orP = (OrP) hasContainer.getPredicate(); List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
Example 6
Source File: TinkerGraphStep.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public void addHasContainer(final HasContainer hasContainer) { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate)); } } else this.hasContainers.add(hasContainer); }
Example 7
Source File: BitsyGraphStep.java From bitsy with Apache License 2.0 | 5 votes |
@Override public void addHasContainer(final HasContainer hasContainer) { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate)); } } else this.hasContainers.add(hasContainer); }
Example 8
Source File: JanusGraphPredicate.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
public static HasContainer convert(HasContainer container) { if (!(container.getPredicate() instanceof ConnectiveP)) { return container; } final ConnectiveJanusPredicate connectivePredicate = instanceConnectiveJanusPredicate(container.getPredicate()); return new HasContainer(container.getKey(), new ConnectiveJanusGraphP(connectivePredicate, convert(((ConnectiveP<?>) container.getPredicate()), connectivePredicate))); }
Example 9
Source File: HasStepFolder.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
static boolean validJanusGraphHas(HasContainer has) { if (has.getPredicate() instanceof ConnectiveP) { List<? extends P<?>> predicates = ((ConnectiveP<?>) has.getPredicate()).getPredicates(); return predicates.stream().allMatch(p -> validJanusGraphHas(new HasContainer(has.getKey(), p))); } else { return JanusGraphPredicate.Converter.supports(has.getBiPredicate()); } }
Example 10
Source File: HBaseGraphStep.java From hgraphdb with Apache License 2.0 | 5 votes |
@Override public void addHasContainer(final HasContainer hasContainer) { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate)); } } else this.hasContainers.add(hasContainer); }
Example 11
Source File: TinkerGraphStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void addHasContainer(final HasContainer hasContainer) { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate)); } } else this.hasContainers.add(hasContainer); }
Example 12
Source File: Neo4jGraphStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void addHasContainer(final HasContainer hasContainer) { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate)); } } else this.hasContainers.add(hasContainer); }
Example 13
Source File: InlineFilterStrategy.java From tinkerpop with Apache License 2.0 | 4 votes |
private static final boolean processOrStep(final OrStep<?> step, final Traversal.Admin<?, ?> traversal) { boolean process = true; String key = null; P predicate = null; final List<String> labels = new ArrayList<>(); for (final Traversal.Admin<?, ?> childTraversal : step.getLocalChildren()) { InlineFilterStrategy.instance().apply(childTraversal); // todo: this may be a bad idea, but I can't seem to find a test case to break it for (final Step<?, ?> childStep : childTraversal.getSteps()) { if (childStep instanceof HasStep) { P p = null; for (final HasContainer hasContainer : ((HasStep<?>) childStep).getHasContainers()) { if (null == key) key = hasContainer.getKey(); else if (!hasContainer.getKey().equals(key)) { process = false; break; } p = null == p ? hasContainer.getPredicate() : p.and(hasContainer.getPredicate()); } if (process) { predicate = null == predicate ? p : predicate.or(p); } labels.addAll(childStep.getLabels()); } else { process = false; break; } } if (!process) break; } if (process) { final HasStep hasStep = new HasStep<>(traversal, new HasContainer(key, predicate)); TraversalHelper.replaceStep(step, hasStep, traversal); TraversalHelper.copyLabels(step, hasStep, false); for (final String label : labels) { hasStep.addLabel(label); } return true; } return false; }