org.apache.tinkerpop.gremlin.process.traversal.Pop Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.Pop. 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: TestColumnNameTranslation.java    From sqlg with MIT License 6 votes vote down vote up
private void testNameWithMultipleSameLabel_assert(SqlgGraph sqlgGraph, Vertex a1, Vertex b1) {
    List<Map<String, Object>> result = sqlgGraph.traversal()
            .V().as("a")
            .out().as("a")
            .in().as("a")
            .select(Pop.all, "a", "a", "a")
            .toList();
    assertEquals(3, result.size());
    Object o1 = result.get(0).get("a");
    Assert.assertTrue(o1 instanceof List);
    @SuppressWarnings("unchecked") List<Vertex> ass = (List) o1;
    assertEquals(a1, ass.get(0));
    assertEquals("a1", ass.get(0).value("name"));
    assertEquals(b1, ass.get(1));
    assertEquals("b1", ass.get(1).value("name"));
    assertEquals(a1, ass.get(2));
    assertEquals("a1", ass.get(2).value("name"));
}
 
Example #2
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X_Simple() {
    loadModern();
    Graph g = this.sqlgGraph;
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, List<Vertex>> traversal = (DefaultGraphTraversal<Vertex, List<Vertex>>) g.traversal()
            .V().as("a")
            .out().as("a")
            .out().as("a")
            .<List<Vertex>>select(Pop.all, "a");
    Assert.assertEquals(4, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(2, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        final List<Vertex> s = traversal.next();
        Assert.assertEquals(3, s.size());
        System.out.println(s);
        counter++;
    }
    Assert.assertEquals(2, counter);
}
 
Example #3
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X() {
    loadModern();
    Graph g = this.sqlgGraph;
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal<Vertex, String>) g.traversal()
            .V().as("a")
            .out().as("a")
            .out().as("a")
            .<List<String>>select(Pop.all, "a")
            .by(__.unfold().values("name").fold())
            .<String>range(Scope.local, 1, 2);
    Assert.assertEquals(5, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        final String s = traversal.next();
        Assert.assertEquals("josh", s);
        counter++;
    }
    Assert.assertEquals(2, counter);
    Assert.assertEquals(3, traversal.getSteps().size());
}
 
Example #4
Source File: Scoping.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the object with the specified key for the current traverser and throws an exception if the key cannot
 * be found.
 *
 * @throws KeyNotFoundException if the key does not exist
 */
public default <S> S getScopeValue(final Pop pop, final Object key, final Traverser.Admin<?> traverser) throws KeyNotFoundException {
    final Object object = traverser.get();
    if (object instanceof Map && ((Map) object).containsKey(key))
        return (S) ((Map) object).get(key);

    if (key instanceof String) {
        final String k = (String) key;
        if (traverser.getSideEffects().exists(k))
            return traverser.getSideEffects().get(k);

        final Path path = traverser.path();
        if (path.hasLabel(k))
            return null == pop ? path.get(k) : path.get(pop, k);
    }

    throw new KeyNotFoundException(key, this);
}
 
Example #5
Source File: MathStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
protected Double map(final Traverser.Admin<S> traverser) {
    final Expression localExpression = new Expression(this.expression.getExpression());
    for (final String var : this.expression.getVariables()) {
        final Object o = var.equals(CURRENT) ?
                TraversalUtil.applyNullable(traverser, this.traversalRing.next()) :
                TraversalUtil.applyNullable((S) this.getNullableScopeValue(Pop.last, var, traverser), this.traversalRing.next());

        // it's possible for ElementValueTraversal to return null or something that is possibly not a Number.
        // worth a check to try to return a nice error message. The TraversalRing<S, Number> is a bit optimistic
        // given type erasure. It could easily end up otherwise.
        if (!(o instanceof Number))
            throw new IllegalStateException(String.format(
                    "The variable %s for math() step must resolve to a Number - it is instead of type %s with value %s",
                    var, Objects.isNull(o) ? "null" : o.getClass().getName(), o));

        localExpression.setVariable(var, ((Number) o).doubleValue());
    }
    this.traversalRing.reset();
    return localExpression.evaluate();
}
 
Example #6
Source File: MatchStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
private boolean hasMatched(final ConnectiveStep.Connective connective, final Traverser.Admin<S> traverser) {
    int counter = 0;
    boolean matched = false;
    for (final Traversal.Admin<Object, Object> matchTraversal : this.matchTraversals) {
        if (traverser.getTags().contains(matchTraversal.getStartStep().getId())) {
            if (connective == ConnectiveStep.Connective.OR) {
                matched = true;
                break;
            }
            counter++;
        }
    }
    if (!matched)
        matched = this.matchTraversals.size() == counter;
    if (matched && this.dedupLabels != null) {
        final Path path = traverser.path();
        final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
        for (final String label : this.dedupLabels) {
            objects.add(path.get(Pop.last, label));
        }
        this.dedups.add(objects);
    }
    return matched;
}
 
Example #7
Source File: ImmutablePath.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public boolean popEquals(final Pop pop, final Object other) {
    if (!(other instanceof Path))
        return false;
    final Path otherPath = (Path) other;
    ImmutablePath currentPath = this;
    while (true) {
        if (currentPath.isTail())
            break;
        for (final String label : currentPath.currentLabels) {
            if (!otherPath.hasLabel(label) || !this.get(pop, label).equals(otherPath.get(pop, label)))
                return false;
        }
        currentPath = currentPath.previousPath;
    }
    return true;
}
 
Example #8
Source File: MatchStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
protected Traverser.Admin<Object> processNextStart() throws NoSuchElementException {
    if (null == this.parent)
        this.parent = ((MatchStep) this.getTraversal().getParent().asStep());

    while (true) {
        final Traverser.Admin traverser = this.starts.next();
        // no end label
        if (null == this.matchKey) {
            // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId, lets ensure they are all at the parent
            traverser.setStepId(this.parent.getId());
            this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal());
            return this.retractUnnecessaryLabels(traverser);
        }
        // TODO: sideEffect check?
        // path check
        final Path path = traverser.path();
        if (!path.hasLabel(this.matchKey) || traverser.get().equals(path.get(Pop.last, this.matchKey))) {
            // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId and thus, lets ensure they are all at the parent
            traverser.setStepId(this.parent.getId());
            traverser.addLabels(this.matchKeyCollection);
            this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal());
            return this.retractUnnecessaryLabels(traverser);
        }
    }
}
 
