I tried these 2 properties and found that consequence in-memory
JanusGraph creation depends on the previous one.
The JanusGraph was created with options:
JanusGraphFactory.Builder builder = JanusGraphFactory.build()
.set("storage.backend", "inmemory")
.set("ids.authority.wait-time", "5")
.set("ids.renew-timeout", "50")
.set("ids.block-size", "1000000000")
.set("ids.renew-percentage", "0.3");
if (customIds) {
builder = builder.set("graph.set-vertex-id", "true");
}
If I first run creating vertices with generated ids and then custom ids
I got:
[generated ids] vertices: 1000, elapsed time: 1255(ms), graph
creation time: 593
[custom ids] vertices: 1000, elapsed time: 255(ms), graph creation
time: 4
The method with generated ids takes about 1 sec and the graph creation
takes about 600ms.
If I first run creating vertices with custom ids I got:
[custom ids] vertices: 1000, elapsed time: 1125(ms), graph creation
time: 590
[generated ids] vertices: 1000, elapsed time: 401(ms), graph creation
time: 3
The method with custom ids takes about 1sec and graph creation takes
about 600ms.
If I run only one of them then each takes about 1 sec and graph creation
takes about 600ms.
Here is the full code that I used:
----------- JanusGraphSample.java -----------------
import
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.T;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraphTransaction;
import org.janusgraph.graphdb.database.StandardJanusGraph;
import org.janusgraph.graphdb.idmanagement.IDManager;
public class JanusGraphSample {
private static final String LABEL = "SampleLabel";
private static final String KEY = "SampleKey";
private static final String VALUE = "SampleValue";
private static final int N = 1000;
public static void main(String[] args) {
addVerticesWithGeneratedIds();
addVerticesWithCustomIds();
}
private static JanusGraph getJanusGraph(boolean customIds) {
JanusGraphFactory.Builder builder = JanusGraphFactory.build()
.set("storage.backend", "inmemory")
.set("ids.authority.wait-time", "5")
.set("ids.renew-timeout", "50")
.set("ids.block-size", "1000000000")
.set("ids.renew-percentage", "0.3");
if (customIds) {
builder = builder.set("graph.set-vertex-id", "true");
}
return builder.open();
}
static long verticesCount(JanusGraph graph) {
try (JanusGraphTransaction tx = graph.newTransaction()) {
GraphTraversalSource g = tx.traversal();
return g.V().count().next();
}
}
public static void addVerticesWithGeneratedIds() {
long time = System.currentTimeMillis();
try (JanusGraph graph = getJanusGraph(false)) {
long creationTime = System.currentTimeMillis();
try (JanusGraphTransaction tx = graph.newTransaction()) {
GraphTraversalSource g = tx.traversal();
for (int i = 1; i <= N; i++) {
String value = String.format("%s-%d", VALUE, i);
g.addV(LABEL).property(KEY, value).next();
}
tx.commit();
}
long elapsedTime = System.currentTimeMillis();
long vertices = verticesCount(graph);
System.out.printf("[generated ids] vertices: %d, elapsed
time: %d(ms), graph creation time: %d%n", vertices, elapsedTime - time,
creationTime - time);
}
}
public static void addVerticesWithCustomIds() {
long time = System.currentTimeMillis();
try (JanusGraph graph = getJanusGraph(true)) {
long creationTime = System.currentTimeMillis();
IDManager idManager = ((StandardJanusGraph)
graph).getIDManager();
try (JanusGraphTransaction tx = graph.newTransaction()) {
GraphTraversalSource g = tx.traversal();
for (int i = 1; i <= N; i++) {
long id = idManager.toVertexId(i);
String value = String.format("%s-%d", VALUE, i);
g.addV(LABEL).property(T.id, id).property(KEY,
value).next();
}
tx.commit();
}
long elapsedTime = System.currentTimeMillis();
long vertices = verticesCount(graph);
System.out.printf("[custom ids] vertices: %d, elapsed time:
%d(ms), graph creation time: %d%n", vertices, elapsedTime - time,
creationTime - time);
}
}
}
----------------------------------------------------
Thanks,
Alexander.
> >
stell...@gmail.com <mailto:
stell...@gmail.com> написал:
> <
http://org.apache.commons.io>.FileUtils;
> <mailto:
janusgraph-users%2Bunsu...@googlegroups.com>
> > <mailto:
janusgraph-use...@googlegroups.com
> <mailto:
janusgraph-users%2Bunsu...@googlegroups.com>>.
> <mailto:
janusgraph-users%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/janusgraph-users/51caccd9-8364-cb9f-0610-ee4ae11bbd73%40gmail.com.
>
>
>
> --
> Thanks
> Akhilesh
>
> --
> You received this message because you are subscribed to the Google
> Groups "JanusGraph users" group.
> To unsubscribe from this group and stop receiving emails from it, send
>
https://groups.google.com/d/msgid/janusgraph-users/CAN8C252-EFtR5pff%3Dapg8s2Y%2BDB98Quj08PbBaTo5SoTOsOn9Q%40mail.gmail.com
> <
https://groups.google.com/d/msgid/janusgraph-users/CAN8C252-EFtR5pff%3Dapg8s2Y%2BDB98Quj08PbBaTo5SoTOsOn9Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.