static List<HasContainer> splitAndP(final List<HasContainer> hasContainers, final Iterable<HasContainer> has) { has.forEach(hasContainer -> { if (hasContainer.getPredicate() instanceof AndP) { for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) { hasContainers.add(new HasContainer(hasContainer.getKey(), predicate)); } } else hasContainers.add(hasContainer); }); return hasContainers; }
static boolean validJanusGraphHas(HasContainer has) { if (has.getPredicate() instanceof ConnectiveP) { final 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()); } }
public static HasContainer convert(final 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))); }
@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); }
@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); }
/** * Filters vertices, edges and vertex properties based on their value. * * @param value the value of the {@link Element} * @param otherValues additional values of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> */ public default GraphTraversal<S, E> hasValue(final Object value, final Object... otherValues) { if (value instanceof P) return this.hasValue((P) value); else { final List<Object> values = new ArrayList<>(); if (value instanceof Object[]) { Collections.addAll(values, (Object[]) value); } else values.add(value); for (final Object v : otherValues) { if (v instanceof Object[]) { Collections.addAll(values, (Object[]) v); } else values.add(v); } this.asAdmin().getBytecode().addStep(Symbols.hasValue, values.toArray()); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.value.getAccessor(), values.size() == 1 ? P.eq(values.get(0)) : P.within(values))); } }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param label the label of the {@link Element} * @param propertyKey the key of the property to filter on * @param predicate the filter to apply to the key's value * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final String label, final String propertyKey, final P<?> predicate) { this.asAdmin().getBytecode().addStep(Symbols.has, label, propertyKey, predicate); TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), P.eq(label))); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, predicate)); }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param propertyKey the key of the property to filter on * @param predicate the filter to apply to the key's value * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final String propertyKey, final P<?> predicate) { this.asAdmin().getBytecode().addStep(Symbols.has, propertyKey, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, predicate)); }
/** * Filters vertices, edges and vertex properties based on their label. * * @param predicate the filter to apply to the label of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.4 */ public default GraphTraversal<S, E> hasLabel(final P<String> predicate) { this.asAdmin().getBytecode().addStep(Symbols.hasLabel, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), predicate)); }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param label the label of the {@link Element} * @param propertyKey the key of the property to filter on * @param value the value to compare the accessor value to for equality * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final String label, final String propertyKey, final Object value) { this.asAdmin().getBytecode().addStep(Symbols.has, label, propertyKey, value); TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), P.eq(label))); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, value instanceof P ? (P) value : P.eq(value))); }
/** * Filters vertices, edges and vertex properties based on their value. * * @param predicate the filter to apply to the value of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.4 */ public default GraphTraversal<S, E> hasValue(final P<Object> predicate) { this.asAdmin().getBytecode().addStep(Symbols.hasValue, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.value.getAccessor(), predicate)); }
public static Condition convAnd(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof AndP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((AndP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.and(newCond, cond); } } return cond; }
public static Condition convOr(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof OrP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((OrP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.or(newCond, cond); } } return cond; }
/** * Filters vertices, edges and vertex properties based on their identifier. * * @param predicate the filter to apply to the identifier of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.4 */ public default GraphTraversal<S, E> hasId(final P<Object> predicate) { this.asAdmin().getBytecode().addStep(Symbols.hasId, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.id.getAccessor(), predicate)); }
/** * Filters vertices, edges and vertex properties based on their key. * * @param predicate the filter to apply to the key of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.4 */ public default GraphTraversal<S, E> hasKey(final P<String> predicate) { this.asAdmin().getBytecode().addStep(Symbols.hasKey, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.key.getAccessor(), predicate)); }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param accessor the {@link T} accessor of the property to filter on * @param predicate the filter to apply to the key's value * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final T accessor, final P<?> predicate) { this.asAdmin().getBytecode().addStep(Symbols.has, accessor, predicate); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(accessor.getAccessor(), predicate)); }
/** * Filters vertices, edges and vertex properties based on their label. * * @param label the label of the {@link Element} * @param otherLabels additional labels of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.2 */ public default GraphTraversal<S, E> hasLabel(final String label, final String... otherLabels) { final String[] labels = new String[otherLabels.length + 1]; labels[0] = label; System.arraycopy(otherLabels, 0, labels, 1, otherLabels.length); this.asAdmin().getBytecode().addStep(Symbols.hasLabel, labels); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), labels.length == 1 ? P.eq(labels[0]) : P.within(labels))); }
/** * Filters vertices, edges and vertex properties based on their key. * * @param label the key of the {@link Element} * @param otherLabels additional key of the {@link Element} * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.2.2 */ public default GraphTraversal<S, E> hasKey(final String label, final String... otherLabels) { final String[] labels = new String[otherLabels.length + 1]; labels[0] = label; System.arraycopy(otherLabels, 0, labels, 1, otherLabels.length); this.asAdmin().getBytecode().addStep(Symbols.hasKey, labels); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.key.getAccessor(), labels.length == 1 ? P.eq(labels[0]) : P.within(labels))); }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param propertyKey the key of the property to filter on * @param value the value to compare the property value to for equality * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final String propertyKey, final Object value) { if (value instanceof P) return this.has(propertyKey, (P) value); else if (value instanceof Traversal) return this.has(propertyKey, (Traversal) value); else { this.asAdmin().getBytecode().addStep(Symbols.has, propertyKey, value); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, P.eq(value))); } }
/** * Filters vertices, edges and vertex properties based on their properties. * * @param accessor the {@link T} accessor of the property to filter on * @param value the value to compare the accessor value to for equality * @return the traversal with an appended {@link HasStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> has(final T accessor, final Object value) { if (value instanceof P) return this.has(accessor, (P) value); else if (value instanceof Traversal) return this.has(accessor, (Traversal) value); else { this.asAdmin().getBytecode().addStep(Symbols.has, accessor, value); return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(accessor.getAccessor(), P.eq(value))); } }