blob: 231aa67d7917d5a26e951cdba466e5cfb18e8b00 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.predicate.index.conjunction;
/**
* Conjunction id posting list iterator for a single feature/assignment (e.g. a=b).
*
* @author bjorncs
*/
public class ConjunctionIdIterator {
private final int[] conjunctionIds;
private final long subqueryBitmap;
private int currentConjunctionId;
private int length;
private int index;
public ConjunctionIdIterator(long subqueryBitmap, int[] conjunctionIds) {
this.subqueryBitmap = subqueryBitmap;
this.conjunctionIds = conjunctionIds;
this.currentConjunctionId = conjunctionIds[0];
this.length = conjunctionIds.length;
this.index = 0;
}
public boolean next(int conjunctionId) {
if (index == length) return false;
int candidate = currentConjunctionId;
while (ConjunctionId.compare(conjunctionId, candidate) > 0 && ++index < length) {
candidate = conjunctionIds[index];
}
currentConjunctionId = candidate;
return ConjunctionId.compare(conjunctionId, candidate) <= 0;
}
public long getSubqueryBitmap() {
return subqueryBitmap;
}
public int getConjunctionId() {
return currentConjunctionId;
}
public int[] getConjunctionIds() {
return conjunctionIds;
}
}
|