org.apache.tinkerpop.gremlin.structure.Vertex - java examples

Here are the examples of the java api org.apache.tinkerpop.gremlin.structure.Vertex taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : TinkerGraphComputerView.java
Copyright Apache License 2.0
Author : apache
public boolean legalVertex(final Vertex vertex) {
    return !this.graphFilter.hasVertexFilter() || this.legalVertices.contains(vertex.id());
}

19 View Complete Implementation : AbstractGenerator.java
Copyright Apache License 2.0
Author : apache
protected final Vertex processVertex(final Vertex vertex, final Map<String, Object> context) {
    vertexProcessor.ifPresent(c -> c.accept(vertex, context));
    return vertex;
}

19 View Complete Implementation : AddEdgeTest.java
Copyright Apache License 2.0
Author : apache
public abstract Traversal<Edge, Edge> get_g_addEXknowsX_fromXaX_toXbX_propertyXweight_0_1X(final Vertex a, final Vertex b);

19 View Complete Implementation : StringFactory.java
Copyright Apache License 2.0
Author : apache
/**
 * Construct the representation for a {@link Vertex}.
 */
public static String vertexString(final Vertex vertex) {
    return V + L_BRACKET + vertex.id() + R_BRACKET;
}

19 View Complete Implementation : ElementHelper.java
Copyright Apache License 2.0
Author : apache
public static boolean areEqual(final Vertex a, final Vertex b) {
    return null != b && null != a && (a == b || haveEqualIds(a, b));
}

19 View Complete Implementation : GraphFilter.java
Copyright Apache License 2.0
Author : apache
/**
 * Returns true if the provided vertex meets the vertex-filter criteria.
 * If no vertex filter is provided, then the vertex is considered legal.
 *
 * @param vertex the vertex to test for legality
 * @return whether the vertex is {@link Legal#YES}.
 */
public boolean legalVertex(final Vertex vertex) {
    return null == this.vertexFilter || TraversalUtil.test(vertex, this.vertexFilter);
}

19 View Complete Implementation : DetachedFactory.java
Copyright Apache License 2.0
Author : apache
public static DetachedVertex detach(final Vertex vertex, final boolean withProperties) {
    return vertex instanceof DetachedVertex ? (DetachedVertex) vertex : new DetachedVertex(vertex, withProperties);
}

19 View Complete Implementation : AddEdgeTest.java
Copyright Apache License 2.0
Author : apache
public abstract Traversal<Vertex, Edge> get_g_withSideEffectXb_bX_VXaX_addEXknowsX_toXbX_propertyXweight_0_5X(final Vertex a, final Vertex b);

19 View Complete Implementation : UpdateVertexLogEntry.java
Copyright GNU General Public License v3.0
Author : HuygensING
clreplaced UpdateVertexLogEntry implements LogEntry {

    private final Vertex vertex;

    private final Vertex previous;

    private final PropertyUpdater propertyUpdater;

    public UpdateVertexLogEntry(Vertex vertex, Vertex previousVersion) {
        this(vertex, previousVersion, LogEntry.SYSTEM_PROPERTIES);
    }

    UpdateVertexLogEntry(Vertex vertex, Vertex previousVersion, Set<String> propertiesToIgnore) {
        this.vertex = vertex;
        this.previous = previousVersion;
        this.propertyUpdater = new PropertyUpdater(vertex, previousVersion, propertiesToIgnore);
    }

    @Override
    public void appendToLog(LogOutput dbLog) {
        dbLog.updateVertex(vertex);
        propertyUpdater.updateProperties(dbLog);
    }
}

19 View Complete Implementation : TinkerMessenger.java
Copyright Apache License 2.0
Author : apache
private void addMessage(final Vertex vertex, final M message, MessageScope messageScope) {
    this.messageBoard.sendMessages.compute(messageScope, (ms, messages) -> {
        if (null == messages)
            messages = new ConcurrentHashMap<>();
        return messages;
    });
    this.messageBoard.sendMessages.get(messageScope).compute(vertex, (v, queue) -> {
        if (null == queue)
            queue = new ConcurrentLinkedQueue<>();
        queue.add(null != this.combiner && !queue.isEmpty() ? this.combiner.combine(queue.remove(), message) : message);
        return queue;
    });
}

