本文整理汇总了Java中org.neo4j.cypher.javacompat.ExecutionResult.columnAs方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionResult.columnAs方法的具体用法?Java ExecutionResult.columnAs怎么用?Java ExecutionResult.columnAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.cypher.javacompat.ExecutionResult
的用法示例。
在下文中一共展示了ExecutionResult.columnAs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runQueryMultipleResult
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
public List<Object> runQueryMultipleResult(NeoProfiler parent, String query, String columnReturn) {
ExecutionEngine engine = new ExecutionEngine(parent.getDB());
List<Object> retvals = new ArrayList<Object>();
try ( Transaction tx = parent.getDB().beginTx() ) {
// log.info(query);
ExecutionResult result = engine.execute(query);
ResourceIterator<Object> rit = result.columnAs(columnReturn);
while(rit.hasNext()) {
retvals.add(rit.next());
}
}
return retvals;
}
示例2: findConnectedNodesUsingCypher
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
/**
* demo usage of traversal API, see http://docs.neo4j.org/chunked/stable/tutorial-traversal.html
*/
@GET
@Produces("application/json")
@Path("/cypher/{label}/{key}/{value}/{relType}/{depth}")
public People findConnectedNodesUsingCypher(
@PathParam("label") String label,
@PathParam("key") String key,
@PathParam("value") String value,
@PathParam("relType") String relType,
@PathParam("depth") int depth) {
StringBuilder cypher = new StringBuilder();
cypher.append("MATCH (:").append(label).append("{").append(key).append(":{value}})-[:").append(relType).append("*").append(depth).append("..").append(depth).append("]->(f) RETURN f.name as name");
// System.out.println(cypher);
// NB: executionEngine opens a transaction on its own unless it's managed explicitly
ExecutionResult result = cypherExecutor.getExecutionEngine().execute(cypher.toString(), Collections.<String, Object>singletonMap("value", value));
Iterator<String> names = result.columnAs("name");
return new People(names);
}
示例3: getAllFriends
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
public List<String> getAllFriends(String userId){
ExecutionResult result0 = engine
.execute("start node=node:nodes(userId = '" + userId + "') "
+ "match node-[:FRIEND_OF]->deg0 " + "return deg0");
List<String> deg0Nodes = new ArrayList<String>();
Iterator<Node> n_column = result0.columnAs("deg0");
for (Node node : IteratorUtil.asIterable(n_column)) {
String nodeResult = null;
try ( Transaction tx = graphDb.beginTx() ){
nodeResult = node.getProperty(USER_ID).toString();
tx.success();
}
deg0Nodes.add(nodeResult);
}
return deg0Nodes;
}
示例4: isConnected
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
private boolean isConnected(Node node1, Node node2) {
String node1Key = null;
String node2Key = null;
try ( Transaction tx = graphDb.beginTx() ){
node1Key = node1.getProperty(USER_ID).toString();
node2Key = node2.getProperty(USER_ID).toString();
tx.success();
}
String query = "start node1=node:nodes(userId = '" + node1Key + "'), "
+ "node2=node:nodes(userId = '" + node2Key + "') "
+ "match node1-[r:FRIEND_OF]->node2 " + "return r";
ExecutionResult result = engine.execute(query);
Iterator<Node> rcolumn = result.columnAs("r");
if (rcolumn.hasNext()) {
// edge exists!
return true;
} else {
return false;
}
}
示例5: isConnected
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
private boolean isConnected(Node node1, Node node2) {
String node1Key = node1.getProperty("message").toString();
String node2Key = node2.getProperty("message").toString();
String query = "start node1=node:nodes(message = '" + node1Key + "'), "
+ "node2=node:nodes(message = '" + node2Key + "') "
+ "match node1-[r:KNOWS]->node2 " + "return r";
ExecutionEngine engine = new ExecutionEngine(graphDb);
ExecutionResult result = engine.execute(query);
Iterator<Node> rcolumn = result.columnAs("r");
if (rcolumn.hasNext()) {
// edge exists!
return true;
} else {
return false;
}
}
示例6: getAllFriends
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
public List<String> getAllFriends(String userId) {
ExecutionEngine engine = new ExecutionEngine(graphDb);
ExecutionResult result0 = engine
.execute("start node=node:nodes(message = '" + userId + "') "
+ "match node-[:KNOWS]->deg0 " + "return deg0");
List<String> deg0Nodes = new ArrayList<String>();
Iterator<Node> n_column = result0.columnAs("deg0");
for (Node node : IteratorUtil.asIterable(n_column)) {
String nodeResult = node.getProperty("message").toString();
deg0Nodes.add(nodeResult);
}
return deg0Nodes;
}
示例7: runQuerySingleResult
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
public Object runQuerySingleResult(NeoProfiler parent, String query, String columnReturn) {
ExecutionEngine engine = new ExecutionEngine(parent.getDB());
try ( Transaction tx = parent.getDB().beginTx() ) {
// log.info(query);
ExecutionResult result = engine.execute(query);
ResourceIterator<Object> vals = result.columnAs(columnReturn);
if(vals.hasNext()) {
Object retval = vals.next();
vals.close();
return retval;
}
return null;
}
}
示例8: runLeafPropertiesCheck
import org.neo4j.cypher.javacompat.ExecutionResult; //导入方法依赖的package包/类
/**
* Check that all leaf nodes have the same expected path length from the
* root
*
* @param rootLabel
* the Label of the root nodes to begin search on
* @param pathLength
* the expected length of the path to the leaf nodes
* @param expectedProperties
* the expected properties all leaf nodes should have
* @param engine
*/
private void runLeafPropertiesCheck(String rootLabel, int pathLength, String[] expectedProperties,
ExecutionEngine engine) {
String query = "MATCH p=(n:" + rootLabel + ")-[:child*]->(e) WHERE NOT (e)-[:child]->() RETURN e,p";
ExecutionResult results = engine.execute(query);
ResourceIterator<Object> leaves = results.columnAs("e");
ResourceIterator<Object> paths = results.columnAs("p");
ACollections.IncMap<String> badPropCounts = new ACollections.IncMap<String>();
int badPathLengths = 0;
int leafCount = 0;
while (leaves.hasNext()) {
Node leaf = (Node) leaves.next();
Path path = (Path) paths.next();
Set<String> properties = new ACollections.HashSet<String>(leaf.getPropertyKeys());
for (String property : expectedProperties) {
if (!properties.contains(property)) {
badPropCounts.inc(property);
}
}
if (path.length() + 1 != pathLength) {
System.out.println("Bad path: " + path);
badPathLengths++;
}
}
assertTrue("Found no leaf nodes", leafCount == 0);
assertTrue("Found " + badPathLengths + " paths not matching length " + pathLength, badPathLengths == 0);
if (badPropCounts.size() > 0) {
String propMessage = "Found " + badPropCounts.size() + " properties missing from " + leafCount
+ " leaf nodes";
System.out.println(propMessage);
for (String prop : badPropCounts.keySet()) {
System.out
.println("\t" + (prop + " ").substring(0, 15) + "\t" + badPropCounts.get(prop));
}
assertTrue(propMessage, false);
}
}