Fixed issue #16 (added skipTo in ElementDistanceSpan)
Change-Id: I671a95515376d54ddaa2091eb8044f3c76238569
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
index dd53ac5..bd7af52 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
@@ -108,7 +108,6 @@
private void addNewCandidates () throws IOException {
while (hasMoreFirstSpans && firstSpans.doc() == candidateListDocNum
&& firstSpans.start() < secondSpans.end()) {
-
if (advanceElementTo(firstSpans)) {
candidateList
.add(new CandidateSpan(firstSpans, elementPosition));
@@ -161,10 +160,8 @@
}
i.remove();
}
- // System.out.println("pos "+position+" " +candidateList.size());
}
-
@Override
protected boolean isSecondSpanValid () throws IOException {
if (advanceElementTo(secondSpans)) {
@@ -176,6 +173,26 @@
return false;
}
+ @Override
+ public boolean skipTo (int target) throws IOException {
+ if (hasMoreSpans && (secondSpans.doc() < target)) {
+ if (!secondSpans.skipTo(target)) {
+ candidateList.clear();
+ return false;
+ }
+ }
+
+ setCandidateList();
+
+ while (hasMoreSpans && !isSecondSpanValid()){
+ hasMoreSpans = secondSpans.next();
+ setCandidateList();
+ }
+
+ matchPayload.clear();
+ isStartEnumeration = false;
+ return advance();
+ }
@Override
public long cost () {