19 View Complete Implementation : DetachedVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowRemove() {
    final Vertex v = graph.addVertex();
    final DetachedVertex detachedVertex = DetachedFactory.detach(v, true);
    detachedVertex.remove();
}

19 View Complete Implementation : TinkerMessenger.java
Copyright Apache License 2.0
Author : apache
// /////////
private static <T extends Traversal.Admin<Vertex, Edge>> T setVertexStart(final Traversal.Admin<Vertex, Edge> incidentTraversal, final Vertex vertex) {
    incidentTraversal.addStart(incidentTraversal.getTraverserGenerator().generate(vertex, incidentTraversal.getStartStep(), 1l));
    return (T) incidentTraversal;
}

19 View Complete Implementation : TinkerGraphTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void shouldUpdateEdgeIndicesInExistingGraph() {
    final TinkerGraph g = TinkerGraph.open();
    final Vertex v = g.addVertex();
    v.addEdge("friend", v, "oid", "1", "weight", 0.5f);
    v.addEdge("friend", v, "oid", "2", "weight", 0.6f);
    // a tricky way to evaluate if indices are actually being used is to preplaced a fake BiPredicate to has()
    // to get into the Pipeline and evaluate what's going through it.  in this case, we know that at index
    // is not used because "1" and "2" weights both preplaced through the pipeline.
    replacedertEquals(new Long(1), g.traversal().E().has("weight", P.test((t, u) -> {
        replacedertTrue(t.equals(0.5f) || t.equals(0.6f));
        return true;
    }, 0.5)).has("oid", "1").count().next());
    g.createIndex("oid", Edge.clreplaced);
    // another spy into the pipeline for index check.  in this case, we know that at index
    // is used because only oid 1 should preplaced through the pipeline due to the inclusion of the
    // key index lookup on "oid".  If there's an weight of something other than 0.5f in the pipeline being
    // evaluated then something is wrong.
    replacedertEquals(new Long(1), g.traversal().E().has("weight", P.test((t, u) -> {
        replacedertEquals(0.5f, t);
        return true;
    }, 0.5)).has("oid", "1").count().next());
}

19 View Complete Implementation : ReferenceVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowAddEdge() {
    final Vertex v = graph.addVertex();
    final ReferenceVertex rv = ReferenceFactory.detach(v);
    rv.addEdge("test", null);
}

19 View Complete Implementation : SparkMessenger.java
Copyright Apache License 2.0
Author : apache
// /////////
private static <T extends Traversal.Admin<Vertex, Edge>> T setVertexStart(final Traversal.Admin<Vertex, Edge> incidentTraversal, final Vertex vertex) {
    incidentTraversal.asAdmin().addStart(incidentTraversal.getTraverserGenerator().generate(vertex, incidentTraversal.asAdmin().getStartStep(), 1l));
    return (T) incidentTraversal;
}

19 View Complete Implementation : ShortestPathVertexProgram.java
Copyright Apache License 2.0
Author : apache
private static Path makePath(final Vertex newVertex) {
    return extendPath(null, newVertex);
}

19 View Complete Implementation : ComputerGraph.java
Copyright Apache License 2.0
Author : apache
public static ComputerVertex mapReduce(final Vertex starVertex) {
    return new ComputerGraph(State.MAP_REDUCE, starVertex, Optional.empty()).starVertex;
}

19 View Complete Implementation : ReferenceFactory.java
Copyright Apache License 2.0
Author : apache
public static ReferenceVertex detach(final Vertex vertex) {
    return vertex instanceof ReferenceVertex ? (ReferenceVertex) vertex : new ReferenceVertex(vertex);
}

19 View Complete Implementation : VertexWritable.java
Copyright Apache License 2.0
Author : apache
public void set(final Vertex vertex) {
    this.vertex = vertex instanceof StarGraph.StarVertex ? (StarGraph.StarVertex) vertex : StarGraph.of(vertex).getStarVertex();
}

