blob: 67156cc86c248e2a88a2e29c9ed788f0d4ac4c54 (
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
|
// 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;
/**
* Implementation of PostingList for regular features that store
* their intervals and nothing else.
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
* @author bjorncs
*/
public class IntervalPostingList extends MultiIntervalPostingList {
private final PredicateIntervalStore store;
private int[] currentIntervals;
private int currentIntervalIndex;
private int currentInterval;
public IntervalPostingList(PredicateIntervalStore store, int[] docIds, int[] dataRefs, long subquery) {
super(docIds, dataRefs, subquery);
this.store = store;
}
@Override
protected boolean prepareIntervals(int dataRef) {
currentIntervals = store.get(dataRef);
currentIntervalIndex = 1;
currentInterval = currentIntervals[0];
return true;
}
@Override
public boolean nextInterval() {
if (currentIntervalIndex < currentIntervals.length) {
this.currentInterval = currentIntervals[currentIntervalIndex++];
return true;
}
return false;
}
@Override
public int getInterval() {
return currentInterval;
}
}
|