@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); triplePatterns.add(triple); } } } });
@Override public void visit(final ElementPathBlock el) { for (Iterator<TriplePath> iterator = el.patternElts(); iterator.hasNext();) { TriplePath tp = iterator.next(); if (inOptionalClause) { optionalTriplePattern.add(tp.asTriple()); } else { if (tp.isTriple()) { triplePattern.add(tp.asTriple()); } } } }
@Override public boolean equals(Object other) { if ( this == other) return true ; if ( ! ( other instanceof TriplePath) ) return false ; TriplePath tp = (TriplePath)other ; // True if one is true and one is false if ( tp.isTriple() ^ this.isTriple() ) return false ; if ( isTriple() ) return asTriple().equals(tp.asTriple()) ; else return subject.equals(tp.subject) && object.equals(tp.object) && path.equals(tp.path) ; }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iterator = el.patternElts(); iterator.hasNext();) { TriplePath tp = iterator.next(); if(inOptionalClause){ if(tp.isTriple()){ optionalTriplePattern.add(tp.asTriple()); if(!parents.isEmpty()){ triple2Parent.put(tp.asTriple(), parents.peek()); } } } else { if(tp.isTriple()){ triplePattern.add(tp.asTriple()); if(!parents.isEmpty()){ triple2Parent.put(tp.asTriple(), parents.peek()); } } } } }
@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); Node subject = triple.getSubject(); if(subject.equals(source)) { outgoingTriples.add(triple); } } } } });
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) VarUtils.addVarsFromTriple(acc, tp.asTriple()) ; else VarUtils.addVarsFromTriplePath(acc, tp) ; } }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) { VarUtils.addVarsFromTriple(vars, tp.asTriple()) ; } else { VarUtils.addVarsFromTriplePath(vars, tp) ; } } }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) { VarUtils.addVarsFromTriple(vars, tp.asTriple()) ; } else { VarUtils.addVarsFromTriplePath(vars, tp) ; } } }
@Override public int hashCode() { if ( hash == -1 ) { if ( isTriple() ) hash = asTriple().hashCode() ; else hash = (subject.hashCode()<<2) ^ path.hashCode() ^ (object.hashCode()<<1) ; } return hash ; }
@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); Node subject = triple.getSubject(); if(subject.equals(source) && triple.getObject().isVariable()) { outgoingTriples.add(triple); } } } } });
public static boolean triplePathIso(TriplePath tp1, TriplePath tp2, NodeIsomorphismMap isoMap) { if ( tp1.isTriple() ^ tp2.isTriple() ) return false ; if ( tp1.isTriple() ) return Iso.tripleIso(tp1.asTriple(), tp2.asTriple(), isoMap) ; else return Iso.nodeIso(tp1.getSubject(), tp2.getSubject(), isoMap) && Iso.nodeIso(tp1.getObject(), tp2.getObject(), isoMap) && tp1.getPath().equalTo(tp2.getPath(), isoMap) ; }
protected void insert(TripleCollector target, ElementPathBlock source) { for ( TriplePath path : source.getPattern() ) { if ( path.isTriple() ) { target.addTriple(path.asTriple()) ; } else { target.addTriplePath(path) ; } } }
void reduce(PathBlock x, PathBlock pathBlock, VarAlloc varAlloc ) { for ( TriplePath tp : pathBlock ) { if ( tp.isTriple() ) { x.add(tp) ; continue ; } reduce(x, varAlloc, tp.getSubject(), tp.getPath(), tp.getObject()) ; } }
@Override public void visit(ElementPathBlock el) { for (final TriplePath pth : el.getPattern().getList()) { if ( ! pth.isTriple()) { throw new QueryParseException("Paths not permitted in data quad", -1, -1) ; } } iter = iter.andThen( WrappedIterator.create(el.getPattern().getList().iterator()) .mapWith( pth -> pth.asTriple() ) .mapWith( MAP )); }
@Override public void visit(ElementPathBlock el) { for (final TriplePath pth : el.getPattern().getList()) { if ( ! pth.isTriple()) { throw new QueryParseException("Paths not permitted in data quad", -1, -1) ; } } iter = iter.andThen( WrappedIterator.create(el.getPattern().getList().iterator()) .mapWith( pth -> pth.asTriple() ) .mapWith( MAP )); }
public static QueryIterator execTriplePath(Binding binding, TriplePath triplePath, ExecutionContext execCxt) { if ( triplePath.isTriple() ) { // Fake it. This happens only for API constructed situations. Path path = new P_Link(triplePath.getPredicate()); triplePath = new TriplePath(triplePath.getSubject(), path, triplePath.getObject()); } return execTriplePath(binding, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject(), execCxt) ; }
/** Convert any paths of exactly one predicate to a triple pattern */ public static Op pathToTriples(PathBlock pattern) { BasicPattern bp = null; Op op = null; for ( TriplePath tp : pattern ) { if ( tp.isTriple() ) { if ( bp == null ) bp = new BasicPattern(); bp.add(tp.asTriple()); continue; } // Path form. op = flush(bp, op); bp = null; OpPath opPath2 = new OpPath(tp); op = OpSequence.create(op, opPath2); continue; } // End. Finish off any outstanding BGP. op = flush(bp, op); return op; }
public static TriplePath substitute(TriplePath triplePath, Binding binding) { if ( triplePath.isTriple() ) return new TriplePath(Substitute.substitute(triplePath.asTriple(), binding)); Node s = triplePath.getSubject(); Node o = triplePath.getObject(); Node s1 = substitute(s, binding); Node o1 = substitute(o, binding); TriplePath tp = triplePath; if ( s1 != s || o1 != o ) tp = new TriplePath(s1, triplePath.getPath(), o1); return tp; }
private TriplePath transform(TriplePath path) { Node s = path.getSubject() ; Node s1 = transform(s) ; Node o = path.getObject() ; Node o1 = transform(o) ; if ( path.isTriple() ) { Node p = path.getPredicate() ; Node p1 = transform(p) ; if ( s == s1 && p == p1 && o == o1 ) return path ; return new TriplePath(Triple.create(s1, p1, o1)) ; } if ( s == s1 && o == o1 ) return path ; return new TriplePath(s1, path.getPath(), o1) ; }
private TriplePath transform(TriplePath path) { Node s = path.getSubject() ; Node s1 = transform(s) ; Node o = path.getObject() ; Node o1 = transform(o) ; if ( path.isTriple() ) { Node p = path.getPredicate() ; Node p1 = transform(p) ; if ( s == s1 && p == p1 && o == o1 ) return path ; return new TriplePath(Triple.create(s1, p1, o1)) ; } if ( s == s1 && o == o1 ) return path ; return new TriplePath(s1, path.getPath(), o1) ; }