| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public boolean test(final QueryContext qc, final InputInfo ii, final long pos) |
| 35 | throws QueryException { |
| 36 | final Iter iter1 = exprs[0].atomIter(qc, info); |
| 37 | final long size1 = iter1.size(); |
| 38 | if(size1 == 0) return false; |
| 39 | |
| 40 | // stable right-hand operand: probe against populated cache without re-evaluating expr2 |
| 41 | final CmpCache cache = qc.threads.get(this, info).get(); |
| 42 | if(stable && cache.value != null) return probe(iter1, cache, qc); |
| 43 | |
| 44 | // dynamic right-hand operand: evaluate, consult cache, fall back if not eligible |
| 45 | final Iter iter2 = exprs[1].atomIter(qc, info); |
| 46 | final long size2 = iter2.size(); |
| 47 | if(size2 == 0) return false; |
| 48 | // check if iterator is based on value with more than one item, check if caching is enabled |
| 49 | if(iter2.valueIter() && size2 > 1 && cache.active(iter2.value(qc, null), iter2)) { |
| 50 | return probe(iter1, cache, qc); |
| 51 | } |
| 52 | return super.compare(iter1, iter2, size1, size2, qc); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Probes items of the left-hand operand against the cached hash set, lazily extending the set |