Search in sources :

Example 51 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.

the class MgmtOlapJobBenchmark method runRemoveIndex.

@Benchmark
public void runRemoveIndex(Blackhole blackhole) throws ExecutionException, InterruptedException {
    JanusGraphManagement mgmt = graph.openManagement();
    blackhole.consume(mgmt.updateIndex(mgmt.getGraphIndex("nameIndex"), SchemaAction.REMOVE_INDEX).get());
    mgmt.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 52 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.

the class MgmtOlapJobBenchmark method setUp.

@Setup(Level.Iteration)
public void setUp() throws Exception {
    graph = JanusGraphFactory.open(getConfiguration());
    JanusGraphManagement mgmt = graph.openManagement();
    PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
    mgmt.buildIndex("nameIndex", Vertex.class).addKey(name).buildCompositeIndex();
    mgmt.commit();
    ManagementSystem.awaitGraphIndexStatus(graph, "nameIndex").call();
    for (int j = 0; j < size; j++) {
        graph.addVertex("name", "value" + j, "alias", "value" + j);
    }
    graph.tx().commit();
    mgmt = graph.openManagement();
    mgmt.buildIndex("aliasIndex", Vertex.class).addKey(mgmt.getPropertyKey("alias")).buildCompositeIndex();
    mgmt.commit();
    ManagementSystem.awaitGraphIndexStatus(graph, "aliasIndex").call();
    mgmt = graph.openManagement();
    mgmt.updateIndex(mgmt.getGraphIndex("nameIndex"), SchemaAction.DISABLE_INDEX).get();
    mgmt.commit();
    ManagementSystem.awaitGraphIndexStatus(graph, "nameIndex").call();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) PropertyKey(org.janusgraph.core.PropertyKey) Setup(org.openjdk.jmh.annotations.Setup)

Example 53 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.

the class JanusGraphIndexTest method testAndForceIndex.

@Test
public void testAndForceIndex() throws Exception {
    JanusGraph customGraph = null;
    try {
        customGraph = this.getForceIndexGraph();
        final JanusGraphManagement management = customGraph.openManagement();
        final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        management.buildIndex("oridx", Vertex.class).addKey(nameProperty, getStringMapping()).addKey(ageProperty).buildMixedIndex(INDEX);
        management.commit();
        customGraph.tx().commit();
        final GraphTraversalSource g = customGraph.traversal();
        g.addV().property("name", "Hiro").property("age", 2).next();
        g.addV().property("name", "Totoro").property("age", 1).next();
        customGraph.tx().commit();
        assertCount(1, g.V().has("name", "Totoro"));
        assertCount(1, g.V().has("age", 2));
        assertCount(1, g.V().and(__.has("name", "Hiro"), __.has("age", 2)));
        assertCount(0, g.V().and(__.has("name", "Totoro"), __.has("age", 2)));
    } finally {
        if (customGraph != null) {
            JanusGraphFactory.close(customGraph);
        }
    }
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraph(org.janusgraph.core.JanusGraph) PropertyKey(org.janusgraph.core.PropertyKey) RepeatedIfExceptionsTest(io.github.artsok.RepeatedIfExceptionsTest) Test(org.junit.jupiter.api.Test)

Example 54 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.

the class JanusGraphIndexTest method testOrForceIndexUniqueMixedIndex.

@Test
public void testOrForceIndexUniqueMixedIndex() throws Exception {
    JanusGraph customGraph = null;
    try {
        customGraph = this.getForceIndexGraph();
        final JanusGraphManagement management = customGraph.openManagement();
        final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        final PropertyKey lengthProperty = management.makePropertyKey("length").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        management.buildIndex("oridx", Vertex.class).addKey(nameProperty, getStringMapping()).addKey(ageProperty).addKey(lengthProperty).buildMixedIndex(INDEX);
        management.commit();
        customGraph.tx().commit();
        testOr(customGraph);
    } finally {
        if (customGraph != null) {
            JanusGraphFactory.close(customGraph);
        }
    }
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) JanusGraph(org.janusgraph.core.JanusGraph) PropertyKey(org.janusgraph.core.PropertyKey) RepeatedIfExceptionsTest(io.github.artsok.RepeatedIfExceptionsTest) Test(org.junit.jupiter.api.Test)

Example 55 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.

the class JanusGraphIndexTest method testIndexDataRetrievalWithLimitLessThenBatch.

@Test
public void testIndexDataRetrievalWithLimitLessThenBatch() throws Exception {
    WriteConfiguration config = getConfiguration();
    config.set("index.search.max-result-set-size", 10);
    JanusGraph customGraph = getForceIndexGraph(config);
    final JanusGraphManagement management = customGraph.openManagement();
    final PropertyKey num = management.makePropertyKey("num").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
    management.buildIndex("oridx", Vertex.class).addKey(num).buildMixedIndex(INDEX);
    management.commit();
    customGraph.tx().commit();
    final GraphTraversalSource g = customGraph.traversal();
    g.addV().property("num", 1).next();
    g.addV().property("num", 2).next();
    customGraph.tx().commit();
    assertEquals(2, customGraph.traversal().V().has("num", P.lt(3)).limit(4).toList().size());
    JanusGraphFactory.close(customGraph);
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraph(org.janusgraph.core.JanusGraph) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) PropertyKey(org.janusgraph.core.PropertyKey) RepeatedIfExceptionsTest(io.github.artsok.RepeatedIfExceptionsTest) Test(org.junit.jupiter.api.Test)

Aggregations

JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)92 PropertyKey (org.janusgraph.core.PropertyKey)44 Test (org.junit.jupiter.api.Test)26 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)24 JanusGraph (org.janusgraph.core.JanusGraph)23 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)20 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)17 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)12 HashMap (java.util.HashMap)9 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)9 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)8 Test (org.junit.Test)8 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)8 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)8 JanusGraphBaseTest (org.janusgraph.graphdb.JanusGraphBaseTest)7 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)6 EdgeLabel (org.janusgraph.core.EdgeLabel)6 Map (java.util.Map)5 JanusGraphException (org.janusgraph.core.JanusGraphException)5