gremlincassandra-3.0janusgraphjava-17drop

Why Does Limit-OF-1 Not Record-Drop 1 Vertex?


In JanusGraph-Java, how can you limit dropping vertex records?

Here's what the logs show:

  1. drop().iterate() does work for a small number
  2. limit(1).drop() does nothing
  3. drop().limit(1) does nothing
  4. drop().limit(1).iterate() drops everything
  5. drop().iterate().limit(1) blows-up
2023-05-11 10:04:13,530 [INFO] [c.d.o.d.i.c.ContactPoints.main] ::   Contact point localhost:29042 resolves to multiple addresses, will use them all ([localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1])
2023-05-11 10:04:13,624 [INFO] [c.d.o.d.i.c.DefaultMavenCoordinates.main] ::     DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.15.0
2023-05-11 10:04:14,190 [INFO] [c.d.o.d.i.c.t.Clock.JanusGraph Session-admin-0] ::   Using native clock for microsecond precision
2023-05-11 10:04:14,468 [WARN] [c.d.o.d.i.c.l.h.OptionalLocalDcHelper.JanusGraph Session-admin-0] ::     [JanusGraph Session|default] You specified datacenter1 as the local DC, but some contact points are from a different DC: Node(endPoint=localhost/[0:0:0:0:0:0:0:1]:29042, hostId=null, hashCode=ca3ba3b)=null; please provide the correct local DC, or check your contact points
2023-05-11 10:04:14,752 [INFO] [o.j.g.i.UniqueInstanceIdRetriever.main] ::   Generated unique-instance-id=c0a8563c18304-rmt-lap-win201
2023-05-11 10:04:14,772 [INFO] [c.d.o.d.i.c.ContactPoints.main] ::   Contact point localhost:29042 resolves to multiple addresses, will use them all ([localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1])
2023-05-11 10:04:14,810 [INFO] [c.d.o.d.i.c.t.Clock.JanusGraph Session-admin-0] ::   Using native clock for microsecond precision
2023-05-11 10:04:14,861 [WARN] [c.d.o.d.i.c.l.h.OptionalLocalDcHelper.JanusGraph Session-admin-0] ::     [JanusGraph Session|default] You specified datacenter1 as the local DC, but some contact points are from a different DC: Node(endPoint=localhost/[0:0:0:0:0:0:0:1]:29042, hostId=null, hashCode=52fbe4d2)=null; please provide the correct local DC, or check your contact points
2023-05-11 10:04:14,884 [INFO] [o.j.d.c.ExecutorServiceBuilder.main] ::  Initiated fixed thread pool of size 40
2023-05-11 10:04:15,023 [INFO] [o.j.g.d.StandardJanusGraph.main] ::  Gremlin script evaluation is disabled
2023-05-11 10:04:15,052 [INFO] [o.j.d.l.k.KCVSLog.main] ::   Loaded unidentified ReadMarker start time 2023-05-11T15:04:15.052014Z into org.janusgraph.diskstorage.log.kcvs.KCVSLog$MessagePuller@f1d0004
2023-05-11 10:04:15,111 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:15,126 [INFO] [Main.main] ::    g.V().count().next():  0
2023-05-11 10:04:16,681 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:16,688 [INFO] [Main.main] ::    g.V().count().next():  2
2023-05-11 10:04:16,692 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:16,853 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:16,856 [INFO] [Main.main] ::    g.V().count().next():  0
2023-05-11 10:04:18,277 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:18,283 [INFO] [Main.main] ::    g.V().count().next():  2
2023-05-11 10:04:18,285 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:18,290 [INFO] [Main.main] ::    g.V().count().next():  2
2023-05-11 10:04:18,292 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:18,298 [INFO] [Main.main] ::    g.V().count().next():  2
2023-05-11 10:04:18,299 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:18,441 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
2023-05-11 10:04:18,444 [INFO] [Main.main] ::    g.V().count().next():  0
2023-05-11 10:04:18,445 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::    Query requires iterating over all vertices [[]]. For better performance, use indexes
Exception in thread "main" java.lang.IllegalStateException: The traversal strategies are complete and the traversal can no longer be modulated
    at org.apache.tinkerpop.gremlin.process.traversal.Traversal$Exceptions.traversalIsLocked(Traversal.java:316)
    at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.addStep(DefaultTraversal.java:374)
    at org.apache.tinkerpop.gremlin.process.traversal.Traversal$Admin.addStep(Traversal.java:372)
    at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal$Admin.addStep(GraphTraversal.java:197)
    at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.limit(GraphTraversal.java:2046)
    at Test8.main(Test8.java:30)

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraphVertex;

public class Test8 {
    private static final Logger logger = LogManager.getLogger(Main.class);
    public static void main(String[] args) {
        JanusGraph janusGraph = JanusGraphFactory.build().set("storage.backend", "cql").set("storage.hostname", "localhost:29042").open();
        GraphTraversalSource g = janusGraph.traversal();
        logger.info("g.V().count().next():\t" + g.V().count().next());
        createVertexes(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        g.V().drop().iterate();
        commitAndOpenJanusgraph(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        createVertexes(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        g.V().limit(1).drop();
        commitAndOpenJanusgraph(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        g.V().drop().limit(1);
        commitAndOpenJanusgraph(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        g.V().drop().limit(1).iterate();
        commitAndOpenJanusgraph(janusGraph);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        g.V().drop().iterate().limit(1);
        logger.info("g.V().count().next():\t" + g.V().count().next());
        janusGraph.close();
    }

    private static void createVertexes(JanusGraph janusGraph) {
        JanusGraphVertex janusGraphVertex = janusGraph.addVertex();
        janusGraphVertex.property("test", "test1");
        janusGraphVertex = janusGraph.addVertex();
        janusGraphVertex.property("test", "test2");
        commitAndOpenJanusgraph(janusGraph);
    }

    private static void commitAndOpenJanusgraph(JanusGraph janusGraph) {
        janusGraph.tx().commit();
        janusGraph.tx().open();
    }
}

Solution

  • Just needed to spell it out a few different ways here.

    Answer:

    g.V().limit(1).drop().iterate();
    

    @Hadoopmarc and I both ended up coming to same conclusion.