19 View Complete Implementation : GraphMutateBenchmark.java
Copyright Apache License 2.0
Author : apache
/**
 * {@code GraphMutateBenchmark} benchmarks {@link Traversal} and  {@link Graph} mutation methods.
 *
 * @author Ted Wilmes (http://twilmes.org)
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public clreplaced GraphMutateBenchmark extends AbstractGraphMutateBenchmark {

    private Vertex a;

    private Vertex b;

    private Vertex c;

    private Edge e;

    @Setup
    @Override
    public void prepare() {
        super.prepare();
        a = g.addV().next();
        b = g.addV().next();
        c = g.addV().next();
        e = b.addEdge("knows", c);
    }

    @Benchmark
    public Vertex testAddVertex() {
        return graph.addVertex("test");
    }

    @Benchmark
    public Vertex testAddVertexWithProps() {
        final List<Object> l = new ArrayList<>();
        l.add(T.label);
        l.add("test");
        for (int iy = 0; iy < 32; iy++) {
            l.add("x" + String.valueOf(iy));
            if (iy % 2 == 0)
                l.add(iy);
            else
                l.add(String.valueOf(iy));
        }
        return graph.addVertex(l.toArray());
    }

    @Benchmark
    public VertexProperty testVertexProperty() {
        return a.property("name", "Susan");
    }

    @Benchmark
    public Edge testAddEdge() {
        return a.addEdge("knows", b);
    }

    @Benchmark
    public Property testEdgeProperty() {
        return e.property("met", 1967);
    }

    @Benchmark
    public Vertex testAddV() {
        return g.addV("test").next();
    }

    @Benchmark
    public Vertex testAddVWithProps() {
        GraphTraversal<Vertex, Vertex> t = g.addV("test");
        for (int iy = 0; iy < 32; iy++) {
            if (iy % 2 == 0)
                t = t.property("x" + String.valueOf(iy), iy);
            else
                t = t.property("x" + String.valueOf(iy), String.valueOf(iy));
        }
        return t.next();
    }

    @Benchmark
    public Vertex testVertexPropertyStep() {
        return g.V(a).property("name", "Susan").next();
    }

    @Benchmark
    public Vertex testAddVWithPropsChained() {
        // construct a traversal that adds 100 vertices with 32 properties each
        GraphTraversal<Vertex, Vertex> t = null;
        for (int ix = 0; ix < 100; ix++) {
            if (null == t)
                t = g.addV("person");
            else
                t = t.addV("person");
            for (int iy = 0; iy < 32; iy++) {
                if (iy % 2 == 0)
                    t = t.property("x" + String.valueOf(iy), iy * ix);
                else
                    t = t.property("x" + String.valueOf(iy), String.valueOf(iy + ix));
            }
        }
        return t.next();
    }

    @Benchmark
    public Edge testAddVAddEWithPropsChained() {
        // construct a traversal that adds 100 vertices with 32 properties each as well as 300 edges with 8
        // properties each
        final Random rand = new Random(584545454L);
        GraphTraversal<Vertex, ?> t = null;
        for (int ix = 0; ix < 10; ix++) {
            if (null == t)
                t = g.addV("person");
            else
                t = t.addV("person");
            for (int iy = 0; iy < 32; iy++) {
                if (iy % 2 == 0)
                    t = t.property("x" + String.valueOf(iy), iy * ix);
                else
                    t = t.property("x" + String.valueOf(iy), String.valueOf(iy + ix));
            }
            t = t.as("person" + ix);
            if (ix > 0) {
                int edgeCount = ix == 9 ? 6 : 3;
                for (int ie = 0; ie < edgeCount; ie++) {
                    t = t.addE("knows").from("person" + ix).to("person" + rand.nextInt(ix));
                    for (int iy = 0; iy < 8; iy++) {
                        if (iy % 2 == 0)
                            t = t.property("x" + String.valueOf(iy), iy * ie);
                        else
                            t = t.property("x" + String.valueOf(iy), String.valueOf(iy + ie));
                    }
                }
            }
        }
        final Edge e = (Edge) t.next();
        return e;
    }

    @Benchmark
    public Edge testAddE() {
        return g.V(a).as("a").V(b).as("b").addE("knows").from("a").to("b").next();
    }

    @Benchmark
    public Edge testEdgePropertyStep() {
        return g.E(e).property("met", 1967).next();
    }
}

19 View Complete Implementation : ReferenceVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowSetProperty() {
    final Vertex v = graph.addVertex();
    final ReferenceVertex rv = ReferenceFactory.detach(v);
    rv.property(VertexProperty.Cardinality.single, "test", "test");
}

19 View Complete Implementation : VertexTest.java
Copyright Apache License 2.0
Author : apache
public abstract Traversal<Vertex, Vertex> get_g_VXv1X_out(final Vertex v1);

19 View Complete Implementation : DetachedVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowSetProperty() {
    final Vertex v = graph.addVertex();
    final DetachedVertex detachedVertex = DetachedFactory.detach(v, true);
    detachedVertex.property(VertexProperty.Cardinality.single, "test", "test");
}

19 View Complete Implementation : ComputerGraph.java
Copyright Apache License 2.0
Author : apache
public static ComputerVertex vertexProgram(final Vertex starVertex, VertexProgram vertexProgram) {
    return new ComputerGraph(State.VERTEX_PROGRAM, starVertex, Optional.of(vertexProgram)).starVertex;
}

19 View Complete Implementation : TinkerFactory.java
Copyright Apache License 2.0
Author : apache
/**
 * Generate the graph in {@link #createClreplacedic()} into an existing graph.
 */
