Created
August 19, 2014 06:23
-
-
Save fancyerii/7420d86f9eff5f196f1c to your computer and use it in GitHub Desktop.
test insert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileInputStream is = new FileInputStream("/Users/lili/Downloads/freebase-rdf-2014-08-03-00-00.gz"); | |
GZIPInputStream gzis=new GZIPInputStream(is); | |
BufferedReader br=new BufferedReader(new InputStreamReader(gzis,"UTF8")); | |
int lineNum=0; | |
String line; | |
TitanGraph g=TitanFactory.open("/Users/lili/soft/titan-server-0.4.4/conf/titan-hbase-es.properties"); | |
long total=0; | |
long start=System.currentTimeMillis(); | |
int statSize=10_000; | |
while((line=br.readLine())!=null){ | |
lineNum++; | |
if(lineNum % 1000000 ==0){ | |
System.out.println("line: "+lineNum); | |
} | |
String[] arr=line.split("\t"); | |
if(arr.length!=4){ | |
continue; | |
} | |
String uri1=arr[0]; | |
try{ | |
Vertex v=g.addVertex(null); | |
v.setProperty("uri", uri1); | |
g.commit(); | |
}catch(Exception e){ | |
} | |
total++; | |
if(arr[2].startsWith("<") && arr[2].endsWith(">")){ | |
try{ | |
Vertex v2=g.addVertex(null); | |
v2.setProperty("uri", arr[2]); | |
g.commit(); | |
}catch(Exception e){ | |
} | |
total++; | |
} | |
if(total>=statSize){ | |
System.out.println("insert speed: "+(1000.0*total/(System.currentTimeMillis()-start))+" vertices/sec."); | |
total=0; | |
start=System.currentTimeMillis(); | |
} | |
} | |
br.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment