org.apache.tinkerpop.gremlin.structure.Column Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Column. 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: TestRepeatStepGraphBoth.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_asXaX_repeatXbothX_timesX3X_emit_asXbX_group_byXselectXaXX_byXselectXbX_dedup_order_byXidX_foldX_selectXvaluesX_unfold_dedup() {
    loadModern();
    final Traversal<Vertex, Collection<String>> traversal = this.sqlgGraph.traversal()
            .V().as("a")
            .repeat(__.both()).times(3).emit().values("name").as("b")
            .group()
            .by(__.select("a"))
            .by(__.select("b").dedup().order().fold())
            .select(Column.values).<Collection<String>>unfold().dedup();
    final List<String> vertices = new ArrayList<>(traversal.next());
    Assert.assertFalse(traversal.hasNext());
    Assert.assertEquals(6, vertices.size());
    Assert.assertEquals("josh", vertices.get(0));
    Assert.assertEquals("lop", vertices.get(1));
    Assert.assertEquals("marko", vertices.get(2));
    Assert.assertEquals("peter", vertices.get(3));
    Assert.assertEquals("ripple", vertices.get(4));
    Assert.assertEquals("vadas", vertices.get(5));
}
 
Example #2
Source File: TestGroupCount.java    From sqlg with MIT License 6 votes vote down vote up
@Test
    public void g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX() {
        loadModern();

        final Traversal<Vertex, Map<Vertex, Long>> traversal = this.sqlgGraph.traversal().V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a");
        printTraversalForm(traversal);
        //  [{v[1]=6, v[2]=2, v[3]=6, v[4]=6, v[5]=2, v[6]=2}]
        final Map<Vertex, Long> map = traversal.next();
        assertFalse(traversal.hasNext());
        assertEquals(6, map.size());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "marko")).longValue());
        assertEquals(2l, map.get(convertToVertex(this.sqlgGraph, "vadas")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "lop")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "josh")).longValue());
        assertEquals(2l, map.get(convertToVertex(this.sqlgGraph, "ripple")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "marko")).longValue());
//        checkSideEffects(traversal.asAdmin().getSideEffects(), "a", HashMap.class);
    }
 
Example #3
Source File: BytecodeTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldHaveProperHashAndEquality() {
    final GraphTraversalSource g = EmptyGraph.instance().traversal();
    final Traversal.Admin traversal1 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.keys).order().by(Order.desc).asAdmin();
    final Traversal.Admin traversal2 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.keys).order().by(Order.desc).asAdmin();
    final Traversal.Admin traversal3 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.values).order().by(Order.desc).asAdmin();

    assertEquals(traversal1, traversal2);
    assertNotEquals(traversal1, traversal3);
    assertNotEquals(traversal2, traversal3);
    //
    assertEquals(traversal1.hashCode(), traversal2.hashCode());
    assertNotEquals(traversal1.hashCode(), traversal3.hashCode());
    assertNotEquals(traversal2.hashCode(), traversal3.hashCode());
    //
    assertEquals(traversal1.getBytecode(), traversal2.getBytecode());
    assertNotEquals(traversal1.getBytecode(), traversal3.getBytecode());
    assertNotEquals(traversal2.getBytecode(), traversal3.getBytecode());
    //
    assertEquals(traversal1.getBytecode().hashCode(), traversal2.getBytecode().hashCode());
    assertNotEquals(traversal1.getBytecode().hashCode(), traversal3.getBytecode().hashCode());
    assertNotEquals(traversal2.getBytecode().hashCode(), traversal3.getBytecode().hashCode());

}
 
Example #4
Source File: TestRepeatStepGraphBoth.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testGroupByByFailure() {
    loadModern();
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Collection<Vertex>> traversal = (DefaultGraphTraversal<Vertex, Collection<Vertex>>) this.sqlgGraph.traversal()
            .V().as("a")
            .repeat(__.both()).times(3).emit().as("b")
            .group()
            .by(__.select("a"))
            .by(__.select("b").dedup().order().by(T.id).fold())
            .select(Column.values)
            .<Collection<Vertex>>unfold()
            .dedup();

    Assert.assertEquals(6, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(5, traversal.getSteps().size());
    final Collection<Vertex> vertices = traversal.next();
    Assert.assertFalse(traversal.hasNext());
    Assert.assertEquals(6, vertices.size());
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "marko")));
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "vadas")));
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "josh")));
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "peter")));
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "lop")));
    Assert.assertTrue(vertices.contains(convertToVertex(this.sqlgGraph, "ripple")));
}
 
Example #5
Source File: TestRepeatStepOnEdges.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings({"RedundantCast", "unchecked"})
private DefaultGraphTraversal query2(GraphTraversalSource g) {
    return (DefaultGraphTraversal)g.withSack(0).V().outE("tsw").as("e").inV().emit().repeat(
            __.flatMap(
                    __.outE("tsw").filter(__.as("edge").select(last, "e").where(P.eq("edge")).by("speed")).
                            group().by(__.inV()).
                            by(__.project("curr", "time").by().
                                    by(__.sack(Operator.assign).by("depTime").select(last, "e").sack(Operator.minus).by("arrTime").sack()).
                                    filter(__.select("time").is(P.gte(0))).fold()).
                            select(Column.values).unfold().order(local).by(__.select("time")).limit(local, 1).select("curr")
            ).as("e").inV().simplePath()
    ).times(20).map(__.union((Traversal) __.select(last, "e").by("speed"), (Traversal) __.path().by(T.id).by(__.valueMap("arrTime", "depTime"))).fold());
}
 
Example #6
Source File: AbstractTypedCompatibilityTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReadWriteColumn() throws Exception {
    final String resourceName = "column";
    assumeCompatibility(resourceName);

    final Column resource = findModelEntryObject(resourceName);
    final Column fromStatic = read(getCompatibility().readFromResource(resourceName), Column.class);
    final Column recycled = read(write(fromStatic, Column.class), Column.class);
    assertEquals(fromStatic, recycled);
    assertEquals(resource, fromStatic);
    assertEquals(resource, recycled);
}
 
Example #7
Source File: ByModulating.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public default void modulateBy(final Function function) throws UnsupportedOperationException {
    if (function instanceof T)
        this.modulateBy((T) function);
    else if (function instanceof Column)
        this.modulateBy(new ColumnTraversal((Column) function));
    else
        this.modulateBy(__.map(new FunctionTraverser<>(function)).asAdmin());
}
 
Example #8
Source File: ByModulating.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public default void modulateBy(final Function function, final Comparator comparator) {
    if (function instanceof T)
        this.modulateBy((T) function, comparator);
    else if (function instanceof Column)
        this.modulateBy((Column) function, comparator);
    else
        this.modulateBy(__.map(new FunctionTraverser<>(function)).asAdmin(), comparator);
}
 
Example #9
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Map<String, Number>> get_g_V_hasLabelXpersonX_group_byXnameX_byXoutE_weight_sumX_orderXlocalX_byXvaluesX() {
    return g.V().hasLabel("person").<String, Number>group().by("name").by(outE().values("weight").sum()).order(Scope.local).by(Column.values);
}
 
Example #10
Source File: GroovyTranslatorTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleColumn() {
    assertTranslation("Column.keys", Column.keys);
}
 
Example #11
Source File: ParameterizedGroovyTranslatorTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleColumn() {
    assertNonParameterizedTranslation("Column.keys", Column.keys);
}
 