public static void generateClreplacedic(final TinkerGraph g) {
    final Vertex marko = g.addVertex(T.id, 1, "name", "marko", "age", 29);
    final Vertex vadas = g.addVertex(T.id, 2, "name", "vadas", "age", 27);
    final Vertex lop = g.addVertex(T.id, 3, "name", "lop", "lang", "java");
    final Vertex josh = g.addVertex(T.id, 4, "name", "josh", "age", 32);
    final Vertex ripple = g.addVertex(T.id, 5, "name", "ripple", "lang", "java");
    final Vertex peter = g.addVertex(T.id, 6, "name", "peter", "age", 35);
    marko.addEdge("knows", vadas, T.id, 7, "weight", 0.5f);
    marko.addEdge("knows", josh, T.id, 8, "weight", 1.0f);
    marko.addEdge("created", lop, T.id, 9, "weight", 0.4f);
    josh.addEdge("created", ripple, T.id, 10, "weight", 1.0f);
    josh.addEdge("created", lop, T.id, 11, "weight", 0.4f);
    peter.addEdge("created", lop, T.id, 12, "weight", 0.2f);
}

19 View Complete Implementation : ShortestPathVertexProgram.java
Copyright Apache License 2.0
Author : apache
private boolean isEndVertex(final Vertex vertex) {
    final Traversal.Admin<Vertex, ?> filterTraversal = this.targetVertexFilterTraversal.getPure();
    // noinspection unchecked
    final Step<Vertex, Vertex> startStep = (Step<Vertex, Vertex>) filterTraversal.getStartStep();
    filterTraversal.addStart(filterTraversal.getTraverserGenerator().generate(vertex, startStep, 1));
    return filterTraversal.hasNext();
}

19 View Complete Implementation : GraphMLWriter.java
Copyright Apache License 2.0
Author : apache
/**
 * This method is not supported for this writer.
 *
 * @throws UnsupportedOperationException when called.
 */
@Override
public void writeVertex(final OutputStream outputStream, final Vertex v, Direction direction) throws IOException {
    throw Io.Exceptions.writerFormatIsForFullGraphSerializationOnly(this.getClreplaced());
}

19 View Complete Implementation : GraphFilter.java
Copyright Apache License 2.0
Author : apache
/**
 * Returns an iterator of legal edges incident to the provided vertex.
 * If no edge filter is provided, then all incident edges are returned.
 *
 * @param vertex the vertex whose legal edges are to be access.
 * @return an iterator of edges that are {@link Legal#YES}.
 */
public Iterator<Edge> legalEdges(final Vertex vertex) {
    return null == this.edgeFilter ? vertex.edges(Direction.BOTH) : TraversalUtil.applyAll(vertex, this.edgeFilter);
}

19 View Complete Implementation : VertexTest.java
Copyright Apache License 2.0
Author : apache
public abstract Traversal<Vertex, String> get_g_VXlistXv1_v2_v3XX_name(final Vertex v1, final Vertex v2, final Vertex v3);

