use of org.janusgraph.core.schema.JanusGraphManagement in project atlas by apache.
the class AtlasJanusGraph method getIndexKeys.
private Set<String> getIndexKeys(Class<? extends Element> janusGraphElementClass) {
JanusGraphManagement mgmt = getGraph().openManagement();
Iterable<JanusGraphIndex> indices = mgmt.getGraphIndexes(janusGraphElementClass);
Set<String> result = new HashSet<String>();
for (JanusGraphIndex index : indices) {
result.add(index.name());
}
mgmt.commit();
return result;
}
use of org.janusgraph.core.schema.JanusGraphManagement in project atlas by apache.
the class AtlasJanusGraphDatabase method updateGlobalConfiguration.
private static void updateGlobalConfiguration(Map<String, Object> map) {
JanusGraph graph = null;
JanusGraphManagement managementSystem = null;
try {
graph = initJanusGraph(getConfiguration());
managementSystem = graph.openManagement();
for (Map.Entry<String, Object> entry : map.entrySet()) {
managementSystem.set(entry.getKey(), entry.getValue());
}
LOG.info("Global properties updated!: {}", map);
} catch (Exception ex) {
LOG.error("Error updating global configuration: {}", map, ex);
} finally {
if (managementSystem != null) {
managementSystem.commit();
}
if (graph != null) {
graph.close();
}
}
}
use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.
the class JanusGraphIndexTest method testOrForceIndexMixedAndCompositeIndex.
@Test
public void testOrForceIndexMixedAndCompositeIndex() 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("nameidx", Vertex.class).addKey(nameProperty, getStringMapping()).buildMixedIndex(INDEX);
management.buildIndex("ageridx", Vertex.class).addKey(ageProperty).buildCompositeIndex();
management.buildIndex("lengthidx", Vertex.class).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 AbstractJanusGraphProvider method loadGraphData.
@Override
public void loadGraphData(final Graph g, final LoadGraphWith loadGraphWith, final Class testClass, final String testName) {
if (loadGraphWith != null) {
this.createIndices((JanusGraph) g, loadGraphWith.value());
} else {
if (TransactionTest.class.equals(testClass) && testName.equalsIgnoreCase("shouldExecuteWithCompetingThreads")) {
JanusGraphManagement management = ((JanusGraph) g).openManagement();
management.makePropertyKey("blah").dataType(Double.class).make();
management.makePropertyKey("bloop").dataType(Integer.class).make();
management.makePropertyKey("test").dataType(Object.class).make();
management.makeEdgeLabel("friend").make();
management.commit();
}
}
super.loadGraphData(g, loadGraphWith, testClass, testName);
}
use of org.janusgraph.core.schema.JanusGraphManagement in project janusgraph by JanusGraph.
the class MgmtOlapJobBenchmark method runReindex.
@Benchmark
public void runReindex(Blackhole blackhole) throws ExecutionException, InterruptedException {
JanusGraphManagement mgmt = graph.openManagement();
blackhole.consume(mgmt.updateIndex(mgmt.getGraphIndex("aliasIndex"), SchemaAction.REINDEX).get());
mgmt.commit();
}
Aggregations