当前位置: 首页 > news >正文

免费建设音乐网站电站建设招聘网站

免费建设音乐网站,电站建设招聘网站,站群优化公司,搜索引擎优化的工具在第1部分中 #xff0c;我们讨论了使用Java REST绑定建立与Neo4j Server的连接。 现在让我们详细了解事务#xff0c;批处理以及REST请求的实际情况。确保org.neo4j.rest.logging_filter to true) as described in Part 1打开日志记录#xff08;将系统属性org.neo4j.rest.… 在第1部分中 我们讨论了使用Java REST绑定建立与Neo4j Server的连接。 现在让我们详细了解事务批处理以及REST请求的实际情况。确保org.neo4j.rest.logging_filter to true) as described in Part 1打开日志记录将系统属性org.neo4j.rest.logging_filter to true) as described in Part 1设置org.neo4j.rest.logging_filter to true) as described in Part 1 。 我们将更改代码以执行这些Neo4j API调用。 范例1 Transaction tx graphDb.beginTx();Map propsnew HashMap();props.put(id, 100);props.put(name,firstNode);Node nodegraphDb.createNode(props);props.put(id,200);props.put(name,secondNode);Node node2graphDb.createNode(props);node.createRelationshipTo(node2, DynamicRelationshipType.withName(KNOWS));tx.success();tx.finish();resultengine.query(start nnode(*) return count(n) as total, Collections.EMPTY_MAP);Iterator iteratorresult.iterator();if(iterator.hasNext()) {Map row iterator.next();out.print(Total nodes: row.get(total));} 检查日志对我来说它们默认显示在Tomcat控制台上然后查找REST调用。 上面的代码产生了 INFO: 1 * Client out-bound request 1 POST http://localhost:7474/db/data/node 1 Accept: application/json; streamtrue 1 X-Stream: true 1 Content-Type: application/json 1 {id:100,name:firstNode}INFO: 1 * Client in-bound response 1 201 1 Access-Control-Allow-Origin: * 1 Transfer-Encoding: chunked 1 Content-Encoding: UTF-8 1 Location: http://localhost:7474/db/data/node/1 1 Content-Type: application/json; streamtrue 1 Server: Jetty(6.1.25) 1 {extensions:{},paged_traverse:http://localhost:7474/db/data/node/1/paged/traverse/{returnType}{?pageSize,leaseTime},outgoing_relationships:http://localhost:7474/db/data/node/1/relationships/out,traverse:http://localhost:7474/db/data/node/1/traverse/{returnType},all_typed_relationships:http://localhost:7474/db/data/node/1/relationships/all/{-list||types},property:http://localhost:7474/db/data/node/1/properties/{key},all_relationships:http://localhost:7474/db/data/node/1/relationships/all,self:http://localhost:7474/db/data/node/1,properties:http://localhost:7474/db/data/node/1/properties,outgoing_typed_relationships:http://localhost:7474/db/data/node/1/relationships/out/{-list||types},incoming_relationships:http://localhost:7474/db/data/node/1/relationships/in,incoming_typed_relationships:http://localhost:7474/db/data/node/1/relationships/in/{-list||types},create_relationship:http://localhost:7474/db/data/node/1/relationships,data:{name:firstNode,id:100}}INFO: 2 * Client out-bound request 2 POST http://localhost:7474/db/data/node 2 Accept: application/json; streamtrue 2 X-Stream: true 2 Content-Type: application/json 2 {id:200,name:secondNode}INFO: 2 * Client in-bound response 2 201 2 Access-Control-Allow-Origin: * 2 Transfer-Encoding: chunked 2 Content-Encoding: UTF-8 2 Location: http://localhost:7474/db/data/node/2 2 Content-Type: application/json; streamtrue 2 Server: Jetty(6.1.25) 2 {extensions:{},paged_traverse:http://localhost:7474/db/data/node/2/paged/traverse/{returnType}{?pageSize,leaseTime},outgoing_relationships:http://localhost:7474/db/data/node/2/relationships/out,traverse:http://localhost:7474/db/data/node/2/traverse/{returnType},all_typed_relationships:http://localhost:7474/db/data/node/2/relationships/all/{-list||types},property:http://localhost:7474/db/data/node/2/properties/{key},all_relationships:http://localhost:7474/db/data/node/2/relationships/all,self:http://localhost:7474/db/data/node/2,properties:http://localhost:7474/db/data/node/2/properties,outgoing_typed_relationships:http://localhost:7474/db/data/node/2/relationships/out/{-list||types},incoming_relationships:http://localhost:7474/db/data/node/2/relationships/in,incoming_typed_relationships:http://localhost:7474/db/data/node/2/relationships/in/{-list||types},create_relationship:http://localhost:7474/db/data/node/2/relationships,data:{name:secondNode,id:200}}INFO: 3 * Client out-bound request 3 POST http://localhost:7474/db/data/node/1/relationships 3 Accept: application/json; streamtrue 3 X-Stream: true 3 Content-Type: application/json 3 {to:http://localhost:7474/db/data/node/2,type:KNOWS}INFO: 3 * Client in-bound response 3 201 3 Access-Control-Allow-Origin: * 3 Transfer-Encoding: chunked 3 Content-Encoding: UTF-8 3 Location: http://localhost:7474/db/data/relationship/0 3 Content-Type: application/json; streamtrue 3 Server: Jetty(6.1.25) 3 {extensions:{},start:http://localhost:7474/db/data/node/1,property:http://localhost:7474/db/data/relationship/0/properties/{key},self:http://localhost:7474/db/data/relationship/0,properties:http://localhost:7474/db/data/relationship/0/properties,type:KNOWS,end:http://localhost:7474/db/data/node/2,data:{}}INFO: 4 * Client out-bound request 4 POST http://localhost:7474/db/data/cypher 4 Accept: application/json; streamtrue 4 X-Stream: true 4 Content-Type: application/json 4 {query:start nnode(*) return count(n) as total,params:{}}INFO: 4 * Client in-bound response 4 200 4 Access-Control-Allow-Origin: * 4 Transfer-Encoding: chunked 4 Content-Encoding: UTF-8 4 Content-Type: application/json; streamtrue 4 Server: Jetty(6.1.25) 4 {columns:[total],data:[[3]]} 网上总共有4个REST调用用于那段很小的代码。 您绝对希望尽可能避免这种情况。 选项1是尽可能使用Cypher。 通过不使用嵌入式样式API并切换到Cypher我们可以将前三个REST调用转换为一个。 范例2 MapString,Object propsnew HashMapString, Object();props.put(id, 100);props.put(name,firstNode);MapString,Object props2new HashMapString, Object();props2.put(id,200);props2.put(name,secondNode);MapString,Object paramsnew HashMapString, Object();params.put(props1,props);params.put(props2,props2);engine.query(create (n1 {props1})-[:KNOWS]-(n2 {props2}), params); 这将产生 1 POST http://localhost:7474/db/data/cypher {query:create (n1 {props1})-[:KNOWS]-(n2 {props2}),params:{props1:{id:100,name:firstNode},props2:{id:100,name:firstNode}}}Jul 24, 2013 10:38:47 PM com.sun.jersey.api.client.filter.LoggingFilter log INFO: 1 * Client in-bound response 1 200 1 Access-Control-Allow-Origin: * 1 Transfer-Encoding: chunked 1 Content-Encoding: UTF-8 1 Content-Type: application/json; streamtrue 1 Server: Jetty(6.1.25) 1 {columns:[],data:[]}批处理事务中的所有操作 https://github.com/neo4j/java-rest-binding上的文档指出 “在1.8中它尝试将tx中的所有操作收集为批处理操作然后将在服务器上执行该批处理操作。 这暗示着在“ tx”中检索到的结果不是立即可用的而是仅在调用tx.success和tx.finish之后才可用。 但是请注意这不是从示例1中看到的默认行为。要启用此功能您需要设置以下系统属性 org.neo4j.rest.batch_transactiontrue 设置系统属性并重新运行示例1后REST调用将如下所示仅请求 INFO: 1 * Client out-bound request 1 POST http://localhost:7474/db/data/batch 1 Accept: application/json; streamtrue 1 X-Stream: true 1 Content-Type: application/json 1 [{id:1,to:node,body:{id:200,name:secondNode},method:POST},{id:2,to:node,body:{id:200,name:secondNode},method:POST},{id:3,to:{1}/relationships,body:{to:{2},type:KNOWS},method:POST}]INFO: 2 * Client out-bound request 2 POST http://localhost:7474/db/data/cypher 2 Accept: application/json; streamtrue 2 X-Stream: true 2 Content-Type: application/json 2 {query:start nnode(*) return count(n) as total,params:{}} 您还可以显式创建批处理操作如下所示 ListNode response graphDb.executeBatch(new BatchCallbackListNode() {Overridepublic ListNode recordBatch(RestAPI batchRestApi) {ListNode nodesnew ArrayListNode();Map propsnew HashMapString, Object();props.put(id,600);nodes.add(batchRestApi.createNode(props));Map props2new HashMapString, Object();props2.put(id,500);nodes.add(batchRestApi.createNode(props2));return nodes;}}); 转换为 INFO: 1 * Client out-bound request 1 POST http://localhost:7474/db/data/batch 1 Accept: application/json; streamtrue 1 X-Stream: true 1 Content-Type: application/json 1 [{id:1,to:node,body:{id:600},method:POST},{id:2,to:node,body:{id:500},method:POST}] 强烈建议在细粒度的Neo4j Java API上使用任何Cypher / Batching方法。 在最后一篇文章中我们将研究事务在REST绑定的上下文中的行为。 参考 Neo4j Java REST绑定–我们JCG合作伙伴 Luanne Misquitta的第2部分批处理 位于Thought Bytes博客上。 翻译自: https://www.javacodegeeks.com/2013/08/neo4j-java-rest-binding-part-2-batching.html
http://www.sadfv.cn/news/215457/