Example #12
Source File: SubgraphStrategyProcessTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
@LoadGraphWith(CREW)
public void shouldFilterVertexProperties() throws Exception {
    GraphTraversalSource sg = g.withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put(SubgraphStrategy.VERTEX_PROPERTIES, has("startTime", P.gt(2005)));
    }})));
    checkResults(Arrays.asList("purcellville", "baltimore", "oakland", "seattle", "aachen"), sg.V().properties("location").value());
    checkResults(Arrays.asList("purcellville", "baltimore", "oakland", "seattle", "aachen"), sg.V().values("location"));
    if (sg.getStrategies().getStrategy(InlineFilterStrategy.class).isPresent())
        assertFalse(TraversalHelper.hasStepOfAssignableClassRecursively(TraversalFilterStep.class, sg.V().properties("location").value().iterate().asAdmin()));
    // check to make sure edge properties are not analyzed
    sg = g.withStrategies(SubgraphStrategy.build().vertexProperties(has("startTime", P.gt(2005))).create());
    checkResults(Arrays.asList("purcellville", "baltimore", "oakland", "seattle", "aachen"), sg.V().as("a").properties("location").as("b").select("a").outE().properties().select("b").value().dedup());
    checkResults(Arrays.asList("purcellville", "baltimore", "oakland", "seattle", "aachen"), sg.V().as("a").values("location").as("b").select("a").outE().properties().select("b").dedup());
    if (sg.getStrategies().getStrategy(InlineFilterStrategy.class).isPresent())
        assertFalse(TraversalHelper.hasStepOfAssignableClassRecursively(TraversalFilterStep.class, sg.V().as("a").values("location").as("b").select("a").outE().properties().select("b").dedup().iterate().asAdmin()));
    //
    sg = g.withStrategies(SubgraphStrategy.build().vertices(has("name", P.neq("stephen"))).vertexProperties(has("startTime", P.gt(2005))).create());
    checkResults(Arrays.asList("baltimore", "oakland", "seattle", "aachen"), sg.V().properties("location").value());
    checkResults(Arrays.asList("baltimore", "oakland", "seattle", "aachen"), sg.V().values("location"));
    //
    sg = g.withStrategies(SubgraphStrategy.build().vertices(has("name", P.not(P.within("stephen", "daniel")))).vertexProperties(has("startTime", P.gt(2005))).create());
    checkResults(Arrays.asList("baltimore", "oakland", "seattle"), sg.V().properties("location").value());
    checkResults(Arrays.asList("baltimore", "oakland", "seattle"), sg.V().values("location"));
    //
    sg = g.withStrategies(SubgraphStrategy.build().vertices(has("name", P.eq("matthias"))).vertexProperties(has("startTime", P.gte(2014))).create());
    checkResults(makeMapList(1, "seattle", 1L), sg.V().groupCount().by("location"));
    //
    sg = g.withStrategies(SubgraphStrategy.build().vertices(has("location")).vertexProperties(hasNot("endTime")).create());
    checkOrderedResults(Arrays.asList("aachen", "purcellville", "santa fe", "seattle"), sg.V().order().by("location", Order.asc).values("location"));
    //
    sg = g.withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put(SubgraphStrategy.VERTICES, has("location"));
        put(SubgraphStrategy.VERTEX_PROPERTIES, hasNot("endTime"));
    }})));
    checkResults(Arrays.asList("aachen", "purcellville", "santa fe", "seattle"), sg.V().valueMap("location").select(Column.values).unfold().unfold());
    checkResults(Arrays.asList("aachen", "purcellville", "santa fe", "seattle"), sg.V().propertyMap("location").select(Column.values).unfold().unfold().value());
    //
    sg = g.withStrategies(SubgraphStrategy.build().edges(__.<Edge>hasLabel("uses").has("skill", 5)).create());
    checkResults(Arrays.asList(5, 5, 5), sg.V().outE().valueMap().select(Column.values).unfold());
    checkResults(Arrays.asList(5, 5, 5), sg.V().outE().propertyMap().select(Column.values).unfold().value());
    //
    sg = g.withStrategies(SubgraphStrategy.build().vertexProperties(hasNot("skill")).create());
    checkResults(Arrays.asList(3, 3, 3, 4, 4, 5, 5, 5), sg.V().outE("uses").values("skill"));
    checkResults(Arrays.asList(3, 3, 3, 4, 4, 5, 5, 5), sg.V().as("a").properties().select("a").dedup().outE().values("skill"));
    checkResults(Arrays.asList(3, 3, 3, 4, 4, 5, 5, 5), sg.V().as("a").properties().select("a").dedup().outE().properties("skill").as("b").identity().select("b").by(__.value()));
}
 
Example #13
Source File: GroupCountTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Map<Vertex, Long>> get_g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX() {
    return g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a");
}
 
Example #14
Source File: GroupCountTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Long> get_g_V_unionXoutXknowsX__outXcreatedX_inXcreatedXX_groupCount_selectXvaluesX_unfold_sum() {
    return g.V().union(out("knows"), out("created").in("created")).groupCount().select(Column.values).unfold().sum();
}
 