19 View Complete Implementation : GraphMLWriter.java
Copyright Apache License 2.0
Author : apache
/**
 * This method is not supported for this writer.
 *
 * @throws UnsupportedOperationException when called.
 */
@Override
public void writeVertex(final OutputStream outputStream, final Vertex v) throws IOException {
    throw Io.Exceptions.writerFormatIsForFullGraphSerializationOnly(this.getClreplaced());
}

19 View Complete Implementation : ReferenceVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowRemove() {
    final Vertex v = graph.addVertex();
    final ReferenceVertex rv = ReferenceFactory.detach(v);
    rv.remove();
}

19 View Complete Implementation : TinkerGraphTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void shouldRemoveAVertexFromAnIndex() {
    final TinkerGraph g = TinkerGraph.open();
    g.createIndex("name", Vertex.clreplaced);
    g.addVertex("name", "marko", "age", 29);
    g.addVertex("name", "stephen", "age", 35);
    final Vertex v = g.addVertex("name", "stephen", "age", 35);
    // a tricky way to evaluate if indices are actually being used is to preplaced a fake BiPredicate to has()
    // to get into the Pipeline and evaluate what's going through it.  in this case, we know that at index
    // is used because only "stephen" ages should preplaced through the pipeline due to the inclusion of the
    // key index lookup on "name".  If there's an age of something other than 35 in the pipeline being evaluated
    // then something is wrong.
    replacedertEquals(new Long(2), g.traversal().V().has("age", P.test((t, u) -> {
        replacedertEquals(35, t);
        return true;
    }, 35)).has("name", "stephen").count().next());
    v.remove();
    replacedertEquals(new Long(1), g.traversal().V().has("age", P.test((t, u) -> {
        replacedertEquals(35, t);
        return true;
    }, 35)).has("name", "stephen").count().next());
}

19 View Complete Implementation : SparkMessenger.java
Copyright Apache License 2.0
Author : apache
public void setVertexAndIncomingMessages(final Vertex vertex, final Iterable<M> incomingMessages) {
    this.vertex = vertex;
    this.incomingMessages = incomingMessages;
    this.outgoingMessages = new ArrayList<>();
}

19 View Complete Implementation : TinkerGraphTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void shouldCloneTinkergraph() {
    final TinkerGraph original = TinkerGraph.open();
    final TinkerGraph clone = TinkerGraph.open();
    final Vertex marko = original.addVertex("name", "marko", "age", 29);
    final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
    marko.addEdge("knows", stephen);
    GraphHelper.cloneElements(original, clone);
    final Vertex michael = clone.addVertex("name", "michael");
    michael.addEdge("likes", marko);
    michael.addEdge("likes", stephen);
    clone.traversal().V().property("newProperty", "someValue").toList();
    clone.traversal().E().property("newProperty", "someValue").toList();
    replacedertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
    replacedertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
    replacedertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
    replacedertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
    replacedertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
    replacedertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
    replacedertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
    replacedertNotSame("cloned elements should reference to different objects", original.traversal().V().has("name", "stephen").next(), clone.traversal().V().has("name", "stephen").next());
}

19 View Complete Implementation : AddEdgeTest.java
Copyright Apache License 2.0
Author : apache
public abstract Traversal<Vertex, Edge> get_g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X(final Vertex a, final Vertex b);

19 View Complete Implementation : AbstractGenerator.java
Copyright Apache License 2.0
Author : apache
protected final Edge addEdge(final Vertex out, final Vertex in) {
    final Edge e = out.addEdge(label, in);
    edgeProcessor.ifPresent(c -> c.accept(e));
    return e;
}

19 View Complete Implementation : TinkerGraphTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void shouldUpdateEdgeIndicesInNewGraph() {
    final TinkerGraph g = TinkerGraph.open();
    g.createIndex("oid", Edge.clreplaced);
    final Vertex v = g.addVertex();
    v.addEdge("friend", v, "oid", "1", "weight", 0.5f);
    v.addEdge("friend", v, "oid", "2", "weight", 0.6f);
    // a tricky way to evaluate if indices are actually being used is to preplaced a fake BiPredicate to has()
    // to get into the Pipeline and evaluate what's going through it.  in this case, we know that at index
    // is used because only oid 1 should preplaced through the pipeline due to the inclusion of the
    // key index lookup on "oid".  If there's an weight of something other than 0.5f in the pipeline being
    // evaluated then something is wrong.
    replacedertEquals(new Long(1), g.traversal().E().has("weight", P.test((t, u) -> {
        replacedertEquals(0.5f, t);
        return true;
    }, 0.5)).has("oid", "1").count().next());
}

