neo4j Exception in java

9 views
Skip to first unread message

pyg...@gmail.com

unread,
May 21, 2015, 8:27:09 AM5/21/15
to ne...@googlegroups.com
Hi,
when I import a big data set in Neo4j database,the graph has 262111  vertices and  1234877 edges,eclipse has exception:Esception in thread "GC-Monitor" java.lang.OutOfMemoryError:GC overhead limit exceeded ,my code is as folows:
                System.out.println("从文件中把图数据到内存(用数组存放)...");
{
String line=null;
String[] arrs = null;
File file=new File(vertexPath);
BufferedReader bf = new BufferedReader(new FileReader(file));
int i=0;
while((line=bf.readLine())!=null){
vid[i++]=Integer.parseInt(line);
}
bf.close();
file=new File(path);
bf = new BufferedReader(new FileReader(file));
int count=0;
while((line=bf.readLine())!=null){
arrs=splitt(line);
int startId=Integer.parseInt(arrs[0]);
int endId=Integer.parseInt(arrs[1]);
edge[count][0]=startId;
edge[count][1]=endId;
++count ;
}
System.out.println("the num of edge is:"+count);
bf.close();
}
System.out.println("把图数据装载在neo4j数据库中...");
{
long startTime = 0, endTime = 0;
double buildTime = 0d;
startTime = System.nanoTime();
startDb();
Transaction tx = graphDb.beginTx();
   try {
    for(int i = 0; i < nv; i++) {
    node[i] = graphDb.createNode();
    node[i].setProperty("id", vid[i]);
    }
    int count=0;
    for(int i=0;i<ne;++i){
    int startId=edge[i][0];
    int endId=edge[i][1];
    int startIndex=locateVertexIndex(startId);
    int endIndex=locateVertexIndex(endId);
    Relationship rel = node[startIndex].createRelationshipTo(node[endIndex], RelTypes.EDGE);
    rel.setProperty("weight",1);
    ++count;
    if(count%10000==0){
    tx.success();
    System.out.println("commit line:"+count);
    }
   
    }
    if(count%10000!=0){
    tx.success();
    System.out.println("commit line:"+count);
    }
   } catch (Exception e) {
    tx.failure();
   }
   finally {
      tx.finish();
   }
   endTime = System.nanoTime();
buildTime = (double) (endTime - startTime) / (1e9);
System.out.println("the time of inserting nodes in Neo4j is锛氾細" + buildTime);
}
I want to know the reason?
Reply all
Reply to author
Forward
0 new messages