protected static void iterate(HDT hdt, CharSequence subject, CharSequence predicate, CharSequence object) throws NotFoundException { StopWatch iterateTime = new StopWatch(); int count = 0; subject = subject.length()==1 && subject.charAt(0)=='?' ? "" : subject; predicate = predicate.length()==1 && predicate.charAt(0)=='?' ? "" : predicate; object = object.length()==1 && object.charAt(0)=='?' ? "" : object; // Iterate over triples as Strings IteratorTripleString it = hdt.search(subject,predicate,object); count = 0; while(it.hasNext()) { TripleString triple = it.next(); System.out.println(triple); count++; } // Iterate over triples only as IDs // TripleID patternID = DictionaryUtil.tripleStringtoTripleID(hdt.getDictionary(), new TripleString(subject, predicate, object)); // IteratorTripleID it2 = hdt.getTriples().search(patternID); // while(it2.hasNext()) { // TripleID triple = it2.next(); // System.out.println(triple); // count++; // } System.out.println("Iterated "+ count + " triples in "+iterateTime.stopAndShow()); }
public void execute() throws Exception { PrintStream out = null; if (rdfOutput.equals("stdout")){ out = System.out; } else { out = new PrintStream(rdfOutput, "UTF-8"); } HDT hdt=HDTManager.mapHDT(hdtInput, this); try { IteratorTripleString it = hdt.search("","",""); StringBuilder build = new StringBuilder(1024); while(it.hasNext()) { TripleString triple = it.next(); build.delete(0, build.length()); triple.dumpNtriple(build); out.print(build); } if(!rdfOutput.equals("stdout")) { out.close(); } } finally { if(hdt!=null) hdt.close(); } }
iter = this.processor.search("", "", ""); } catch (NotFoundException e) { ExceptionOutput.output(e, "HDT iterator error", logger);