Example #15
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public Traversal<Vertex, Map.Entry<String, Number>> get_g_V_hasLabelXpersonX_group_byXnameX_byXoutE_weight_sumX_unfold_order_byXvalues_descX() {
    return g.V().hasLabel("person").group().by("name").by(outE().values("weight").sum()).<Map.Entry<String, Number>>unfold().order().by(Column.values, desc);
}
 
Example #16
Source File: GraphSONTypeSerializerV3d0.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Class getClassFromObject(final Object o) {
    final Class c = o.getClass();
    if (classMap.containsKey(c))
        return classMap.get(c);

    final Class mapped;
    if (Map.class.isAssignableFrom(c)) {
        if (Tree.class.isAssignableFrom(c))
            mapped = Tree.class;
        else
            mapped = Map.class;
    } else if (List.class.isAssignableFrom(c))
        mapped = List.class;
    else if (Set.class.isAssignableFrom(c) && !BulkSet.class.isAssignableFrom(c))   // we have special handling of BulkSet
        mapped = Set.class;
    else if (Vertex.class.isAssignableFrom(c))
        mapped = Vertex.class;
    else if (Edge.class.isAssignableFrom(c))
        mapped = Edge.class;
    else if (Path.class.isAssignableFrom(c))
        mapped = Path.class;
    else if (VertexProperty.class.isAssignableFrom(c))
        mapped = VertexProperty.class;
    else if (Metrics.class.isAssignableFrom(c))
        mapped = Metrics.class;
    else if (TraversalMetrics.class.isAssignableFrom(c))
        mapped = TraversalMetrics.class;
    else if (Property.class.isAssignableFrom(c))
        mapped = Property.class;
    else if (ByteBuffer.class.isAssignableFrom(c))
        mapped = ByteBuffer.class;
    else if (InetAddress.class.isAssignableFrom(c))
        mapped = InetAddress.class;
    else if (Traverser.class.isAssignableFrom(c))
        mapped = Traverser.class;
    else if (Lambda.class.isAssignableFrom(c))
        mapped = Lambda.class;
    else if (VertexProperty.Cardinality.class.isAssignableFrom(c))
        mapped = VertexProperty.Cardinality.class;
    else if (Column.class.isAssignableFrom(c))
        mapped = Column.class;
    else if (Direction.class.isAssignableFrom(c))
        mapped = Direction.class;
    else if (Operator.class.isAssignableFrom(c))
        mapped = Operator.class;
    else if (Order.class.isAssignableFrom(c))
        mapped = Order.class;
    else if (Pop.class.isAssignableFrom(c))
        mapped = Pop.class;
    else if (SackFunctions.Barrier.class.isAssignableFrom(c))
        mapped = SackFunctions.Barrier.class;
    else if (TraversalOptionParent.Pick.class.isAssignableFrom(c))
        mapped = TraversalOptionParent.Pick.class;
    else if (Scope.class.isAssignableFrom(c))
        mapped = Scope.class;
    else if (T.class.isAssignableFrom(c))
        mapped = T.class;
    else
        mapped = c;

    classMap.put(c, mapped);
    return mapped;
}
 
