• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExecutionResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.neo4j.cypher.javacompat.ExecutionResult的典型用法代码示例。如果您正苦于以下问题:Java ExecutionResult类的具体用法?Java ExecutionResult怎么用?Java ExecutionResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExecutionResult类属于org.neo4j.cypher.javacompat包,在下文中一共展示了ExecutionResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:17,代码来源:QueryRunner.java


示例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);
}
 
开发者ID:sarmbruster,项目名称:unmanaged-extension,代码行数:26,代码来源:UnmanagedExtension.java


示例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;
}
 
开发者ID:karth707,项目名称:iBase,代码行数:20,代码来源:FriendGraph.java


示例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;
	}
}
 
开发者ID:karth707,项目名称:iBase,代码行数:24,代码来源:FriendGraph.java


示例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;
		}
	}
 
开发者ID:karth707,项目名称:iBase,代码行数:21,代码来源:GraphInstanceTest.java


示例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;

	}
 
开发者ID:karth707,项目名称:iBase,代码行数:17,代码来源:GraphInstanceTest.java


示例7: createData

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private Node createData()
{
    ExecutionEngine engine = new ExecutionEngine( db );
    String query = "CREATE (joe {name: 'Joe'}), (sara {name: 'Sara'}), "
       + "(lisa {name: 'Lisa'}), (peter {name: 'PETER'}), (dirk {name: 'Dirk'}), "
                   + "(lars {name: 'Lars'}), (ed {name: 'Ed'}),"
       + "(joe)-[:KNOWS]->(sara), (lisa)-[:LIKES]->(joe), "
       + "(peter)-[:KNOWS]->(sara), (dirk)-[:KNOWS]->(peter), "
       + "(lars)-[:KNOWS]->(drk), (ed)-[:KNOWS]->(lars), " 
       + "(lisa)-[:KNOWS]->(lars) " 
       + "RETURN joe";
    ExecutionResult result = engine.execute( query );
    Object joe = result.columnAs( "joe" ).next();
    if ( joe instanceof Node )
    {
        return (Node) joe;
    }
    else
    {
        throw new RuntimeException( "Joe isn't a node!" );
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:23,代码来源:DbManager.java


示例8: runQueryComplexResult

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public Map<String,List<Object>> runQueryComplexResult(NeoProfiler parent, String query, String...columns) {
	HashMap<String,List<Object>> all = new HashMap<String,List<Object>>();
	
	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<Map<String,Object>> rows = result.iterator();
		
		while(rows.hasNext()) {
			Map<String,Object> row = rows.next();
			
			for(String col : columns) { 
				if(!all.containsKey(col)) all.put(col, new ArrayList<Object>());
				all.get(col).add(row.get(col));
			}
		}
		
		rows.close();
	} // End try
	
	return all;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:27,代码来源:QueryRunner.java


示例9: 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;
	}		
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:18,代码来源:QueryRunner.java


示例10: execute

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@Override
public void execute(String query, JsonObject params, Handler<JsonObject> handler) {
	ExecutionResult result;
	try (Transaction tx = gdb.beginTx()) {
		if (params != null){
			result = engine.execute(query, params.toMap());
		} else {
			result = engine.execute(query);
		}
		JsonObject json = new JsonObject().putArray("result",toJson(result));
		tx.success();
		handler.handle(json);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		handler.handle(ExceptionUtils.exceptionToJson(e));
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:18,代码来源:Neo4jEmbedded.java


示例11: executeBatch

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@Override
public void executeBatch(JsonArray queries, Handler<JsonObject> handler) {
	ExecutionResult result;
	try (Transaction tx = gdb.beginTx()) {
		JsonArray results = new JsonArray();
		int i = 0;
		for (Object q: queries) {
			JsonObject qr = (JsonObject) q;
			String query = qr.getString("query");
			JsonObject params = qr.getObject("params");
			if (params != null){
				result = engine.execute(query, params.toMap());
			} else {
				result = engine.execute(query);
			}
			results.addObject(new JsonObject().putArray("result", toJson(result))
					.putNumber("idx", i++));
		}
		JsonObject json = new JsonObject().putArray("results", results);
		tx.success();
		handler.handle(json);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		handler.handle(ExceptionUtils.exceptionToJson(e));
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:27,代码来源:Neo4jEmbedded.java


示例12: info

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@GET
@Path("/csvtree")
@Produces("application/json")
public Response info(@QueryParam(value = "debug") Boolean debug,
		@Context GraphDatabaseService db) {
	try {
		logger.info("Processing 'loadcsvtree_version' request");
		if (debug == null) debug = false;
		HashMap<String, Object> response = new HashMap<String, Object>();
		response.put("version", "0.0.4");
		ExecutionEngine engine = new ExecutionEngine(db);
		ExecutionResult result = engine.execute("MATCH (g:DeviceGroup)-->(d:Device) RETURN g.name as Group, count(d) as Devices");
		for (Map<String, Object> record : result) {
			response.put(record.get("Group").toString(), record.get("Devices"));
		}
		return Response.ok().entity(new ObjectMapper().writeValueAsString(response)).build();
	} catch (IOException e) {
		logger.severe("Error processing 'loadcsvtree_version' request: " + e.getMessage());
		return Response.status(404).entity(e.getMessage()).build();
	}
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:22,代码来源:CSVTreeLoaderService.java


示例13: executeCypher

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
/**
 * Executes the cypher
 * @param cypher
 * @return
 */
String executeCypher(String cypher){
    final GraphDatabaseService graphDb = getGraphDb();
    Transaction tx = graphDb.beginTx();
    ExecutionResult result = null;
    try {
        ExecutionEngine engine = new ExecutionEngine( graphDb );
        result = engine.execute( cypher );
        tx.success();
    } catch(Exception e){
        throw new RuntimeException("Error executing cypher: ", e);
    } finally {
        tx.finish();
    }
    return result.dumpToString();
}
 
开发者ID:fizalihsan,项目名称:Fig,代码行数:21,代码来源:Neo4jHelper.java


示例14: ExecutionResultIterator

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public ExecutionResultIterator(ExecutionResult results, GraphDatabaseService graphdb) {
	//this.results = results;
	//System.out.println("In iterator constructor");
	this.delegate = results.iterator();
	this.graphdb = graphdb;
	//this.transaction = tx;
	
	//System.out.println(delegate.hasNext());
	//System.out.println("constructor next:"+delegate.next());
	//System.out.println(results.dumpToString());
	
	//System.out.println(delegate.next().size());
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:14,代码来源:ExecutionResultIterator.java


示例15: deleteEdge

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private void deleteEdge(Node node1, Node node2) {
	String node1Key = node1.getProperty(USER_ID).toString();
	String node2Key = node2.getProperty(USER_ID).toString();
	
	String query = "start node1=node:nodes(userId = '" + node1Key + "'), "
			+ "node2=node:nodes(userId = '" + node2Key + "') "
			+ "match node1-[r:FRIEND_OF]->node2 " + "delete r";
	
	ExecutionResult result = engine.execute(query);
	logger.info("deleted edge between: "+ node1Key
			+ " and " + node2Key + "; result: "+ result.toString());
}
 
开发者ID:karth707,项目名称:iBase,代码行数:13,代码来源:FriendGraph.java


示例16: deleteEdge

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@SuppressWarnings("unused")
private void deleteEdge(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 " + "delete r";

	ExecutionEngine engine = new ExecutionEngine(graphDb);
	ExecutionResult result = engine.execute(query);
	System.out.println((result.toString()));
}
 
开发者ID:karth707,项目名称:iBase,代码行数:14,代码来源:GraphInstanceTest.java


示例17: executeTransaction

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@Override
public void executeTransaction(JsonArray statements, Integer transactionId,
		boolean commit, Handler<JsonObject> handler) {
	ExecutionResult result;
	try (Transaction tx = gdb.beginTx()) {
		JsonArray results = new JsonArray();
		for (Object o : statements) {
			if (!(o instanceof JsonObject)) continue;
			JsonObject qr = (JsonObject) o;
			String statement = qr.getString("statement");
			JsonObject params = qr.getObject("parameters");
			if (params != null){
				result = engine.execute(statement, params.toMap());
			} else {
				result = engine.execute(statement);
			}
			results.addArray(toJson(result));
		}
		tx.success();
		JsonObject json = new JsonObject().putArray("results", results);
		if (!commit) {
			json.putNumber("transactionId", 0);
		}
		handler.handle(json);
	} catch (Exception e) {
		handler.handle(ExceptionUtils.exceptionToJson(e));
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:29,代码来源:Neo4jEmbedded.java


示例18: toJson

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private JsonArray toJson (ExecutionResult result) {
	JsonArray json = new JsonArray();
	if (result == null) {
		return json;
	}
	for (Map<String, Object> row : result) {
			JsonObject jsonRow = new JsonObject();
			json.addObject(jsonRow);
		for (Map.Entry<String, Object> column : row.entrySet()) {
			Object v = column.getValue();
			if (v == null) {
				jsonRow.putValue(column.getKey(), null);
			} else if (v instanceof Node) {
				JsonObject nodeJson = nodeToJsonObject((Node) v);
				jsonRow.putObject(column.getKey(), nodeJson);
			} else if (isNodeArray(v)) {
				Node[] nodes;
				if (v instanceof Iterable) {
					nodes = ((List<Node>) v).toArray(new Node[((List<Node>) v).size()]);
				} else { //if (v != null && v.getClass().isArray()) {
					nodes = (Node[]) v;
				}
				JsonArray nodesRes = new JsonArray();
				for (Node n: nodes) {
					nodesRes.addObject(nodeToJsonObject(n));
				}
				jsonRow.putArray(column.getKey(), nodesRes);
			} else {
				propertyToJson(jsonRow, column.getKey(), v);
			}
		}
	}
	return json;
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:36,代码来源:Neo4jEmbedded.java


示例19: 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);
	}
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:49,代码来源:CSVTreeLoaderServiceTest.java


示例20: put

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
/**
 * PUT nodeset {label} {key} {value}
 *
 * tx.merge(label, key, value)
 *
 * MERGE-RETURN
 * No locking(?)
 *
 * @param request
 */
@Override
public PropertyContainer put(Transaction tx, Request request) throws ClientError, ServerError {
    String labelName = request.getStringData(0);
    String key = request.getStringData(1);
    Object value = request.getData(2);
    try {
        HashMap<String, Integer> stats = new HashMap<>();
        String query = "MERGE (a:`" + labelName.replace("`", "``") +
                "` {`" + key.replace("`", "``") + "`:{value}}) RETURN a";
        HashMap<String, Object> params = new HashMap<>(1);
        params.put("value", value);
        ExecutionResult result = execute(query, params);
        Node firstNode = null;
        for (Map<String, Object> row : result) {
            Node node = (Node)row.get("a");
            sendContinue(node);
            if (firstNode == null) {
                firstNode = node;
            }
        }
        int nodesCreated = result.getQueryStatistics().getNodesCreated();
        stats.put("nodes_created", nodesCreated);
        if (nodesCreated == 0) {
            sendOK(stats);
        } else {
            sendCreated(stats);
        }
        return firstNode;
    } catch (CypherException ex) {
        throw new ServerError(new Response(Response.SERVER_ERROR, ex.getMessage()));
    }
}
 
开发者ID:TinderBackend,项目名称:neo4j-zmq-extension,代码行数:43,代码来源:NodeSetResource.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java X509CertificatePair类代码示例发布时间:2022-05-21
下一篇:
Java Data类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap