/** * Check whether this triple matches a pattern. A pattern is just a TripleString where each empty component means <em>any</em>. * @param pattern * @return */ public boolean match(TripleString pattern) { if (pattern.getSubject() == "" || pattern.getSubject().equals(this.subject)) { if (pattern.getPredicate() == "" || pattern.getPredicate().equals(this.predicate)) { if (pattern.getObject() == "" || pattern.getObject().equals(this.object)) { return true; } } } return false; }
@Override public void addTriple(TripleString triple) throws IOException { triples.insert( dictionary.insert(triple.getSubject(), TripleComponentRole.SUBJECT), dictionary.insert(triple.getPredicate(), TripleComponentRole.PREDICATE), dictionary.insert(triple.getObject(), TripleComponentRole.OBJECT) ); num++; size+=triple.getSubject().length()+triple.getPredicate().length()+triple.getObject().length()+4; // Spaces and final dot }
@Override public int compare(TripleString o1, TripleString o2) { int result = CharSequenceComparator.getInstance().compare(o1.getSubject(), o2.getSubject()); if (result == 0) { result = CharSequenceComparator.getInstance().compare(o1.getPredicate(), o2.getPredicate()); if (result == 0) { // The third component is different? return CharSequenceComparator.getInstance().compare(o1.getObject(), o2.getObject()); } else { // the second component is different return result; } } else { // the first component is different return result; } } }
@Override public void processTriple(TripleString triple, long pos) { triples.insert( dict.insert(triple.getSubject(), TripleComponentRole.SUBJECT), dict.insert(triple.getPredicate(), TripleComponentRole.PREDICATE), dict.insert(triple.getObject(), TripleComponentRole.OBJECT) ); num++; size+=triple.getSubject().length()+triple.getPredicate().length()+triple.getObject().length()+4; // Spaces and final dot ListenerUtil.notifyCond(listener, "Loaded "+num+" triples", num, 0, 100); } }
/** * Converts a TripleString to a TripleID using a dictionary. * * @param tripleString * The Triple to convert from * @return TripleID */ public static TripleID tripleStringtoTripleID(Dictionary dict, TripleString tripleString) { return new TripleID( dict.stringToId(tripleString.getSubject().toString(), TripleComponentRole.SUBJECT), dict.stringToId(tripleString.getPredicate().toString(), TripleComponentRole.PREDICATE), dict.stringToId(tripleString.getObject().toString(), TripleComponentRole.OBJECT) ); } }
System.out.println("Query: |"+triplePattern.getSubject()+"| |"+triplePattern.getPredicate()+"| |" + triplePattern.getObject()+"|"); iterate(hdt,triplePattern.getSubject(),triplePattern.getPredicate(),triplePattern.getObject()); } catch (ParserException e) { System.err.println("Could not parse triple pattern: "+e.getMessage());
@Override public CharSequence getBaseURI() { IteratorTripleString it = search("", HeaderUtil.cleanURI(HDTVocabulary.RDF_TYPE), HeaderUtil.cleanURI(HDTVocabulary.HDT_DATASET)); if(it.hasNext()) { TripleString ts = it.next(); return ts.getSubject(); } return ""; } }
@Override public void processTriple(TripleString triple, long pos) { dict.insert(triple.getSubject(), TripleComponentRole.SUBJECT); dict.insert(triple.getPredicate(), TripleComponentRole.PREDICATE); dict.insert(triple.getObject(), TripleComponentRole.OBJECT); count++; ListenerUtil.notifyCond(listener, "Generating dictionary "+count+" triples processed.", count, 0, 100); }
@Override public void processTriple(TripleString triple, long pos) { triples.insert( dict.stringToId(triple.getSubject(), TripleComponentRole.SUBJECT), dict.stringToId(triple.getPredicate(), TripleComponentRole.PREDICATE), dict.stringToId(triple.getObject(), TripleComponentRole.OBJECT) ); count++; ListenerUtil.notifyCond(listener, "Generating triples "+count+" triples processed.", count, 0, 100); } }
TripleString triple = iterator.next(); triples.insert( dictionary.insert(triple.getSubject(), TripleComponentRole.SUBJECT), dictionary.insert(triple.getPredicate(), TripleComponentRole.PREDICATE), dictionary.insert(triple.getObject(), TripleComponentRole.OBJECT) ); num++; size+=triple.getSubject().length()+triple.getPredicate().length()+triple.getObject().length()+4; // Spaces and final dot ListenerUtil.notifyCond(listener, "Loaded "+num+" triples", num, 0, 100);
IteratorTripleString it = header.search("", HDTVocabulary.RDF_TYPE, HDTVocabulary.HDT_DATASET); if(it.hasNext()) { this.baseUri = it.next().getSubject().toString();
IteratorTripleString it = header.search("", HDTVocabulary.RDF_TYPE, HDTVocabulary.HDT_DATASET); if(it.hasNext()) { this.baseUri = it.next().getSubject().toString();
totalQuadsProcessed++; Node s = this.nodeDictionary.getNode(this.hdtDictionary.stringToId(triple.getSubject(), TripleComponentRole.SUBJECT), TripleComponentRole.SUBJECT); Node p = this.nodeDictionary.getNode(this.hdtDictionary.stringToId(triple.getPredicate(), TripleComponentRole.PREDICATE), TripleComponentRole.PREDICATE); Node o = this.nodeDictionary.getNode(this.hdtDictionary.stringToId(triple.getObject(), TripleComponentRole.OBJECT), TripleComponentRole.OBJECT);