org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory. 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: BytecodeHelper.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
public static void detachElements(final Bytecode bytecode) {
    for (final Bytecode.Instruction instruction : bytecode.getInstructions()) {
        final Object[] arguments = instruction.getArguments();
        for (int i = 0; i < arguments.length; i++) {
            if (arguments[i] instanceof Bytecode)
                detachElements((Bytecode) arguments[i]);
            else if(arguments[i] instanceof List) {
                final List<Object> list = new ArrayList<>();
                for(final Object object : (List)arguments[i]) {
                    list.add( DetachedFactory.detach(object, false));
                }
                arguments[i] = list;
            }
            else
                arguments[i] = DetachedFactory.detach(arguments[i], false);
        }
    }
}
 
Example #2
Source File: TestLoadEdge.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void shouldConstructDetachedEdge() {
    Graph g = this.sqlgGraph;
    loadModern();
    assertModernGraph(g, true, false);
    Edge e = g.traversal().E(convertToEdgeId("marko", "knows", "vadas")).next();
    e.property("year", 2002);
    g.tx().commit();
    e = g.traversal().E(convertToEdgeId("marko", "knows", "vadas")).next();
    final DetachedEdge detachedEdge = DetachedFactory.detach(e, true);
    Assert.assertEquals(convertToEdgeId("marko", "knows", "vadas"), detachedEdge.id());

    Assert.assertEquals("knows", detachedEdge.label());
    Assert.assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.OUT).next().getClass());
    Assert.assertEquals(convertToVertexId("marko"), detachedEdge.vertices(Direction.OUT).next().id());
    Assert.assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());
    Assert.assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.IN).next().getClass());
    Assert.assertEquals(convertToVertexId("vadas"), detachedEdge.vertices(Direction.IN).next().id());
    Assert.assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());

    Assert.assertEquals(2, IteratorUtils.count(detachedEdge.properties()));
    Assert.assertEquals(1, IteratorUtils.count(detachedEdge.properties("year")));
    Assert.assertEquals(0.5d, detachedEdge.properties("weight").next().value());
}
 
Example #3
Source File: HaltedTraverserStrategyTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnDetachedElements() {
    final Graph graph = TinkerFactory.createModern();
    final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put(HaltedTraverserStrategy.HALTED_TRAVERSER_FACTORY, DetachedFactory.class.getCanonicalName());
    }})));
    g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    // should handle nested collections
    g.V().out().fold().next().forEach(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
}
 
Example #4
Source File: HaltedTraverserStrategyTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnDetachedElements() {
    final Graph graph = TinkerFactory.createModern();
    final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put(HaltedTraverserStrategy.HALTED_TRAVERSER_FACTORY, DetachedFactory.class.getCanonicalName());
    }})));
    g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    // should handle nested collections
    g.V().out().fold().next().forEach(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
}
 
Example #5
Source File: ReferenceVertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldHaveSameHashCode() {
    assertEquals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).hashCode(), ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).hashCode());
    assertEquals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).hashCode(), g.V(convertToVertexId("marko")).next().hashCode());
    assertEquals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).hashCode(), DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), false).hashCode());
    assertEquals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).hashCode(), DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), true).hashCode());
}
 
Example #6
Source File: HaltedTraverserStrategy.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public <R> Traverser.Admin<R> halt(final Traverser.Admin<R> traverser) {
    if (this.useReference)
        traverser.set(ReferenceFactory.detach(traverser.get()));
    else
        traverser.set(DetachedFactory.detach(traverser.get(), true));
    return traverser;
}
 
Example #7
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_UUID_IDS)
public void shouldIterateVerticesWithUuidIdSupportUsingDetachedVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, UUID.randomUUID()) : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(DetachedFactory.detach(v1, true)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(DetachedVertex.class))));
    });
}
 
Example #8
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_CUSTOM_IDS)
public void shouldIterateVerticesWithCustomIdSupportUsingDetachedVertex() {
    final Vertex v1 = graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(DetachedFactory.detach(v1, true)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(DetachedVertex.class))));
    });
}
 
