use of org.janusgraph.core.Namifiable in project grakn by graknlabs.
the class TxFactoryJanus method makeIndicesVertexCentric.
private static void makeIndicesVertexCentric(JanusGraphManagement management) {
ResourceBundle keys = ResourceBundle.getBundle("indices-edges");
Set<String> edgeLabels = keys.keySet();
for (String edgeLabel : edgeLabels) {
String[] propertyKeyStrings = keys.getString(edgeLabel).split(",");
// Get all the property keys we need
Set<PropertyKey> propertyKeys = stream(propertyKeyStrings).map(keyId -> {
PropertyKey key = management.getPropertyKey(keyId);
if (key == null) {
throw new RuntimeException("Trying to create edge index on label [" + edgeLabel + "] but the property [" + keyId + "] does not exist");
}
return key;
}).collect(Collectors.toSet());
// Get the edge and indexing information
RelationType relationType = management.getRelationType(edgeLabel);
EdgeLabel label = management.getEdgeLabel(edgeLabel);
// Create index on each property key
for (PropertyKey key : propertyKeys) {
if (management.getRelationIndex(relationType, edgeLabel + "by" + key.name()) == null) {
management.buildEdgeIndex(label, edgeLabel + "by" + key.name(), Direction.BOTH, Order.decr, key);
}
}
// Create index on all property keys
String propertyKeyId = propertyKeys.stream().map(Namifiable::name).collect(Collectors.joining("_"));
if (management.getRelationIndex(relationType, edgeLabel + "by" + propertyKeyId) == null) {
PropertyKey[] allKeys = propertyKeys.toArray(new PropertyKey[propertyKeys.size()]);
management.buildEdgeIndex(label, edgeLabel + "by" + propertyKeyId, Direction.BOTH, Order.decr, allKeys);
}
}
}
Aggregations