当前位置: 首页>>代码示例>>Java>>正文


Java IndexDefinition.getPropertyKeys方法代码示例

本文整理汇总了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 + "'");
	}
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:36,代码来源:CSVTreeBuilder.java

示例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;
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:23,代码来源:CreateIndexTest.java


注:本文中的org.neo4j.graphdb.schema.IndexDefinition.getPropertyKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。