Is there a way to truncate a graph using Java?
Got this from Jonathan:
https://docs.datastax.com/en/developer/java-driver-dse/1.8/manual/graph/querying/graph_options/
You can run system queries by building a SimpleGraphStatement with the query as a string:
GraphStatement s = new SimpleGraphStatement("system.graph('demo').ifExists().truncate()")
.setSystemQuery();
dseSession.executeGraph(s);
Ah ha! So they have an unpublished truncate method. I'm going to have to try that out.
I wonder what else is hidden on `system.graph()`.
Thanks for sharing.
truncate is a feature of the labs preview version. You won't find it in 6.7 or earlier.
It looks like I can get this effect doing g.V().drop(). Does truncate do more?
it turns out using g.V().drop() with a large enough graph cannot complete. the max-mutations may be exceeded. Using .with("max-mutations", N) can only go as high as the largest integer which may not be large enough to adequately drop all the vertices in a large graph.
Sean, that's what I do. I've got it coded a few different ways.
In my integration tests class, I first make sure that allow_scan is enabled and then run g.V().drop().iterate().
I have a data loader code that uses DSE Analytics with the Java API (and let me tell you, coding Spark with Java is a pain, but I'm in a Java-only shop and Scala wouldn't fly here.). It too uses g.V().drop().iterate(), but it seems to take a long time even with graphs that are just a few GB of data.
I suspect that there's some bookkeeping that DSE Graph is wanting to do in the background which prevent it from just doing a TRUNCATE TABLE operation on each table.
5 People are following this question.
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2023 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use