Example #9
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_NUMERIC_IDS)
public void shouldIterateVerticesWithNumericSupportUsingDetachedVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, 1l) : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(DetachedFactory.detach(v1, true)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(DetachedVertex.class))));
    });
}
 
Example #10
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_STRING_IDS)
public void shouldIterateVerticesWithStringSupportUsingDetachedVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, "1") : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(DetachedFactory.detach(v1, true)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(DetachedVertex.class))));
    });
}
 
Example #11
Source File: ReferenceEdgeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldEvaluateToEqual() {
    assertTrue(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).equals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next())));
    assertTrue(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).equals(g.E(convertToEdgeId("josh", "created", "lop")).next()));
    assertTrue(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).equals(DetachedFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next(), true)));
    //
    assertTrue(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).equals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next())));
    assertTrue(g.E(convertToEdgeId("josh", "created", "lop")).next().equals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next())));
    assertTrue(DetachedFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next(), true).equals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next())));
}
 
Example #12
Source File: ReferenceEdgeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldHaveSameHashCode() {
    assertEquals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).hashCode(), ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).hashCode());
    assertEquals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).hashCode(), g.E(convertToEdgeId("josh", "created", "lop")).next().hashCode());
    assertEquals(ReferenceFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next()).hashCode(), DetachedFactory.detach(g.E(convertToEdgeId("josh", "created", "lop")).next(), false).hashCode());
}
 
Example #13
Source File: ReferenceVertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldEvaluateToEqualForVerticesAndDetachments() {
    assertTrue(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).equals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next())));
    assertTrue(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).equals(g.V(convertToVertexId("marko")).next()));
    assertTrue(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).equals(DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), true)));
    assertTrue(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()).equals(DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), false)));
    // reverse
    assertTrue(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next().equals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next()))));
    assertTrue(g.V(convertToVertexId("marko")).next().equals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next())));
    assertTrue(DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), true).equals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next())));
    assertTrue(DetachedFactory.detach(g.V(convertToVertexId("marko")).next(), false).equals(ReferenceFactory.detach(g.V(convertToVertexId("marko")).next())));
}
 
Example #14
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateEdgesWithUuidIdSupportUsingDetachedEdge() {
  Edge edge1 = createEdge();
  Edge edge2 = getActGraph().edges(DetachedFactory.detach(edge1, true)).next();
  assertEquals(edge1.id(), edge2.id());
  assertFalse(edge2 instanceof DetachedEdge);
}
 
Example #15
Source File: IoEdgeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldReadWriteDetachedEdge() throws Exception {
    final Vertex v1 = graph.addVertex(T.label, "person");
    final Vertex v2 = graph.addVertex(T.label, "person");
    final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), true);

    assertEdge(v1, v2, e, true);
}
 
Example #16
Source File: IoEdgeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldReadWriteDetachedEdgeAsReference() throws Exception {
    final Vertex v1 = graph.addVertex(T.label, "person");
    final Vertex v2 = graph.addVertex(T.label, "person");
    final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), false);

    assertEdge(v1, v2, e, false);
}
 
Example #17
Source File: IoVertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_STRING_VALUES)
@FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldReadWriteDetachedVertexNoEdges() throws Exception {
    final Vertex v1 = graph.addVertex("name", "marko", "acl", "rw");
    final Vertex v2 = graph.addVertex();
    v1.addEdge("friends", v2, "weight", 0.5d);
    assertVertexToSerialize(DetachedFactory.detach(v1, true), true);
}
 
Example #18
Source File: IoVertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_STRING_VALUES)
@FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldReadWriteDetachedVertexAsReferenceNoEdges() throws Exception {
    final Vertex v1 = graph.addVertex("name", "marko", "acl", "rw");
    final Vertex v2 = graph.addVertex();
    v1.addEdge("friends", v2, "weight", 0.5d);
    assertVertexToSerialize(DetachedFactory.detach(v1, false), false);
}
 
Example #19
Source File: TestIoEdge.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void shouldReadWriteDetachedEdge() throws Exception {
    final Vertex v1 = this.sqlgGraph.addVertex(T.label, "person");
    final Vertex v2 = this.sqlgGraph.addVertex(T.label, "person");
    final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), true);

    assertEdge(v1, v2, e, true);
}
 