19 View Complete Implementation : DetachedVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test(expected = IllegalStateException.clreplaced)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowAddEdge() {
    final Vertex v = graph.addVertex();
    final DetachedVertex detachedVertex = DetachedFactory.detach(v, true);
    detachedVertex.addEdge("test", null);
}

18 View Complete Implementation : RepeatTest.java
Copyright Apache License 2.0
Author : apache
@Test
@LoadGraphWith(MODERN)
public void g_V_repeatXoutX_timesX2X() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_repeatXoutX_timesX2X();
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        Vertex vertex = traversal.next();
        replacedertTrue(vertex.value("name").equals("lop") || vertex.value("name").equals("ripple"));
    }
    replacedertEquals(2, counter);
    replacedertFalse(traversal.hasNext());
}

18 View Complete Implementation : GroovyTranslatorTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void shouldHandleVertexAndEdge() {
    final TinkerGraph graph = TinkerFactory.createModern();
    final GraphTraversalSource g = graph.traversal();
    // customer:10:foo bar $100#90
    final Object id1 = "customer:10:foo\u0020bar\u0020\u0024100#90";
    final Vertex vertex1 = DetachedVertex.build().setLabel("customer").setId(id1).create();
    final String script1 = GroovyTranslator.of("g").translate(g.inject(vertex1).asAdmin().getBytecode()).getScript();
    replacedertEquals("g.inject(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(" + "\"customer:10:foo bar \\$100#90\"," + "\"customer\", Collections.emptyMap()))", script1);
    replacedertThatScriptOk(script1, "g", g);
    // user:20:foo\u0020bar\u005c\u0022mr\u005c\u0022\u00241000#50
    final Object id2 = "user:20:foo\\u0020bar\\u005c\\u0022mr\\u005c\\u0022\\u00241000#50";
    final Vertex vertex2 = DetachedVertex.build().setLabel("user").setId(id2).create();
    final String script2 = GroovyTranslator.of("g").translate(g.inject(vertex2).asAdmin().getBytecode()).getScript();
    replacedertEquals("g.inject(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(" + "\"user:20:foo\\\\u0020bar\\\\u005c\\\\u0022mr\\\\u005c\\\\u0022\\\\u00241000#50\"," + "\"user\", Collections.emptyMap()))", script2);
    replacedertThatScriptOk(script2, "g", g);
    final Object id3 = "knows:30:foo\u0020bar\u0020\u0024100:\\u0020\\u0024500#70";
    final Edge edge = DetachedEdge.build().setLabel("knows").setId(id3).setOutV((DetachedVertex) vertex1).setInV((DetachedVertex) vertex2).create();
    final String script3 = GroovyTranslator.of("g").translate(g.inject(edge).asAdmin().getBytecode()).getScript();
    replacedertEquals("g.inject(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge(" + "\"knows:30:foo bar \\$100:\\\\u0020\\\\u0024500#70\"," + "\"knows\",Collections.emptyMap()," + "\"customer:10:foo bar \\$100#90\",\"customer\"," + "\"user:20:foo\\\\u0020bar\\\\u005c\\\\u0022mr\\\\u005c\\\\u0022\\\\u00241000#50\",\"user\"))", script3);
    replacedertThatScriptOk(script3, "g", g);
    final String script4 = GroovyTranslator.of("g").translate(g.addE("knows").from(vertex1).to(vertex2).property("when", "2018/09/21").asAdmin().getBytecode()).getScript();
    replacedertEquals("g.addE(\"knows\")" + ".from(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(\"customer:10:foo bar \\$100#90\",\"customer\", Collections.emptyMap()))" + ".to(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(\"user:20:foo\\\\u0020bar\\\\u005c\\\\u0022mr\\\\u005c\\\\u0022\\\\u00241000#50\",\"user\", Collections.emptyMap()))" + ".property(\"when\",\"2018/09/21\")", script4);
}