Example #17
Source File: MessagePassingReductionStrategyTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {
    final Function<Traverser<Vertex>, Vertex> mapFunction = t -> t.get().vertices(Direction.OUT).next();
    return Arrays.asList(new Object[][]{
            {__.V().out().count(), __.V().outE().count(), Collections.singletonList(AdjacentToIncidentStrategy.instance())},
            {__.V().in().count(), __.V().local(__.inE().id()).count(), Collections.singletonList(AdjacentToIncidentStrategy.instance())},
            {__.V().id(), __.V().id(), Collections.emptyList()},
            {__.V().local(out()), __.V().local(out()), Collections.emptyList()},
            {__.V().local(in()), __.V().local(in()), Collections.emptyList()},
            {__.V().local(out()).count(), __.V().local(out()).count(), Collections.emptyList()},
            {__.V().local(in()).count(), __.V().local(in()).count(), Collections.emptyList()},
            {__.V().out().count(), __.V().local(out().id()).count(), Collections.emptyList()},
            {__.V().out().label().count(), __.V().out().label().count(), Collections.emptyList()},
            {__.V().in().id(), __.V().local(in().id()), Collections.emptyList()},
            {in().id(), __.local(in().id()), Collections.emptyList()}, // test inject
            {__.V().out().id(), __.V().local(out().id()), Collections.emptyList()},
            {__.V().both().id(), __.V().local(__.both().id()), Collections.emptyList()},
            {__.V().outE().inV().id().count(), __.V().local(outE().inV().id()).count(), Collections.emptyList()},
            {__.V().map(outE().inV()).count(), __.V().local(__.map(outE().inV()).id()).count(), Collections.emptyList()},
            {__.V().out().map(outE().inV()).count(), __.V().out().map(outE().inV()).count(), Collections.emptyList()},
            {__.V().outE().map(__.inV()).id().count(), __.V().local(__.outE().map(__.inV()).id()).count(), Collections.emptyList()},
            {__.V().outE().map(__.inV()).count(), __.V().local(outE().map(__.inV()).id()).count(), Collections.emptyList()},
            {__.V().outE().map(__.inV()).values("name").count(), __.V().outE().map(__.inV()).values("name").count(), Collections.emptyList()},
            {__.V().outE().inV().count(), __.V().local(outE().inV().id()).count(), Collections.emptyList()},
            {__.V().out().id().count(), __.V().local(out().id()).count(), Collections.emptyList()},
            {__.V().in().id().count(), __.V().local(in().id()).count(), Collections.emptyList()},
            {__.V().in().id().select("id-map").dedup().count(), __.V().local(in().id().select("id-map")).dedup().count(), Collections.emptyList()},
            {__.V().in().id().groupCount().select(keys).unfold().dedup().count(), __.V().local(in().id()).groupCount().select(keys).unfold().dedup().count(), Collections.emptyList()},
            {__.V().outE().hasLabel("knows").values("weight"), __.V().local(outE().hasLabel("knows").values("weight")), Collections.emptyList()},
            {__.V().outE().values("weight").sum(), __.V().local(outE().values("weight")).sum(), Collections.emptyList()},
            {__.V().inE().values("weight"), __.V().local(inE().values("weight")), Collections.emptyList()},
            {__.V().inE().values("weight").sum(), __.V().local(inE().values("weight")).sum(), Collections.emptyList()},
            {__.V().inE().values("weight").sum().dedup().count(), __.V().local(inE().values("weight")).sum().dedup().count(), Collections.emptyList()},
            {__.V().as("a").out("knows").as("b").select("a", "b"), __.V().as("a").out("knows").as("b").select("a", "b"), Collections.emptyList()},
            {__.V().out().groupCount("x").cap("x"), __.V().out().groupCount("x").cap("x"), Collections.emptyList()},
            {__.V().outE().inV().groupCount().select(Column.values).unfold().dedup().count(), __.V().outE().inV().groupCount().select(Column.values).unfold().dedup().count(), Collections.emptyList()},
            {__.V().outE().inV().groupCount(), __.V().outE().inV().groupCount(), Collections.emptyList()},
            {__.V().outE().inV().groupCount().by("name"), __.V().outE().inV().groupCount().by("name"), Collections.emptyList()},
            {__.V().inE().id().groupCount(), __.V().local(inE().id()).groupCount(), Collections.emptyList()},
            {__.V().inE().values("weight").groupCount(), __.V().local(inE().values("weight")).groupCount(), Collections.emptyList()},
            {__.V().outE().inV().tree(), __.V().outE().inV().tree(), Collections.emptyList()},
            {__.V().in().values("name").groupCount(), __.V().in().values("name").groupCount(), Collections.emptyList()},
            {__.V().outE().inV().groupCount("x"), __.V().outE().inV().groupCount("x"), Collections.emptyList()},
            {__.V().in().dedup().count(), __.V().local(in().id()).dedup().count(), Collections.emptyList()},
            {__.V().bothE().dedup().count(), __.V().local(bothE().id()).dedup().count(), Collections.emptyList()},
            {__.V().bothE().dedup().by("name").count(), __.V().bothE().dedup().by("name").count(), Collections.emptyList()},
            {__.V().map(mapFunction).inV().count(), __.V().map(mapFunction).inV().count(), Collections.emptyList()},
            {__.V().groupCount().by(__.out().count()), __.V().groupCount().by(__.out().count()), Collections.emptyList()},
            {__.V().identity().out().identity().count(), __.V().local(__.identity().out().identity().id()).count(), Collections.emptyList()},
            {__.V().identity().out().identity().dedup().count(), __.V().local(__.identity().out().identity().id()).dedup().count(), Collections.emptyList()},
    });
}
 
