Search in sources :

Example 1 with DefaultRemoteTraverser

use of org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser in project java-driver by datastax.

the class GraphTestUtils method singleGraphRow.

public static Message singleGraphRow(GraphProtocol graphProtocol, GraphBinaryModule module) throws IOException {
    Vertex value = DetachedVertex.build().setId(1).setLabel("person").addProperty(DetachedVertexProperty.build().setId(11).setLabel("name").setValue("marko").create()).create();
    DseRowsMetadata metadata = new DseRowsMetadata(ImmutableList.of(new ColumnSpec("ks", "table", "gremlin", 0, graphProtocol.isGraphBinary() ? RawType.PRIMITIVES.get(ProtocolConstants.DataType.BLOB) : RawType.PRIMITIVES.get(ProtocolConstants.DataType.VARCHAR))), null, new int[] {}, null, 1, true);
    Queue<List<ByteBuffer>> data = new ArrayDeque<>();
    data.add(ImmutableList.of(serialize(graphProtocol.isGraphBinary() ? // GraphBinary returns results directly inside a Traverser
    new DefaultRemoteTraverser<>(value, 1) : ImmutableMap.of("result", value), graphProtocol, module)));
    return new DefaultRows(metadata, data);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DetachedVertex(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex) ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) DefaultRows(com.datastax.oss.protocol.internal.response.result.DefaultRows) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) List(java.util.List) DseRowsMetadata(com.datastax.dse.protocol.internal.response.result.DseRowsMetadata) DefaultRemoteTraverser(org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser) ArrayDeque(java.util.ArrayDeque)

Example 2 with DefaultRemoteTraverser

use of org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser in project java-driver by datastax.

the class GraphTestUtils method tenGraphRows.

// Returns 10 rows, each with a vertex
public static Rows tenGraphRows(GraphProtocol graphProtocol, GraphBinaryModule module, int page, boolean last) throws IOException {
    DseRowsMetadata metadata = new DseRowsMetadata(ImmutableList.of(new ColumnSpec("ks", "table", "gremlin", 0, graphProtocol.isGraphBinary() ? RawType.PRIMITIVES.get(ProtocolConstants.DataType.BLOB) : RawType.PRIMITIVES.get(ProtocolConstants.DataType.VARCHAR))), null, new int[] {}, null, page, last);
    Queue<List<ByteBuffer>> data = new ArrayDeque<>();
    int start = (page - 1) * 10;
    for (int i = start; i < start + 10; i++) {
        Vertex v = DetachedVertex.build().setId("vertex" + i).setLabel("person").addProperty(DetachedVertexProperty.build().setId("property" + i).setLabel("name").setValue("user" + i).create()).create();
        data.add(ImmutableList.of(serialize(graphProtocol.isGraphBinary() ? // GraphBinary returns results directly inside a Traverser
        new DefaultRemoteTraverser<>(v, 1) : ImmutableMap.of("result", v), graphProtocol, module)));
    }
    return new DefaultRows(metadata, data);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DetachedVertex(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex) ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) DefaultRows(com.datastax.oss.protocol.internal.response.result.DefaultRows) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) List(java.util.List) DseRowsMetadata(com.datastax.dse.protocol.internal.response.result.DseRowsMetadata) DefaultRemoteTraverser(org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser) ArrayDeque(java.util.ArrayDeque)

Example 3 with DefaultRemoteTraverser

use of org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser in project GraphScope by alibaba.

the class NettyTraverserVertexProcessor method process.

@Override
public void process(Object obj) {
    if (obj instanceof Map) {
        // Temporary process for gremlin result
        Map.class.cast(obj).remove("id");
    }
    DefaultRemoteTraverser value = new DefaultRemoteTraverser<>(obj, 1);
    batchResultList.add(value);
    if (batchResultList.size() >= batchSize) {
        AbstractMixedOpProcessor.writeResultList(context, batchResultList, ResponseStatusCode.PARTIAL_CONTENT);
        batchResultList = Lists.newArrayListWithCapacity(this.batchSize);
    }
    if (queryCacheFlag) {
        resultList.add(value);
    }
}
Also used : DefaultRemoteTraverser(org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser) Map(java.util.Map)

Aggregations

DefaultRemoteTraverser (org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser)3 DseRowsMetadata (com.datastax.dse.protocol.internal.response.result.DseRowsMetadata)2 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)2 ColumnSpec (com.datastax.oss.protocol.internal.response.result.ColumnSpec)2 DefaultRows (com.datastax.oss.protocol.internal.response.result.DefaultRows)2 ArrayDeque (java.util.ArrayDeque)2 List (java.util.List)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 DetachedVertex (org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)2 Map (java.util.Map)1