2017-07-12 53 views
-1

我正在使用neo4j版本3.1.0。我创建了2000万图。每个图包含9个节点及其各自的属性。我正在使用嵌入模式(api 3.1.0)。我试图更改节点的属性。在运行时,我更改了节点的属性但它不反映在数据库中,当我试图使用neo4j外壳获取节点属性。图表数据库未更新Neo4j

数据库大小差不多是20GB。我正在服务器上运行它。我猜这些更改是在缓存中发生的,但它并不反映在图形数据库中。我应该在图形数据库中更新哪些更改?试图通过按CNTRL + C.Hence来处理这种情况下,该段添加到您的代码停止代码时

try(Transaction tx=GraphCreation.getInstance().dbService.beginTx()){ 
      Node n= GraphCreation.getInstance().dbService.findNode(MyLabels.IMSI,"IMSI" ,"A"+0); 
      n.setProperty("MSISDN", "Z"+0); 


      tx.success(); // commit 


     } catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
     try(Transaction tx=GraphCreation.getInstance().dbService.beginTx()) 
     { 
     String cql ="match(a:IMSI{IMSI : 'A0'}) return a.MSISDN";    
      Result result= GraphCreation.getInstance().dbService.execute(cql); 
      while (result.hasNext()) 
      { 
       Map<String, Object> row = result.next(); 
       for (String key : result.columns()) 
       { 
        System.out.printf("%s = %s%n", key, row.get(key)); 
       } 
      } 
      tx.success(); 
      timerContext.close(); 

     } catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
+0

我已经使用了tx.success()也 – vinay

+0

你可以分享相关的代码片段(你在做更新)吗?当你说neo4j shell ...你的意思是你在服务器模式下启动嵌入式数据库并连接到它?你确定(只是检查)你连接到同一个数据库吗? –

+0

我相信3.1.0版本也具有嵌入式Cypher功能。您可以在第二个事务中的嵌入式数据库上运行graphdb.execute(cypherquery)以验证您的更改是否已经过? –

回答

0

这个问题已经解决了.Graph DB一直没有正常关机。

private static void registerShutdownHook(final GraphDatabaseService graphDb) 
{ 
    // Registers a shutdown hook for the Neo4j instance so that it 
    // shuts down nicely when the VM exits (even if you "Ctrl-C" the 
    // running application). 
    Runtime.getRuntime().addShutdownHook(new Thread() 
    { 
     @Override 
     public void run() 
     { 
      graphDb.shutdown(); 
     } 
    }); 
}