Example #18
Source File: ByModulating.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public default void modulateBy(final Column column, final Comparator comparator) {
    this.modulateBy(new ColumnTraversal(column), comparator);
}
 
Example #19
Source File: __.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
/**
 * @see GraphTraversal#select(Column)
 */
public static <A, B> GraphTraversal<A, Collection<B>> select(final Column column) {
    return __.<A>start().select(column);
}
 
Example #20
Source File: ColumnTraversal.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public Column getColumn() {
    return this.column;
}
 
Example #21
Source File: ColumnTraversal.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public ColumnTraversal(final Column column) {
    this.column = column;
}
 
Example #22
Source File: GraphSONTypeSerializerV2d0.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Class getClassFromObject(final Object o) {
    final Class c = o.getClass();
    if (classMap.containsKey(c))
        return classMap.get(c);

    final Class mapped;
    if (Vertex.class.isAssignableFrom(c))
        mapped = Vertex.class;
    else if (Edge.class.isAssignableFrom(c))
        mapped = Edge.class;
    else if (Path.class.isAssignableFrom(c))
        mapped = Path.class;
    else if (VertexProperty.class.isAssignableFrom(c))
        mapped = VertexProperty.class;
    else if (Metrics.class.isAssignableFrom(c))
        mapped = Metrics.class;
    else if (TraversalMetrics.class.isAssignableFrom(c))
        mapped = TraversalMetrics.class;
    else if (Property.class.isAssignableFrom(c))
        mapped = Property.class;
    else if (ByteBuffer.class.isAssignableFrom(c))
        mapped = ByteBuffer.class;
    else if (InetAddress.class.isAssignableFrom(c))
        mapped = InetAddress.class;
    else if (Traverser.class.isAssignableFrom(c))
        mapped = Traverser.class;
    else if (Lambda.class.isAssignableFrom(c))
        mapped = Lambda.class;
    else if (VertexProperty.Cardinality.class.isAssignableFrom(c))
        mapped = VertexProperty.Cardinality.class;
    else if (Column.class.isAssignableFrom(c))
        mapped = Column.class;
    else if (Direction.class.isAssignableFrom(c))
        mapped = Direction.class;
    else if (Operator.class.isAssignableFrom(c))
        mapped = Operator.class;
    else if (Order.class.isAssignableFrom(c))
        mapped = Order.class;
    else if (Pop.class.isAssignableFrom(c))
        mapped = Pop.class;
    else if (SackFunctions.Barrier.class.isAssignableFrom(c))
        mapped = SackFunctions.Barrier.class;
    else if (TraversalOptionParent.Pick.class.isAssignableFrom(c))
        mapped = TraversalOptionParent.Pick.class;
    else if (Scope.class.isAssignableFrom(c))
        mapped = Scope.class;
    else if (T.class.isAssignableFrom(c))
        mapped = T.class;
    else
        mapped = c;

    classMap.put(c, mapped);
    return mapped;
}
 
Example #23
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * A version of {@code select} that allows for the extraction of a {@link Column} from objects in the traversal.
 *
 * @param column the column to extract
 * @return the traversal with an appended {@link TraversalMapStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step" target="_blank">Reference Documentation - Select Step</a>
 * @since 3.1.0-incubating
 */
public default <E2> GraphTraversal<S, Collection<E2>> select(final Column column) {
    this.asAdmin().getBytecode().addStep(Symbols.select, column);
    return this.asAdmin().addStep(new TraversalMapStep<>(this.asAdmin(), new ColumnTraversal(column)));
}