| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query.spans; |
| 2 | |
| 3 | import java.io.IOException; |
| Eliza Margaretha | 9738c39 | 2014-02-03 17:04:53 +0000 | [diff] [blame] | 4 | import java.util.ArrayList; |
| 5 | import java.util.Collection; |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 6 | import java.util.Collections; |
| Eliza Margaretha | 9738c39 | 2014-02-03 17:04:53 +0000 | [diff] [blame] | 7 | import java.util.LinkedList; |
| 8 | import java.util.List; |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 9 | import java.util.Map; |
| 10 | |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 11 | import org.apache.logging.log4j.LogManager; |
| 12 | import org.apache.logging.log4j.Logger; |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 13 | import org.apache.lucene.index.LeafReaderContext; |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 14 | import org.apache.lucene.index.Term; |
| 15 | import org.apache.lucene.index.TermContext; |
| Eliza Margaretha | 9738c39 | 2014-02-03 17:04:53 +0000 | [diff] [blame] | 16 | import org.apache.lucene.search.spans.Spans; |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 17 | import org.apache.lucene.util.Bits; |
| 18 | |
| 19 | import de.ids_mannheim.korap.query.SpanDistanceQuery; |
| 20 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 21 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 22 | * Enumeration of span matches, whose two child spans have a specific |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 23 | * range of distance (within a minimum and a maximum distance) and can |
| 24 | * occur in any order. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 25 | * |
| 26 | * @author margaretha |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 27 | */ |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 28 | public abstract class UnorderedDistanceSpans extends DistanceSpans { |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 29 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 30 | protected int minDistance, maxDistance; |
| 31 | protected boolean hasMoreFirstSpans, hasMoreSecondSpans; |
| 32 | protected List<CandidateSpan> firstSpanList, secondSpanList; |
| 33 | protected List<CandidateSpan> matchList; |
| 34 | private long matchCost; |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 35 | protected int currentDocNum; |
| Nils Diewald | 34eaa86 | 2014-06-03 10:56:27 +0000 | [diff] [blame] | 36 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 37 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 38 | * Constructs UnorderedDistanceSpans for the given |
| 39 | * {@link SpanDistanceQuery} . |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 40 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 41 | * @param query |
| 42 | * a SpanDistanceQuery |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 43 | * @param context |
| 44 | * @param acceptDocs |
| 45 | * @param termContexts |
| 46 | * @throws IOException |
| 47 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 48 | public UnorderedDistanceSpans (SpanDistanceQuery query, |
| Akron | 4299355 | 2016-02-04 13:24:24 +0100 | [diff] [blame] | 49 | LeafReaderContext context, Bits acceptDocs, |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 50 | Map<Term, TermContext> termContexts) |
| 51 | throws IOException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 52 | super(query, context, acceptDocs, termContexts); |
| 53 | minDistance = query.getMinDistance(); |
| 54 | maxDistance = query.getMaxDistance(); |
| Nils Diewald | 34eaa86 | 2014-06-03 10:56:27 +0000 | [diff] [blame] | 55 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 56 | firstSpanList = new ArrayList<CandidateSpan>(); |
| 57 | secondSpanList = new ArrayList<CandidateSpan>(); |
| 58 | matchList = new ArrayList<CandidateSpan>(); |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 59 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 60 | hasMoreFirstSpans = firstSpans.next(); |
| 61 | hasMoreSecondSpans = secondSpans.next(); |
| 62 | hasMoreSpans = hasMoreFirstSpans && hasMoreSecondSpans; |
| 63 | } |
| Eliza Margaretha | 9738c39 | 2014-02-03 17:04:53 +0000 | [diff] [blame] | 64 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 65 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 66 | protected boolean advance () throws IOException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 67 | while (hasMoreSpans || !matchList.isEmpty()) { |
| 68 | if (!matchList.isEmpty()) { |
| 69 | setMatchProperties(); |
| 70 | return true; |
| 71 | } |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 72 | if (prepareLists()) setMatchList(); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 73 | } |
| 74 | return false; |
| 75 | } |
| Nils Diewald | 34eaa86 | 2014-06-03 10:56:27 +0000 | [diff] [blame] | 76 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 77 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 78 | * Updates the firstSpanList and secondSpanList by adding the next |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 79 | * possible first and second spans. Both the spans must be in the |
| 80 | * same document. In UnorderedElementDistanceSpans, a span that is |
| 81 | * not in an element (distance unit), is not added to its |
| 82 | * candidate list. The element must also be in the same document. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 83 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 84 | * @return <code>true</code> if at least one of the candidate |
| 85 | * lists can be |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 86 | * filled, <code>false</code> otherwise. |
| 87 | * @throws IOException |
| 88 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 89 | protected abstract boolean prepareLists () throws IOException; |
| 90 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 91 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 92 | * Sets the list of matches for the span having the smallest |
| margaretha | 50110f3 | 2015-05-12 18:21:29 +0200 | [diff] [blame] | 93 | * position (i.e. between the first and the second spans), and its |
| 94 | * candidates (i.e. its counterparts). The candidates also must |
| 95 | * have smaller positions. Simply remove the span if it does not |
| 96 | * have any candidates. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 97 | * |
| 98 | * @throws IOException |
| 99 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 100 | protected void setMatchList () throws IOException { |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 101 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 102 | hasMoreFirstSpans = setCandidateList(firstSpanList, firstSpans, |
| 103 | hasMoreFirstSpans, secondSpanList); |
| 104 | hasMoreSecondSpans = setCandidateList(secondSpanList, secondSpans, |
| 105 | hasMoreSecondSpans, firstSpanList); |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 106 | // System.out.println("--------------------"); |
| 107 | // System.out.println("firstSpanList:"); |
| 108 | // for (CandidateSpan cs : firstSpanList) { |
| 109 | // System.out.println(cs.getStart() + " " + cs.getEnd()); |
| 110 | // } |
| 111 | // |
| 112 | // System.out.println("secondSpanList:"); |
| 113 | // for (CandidateSpan cs : secondSpanList) { |
| 114 | // System.out.println(cs.getStart() + " " + cs.getEnd()); |
| 115 | // } |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 116 | |
| 117 | CandidateSpan currentFirstSpan, currentSecondSpan; |
| 118 | if (!firstSpanList.isEmpty() && !secondSpanList.isEmpty()) { |
| 119 | |
| 120 | currentFirstSpan = firstSpanList.get(0); |
| 121 | currentSecondSpan = secondSpanList.get(0); |
| 122 | |
| margaretha | 50110f3 | 2015-05-12 18:21:29 +0200 | [diff] [blame] | 123 | if (currentFirstSpan.getStart() < currentSecondSpan.getStart() |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 124 | || isLastCandidateSmaller(currentFirstSpan, |
| 125 | currentSecondSpan)) { |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 126 | matchList = findMatches(currentFirstSpan, secondSpanList, true); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 127 | updateList(firstSpanList); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 128 | } |
| 129 | else { |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 130 | matchList = |
| 131 | findMatches(currentSecondSpan, firstSpanList, false); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 132 | updateList(secondSpanList); |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 133 | |
| 134 | if (currentFirstSpan.getStart() == currentSecondSpan.getStart() |
| 135 | && currentFirstSpan.getEnd() == currentSecondSpan |
| 136 | .getEnd()) { |
| 137 | matchList.addAll(findMatches(currentFirstSpan, |
| 138 | secondSpanList, false)); |
| 139 | Collections.sort(matchList); |
| 140 | updateList(firstSpanList); |
| 141 | } |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 142 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 143 | } |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 144 | else if (!secondSpanList.isEmpty()) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 145 | updateList(secondSpanList); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 146 | } |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 147 | else if (!firstSpanList.isEmpty()) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 148 | updateList(firstSpanList); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 153 | * Tells if the last candidate from the secondSpanList has a |
| margaretha | 50110f3 | 2015-05-12 18:21:29 +0200 | [diff] [blame] | 154 | * smaller end position than the end position of the the last |
| 155 | * candidate from the firstSpanList. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 156 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 157 | * @param currentFirstSpan |
| 158 | * the current firstspan |
| 159 | * @param currentSecondSpan |
| 160 | * the current secondspan |
| 161 | * @return <code>true</code> if the end position of the last |
| margaretha | 50110f3 | 2015-05-12 18:21:29 +0200 | [diff] [blame] | 162 | * candidate from the secondSpanList is smaller than that |
| 163 | * from the firstSpanList, <code>false</code> otherwise. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 164 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 165 | private boolean isLastCandidateSmaller (CandidateSpan currentFirstSpan, |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 166 | CandidateSpan currentSecondSpan) { |
| 167 | if (currentFirstSpan.getEnd() == currentSecondSpan.getEnd()) { |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 168 | int secondEnd = |
| 169 | secondSpanList.get(secondSpanList.size() - 1).getEnd(); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 170 | int firstEnd = firstSpanList.get(firstSpanList.size() - 1).getEnd(); |
| 171 | return (secondEnd < firstEnd ? true : false); |
| 172 | } |
| 173 | |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Performs an update based on the given candidateList. In |
| 179 | * {@link UnorderedTokenDistanceSpans}, the first candidate in the |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 180 | * candidateList is simply removed. In |
| 181 | * {@link UnorderedElementDistanceSpans} , the elementList is also |
| 182 | * updated. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 183 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 184 | * @param candidateList |
| 185 | * a candidateList |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 186 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 187 | protected abstract void updateList (List<CandidateSpan> candidateList); |
| 188 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 189 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 190 | * Sets the candidate list for the first element in the target |
| 191 | * list and |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 192 | * tells if the the specified spans has finished or not. |
| 193 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 194 | * @param candidateList |
| 195 | * a list of candidate spans |
| 196 | * @param candidate |
| 197 | * a Spans |
| 198 | * @param hasMoreCandidates |
| 199 | * a boolean |
| 200 | * @param targetList |
| 201 | * a list of target spans |
| 202 | * @return <code>true</code> if the span enumeration still has a |
| 203 | * next |
| 204 | * element to be a candidate, <code>false</code> |
| 205 | * otherwise. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 206 | * @throws IOException |
| 207 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 208 | protected abstract boolean setCandidateList ( |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 209 | List<CandidateSpan> candidateList, Spans candidate, |
| 210 | boolean hasMoreCandidates, List<CandidateSpan> targetList) |
| 211 | throws IOException; |
| 212 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 213 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 214 | * Finds all matches between the target span and its candidates in |
| 215 | * the |
| 216 | * candidate list. |
| 217 | * |
| 218 | * @param target |
| 219 | * a target span |
| 220 | * @param candidateList |
| 221 | * a candidate list |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 222 | * @param isTargetFirstSpan |
| 223 | * true is the target span is of the first span, false |
| 224 | * otherwise |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 225 | * @return the matches in a list |
| 226 | */ |
| 227 | protected abstract List<CandidateSpan> findMatches (CandidateSpan target, |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 228 | List<CandidateSpan> candidateList, boolean isTargetFirstSpan); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 229 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 230 | /** |
| 231 | * Computes match properties and creates a candidate span match to |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 232 | * be added to the match list. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 233 | * |
| 234 | * @return a candidate span match |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 235 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 236 | protected CandidateSpan createMatchCandidate (CandidateSpan target, |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 237 | CandidateSpan cs, boolean isDistanceZero, |
| 238 | boolean isTargetFirstSpan) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 239 | |
| 240 | int start = Math.min(target.getStart(), cs.getStart()); |
| 241 | int end = Math.max(target.getEnd(), cs.getEnd()); |
| 242 | int doc = target.getDoc(); |
| 243 | long cost = target.getCost() + cs.getCost(); |
| 244 | |
| 245 | Collection<byte[]> payloads = new LinkedList<byte[]>(); |
| 246 | if (collectPayloads) { |
| 247 | if (target.getPayloads() != null) { |
| 248 | payloads.addAll(target.getPayloads()); |
| 249 | } |
| 250 | if (cs.getPayloads() != null) { |
| 251 | payloads.addAll(cs.getPayloads()); |
| 252 | } |
| 253 | } |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 254 | CandidateSpan match = |
| 255 | new CandidateSpan(start, end, doc, cost, payloads); |
| margaretha | 3512087 | 2016-12-19 18:24:22 +0100 | [diff] [blame] | 256 | if (isTargetFirstSpan) { |
| 257 | match.setChildSpan(target); |
| 258 | match.setSecondChildSpan(cs); |
| 259 | } |
| 260 | else { |
| 261 | match.setChildSpan(cs); |
| 262 | match.setSecondChildSpan(target); |
| 263 | } |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 264 | // match.setChildSpan(cs); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 265 | return match; |
| 266 | } |
| 267 | |
| 268 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 269 | * Assigns the first candidate span in the match list as the |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 270 | * current span match, and removes it from the matchList. |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 271 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 272 | private void setMatchProperties () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 273 | CandidateSpan cs = matchList.get(0); |
| 274 | matchDocNumber = cs.getDoc(); |
| 275 | matchStartPosition = cs.getStart(); |
| 276 | matchEndPosition = cs.getEnd(); |
| 277 | matchCost = cs.getCost(); |
| 278 | matchPayload.addAll(cs.getPayloads()); |
| 279 | matchList.remove(0); |
| 280 | |
| margaretha | c66265c | 2016-12-14 13:48:45 +0100 | [diff] [blame] | 281 | setMatchFirstSpan(cs.getChildSpan()); |
| 282 | setMatchSecondSpan(cs.getSecondChildSpan()); |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 283 | |
| 284 | // log.trace("Match doc#={} start={} end={}", matchDocNumber, |
| 285 | // matchStartPosition, matchEndPosition); |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 286 | // log.trace("firstspan " + getMatchFirstSpan().getStart() + " |
| 287 | // " |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 288 | // + getMatchFirstSpan().getEnd()); |
| margaretha | bb5c26c | 2019-03-12 13:54:22 +0100 | [diff] [blame] | 289 | // log.trace("secondspan " + getMatchSecondSpan().getStart() + |
| 290 | // " " |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 291 | // + getMatchSecondSpan().getEnd()); |
| 292 | } |
| 293 | |
| 294 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 295 | public boolean skipTo (int target) throws IOException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 296 | if (hasMoreSpans && (secondSpans.doc() < target)) { |
| 297 | if (!secondSpans.skipTo(target)) { |
| 298 | hasMoreSpans = false; |
| 299 | return false; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | firstSpanList.clear(); |
| 304 | secondSpanList.clear(); |
| 305 | matchPayload.clear(); |
| 306 | isStartEnumeration = false; |
| 307 | return advance(); |
| 308 | } |
| 309 | |
| 310 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 311 | public long cost () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 312 | return matchCost; |
| 313 | } |
| Eliza Margaretha | 1751dbf | 2014-02-03 09:47:19 +0000 | [diff] [blame] | 314 | |
| 315 | } |