Example #9
Source File: PathProcessorStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {

    return Arrays.asList(new Object[][]{
            // select("a")
            {__.select("a"), __.select("a"), Collections.emptyList()},
            {__.select("a").by(), __.select("a").by(), Collections.emptyList()},
            {__.select("a").by(__.outE().count()), __.select("a").map(__.outE().count()), Collections.emptyList()},
            {__.select("a").by("name"), __.select("a").map(new ValueTraversal<>("name")), Collections.emptyList()},
            {__.select("a").out(), __.select("a").out(), Collections.emptyList()},
            {__.select(Pop.all, "a").by(__.values("name")), __.select(Pop.all, "a").by("name"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select(Pop.last, "a").by(__.values("name")), __.select(Pop.last, "a").map(__.values("name")), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select(Pop.first, "a").by(__.values("name")), __.select(Pop.first, "a").map(__.values("name")), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            // select("a","b")
            {__.select("a", "b"), __.select("a", "b"), Collections.emptyList()},
            {__.select("a", "b").by(), __.select("a", "b").by(), Collections.emptyList()},
            {__.select("a", "b", "c").by(), __.select("a", "b", "c").by(), Collections.emptyList()},
            {__.select("a", "b").by().by("age"), __.select("b").map(new ValueTraversal<>("age")).as("b").select("a").map(new IdentityTraversal<>()).as("a").select(Pop.last, "a", "b"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select("a", "b").by("name").by("age"), __.select("b").map(new ValueTraversal<>("age")).as("b").select("a").map(new ValueTraversal<>("name")).as("a").select(Pop.last, "a", "b"), Collections.emptyList()},
            {__.select("a", "b", "c").by("name").by(__.outE().count()), __.select("c").map(new ValueTraversal<>("name")).as("c").select("b").map(__.outE().count()).as("b").select("a").map(new ValueTraversal<>("name")).as("a").select(Pop.last, "a", "b", "c"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select(Pop.first, "a", "b").by("name").by("age"), __.select(Pop.first, "b").map(new ValueTraversal<>("age")).as("b").select(Pop.first, "a").map(new ValueTraversal<>("name")).as("a").select(Pop.last, "a", "b"), Collections.emptyList()},
            {__.select(Pop.last, "a", "b").by("name").by("age"), __.select(Pop.last, "b").map(new ValueTraversal<>("age")).as("b").select(Pop.last, "a").map(new ValueTraversal<>("name")).as("a").select(Pop.last, "a", "b"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select(Pop.all, "a", "b").by("name").by("age"), __.select(Pop.all, "a", "b").by("name").by("age"), Collections.emptyList()},
            {__.select(Pop.mixed, "a", "b").by("name").by("age"), __.select(Pop.mixed, "a", "b").by("name").by("age"), Collections.emptyList()},
            // where(as("a")...)
            {__.where(__.out("knows")), __.where(__.outE("knows")), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.where(__.as("a").out("knows")), __.identity().as("xyz").select(Pop.last, "a").filter(__.out("knows")).select(Pop.last, "xyz"), Collections.emptyList()},
            {__.where(__.as("a").has("age", P.gt(10))), __.identity().as("xyz").select(Pop.last, "a").has("age", P.gt(10)).select(Pop.last, "xyz"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.select("b").where(__.as("a").has("age", P.gt(10))), __.select("b").as("xyz").select(Pop.last, "a").has("age", P.gt(10)).select(Pop.last, "xyz"), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.where(__.as("a").out("knows").as("b")), __.identity().as("xyz").select(Pop.last, "a").where(__.out("knows").as("b")).select(Pop.last, "xyz"), Collections.emptyList()},
            {__.where("a", P.eq("b")), __.where("a", P.eq("b")), Collections.emptyList()},
            {__.as("a").out().where(__.as("a").has("age", P.gt(10))).in(), __.as("a").out().as("xyz").select(Pop.last, "a").has("age", P.gt(10)).select(Pop.last, "xyz").in(), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
            {__.as("a").out().where(__.as("a").has("age", P.gt(10))).in().path(), __.as("a").out().where(__.as("a").has("age", P.gt(10))).in().path(), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
    });
}
 
Example #10
Source File: MatchStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected Traverser.Admin<Object> processNextStart() throws NoSuchElementException {
    if (null == this.parent)
        this.parent = (MatchStep<?, ?>) this.getTraversal().getParent();

    final Traverser.Admin<Object> traverser = this.starts.next();
    this.parent.getMatchAlgorithm().recordStart(traverser, this.getTraversal());
    // TODO: sideEffect check?
    return null == this.selectKey ? traverser : traverser.split(traverser.path().get(Pop.last, this.selectKey), this);
}
 
Example #11
Source File: AbstractTypedCompatibilityTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReadWritePop() throws Exception {
    final String resourceName = "pop";
    assumeCompatibility(resourceName);

    final Pop resource = findModelEntryObject(resourceName);
    final Pop fromStatic = read(getCompatibility().readFromResource(resourceName), Pop.class);
    final Pop recycled = read(write(fromStatic, Pop.class), Pop.class);
    assertEquals(fromStatic, recycled);
    assertEquals(resource, fromStatic);
    assertEquals(resource, recycled);
}
 
Example #12
Source File: SelectStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public SelectStep(final Traversal.Admin traversal, final Pop pop, final String... selectKeys) {
    super(traversal);
    this.pop = pop;
    this.selectKeys = Arrays.asList(selectKeys);
    this.selectKeysSet = Collections.unmodifiableSet(new HashSet<>(this.selectKeys));
    if (this.selectKeys.size() < 2)
        throw new IllegalArgumentException("At least two select keys must be provided: " + this);
}
 
Example #13
Source File: TestPathStep.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testNameWithMultipleSameLabel() {
    Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
    Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2");
    Vertex a3 = this.sqlgGraph.addVertex(T.label, "A", "name", "a3");
    Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
    Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2");
    Vertex b3 = this.sqlgGraph.addVertex(T.label, "B", "name", "b3");
    a1.addEdge("ab", b1);
    a2.addEdge("ab", b2);
    a3.addEdge("ab", b3);
    this.sqlgGraph.tx().commit();

    DefaultGraphTraversal<Vertex, Map<String, Object>> traversal = (DefaultGraphTraversal<Vertex, Map<String, Object>>)this.sqlgGraph.traversal()
            .V().as("a")
            .out().as("a")
            .in().as("a")
            .select(Pop.all,"a", "a", "a");
    Assert.assertEquals(4, traversal.getSteps().size());
    List<Map<String, Object>> result = traversal.toList();
    Assert.assertEquals(2, traversal.getSteps().size());
    Assert.assertEquals(3, result.size());
    Object o1 = result.get(0).get("a");
    Assert.assertTrue(o1 instanceof List);
    @SuppressWarnings("unchecked") List<Vertex> ass = (List<Vertex>) o1;
    Assert.assertEquals(a1, ass.get(0));
    Assert.assertEquals("a1", ass.get(0).value("name"));
    Assert.assertEquals(b1, ass.get(1));
    Assert.assertEquals("b1", ass.get(1).value("name"));
    Assert.assertEquals(a1, ass.get(2));
    Assert.assertEquals("a1", ass.get(2).value("name"));

}
 
Example #14
Source File: SqlgWhereTraversalStepBarrier.java    From sqlg with MIT License 5 votes vote down vote up
@Override
protected Object map(final Traverser.Admin<S> traverser) {
    if (this.getTraversal().getEndStep() instanceof SqlgWhereTraversalStepBarrier.SqlgWhereEndStep)
        ((SqlgWhereEndStep) this.getTraversal().getEndStep()).processStartTraverser(traverser);
    else if (this.getTraversal().getEndStep() instanceof ProfileStep && this.getTraversal().getEndStep().getPreviousStep() instanceof SqlgWhereTraversalStepBarrier.SqlgWhereEndStep)     // TOTAL SUCKY HACK!
        ((SqlgWhereEndStep) this.getTraversal().getEndStep().getPreviousStep()).processStartTraverser(traverser);
    return null == this.selectKey ? traverser.get() : this.getScopeValue(Pop.last, this.selectKey, traverser);
}
 
Example #15
Source File: Scoping.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Calls {@link #getScopeValue(Pop, Object, Traverser.Admin)} but throws an unchecked {@code IllegalStateException}
 * if the key cannot be found.
 */
public default <S> S getSafeScopeValue(final Pop pop, final Object key, final Traverser.Admin<?> traverser) {
    try {
        return getScopeValue(pop, key, traverser);
    } catch (KeyNotFoundException nfe) {
        throw new IllegalArgumentException(nfe.getMessage(), nfe);
    }
}
 
Example #16
Source File: Scoping.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Calls {@link #getScopeValue(Pop, Object, Traverser.Admin)} and returns {@code null} if the key is not found.
 * Use this method with caution as {@code null} has one of two meanings as a return value. It could be that the
 * key was found and its value was {@code null} or it might mean that the key was not found and {@code null} was
 * simply returned.
 */
public default <S> S getNullableScopeValue(final Pop pop, final String key, final Traverser.Admin<?> traverser) {
    try {
        return getScopeValue(pop, key, traverser);
    } catch (KeyNotFoundException nfe) {
        return null;
    }
}
 
Example #17
Source File: MutablePath.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public <A> A get(final Pop pop, final String label) {
    if (Pop.mixed == pop) {
        return this.get(label);
    } else if (Pop.all == pop) {
        if (this.hasLabel(label)) {
            final Object object = this.get(label);
            if (object instanceof List)
                return (A) object;
            else
                return (A) Collections.singletonList(object);
        } else {
            return (A) Collections.emptyList();
        }
    } else {
        // Override default to avoid building temporary list, and to stop looking when we find the label.
        if (Pop.last == pop) {
            for (int i = this.labels.size() - 1; i >= 0; i--) {
                if (labels.get(i).contains(label))
                    return (A) objects.get(i);
            }
        } else {
            for (int i = 0; i != this.labels.size(); i++) {
                if (labels.get(i).contains(label))
                    return (A) objects.get(i);
            }
        }
        throw Path.Exceptions.stepWithProvidedLabelDoesNotExist(label);
    }
}
 
Example #18
Source File: WherePredicateStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean filter(final Traverser.Admin<S> traverser) {
    final Object value = null == this.startKey ?
            TraversalUtil.applyNullable(traverser, this.traversalRing.next()) :
            TraversalUtil.applyNullable((S) this.getSafeScopeValue(Pop.last, this.startKey, traverser), this.traversalRing.next());
    this.setPredicateValues(this.predicate, traverser, this.selectKeys.iterator());
    this.traversalRing.reset();
    return this.predicate.test(value);
}
 
Example #19
Source File: WhereTraversalStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected Object map(final Traverser.Admin<S> traverser) {
    if (this.getTraversal().getEndStep() instanceof WhereEndStep)
        ((WhereEndStep) this.getTraversal().getEndStep()).processStartTraverser(traverser);
    else if (this.getTraversal().getEndStep() instanceof ProfileStep && this.getTraversal().getEndStep().getPreviousStep() instanceof WhereEndStep)     // TOTAL SUCKY HACK!
        ((WhereEndStep) this.getTraversal().getEndStep().getPreviousStep()).processStartTraverser(traverser);
    return null == this.selectKey ? traverser.get() : this.getSafeScopeValue(Pop.last, this.selectKey, traverser);
}
 
Example #20
Source File: DedupGlobalStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean filter(final Traverser.Admin<S> traverser) {
    if (this.onGraphComputer && !this.executingAtMaster) return true;
    traverser.setBulk(1L);
    if (null == this.dedupLabels) {
        return this.duplicateSet.add(TraversalUtil.applyNullable(traverser, this.dedupTraversal));
    } else {
        final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
        this.dedupLabels.forEach(label -> objects.add(TraversalUtil.applyNullable((S) this.getSafeScopeValue(Pop.last, label, traverser), this.dedupTraversal)));
        return this.duplicateSet.add(objects);
    }
}
 
Example #21
Source File: DedupGlobalStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Map<Object, Traverser.Admin<S>> nextBarrier() throws NoSuchElementException {
    final Map<Object, Traverser.Admin<S>> map = null != this.barrier ? this.barrier : new HashMap<>();
    while (this.starts.hasNext()) {
        final Traverser.Admin<S> traverser = this.starts.next();
        final Object object;
        if (null != this.dedupLabels) {
            object = new ArrayList<>(this.dedupLabels.size());
            for (final String label : this.dedupLabels) {
                ((List) object).add(TraversalUtil.applyNullable((S) this.getSafeScopeValue(Pop.last, label, traverser), this.dedupTraversal));
            }
        } else {
            object = TraversalUtil.applyNullable(traverser, this.dedupTraversal);
        }
        if (!map.containsKey(object)) {
            traverser.setBulk(1L);

            // DetachedProperty and DetachedVertexProperty both have a transient for the Host element. that causes
            // trouble for olap which ends up requiring the Host later. can't change the transient without some
            // consequences: (1) we break gryo formatting and io tests start failing (2) storing the element with
            // the property has the potential to bloat detached Element instances as it basically stores that data
            // twice. Not sure if it's smart to change that at least in 3.4.x and not without some considerable
            // thought as to what might be major changes. To work around the problem we will detach properties as
            // references so that the parent element goes with it. Also, given TINKERPOP-2318 property comparisons
            // have changed in such a way that allows this to work properly
            if (traverser.get() instanceof Property)
                traverser.set(ReferenceFactory.detach(traverser.get()));
            else
                traverser.set(DetachedFactory.detach(traverser.get(), true));
            map.put(object, traverser);
        }
    }
    this.barrier = null;
    this.barrierIterator = null;
    if (map.isEmpty())
        throw FastNoSuchElementException.instance();
    else
        return map;
}
 
Example #22
Source File: SelectStepTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.select(Pop.all, "x", "y"),
            __.select(Pop.first, "x", "y"),
            __.select(Pop.last, "x", "y"),
            __.select(Pop.mixed, "x", "y"),
            __.select(Pop.all, "x", "y").by("name").by("age"),
            __.select(Pop.first, "x", "y").by("name").by("age"),
            __.select(Pop.last, "x", "y").by("name").by("age"),
            __.select(Pop.mixed, "x", "y").by("name").by("age")
    );
}
 
Example #23
Source File: SelectOneStepTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.select(Pop.all, "x"),
            __.select(Pop.first, "x"),
            __.select(Pop.last, "x"),
            __.select(Pop.mixed, "x"),
            __.select(Pop.all, "x").by("name"),
            __.select(Pop.first, "x").by("name"),
            __.select(Pop.last, "x").by("name"),
            __.select(Pop.mixed, "x").by("name")
    );
}
 
Example #24
Source File: JanusPreviousPropertyStep.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Iterator<JanusGraphVertex> flatMap(Traverser.Admin<S> traverser) {
    JanusGraphTransaction tx = JanusGraphTraversalUtil.getTx(this.traversal);

    // Retrieve property value to look-up, that is identified in the traversal by the `stepLabel`
    Object value = getNullableScopeValue(Pop.first, stepLabel, traverser);

    return value != null ? verticesWithProperty(tx, value) : emptyIterator();
}
 
Example #25
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Map<String, Object>> get_g_V_valueMap_selectXall_a_bX() {
    return g.V().valueMap().select(Pop.all, "a", "b");
}
 
Example #26
Source File: SqlgWhereTraversalStepBarrier.java    From sqlg with MIT License 4 votes vote down vote up
void processStartTraverser(final Traverser.Admin traverser) {
    if (null != this.matchKey) {
        this.matchValue = this.getScopeValue(Pop.last, this.matchKey, traverser);
        this.startValueMap.put(traverser, this.matchValue);
    }
}
 
Example #27
Source File: TailTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, List<String>> get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_2X() {
    return g.V().as("a").out().as("a").out().as("a").<List<String>>select(Pop.mixed, "a").by(unfold().values("name").fold()).tail(local, 2);
}
 
Example #28
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(final Object v1Id) {
    return g.V(v1Id).as("a").repeat(__.out().as("a")).times(2).select(Pop.last, "a");
}
 
Example #29
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Map<String, Object>> get_g_V_selectXall_a_bX() {
    return g.V().select(Pop.all, "a", "b");
}
 
Example #30
Source File: RangeTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, List<String>> get_g_V_asXaX_in_asXaX_in_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_limitXlocal_2X() {
    return g.V().as("a").in().as("a").in().as("a").<List<String>>select(Pop.mixed, "a").by(unfold().values("name").fold()).limit(local, 2);
}