本文整理汇总了Java中org.neo4j.helpers.collection.IteratorUtil.asIterable方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtil.asIterable方法的具体用法?Java IteratorUtil.asIterable怎么用?Java IteratorUtil.asIterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.helpers.collection.IteratorUtil
的用法示例。
在下文中一共展示了IteratorUtil.asIterable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVertex
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@Override
public Vertex createVertex(long id, int weight) {
Vertex v = null;
try {
beginTransaction();
Result result = graphDb.execute("MERGE (a:NODE{INDEX:" + id + "}) RETURN a");
Iterator<Node> n_column = result.columnAs("a");
Node node = null;
for (Node n : IteratorUtil.asIterable(n_column)) {
node = n;
}
node.setProperty(NetworkNeo4jProperties.WEIGHT, weight);
node.setProperty(NetworkNeo4jProperties.LEVEL, (int) 0);
v = new Vertex(id, weight);
} finally {
endTransaction();
}
return v;
}
示例2: edgeExist
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@Override
public boolean edgeExist(long id1, long id2) {
boolean res = false;
try {
beginTransaction();
Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + String.valueOf(id1) + "})-[r:LINK]-(b:NODE{INDEX:" + String.valueOf(id2) + "}) RETURN r LIMIT 1");
Relationship rel_result = null;
Iterator<Relationship> n_column = result.columnAs("r");
for (Relationship rel : IteratorUtil.asIterable(n_column)) {
rel_result = rel;
}
if (rel_result != null) {
res = false;
}
} finally {
endTransaction();
}
return res;
}
示例3: getAllFriends
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的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: getAllFriends
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的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;
}
示例5: getInnerNode
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
private Node getInnerNode(long id) {
Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + String.valueOf(id) + "}) RETURN a LIMIT 1");
Node node_result = null;
Iterator<Node> n_column = result.columnAs("a");
for (Node node : IteratorUtil.asIterable(n_column)) {
node_result = node;
}
return node_result;
}
示例6: getInnerRelationship
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
private Relationship getInnerRelationship(long id) {
Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK{INDEX:" + String.valueOf(id) + "}]-(b:NODE) RETURN r LIMIT 1");
Relationship rel_result = null;
Iterator<Relationship> n_column = result.columnAs("r");
for (Relationship rel : IteratorUtil.asIterable(n_column)) {
rel_result = rel;
}
return rel_result;
}
示例7: writeOutContent
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
public void writeOutContent(String filename) {
GlobalGraphOperations ops = GlobalGraphOperations.at(graphDb);
ExecutionEngine engine = new ExecutionEngine(graphDb);
try (FileWriter writer = new FileWriter(filename);
Transaction tx = graphDb.beginTx()) {
for (Node n : ops.getAllNodes()) {
writer.write("[" + n.getId() + "," + n.getProperty(PROP_NAME)
+ ",[");
Iterator<Node> connected = engine.execute(
"START s=node(" + n.getId()
+ ") MATCH s-[r]->n RETURN n").columnAs("n");
for (Node e : IteratorUtil.asIterable(connected)) {
Iterator<String> rel = engine.execute(
"START s=node(" + n.getId() + "), e=node("
+ e.getId()
+ ") MATCH s-[r]->e RETURN r.value")
.columnAs("r.value");
String relVal = rel.hasNext()? rel.next() : "";
writer.write("[" + e.getId() + ","
+ relVal + "],");
}
writer.write("]]\n");
}
tx.success();
} catch (IOException e1) {
e1.printStackTrace();
}
}
示例8: getCoarsenVertex
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@Override
public Vertex getCoarsenVertex(long id, int level) {
Vertex v = null;
try {
beginTransaction();
Result result = null;
if (level == 0) {
result = graphDb.execute("MATCH (a:NODE{INDEX:" + id + "})-[r:COARSEN]->(b) RETURN b LIMIT 1");
} else {
result = graphDb.execute("MATCH (a:COARSEN_NODE{INDEX:" + id + ", LEVEL:" + level + "})-[r:COARSEN]->(b) RETURN b LIMIT 1");
}
Node node_result = null;
Iterator<Node> n_column = result.columnAs("b");
for (Node node : IteratorUtil.asIterable(n_column)) {
node_result = node;
}
if (node_result != null) {
int partition = Vertex.DEFAULT_PARTITION_NONE;
if (node_result.hasProperty(NetworkNeo4jProperties.PARTITION)) {
partition = (int) node_result.getProperty(NetworkNeo4jProperties.PARTITION);
}
v = new Vertex((long) node_result.getProperty(NetworkNeo4jProperties.INDEX),
(int) node_result.getProperty(NetworkNeo4jProperties.WEIGHT),
partition,
level + 1);
}
} finally {
endTransaction();
}
return v;
}
示例9: createEdge
import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@Override
public Edge createEdge(int weight, long startNode, long endNode) {
Edge edge = null;
long id = 0;
try {
beginTransaction();
Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.INDEX DESC LIMIT 1");
Iterator<Relationship> edges = result.columnAs("r");
if (edges.hasNext()) {
id = ((int) edges.next().getId()) + 1;
}
result = graphDb.execute("MATCH (a:NODE{INDEX:" + startNode + "})-[r:LINK]-(b:NODE{INDEX:" + endNode + "}) RETURN r ORDER BY r.INDEX DESC LIMIT 1");
edges = result.columnAs("r");
if (!edges.hasNext()) {
Node firstNode = getInnerNode(startNode);
Node secondNode = getInnerNode(endNode);
result = graphDb.execute("MATCH (a:NODE{INDEX:" + startNode + "}), (b:NODE{INDEX:" + endNode + "}) "
+ "CREATE (a)-[r:LINK]->(b) "
+ "RETURN r");
Iterator<Relationship> n_column = result.columnAs("r");
Relationship rel = null;
for (Relationship r : IteratorUtil.asIterable(n_column)) {
rel = r;
}
rel.setProperty(NetworkNeo4jProperties.INDEX, id);
rel.setProperty(NetworkNeo4jProperties.WEIGHT, weight);
Vertex v1 = getVertex(startNode);
Vertex v2 = getVertex(endNode);
edge = new Edge(id, weight, v1, v2);
}
} finally {
endTransaction();
}
return edge;
}