Search in sources :

Example 1 with Row

use of com.tinkerpop.pipes.util.structures.Row in project gremlin by tinkerpop.

the class SelectStepTest method test_g_v1_asXaX_outXknowsX_asXbX_selectXa_nameX.

public void test_g_v1_asXaX_outXknowsX_asXbX_selectXa_nameX(final Iterator<Row> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Row list = pipe.next();
        assertEquals(list.size(), 1);
        assertEquals(list.get(0).toString(), "marko");
        assertEquals(list.getColumn("a"), "marko");
    }
    assertEquals(counter, 2);
}
Also used : Row(com.tinkerpop.pipes.util.structures.Row)

Example 2 with Row

use of com.tinkerpop.pipes.util.structures.Row in project gremlin by tinkerpop.

the class SelectStepTest method test_g_v1_asXaX_outXknowsX_asXbX_selectXaX.

public void test_g_v1_asXaX_outXknowsX_asXbX_selectXaX(final Iterator<Row> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Row list = pipe.next();
        assertEquals(list.size(), 1);
        assertEquals(((Vertex) list.get(0)).getId().toString(), "1");
        assertEquals(((Vertex) list.getColumn("a")).getId().toString(), "1");
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Row(com.tinkerpop.pipes.util.structures.Row)

Example 3 with Row

use of com.tinkerpop.pipes.util.structures.Row in project gremlin by tinkerpop.

the class SelectStepTest method test_g_v1_asXaX_outXknowsX_asXbX_selectXnameX.

public void test_g_v1_asXaX_outXknowsX_asXbX_selectXnameX(final Iterator<Row> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Row list = pipe.next();
        assertEquals(list.size(), 2);
        assertEquals(list.get(0).toString(), "marko");
        assertTrue(list.get(1).toString().equals("josh") || list.get(1).toString().equals("vadas"));
        assertTrue(list.getColumn("b").toString().equals("josh") || list.getColumn("b").toString().equals("vadas"));
    }
    assertEquals(counter, 2);
}
Also used : Row(com.tinkerpop.pipes.util.structures.Row)

Example 4 with Row

use of com.tinkerpop.pipes.util.structures.Row in project incubator-atlas by apache.

the class Titan0Graph method convertGremlinValue.

private Object convertGremlinValue(Object rawValue) {
    if (rawValue instanceof Vertex) {
        return GraphDbObjectFactory.createVertex(this, (Vertex) rawValue);
    } else if (rawValue instanceof Edge) {
        return GraphDbObjectFactory.createEdge(this, (Edge) rawValue);
    } else if (rawValue instanceof Row) {
        Row rowValue = (Row) rawValue;
        Map<String, Object> result = new HashMap<>(rowValue.size());
        List<String> columnNames = rowValue.getColumnNames();
        for (int i = 0; i < rowValue.size(); i++) {
            String key = columnNames.get(i);
            Object value = convertGremlinValue(rowValue.get(i));
            result.put(key, value);
        }
        return result;
    } else if (rawValue instanceof List) {
        return Lists.transform((List) rawValue, new Function<Object, Object>() {

            @Override
            public Object apply(Object input) {
                return convertGremlinValue(input);
            }
        });
    } else if (rawValue instanceof Collection) {
        throw new UnsupportedOperationException("Unhandled collection type: " + rawValue.getClass());
    }
    return rawValue;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) Vertex(com.tinkerpop.blueprints.Vertex) HashMap(java.util.HashMap) Function(com.google.common.base.Function) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) Row(com.tinkerpop.pipes.util.structures.Row) Edge(com.tinkerpop.blueprints.Edge) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Aggregations

Row (com.tinkerpop.pipes.util.structures.Row)4 Vertex (com.tinkerpop.blueprints.Vertex)2 Function (com.google.common.base.Function)1 Edge (com.tinkerpop.blueprints.Edge)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)1 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)1