Example #20
Source File: TestIoEdge.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void shouldReadWriteDetachedEdgeAsReference() throws Exception {
    final Vertex v1 = this.sqlgGraph.addVertex(T.label, "person");
    final Vertex v2 = this.sqlgGraph.addVertex(T.label, "person");
    final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), false);

    assertEdge(v1, v2, e, false);
}
 
Example #21
Source File: GryoWriter.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeEdge(final OutputStream outputStream, final Edge e) throws IOException {
    final Output output = new Output(outputStream);
    writeHeader(output);
    kryo.writeObject(output, DetachedFactory.detach(e, true));
    output.flush();
}
 
Example #22
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateVerticesWithUuidIdSupportUsingDetachedVertex() {
  Vertex vertex1 = createVertex();
  Vertex vertex2 = getActGraph().vertices(DetachedFactory.detach(vertex1, true)).next();
  assertEquals(vertex1.id(), vertex2.id());
  assertFalse(vertex2 instanceof DetachedVertex);
}
 
Example #23
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateVerticesWithUuidIdSupportUsingDetachedVertex() {
  Vertex vertex1 = createVertex();
  Vertex vertex2 = getActGraph().vertices(DetachedFactory.detach(vertex1, true)).next();
  assertEquals(vertex1.id(), vertex2.id());
  assertFalse(vertex2 instanceof DetachedVertex);
}
 
Example #24
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateEdgesWithUuidIdSupportUsingDetachedEdge() {
  Edge edge1 = createEdge();
  Edge edge2 = getActGraph().edges(DetachedFactory.detach(edge1, true)).next();
  assertEquals(edge1.id(), edge2.id());
  assertFalse(edge2 instanceof DetachedEdge);
}
 
Example #25
Source File: HaltedTraverserStrategy.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private HaltedTraverserStrategy(final Class haltedTraverserFactory) {
    if (haltedTraverserFactory.equals(DetachedFactory.class) || haltedTraverserFactory.equals(ReferenceFactory.class)) {
        this.haltedTraverserFactory = haltedTraverserFactory;
        this.useReference = ReferenceFactory.class.equals(this.haltedTraverserFactory);
    } else
        throw new IllegalArgumentException("The provided traverser detachment factory is unknown: " + haltedTraverserFactory);
}
 
Example #26
Source File: GryoWriter.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeVertexProperty(final OutputStream outputStream, final VertexProperty vp) throws IOException {
    final Output output = new Output(outputStream);
    writeHeader(output);
    kryo.writeObject(output, DetachedFactory.detach(vp, true));
    output.flush();
}
 
Example #27
Source File: GryoWriter.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeProperty(final OutputStream outputStream, final Property p) throws IOException {
    final Output output = new Output(outputStream);
    writeHeader(output);
    kryo.writeObject(output, DetachedFactory.detach(p, true));
    output.flush();
}
 
Example #28
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final Path path, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException, JsonGenerationException {
    jsonGenerator.writeStartObject();

    // paths shouldn't serialize with properties if the path contains graph elements
    final Path p = DetachedFactory.detach(path, false);
    jsonGenerator.writeObjectField(GraphSONTokens.LABELS, p.labels());
    jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, p.objects());

    jsonGenerator.writeEndObject();
}
 
Example #29
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final Path path, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException, JsonGenerationException {
    jsonGenerator.writeStartObject();

    // paths shouldn't serialize with properties if the path contains graph elements
    final Path p = DetachedFactory.detach(path, false);
    jsonGenerator.writeObjectField(GraphSONTokens.LABELS, p.labels());
    jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, p.objects());

    jsonGenerator.writeEndObject();
}
 
Example #30
Source File: CollectingBarrierStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public TraverserSet<S> nextBarrier() throws NoSuchElementException {
    this.processAllStarts();
    if (this.traverserSet.isEmpty())
        throw FastNoSuchElementException.instance();
    else {
        final TraverserSet<S> temp = new TraverserSet<>();
        IteratorUtils.removeOnNext(this.traverserSet.iterator()).forEachRemaining(t -> {
            DetachedFactory.detach(t, true); // this should be dynamic
            temp.add(t);
        });
        return temp;
    }
}