本文整理汇总了Java中org.janusgraph.core.EdgeLabel类的典型用法代码示例。如果您正苦于以下问题:Java EdgeLabel类的具体用法?Java EdgeLabel怎么用?Java EdgeLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdgeLabel类属于org.janusgraph.core包,在下文中一共展示了EdgeLabel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWeightIndex
import org.janusgraph.core.EdgeLabel; //导入依赖的package包/类
/**
* Create both <i>posts</i> and <i>follows</i> edges and related index.
* <br/>
*
* Because the property and index for both follows and posts is the same we create them at the same point here.
*/
private void createWeightIndex() {
LOGGER.info("create weight index");
EdgeLabel follows = mgt.getEdgeLabel(Schema.FOLLOWS);
PropertyKey weight = mgt.makePropertyKey(WEIGHT).dataType(Float.class).make();
mgt.buildIndex(Schema.indexName(Schema.FOLLOWS, WEIGHT), Edge.class).
addKey(weight).
indexOnly(follows).
buildMixedIndex(Schema.BACKING_INDEX);
}
示例2: makeEdgeLabels
import org.janusgraph.core.EdgeLabel; //导入依赖的package包/类
private static void makeEdgeLabels(JanusGraphManagement management){
for (Schema.EdgeLabel edgeLabel : Schema.EdgeLabel.values()) {
EdgeLabel label = management.getEdgeLabel(edgeLabel.getLabel());
if(label == null) {
management.makeEdgeLabel(edgeLabel.getLabel()).make();
}
}
}
示例3: makeVCIndex
import org.janusgraph.core.EdgeLabel; //导入依赖的package包/类
/**
* Create vertex-centric index
*
* {
* "name": "indexName",
* "edge": "edgeLebel",
* "propertyKeys": [ "propertyKey1", "propertyKey2" ],
* "order": "incr|decr",
* "direction": "BOTH|IN|OUT"
* }
*/
void makeVCIndex(JanusGraphManagement mgmt, JsonNode node) {
if (!node.has("name")) {
log.info("missing 'name' property, not able to create an index");
return;
}
if (!node.has("edge")) {
log.info("vertex-centric index needs 'edge' property to specify a edge label");
return;
}
String edgeName = node.get("edge").asText();
EdgeLabel elabel = mgmt.getEdgeLabel(edgeName);
if (elabel == null) {
log.info("edge: " + edgeName + " doesn't exist");
return;
}
String name = node.get("name").asText();
if (mgmt.containsRelationIndex(elabel, name)) {
log.info("index: " + name + " exists");
return;
}
if (!node.has("propertyKeys")) {
log.info("missing 'propertyKeys property, not able to create an index");
return;
}
JsonNode properties = node.findValue("propertyKeys");
if (properties == null || properties.size() == 0) {
log.info("index: " + name + " needs 'propertyKeys' properties");
return;
}
Direction dir = node.has("direction") ? Direction.valueOf(node.get("direction").asText()) : Direction.BOTH;
Order order = node.has("order") ? Order.valueOf(node.get("order").asText()) : Order.incr;
PropertyKey[] keys = new PropertyKey[properties.size()];
int counter = 0;
for (JsonNode property : properties) {
PropertyKey key = mgmt.getPropertyKey(property.asText());
if (key == null) {
log.info("propertyKey:${property.asText()} doesn't exist, can't create ${name} vertex-centric index");
return;
}
keys[counter++] = mgmt.getPropertyKey(property.asText());
}
mgmt.buildEdgeIndex(elabel, name, dir, order, keys);
log.info("vertex-centric index: ${name} creation is done");
}