18 View Complete Implementation : ElementHelper.java
Copyright Apache License 2.0
Author : apache
/**
 * replacedign key/value pairs as properties to an {@link Vertex}.  If the value of {@link T#id} or {@link T#label} is
 * in the set of pairs, then they are ignored. The {@link VertexProperty.Cardinality} of the key is determined from
 * the {@link Graph.Features.VertexFeatures}.
 *
 * @param vertex            the graph vertex to replacedign the {@code propertyKeyValues}
 * @param propertyKeyValues the key/value pairs to replacedign to the {@code element}
 * @throws ClreplacedCastException       if the value of the key is not a {@link String}
 * @throws IllegalArgumentException if the value of {@code element} is null
 */
public static void attachProperties(final Vertex vertex, final Object... propertyKeyValues) {
    if (null == vertex)
        throw Graph.Exceptions.argumentCanNotBeNull("vertex");
    final boolean allowNullPropertyValues = vertex.graph().features().vertex().supportsNullPropertyValues();
    for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
        if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label))
            if (!allowNullPropertyValues && null == propertyKeyValues[i + 1])
                vertex.properties(((String) propertyKeyValues[i])).forEachRemaining(VertexProperty::remove);
            else
                vertex.property(vertex.graph().features().vertex().getCardinality((String) propertyKeyValues[i]), (String) propertyKeyValues[i], propertyKeyValues[i + 1]);
    }
}

18 View Complete Implementation : PartitionStrategyProcessTest.java
Copyright Apache License 2.0
Author : apache
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexFeatures.clreplaced, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
public void shouldNotAppendParreplacedionToVertexProperty() {
    final ParreplacedionStrategy parreplacedionStrategy = ParreplacedionStrategy.build().includeMetaProperties(false).parreplacedionKey(parreplacedion).writeParreplacedion("A").readParreplacedions("A").create();
    final Vertex v = g.withStrategies(parreplacedionStrategy).addV().property("any", "thing").next();
    replacedertNotNull(v);
    replacedertEquals("thing", g.V(v).values("any").next());
    replacedertEquals("A", g.V(v).values(parreplacedion).next());
    replacedertThat(g.V(v).properties("any").properties().hasNext(), is(false));
}

18 View Complete Implementation : GryoReader.java
Copyright Apache License 2.0
Author : apache
private Vertex readVertexInternal(final Function<Attachable<Vertex>, Vertex> vertexMaker, final Function<Attachable<Edge>, Edge> edgeMaker, final Direction d, final Input input) throws IOException {
    readHeader(input);
    final StarGraph starGraph = kryo.readObject(input, StarGraph.clreplaced);
    // read the terminator
    kryo.readClreplacedAndObject(input);
    final Vertex v = vertexMaker.apply(starGraph.getStarVertex());
    if (edgeMaker != null)
        starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable<Edge>) e));
    return v;
}

18 View Complete Implementation : IoVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test
@FeatureRequirement(featureClreplaced = Graph.Features.EdgeFeatures.clreplaced, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexFeatures.clreplaced, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexPropertyFeatures.clreplaced, feature = FEATURE_STRING_VALUES)
@FeatureRequirement(featureClreplaced = Graph.Features.EdgePropertyFeatures.clreplaced, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldReadWriteVertexNoEdges() throws Exception {
    final Vertex v1 = graph.addVertex("name", "marko", "acl", "rw");
    final Vertex v2 = graph.addVertex();
    v1.addEdge("friends", v2, "weight", 0.5d);
    replacedertVertexToSerialize(v1, true);
}

18 View Complete Implementation : ElementHelper.java
Copyright Apache License 2.0
Author : apache
/**
 * replacedign key/value pairs as properties to a {@link Vertex}. If the value of {@link T#id} or {@link T#label} is
 * in the set of pairs, then they are ignored.
 *
 * @param vertex            the vertex to attach the properties to
 * @param cardinality       the cardinality of the key value pair settings
 * @param propertyKeyValues the key/value pairs to replacedign to the {@code element}
 * @throws ClreplacedCastException       if the value of the key is not a {@link String}
 * @throws IllegalArgumentException if the value of {@code element} is null
 */
public static void attachProperties(final Vertex vertex, final VertexProperty.Cardinality cardinality, final Object... propertyKeyValues) {
    if (null == vertex)
        throw Graph.Exceptions.argumentCanNotBeNull("vertex");
    final boolean allowNullPropertyValues = vertex.graph().features().vertex().supportsNullPropertyValues();
    for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
        if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label))
            if (!allowNullPropertyValues && null == propertyKeyValues[i + 1])
                vertex.properties(((String) propertyKeyValues[i])).forEachRemaining(VertexProperty::remove);
            else
                vertex.property(cardinality, (String) propertyKeyValues[i], propertyKeyValues[i + 1]);
    }
}

