use of com.thinkaurelius.titan.core.schema.TitanManagement in project titan by thinkaurelius.
the class AbstractTitanGraphProvider method createIndices.
private void createIndices(final TitanGraph g, final LoadGraphWith.GraphData graphData) {
TitanManagement mgmt = g.openManagement();
if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) {
VertexLabel artist = mgmt.makeVertexLabel("artist").make();
VertexLabel song = mgmt.makeVertexLabel("song").make();
PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey songType = mgmt.makePropertyKey("songType").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey performances = mgmt.makePropertyKey("performances").cardinality(Cardinality.LIST).dataType(Integer.class).make();
mgmt.buildIndex("artistByName", Vertex.class).addKey(name).indexOnly(artist).buildCompositeIndex();
mgmt.buildIndex("songByName", Vertex.class).addKey(name).indexOnly(song).buildCompositeIndex();
mgmt.buildIndex("songByType", Vertex.class).addKey(songType).indexOnly(song).buildCompositeIndex();
mgmt.buildIndex("songByPerformances", Vertex.class).addKey(performances).indexOnly(song).buildCompositeIndex();
} else if (graphData.equals(LoadGraphWith.GraphData.MODERN)) {
VertexLabel person = mgmt.makeVertexLabel("person").make();
VertexLabel software = mgmt.makeVertexLabel("software").make();
PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey lang = mgmt.makePropertyKey("lang").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey age = mgmt.makePropertyKey("age").cardinality(Cardinality.LIST).dataType(Integer.class).make();
mgmt.buildIndex("personByName", Vertex.class).addKey(name).indexOnly(person).buildCompositeIndex();
mgmt.buildIndex("softwareByName", Vertex.class).addKey(name).indexOnly(software).buildCompositeIndex();
mgmt.buildIndex("personByAge", Vertex.class).addKey(age).indexOnly(person).buildCompositeIndex();
mgmt.buildIndex("softwareByLang", Vertex.class).addKey(lang).indexOnly(software).buildCompositeIndex();
} else if (graphData.equals(LoadGraphWith.GraphData.CLASSIC)) {
PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey lang = mgmt.makePropertyKey("lang").cardinality(Cardinality.LIST).dataType(String.class).make();
PropertyKey age = mgmt.makePropertyKey("age").cardinality(Cardinality.LIST).dataType(Integer.class).make();
mgmt.buildIndex("byName", Vertex.class).addKey(name).buildCompositeIndex();
mgmt.buildIndex("byAge", Vertex.class).addKey(age).buildCompositeIndex();
mgmt.buildIndex("byLang", Vertex.class).addKey(lang).buildCompositeIndex();
} else {
// TODO: add CREW work here.
// TODO: add meta_property indices when meta_property graph is provided
//throw new RuntimeException("Could not load graph with " + graphData);
}
mgmt.commit();
}
Aggregations