相关文章:

  • 企业网站建设教程视频更换wordpress编辑器
  • 盐城做网站的价格wordpress store
  • 平面设计学生作品集株洲网站优化找哪家
  • 做带支付平台的网站珠海网站建设维护
  • 石家庄兼职建站seo建设者
  • 湖南网站营销seo哪家好医疗网站建设管理
  • 网页建站点网站建设及优化重要性
  • 网站开发源码做网站 十万
  • 最近一两天的新闻有哪些海外seo
  • 40万用户自助建站百度推广app下载安卓版
  • 如何查看网站是用什么模板做的开发网站性能监控
  • 如何用frontpage2003做网站网页制作动画怎么做
  • 做网站的是什么专业创建销售网站多少钱
  • 如何评价一个网站做的是否好北京设计网站的公司哪家好
  • 广东外贸网站推广网站频道建设
  • 网站中弹出广告怎么做网站建设宣传语怎么写
  • 诏安县城乡规划建设局网站重庆网站建设子沃科技公司
  • 苏州哪家做网站好些设计类专业就业方向
  • 网站建设上线问题做模具做什么网站
  • 如何加强网站安全建设网站建设 上海
  • 吴江区住房与建设局网站网推资源网站
  • 网站建设实习目的精东影视文化传媒有限公司官网
  • 廊坊酒店网站建设网络培训投诉平台
  • 简约 时尚 高端 网站建设莆田网站建设模板
  • 盐城网站建设系统公司无锡网站营销公司哪家好
  • 网站建设公司宣传词wordpress站点搬家
  • 做婚礼网站的公司软件设计专业就业前景
  • 国外工作室网站培训网站导航
  • 中国空间站合作的17个国家网站建设合同内容与结构
  • 泉州网站制作网页静海县建设局网站