本文整理汇总了Java中org.neo4j.graphdb.schema.IndexDefinition.getPropertyKeys方法的典型用法代码示例。如果您正苦于以下问题:Java IndexDefinition.getPropertyKeys方法的具体用法?Java IndexDefinition.getPropertyKeys怎么用?Java IndexDefinition.getPropertyKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.schema.IndexDefinition
的用法示例。
在下文中一共展示了IndexDefinition.getPropertyKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RootTreeNodeBuilder
import org.neo4j.graphdb.schema.IndexDefinition; //导入方法依赖的package包/类
private RootTreeNodeBuilder(ColumnSpec columnSpec, RelationshipType child, GraphDatabaseService db, ExecutionEngine engine) {
super(columnSpec, null, child);
this.db = db;
this.engine = engine;
try (Transaction tx = db.beginTx()) {
boolean indexExists = false;
for (IndexDefinition index : db.schema().getIndexes(this.column.label)) {
ArrayList<String> keys = new ArrayList<String>();
for (String key : index.getPropertyKeys()) {
keys.add(key);
}
if (keys.size() != 1 || !keys.get(0).equals(this.column.property)) {
throw new RuntimeException("Schema Index for " + this.column.label + "." + this.column.property
+ " cannot be made because different index for " + this.column.label + "." + keys
+ " already exists");
}
indexExists = true;
}
if (!indexExists) {
db.schema().constraintFor(this.column.label).assertPropertyIsUnique(this.column.property).create();
}
tx.success();
}
queryString = "MERGE (n:" + column.label + " {" + column.property + ": {" + column.property + "}}) RETURN n";
try (Transaction tx = db.beginTx()) {
ResourceIterator<Object> resultIterator = engine.execute("MATCH (n:" + column.label + ") RETURN n").columnAs(
"n");
while (resultIterator.hasNext()) {
Node node = (Node) resultIterator.next();
cachedRoots.put(node.getProperty(column.property).toString(), node);
}
tx.success();
debug("Cached " + cachedRoots.size() + " existing tree roots with Label '" + this.column.label + "'");
}
}
示例2: findIndex
import org.neo4j.graphdb.schema.IndexDefinition; //导入方法依赖的package包/类
/**
* Find an index.
*
* @param graphDatabaseService
* The Graph database service.
* @param label
* The label.
* @param propertyName
* The property name.
* @return The index or <code>null</code>:
*/
private IndexDefinition findIndex(GraphDatabaseService graphDatabaseService, Label label, String propertyName) {
final Iterable<IndexDefinition> indexes = graphDatabaseService.schema().getIndexes(label);
for (IndexDefinition indexDefinition : indexes) {
for (String key : indexDefinition.getPropertyKeys()) {
if (key.equals(propertyName)) {
return indexDefinition;
}
}
}
return null;
}