MCPcopy Create free account
hub / github.com/BaseXdb/basex / compare

Method compare

basex-core/src/main/java/org/basex/query/expr/CmpG.java:200–225  ·  view source on GitHub ↗

Compares all values of the first and second iterators. @param iter1 first atomic iterator @param iter2 second atomic iterator @param size1 size of first iterator @param size2 size of second iterator @param qc query context @return result of check @throws QueryException query exception

(final Iter iter1, final Iter iter2, final long size1, final long size2,
      final QueryContext qc)

Source from the content-addressed store, hash-verified

198 * @throws QueryException query exception
199 */
200 boolean compare(final Iter iter1, final Iter iter2, final long size1, final long size2,
201 final QueryContext qc) throws QueryException {
202 // improve cache efficiency by looping the smaller array in the outer loop
203 if(size1 < size2 || size2 == -1) {
204 // (1, 2) = (3, 4, 5, 6, 7) → 1 = 3, 1 = 4, ..., 2 = 3, ...
205 Iter ir2 = iter2;
206 for(Item item1; (item1 = iter1.next()) != null;) {
207 if(ir2 == null) ir2 = exprs[1].atomIter(qc, info);
208 for(Item item2; (item2 = qc.next(ir2)) != null;) {
209 if(eval(item1, item2)) return true;
210 }
211 ir2 = null;
212 }
213 } else {
214 // (1, 2, 3, 4, 5) = (6, 7) → 1 = 6, 2 = 6, ..., 1 = 7, ...
215 Iter ir1 = iter1;
216 for(Item item2; (item2 = iter2.next()) != null;) {
217 if(ir1 == null) ir1 = exprs[0].atomIter(qc, info);
218 for(Item item1; (item1 = qc.next(ir1)) != null;) {
219 if(eval(item1, item2)) return true;
220 }
221 ir1 = null;
222 }
223 }
224 return false;
225 }
226
227 /**
228 * Compares a single item.

Callers 8

testMethod · 0.95
nextMethod · 0.45
evalMethod · 0.45
testMethod · 0.45
evalMethod · 0.45
nextMethod · 0.45
testMethod · 0.45
nextMethod · 0.45

Calls 3

evalMethod · 0.95
nextMethod · 0.65
atomIterMethod · 0.45

Tested by

no test coverage detected