public BitmapTriplesIteratorZFOQ(BitmapTriples triples, TripleID pattern) { this.triples = triples; this.pattern = new TripleID(pattern); this.returnTriple = new TripleID(); TripleOrderConvert.swapComponentOrder(this.pattern, TripleComponentOrder.SPO, triples.order); patZ = this.pattern.getObject(); if(patZ==0 && (patY!=0 || this.pattern.getSubject()!=0)) { throw new IllegalArgumentException("This structure is not meant to process this pattern"); } patY = this.pattern.getPredicate(); adjY = triples.adjY; adjIndex = triples.adjIndex; calculateRange(); goToStart(); }
@Override public boolean canGoTo() { return pattern.isEmpty(); }
public static void swapComponentOrder(TripleID triple, TripleComponentOrder from, TripleComponentOrder to) { if(from==to) { return; } if(from==TripleComponentOrder.Unknown || to==TripleComponentOrder.Unknown) { throw new IllegalArgumentException("Cannot swap Unknown Orders"); } boolean swap1 = swap1tab[from.ordinal() - 1][to.ordinal() - 1]; boolean swap2 = swap2tab[from.ordinal() - 1][to.ordinal() - 1]; boolean swap3 = swap3tab[from.ordinal() - 1][to.ordinal() - 1]; if(swap1){ int tmp = triple.getSubject(); triple.setSubject(triple.getPredicate()); triple.setPredicate(tmp); } if(swap2){ int tmp = triple.getSubject(); triple.setSubject(triple.getObject()); triple.setObject(tmp); } if(swap3){ int tmp = triple.getPredicate(); triple.setPredicate(triple.getObject()); triple.setObject(tmp); } } }
public void assign(TripleID replacement) { subject = replacement.getSubject(); object = replacement.getObject(); predicate = replacement.getPredicate(); }
@Override public boolean test(TripleID t) { if(varIsSO[0] && t.getSubject()>numSharedSO) { return false; } if(varIsSO[2] && t.getObject()>numSharedSO) { return false; } return true; } });
public void newSearch(TripleID pattern) { this.pattern.assign(pattern); TripleOrderConvert.swapComponentOrder(this.pattern, TripleComponentOrder.SPO, triples.order); patX = this.pattern.getSubject(); patY = this.pattern.getPredicate(); patZ = this.pattern.getObject(); adjY = triples.adjY; adjZ = triples.adjZ; // ((BitSequence375)triples.bitmapZ).dump(); findRange(); goToStart(); }
@Override public void save(OutputStream output, ControlInfo controlInformation, ProgressListener listener) throws IOException { controlInformation.clear(); controlInformation.setInt("numTriples", numValidTriples); controlInformation.setFormat(HDTVocabulary.TRIPLES_TYPE_TRIPLESLIST); controlInformation.setInt("order", order.ordinal()); controlInformation.save(output); DataOutputStream dout = new DataOutputStream(output); int count = 0; for (TripleID triple : arrayOfTriples) { if(triple.isValid()) { dout.writeInt(triple.getSubject()); dout.writeInt(triple.getPredicate()); dout.writeInt(triple.getObject()); ListenerUtil.notifyCond(listener, "Saving TriplesList", count, arrayOfTriples.size()); } count++; } }
@Override public boolean insert(int subject, int predicate, int object) { arrayOfTriples.add(new TripleID(subject,predicate,object)); numValidTriples++; sorted = false; return true; }
patternID.setSubject(translateBinding(input, var[0], dictionary, TripleComponentRole.SUBJECT)); patternID.setPredicate(translateBinding(input, var[1], dictionary, TripleComponentRole.PREDICATE)); patternID.setObject(translateBinding(input, var[2], dictionary, TripleComponentRole.OBJECT)); if(patternID.isNoMatch()) {
public BitmapTriplesIteratorY(BitmapTriples triples, TripleID pattern) { this.triples = triples; this.pattern = new TripleID(pattern); this.returnTriple = new TripleID(); TripleOrderConvert.swapComponentOrder(this.pattern, TripleComponentOrder.SPO, triples.order); patY = this.pattern.getPredicate(); if(patY==0) { throw new IllegalArgumentException("This structure is not meant to process this pattern"); } adjY = triples.adjY; adjZ = triples.adjZ; goToStart(); }
BitmapTriplesIteratorZ(BitmapTriples triples, TripleID pattern) { this.triples = triples; this.pattern = new TripleID(pattern); this.returnTriple = new TripleID(); TripleOrderConvert.swapComponentOrder(this.pattern, TripleComponentOrder.SPO, triples.order); patZ = this.pattern.getObject(); if(patZ==0) { throw new IllegalArgumentException("This structure is not meant to process this pattern"); } adjY = triples.adjY; adjZ = triples.adjZ; goToStart(); }
if (getNumberOfElements() == 0 || pattern.isNoMatch()) { return new EmptyTriplesIterator(order); TripleID reorderedPat = new TripleID(pattern); TripleOrderConvert.swapComponentOrder(reorderedPat, TripleComponentOrder.SPO, order); String patternString = reorderedPat.getPatternString();
@Override public int compare(TripleID o1, TripleID o2) { int result = o1.getSubject() - o2.getSubject(); if (result == 0) { result = o1.getPredicate() - o2.getPredicate(); if (result == 0) { // The third component is different? return o1.getObject() - o2.getObject(); } else { // the second component is different return result; } } else { // the first component is different return result; } }
@Override public boolean insert(TripleID... triples) { for (TripleID triple : triples) { arrayOfTriples.add(new TripleID(triple)); numValidTriples++; } sorted = false; return true; }
public BitmapTriplesIteratorYFOQ(BitmapTriples triples, TripleID pattern) { this.triples = triples; this.pattern = new TripleID(pattern); this.returnTriple = new TripleID(); TripleOrderConvert.swapComponentOrder(this.pattern, TripleComponentOrder.SPO, triples.order); patY = this.pattern.getPredicate(); if(patY==0) { throw new IllegalArgumentException("This structure is not meant to process this pattern"); } adjY = new AdjacencyList(triples.getSeqY(), triples.getBitmapY()); adjZ = new AdjacencyList(triples.getSeqZ(), triples.getBitmapZ()); numOccurrences = triples.predicateIndex.getNumOcurrences(patY); predBase = triples.predicateIndex.getBase(patY); maxZ = triples.adjZ.getNumberOfElements(); goToStart(); }
/** * Check whether this triple matches a pattern of TripleID. 0 acts as a wildcard * * @param pattern * The pattern to match against * @return boolean */ public boolean match(TripleID pattern) { // get the components of the pattern int subjectPattern = pattern.getSubject(); int predicatePattern = pattern.getPredicate(); int objectPattern = pattern.getObject(); /* Remember that 0 acts as a wildcard */ if (subjectPattern == 0 || this.subject == subjectPattern) { if (predicatePattern == 0 || this.predicate == predicatePattern) { if (objectPattern == 0 || this.object == objectPattern) { return true; } } } return false; }
private void fetchBlock() { reset(); int [] arrSubjects = new int[blockSize]; int [] arrPredicates = new int[blockSize]; int [] arrObjects = new int[blockSize]; int count=0; for(int i=0;i<blockSize && iterator.hasNext();i++) { TripleID t = new TripleID(iterator.next()); triples.add(t); if(s.length()==0) arrSubjects[count] = t.getSubject(); if(p.length()==0) arrPredicates[count] = t.getPredicate(); if(o.length()==0) arrObjects[count] = t.getObject(); count++; } if(s.length()==0) fill(arrSubjects, count, mapSubject, TripleComponentRole.SUBJECT); if(p.length()==0) fill(arrPredicates, count, mapPredicate, TripleComponentRole.PREDICATE); if(o.length()==0) fill(arrObjects, count, mapObject, TripleComponentRole.OBJECT); this.child = triples.iterator(); }