18 View Complete Implementation : DetachedVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldConstructDetachedVertex() {
    final Vertex v = graph.addVertex("test", "123");
    final DetachedVertex detachedVertex = DetachedFactory.detach(v, true);
    replacedertEquals(v.id(), detachedVertex.id());
    replacedertEquals(v.label(), detachedVertex.label());
    replacedertEquals("123", detachedVertex.value("test"));
    replacedertEquals(1, IteratorUtils.count(detachedVertex.properties()));
}

18 View Complete Implementation : IoVertexTest.java
Copyright Apache License 2.0
Author : apache
@Test
@FeatureRequirement(featureClreplaced = Graph.Features.EdgeFeatures.clreplaced, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexFeatures.clreplaced, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexPropertyFeatures.clreplaced, feature = FEATURE_STRING_VALUES)
@FeatureRequirement(featureClreplaced = Graph.Features.EdgePropertyFeatures.clreplaced, 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);
    replacedertVertexToSerialize(DetachedFactory.detach(v1, true), true);
}

18 View Complete Implementation : TinkerFactory.java
Copyright Apache License 2.0
Author : apache
/**
 * Generate the graph in {@link #createModern()} into an existing graph.
 */
public static void generateModern(final TinkerGraph g) {
    final Vertex marko = g.addVertex(T.id, 1, T.label, "person", "name", "marko", "age", 29);
    final Vertex vadas = g.addVertex(T.id, 2, T.label, "person", "name", "vadas", "age", 27);
    final Vertex lop = g.addVertex(T.id, 3, T.label, "software", "name", "lop", "lang", "java");
    final Vertex josh = g.addVertex(T.id, 4, T.label, "person", "name", "josh", "age", 32);
    final Vertex ripple = g.addVertex(T.id, 5, T.label, "software", "name", "ripple", "lang", "java");
    final Vertex peter = g.addVertex(T.id, 6, T.label, "person", "name", "peter", "age", 35);
    marko.addEdge("knows", vadas, T.id, 7, "weight", 0.5d);
    marko.addEdge("knows", josh, T.id, 8, "weight", 1.0d);
    marko.addEdge("created", lop, T.id, 9, "weight", 0.4d);
    josh.addEdge("created", ripple, T.id, 10, "weight", 1.0d);
    josh.addEdge("created", lop, T.id, 11, "weight", 0.4d);
    peter.addEdge("created", lop, T.id, 12, "weight", 0.2d);
}

18 View Complete Implementation : GraphSONWriter.java
Copyright Apache License 2.0
Author : apache
/**
 * Writes a single {@link Vertex} with no edges serialized.
 *
 * @param outputStream the stream to write to.
 * @param v            the vertex to write.
 */
@Override
public void writeVertex(final OutputStream outputStream, final Vertex v) throws IOException {
    writeVertex(outputStream, v, null);
}

18 View Complete Implementation : PartitionStrategyProcessTest.java
Copyright Apache License 2.0
Author : apache
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClreplaced = Graph.Features.VertexFeatures.clreplaced, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
public void shouldAppendParreplacedionToVertexProperty() {
    final ParreplacedionStrategy parreplacedionStrategy = ParreplacedionStrategy.build().includeMetaProperties(true).parreplacedionKey(parreplacedion).writeParreplacedion("A").readParreplacedions("A").create();
    final Vertex v = g.withStrategies(parreplacedionStrategy).addV().property("any", "thing").next();
    replacedertNotNull(v);
    replacedertEquals("thing", g.V(v).values("any").next());
    replacedertEquals("A", g.V(v).values(parreplacedion).next());
}