Hi,
when I import a big data set in the OrientDB database,the graph has four 
million vertices and 16 million edges,the speed is slow ,the whole time is 
50 minutes,my code is as folows:
private static void insertEdge(OrientGraph graph,OGraphBatchInsert 
batch,String path,String vertexPath) throws IOException{
System.out.println("the begin of inserting edges...");
long startTime = 0, endTime = 0;
double buildTime = 0d;
startTime = System.nanoTime();
batch.begin();
File file=null;
String line = null,vertexLine=null;
String[] arrs = null;
long startId = 0, endId = 0;
Map<String, Object> edgeProps = new HashMap<String, Object>();
Map<String, Object> vertexProps = new HashMap<String, Object>();
edgeProps.put("weight", 1);
int num = -1;
int count=0;
try {
file=new File(path);
BufferedReader bf = new BufferedReader(new FileReader(file));
while ((line = bf.readLine()) != null) {
if (!line.startsWith("#")) {
++num;
if(num==0)
graphKind=line;
if (num != 0 && num != 1) {
++count;
arrs = splitt(line);
startId = Integer.parseInt(arrs[0]);
endId = Integer.parseInt(arrs[1]);
batch.createVertex(startId);
batch.createVertex(endId);
batch.createEdge(startId, endId, edgeProps); 
if(count%10000==0){
System.out.println("commit line:"+count);
} 
}
}
}
bf.close();
if(count%10000!=0)
System.out.println("commit line:"+count);
//节点与边建立结束,下面给节点增加属性值
count=0;
file=new File(vertexPath);
bf = new BufferedReader(new FileReader(file));
while((vertexLine = bf.readLine()) != null){
++count;
long vid=Integer.parseInt(vertexLine);
vertexProps.put("vid", vid);
batch.setVertexProperties(vid, vertexProps);
if(count%10000==0)
{
System.out.println("commit line:"+count);
}
 }
bf.close();
if(count%10000!=0)
System.out.println("commit line:"+count);
batch.end();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
endTime = System.nanoTime();
buildTime = (double) (endTime - startTime) / (1e9);
System.out.println("the time of inserting edges in OrientDB is:" + 
buildTime);
 System.out.println("num of edge is:"+graph.countEdges());
System.out.println("num of vertex is:"+graph.countVertices());
}
how can I improve the speed??

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to