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();
}
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();
}
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);
}
}
}
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);
}
}
}
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);
}
Aggregations