Search in sources :

Example 1 with EdgeLabelMaker

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();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) JanusGraph(org.janusgraph.core.JanusGraph) EdgeLabelMaker(org.janusgraph.core.schema.EdgeLabelMaker)

Example 2 with EdgeLabelMaker

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();
    }
}
Also used : JanusGraphTransaction(org.janusgraph.core.JanusGraphTransaction) RelationType(org.janusgraph.core.RelationType) EdgeLabelMaker(org.janusgraph.core.schema.EdgeLabelMaker) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Aggregations

EdgeLabelMaker (org.janusgraph.core.schema.EdgeLabelMaker)2 JanusGraph (org.janusgraph.core.JanusGraph)1 JanusGraphTransaction (org.janusgraph.core.JanusGraphTransaction)1 RelationType (org.janusgraph.core.RelationType)1 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1