2015-06-23 49 views
2

我正在使用java中的neo4j,我有一個問題。當我創建節點時,如何驗證數據庫是否爲空?驗證數據庫是否在neo4j中爲空

這裏是我的代碼來創建一個節點:

br = new BufferedReader(new FileReader(csvFile)); 

     while (br.ready()==true) { 
      transaction = graphDb.beginTx(); 
      int cont = 0;//limitador de tuplas por query 
      while ((line = br.readLine()) != null && cont < 10000) { 

       String[] dado = line.split(cvsSplitBy); 

       // inserir comando para criar o nós com a data 
       Node no = graphDb.createNode(); 
       no.setProperty("data", dado[0]); 
       no.setProperty("temperatura", dado[1]); 
       no.setProperty("latitude", dado[2]); 
       no.setProperty("longitude", dado[3]); 
       no.setProperty("variação", dado[4]); 

       System.out.println(cont); 
       cont++; 
      } 
      transaction.success(); 
      transaction.close(); 
     } 

回答

3

這是一個高效的Cypher查詢,返回一個布爾值isEmpty結果。

MATCH (n) 
RETURN n IS NULL AS isEmpty 
LIMIT 1; 
1
match (n) 
return 1 
limit 1 

希望的Neo4j會打擾較少的處理這個查詢,知道它不具有打擾計數或打擾過濾在以前的答案

建議