use of org.janusgraph.core.schema.EdgeLabelMaker in project janusgraph by JanusGraph.
the class JanusGraphGrpcServerBaseTest method createEdgeLabel.
public long createEdgeLabel(String graph, EdgeLabelOrBuilder edgeLabel) {
JanusGraphManagement management = ((JanusGraph) graphManager.getGraph(graph)).openManagement();
EdgeLabelMaker edgeLabelMaker = management.makeEdgeLabel(edgeLabel.getName());
if (edgeLabel.getDirection() == EdgeLabel.Direction.BOTH) {
edgeLabelMaker.directed();
} else {
edgeLabelMaker.unidirected();
}
edgeLabelMaker.multiplicity(GrpcUtils.convertGrpcEdgeMultiplicity(edgeLabel.getMultiplicity()));
org.janusgraph.core.EdgeLabel createdEdgeLabel = edgeLabelMaker.make();
management.commit();
return createdEdgeLabel.longId();
}
use of org.janusgraph.core.schema.EdgeLabelMaker in project janusgraph by JanusGraph.
the class JanusGraphConcurrentTest method concurrentTxRead.
@RepeatedTest(10)
public void concurrentTxRead() throws Exception {
final int numTypes = 20;
final int numThreads = 100;
for (int i = 0; i < numTypes / 2; i++) {
if (i % 4 == 0)
makeVertexIndexedUniqueKey("test" + i, String.class);
else
makeKey("test" + i, String.class);
}
for (int i = numTypes / 2; i < numTypes; i++) {
EdgeLabelMaker tm = mgmt.makeEdgeLabel("test" + i);
if (i % 4 == 1)
tm.unidirected();
tm.make();
}
finishSchema();
clopen();
Thread[] threads = new Thread[numThreads];
for (int t = 0; t < numThreads; t++) {
threads[t] = new Thread(() -> {
JanusGraphTransaction tx = graph.newTransaction();
for (int i = 0; i < numTypes; i++) {
RelationType type = tx.getRelationType("test" + i);
if (i < numTypes / 2)
assertTrue(type.isPropertyKey());
else
assertTrue(type.isEdgeLabel());
}
tx.commit();
});
threads[t].start();
}
for (int t = 0; t < numThreads; t++) {
threads[t].join();
}
}
Aggregations