| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query.spans; |
| 2 | |
| Eliza Margaretha | 2289898 | 2014-11-04 17:10:21 +0000 | [diff] [blame] | 3 | import java.io.IOException; |
| 4 | import java.util.ArrayList; |
| 5 | import java.util.Collection; |
| 6 | import java.util.LinkedList; |
| 7 | import java.util.Map; |
| 8 | |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 9 | import org.apache.lucene.index.LeafReaderContext; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 10 | import org.apache.lucene.index.Term; |
| 11 | import org.apache.lucene.index.TermContext; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 12 | import org.apache.lucene.search.DocIdSetIterator; |
| Eliza Margaretha | 2289898 | 2014-11-04 17:10:21 +0000 | [diff] [blame] | 13 | import org.apache.lucene.search.spans.Spans; |
| 14 | import org.apache.lucene.util.Bits; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 15 | import org.slf4j.Logger; |
| 16 | import org.slf4j.LoggerFactory; |
| 17 | |
| Eliza Margaretha | 2289898 | 2014-11-04 17:10:21 +0000 | [diff] [blame] | 18 | import de.ids_mannheim.korap.query.SpanWithinQuery; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 19 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * SpanWithinQuery is DEPRECATED and will |
| 23 | * be replaced by SpanPositionQuery in the near future |
| Nils Diewald | cb8afb3 | 2015-02-04 21:12:37 +0000 | [diff] [blame] | 24 | * |
| 25 | * TODO: Support exclusivity |
| 26 | * TODO: Use the term "queue" and implement it similar to SpanOrQuery |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 27 | */ |
| 28 | |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 29 | /** |
| Nils Diewald | 1455e1e | 2014-08-01 16:12:43 +0000 | [diff] [blame] | 30 | * Compare two spans and check how they relate positionally. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 31 | * |
| Nils Diewald | 44d5fa1 | 2015-01-15 21:31:52 +0000 | [diff] [blame] | 32 | * @author diewald |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 33 | */ |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 34 | public class WithinSpans extends Spans { |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 35 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 36 | // Logger |
| 37 | private final Logger log = LoggerFactory.getLogger(WithinSpans.class); |
| Nils Diewald | 1455e1e | 2014-08-01 16:12:43 +0000 | [diff] [blame] | 38 | |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 39 | // This advices the java compiler to ignore all loggings |
| 40 | public static final boolean DEBUG = false; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 41 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 42 | private boolean more = false; |
| 43 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 44 | // Boolean value indicating if span B |
| 45 | // should be forwarded next (true) |
| 46 | // or span A (false); |
| 47 | boolean nextSpanB = true; |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 48 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 49 | private int wrapStart = -1, wrapEnd = -1, embeddedStart = -1, |
| 50 | embeddedEnd = -1, wrapDoc = -1, embeddedDoc = -1, matchDoc = -1, |
| 51 | matchStart = -1, matchEnd = -1; |
| 52 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 53 | private Collection<byte[]> matchPayload; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 54 | private Collection<byte[]> embeddedPayload; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 55 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 56 | // Indicates that the wrap and the embedded spans are in the same doc |
| 57 | private boolean inSameDoc = false; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 58 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 59 | /* |
| 60 | Supported flags are currently: |
| Nils Diewald | cb8afb3 | 2015-02-04 21:12:37 +0000 | [diff] [blame] | 61 | ov -> 0 | overlap: A & B != empty |
| 62 | rov -> 2 | real overlap: A & B != empty and |
| 63 | ((A | B) != A or |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 64 | (A | B) != B) |
| Nils Diewald | cb8afb3 | 2015-02-04 21:12:37 +0000 | [diff] [blame] | 65 | in -> 4 | within: A | B = A |
| 66 | rin -> 6 | real within: A | B = A and |
| 67 | A & B != A |
| 68 | ew -> 8 | endswith: A | B = A and |
| 69 | A.start = B.start |
| 70 | sw -> 10 | startswith: A | B = A and |
| 71 | A.end = B.end |
| 72 | m -> 12 | A = B |
| 73 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 74 | public static final byte OVERLAP = (byte) 0, REAL_OVERLAP = (byte) 2, |
| 75 | WITHIN = (byte) 4, REAL_WITHIN = (byte) 6, ENDSWITH = (byte) 8, |
| 76 | STARTSWITH = (byte) 10, MATCH = (byte) 12; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 77 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 78 | private byte flag; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 79 | |
| Nils Diewald | 1455e1e | 2014-08-01 16:12:43 +0000 | [diff] [blame] | 80 | // Contains the query |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 81 | private SpanWithinQuery query; |
| 82 | |
| Nils Diewald | cb8afb3 | 2015-02-04 21:12:37 +0000 | [diff] [blame] | 83 | // Representing the first operand |
| 84 | private final Spans wrapSpans; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 85 | |
| Nils Diewald | cb8afb3 | 2015-02-04 21:12:37 +0000 | [diff] [blame] | 86 | // Representing the second operand |
| 87 | private final Spans embeddedSpans; |
| 88 | |
| 89 | // Check flag if the current constellation |
| 90 | // was checked yet |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 91 | private boolean tryMatch = true; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 92 | |
| Nils Diewald | 01ff7af | 2015-02-04 22:54:26 +0000 | [diff] [blame] | 93 | // Two buffers for storing candidates |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 94 | private LinkedList<WithinSpan> spanStore1, spanStore2; |
| 95 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 96 | |
| Nils Diewald | 01ff7af | 2015-02-04 22:54:26 +0000 | [diff] [blame] | 97 | /** |
| 98 | * Construct a new WithinSpans object. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 99 | * |
| 100 | * @param spanWithinQuery |
| 101 | * The parental {@link SpanWithinQuery}. |
| 102 | * @param context |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 103 | * The {@link LeafReaderContext}. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 104 | * @param acceptDocs |
| 105 | * Bit vector representing the documents |
| 106 | * to be searched in. |
| 107 | * @param termContexts |
| 108 | * A map managing {@link TermState TermStates}. |
| 109 | * @param flag |
| 110 | * A byte flag indicating the positional condition of |
| 111 | * the sub spans. |
| Nils Diewald | 01ff7af | 2015-02-04 22:54:26 +0000 | [diff] [blame] | 112 | */ |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 113 | public WithinSpans (SpanWithinQuery spanWithinQuery, |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 114 | LeafReaderContext context, Bits acceptDocs, |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 115 | Map<Term, TermContext> termContexts, byte flag) |
| 116 | throws IOException { |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 117 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 118 | if (DEBUG) |
| 119 | log.trace("Construct WithinSpans"); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 120 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 121 | // Init copies |
| 122 | this.matchPayload = new LinkedList<byte[]>(); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 123 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 124 | // Get spans |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 125 | this.wrapSpans = spanWithinQuery.wrap().getSpans(context, acceptDocs, |
| 126 | termContexts); |
| 127 | this.embeddedSpans = spanWithinQuery.embedded().getSpans(context, |
| 128 | acceptDocs, termContexts); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 129 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 130 | this.flag = flag; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 131 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 132 | // SpanStores for backtracking |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 133 | this.spanStore1 = new LinkedList<WithinSpan>(); |
| 134 | this.spanStore2 = new LinkedList<WithinSpan>(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 135 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 136 | // kept for toString() only. |
| 137 | this.query = spanWithinQuery; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 138 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 139 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 140 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 141 | // Move to next match, returning true iff any such exists. |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 142 | @Override |
| 143 | public boolean next () throws IOException { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 144 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 145 | if (DEBUG) |
| 146 | log.trace("Next with docs {}, {}", wrapDoc, embeddedDoc); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 147 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 148 | // Initialize spans |
| 149 | if (!this.init()) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 150 | this.more = false; |
| 151 | this.inSameDoc = false; |
| 152 | this.wrapDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 153 | this.embeddedDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 154 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 155 | return false; |
| 156 | }; |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 157 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 158 | // There are more spans and they are in the same document |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 159 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 160 | while (this.more && (wrapDoc == embeddedDoc || |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 161 | // this.inSameDoc || |
| 162 | this.toSameDoc())) { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 163 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 164 | log.trace("We are in the same doc: {}, {}", wrapDoc, |
| 165 | embeddedDoc); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 166 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 167 | // Both spans match according to the flag |
| 168 | // Silently the next operations are prepared |
| 169 | if (this.tryMatch && this.doesMatch()) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 170 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 171 | if (this.wrapEnd == -1) |
| 172 | this.wrapEnd = this.wrapSpans.end(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 173 | |
| 174 | this.matchStart = embeddedStart < wrapStart ? embeddedStart |
| 175 | : wrapStart; |
| 176 | this.matchEnd = embeddedEnd > wrapEnd ? embeddedEnd : wrapEnd; |
| 177 | this.matchDoc = embeddedDoc; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 178 | this.matchPayload.clear(); |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 179 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 180 | if (this.embeddedPayload != null) |
| 181 | matchPayload.addAll(embeddedPayload); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 182 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 183 | if (this.wrapSpans.isPayloadAvailable()) |
| 184 | this.matchPayload.addAll(wrapSpans.getPayload()); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 185 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 186 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 187 | log.trace(" ---- MATCH ---- {}-{} ({})", matchStart, |
| 188 | matchEnd, matchDoc); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 189 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 190 | this.tryMatch = false; |
| 191 | return true; |
| 192 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 193 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 194 | // Get next embedded |
| 195 | else if (this.nextSpanB) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 196 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 197 | // Next time try the match |
| 198 | this.tryMatch = true; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 199 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 200 | if (DEBUG) |
| 201 | log.trace("In the next embedded branch"); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 202 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 203 | WithinSpan current = null; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 204 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 205 | // New - fetch until theres a span in the correct doc or bigger |
| 206 | while (!this.spanStore2.isEmpty()) { |
| 207 | current = spanStore2.removeFirst(); |
| 208 | if (current.doc >= this.wrapDoc) |
| 209 | break; |
| 210 | }; |
| 211 | |
| 212 | |
| 213 | // There is nothing in the second store |
| 214 | if (current == null) { |
| 215 | if (DEBUG) |
| 216 | log.trace("SpanStore 2 is empty"); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 217 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 218 | // Forward with embedding |
| 219 | if (!this.embeddedSpans.next()) { |
| 220 | this.nextSpanA(); |
| 221 | continue; |
| 222 | } |
| 223 | |
| 224 | else if (DEBUG) { |
| 225 | log.trace("Fetch next embedded span"); |
| 226 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 227 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 228 | this.embeddedStart = this.embeddedSpans.start(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 229 | this.embeddedEnd = -1; |
| 230 | this.embeddedPayload = null; |
| 231 | this.embeddedDoc = this.embeddedSpans.doc(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 232 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 233 | if (this.embeddedDoc != this.wrapDoc) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 234 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 235 | if (DEBUG) { |
| 236 | log.trace("Embedded span is in a new document {}", |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 237 | _currentEmbedded().toString()); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 238 | log.trace("Reset current embedded doc"); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 239 | }; |
| 240 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 241 | /* |
| 242 | if (DEBUG) |
| 243 | log.trace("Clear all span stores"); |
| 244 | this.spanStore1.clear(); |
| 245 | this.spanStore2.clear(); |
| 246 | */ |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 247 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 248 | this.storeEmbedded(); |
| 249 | |
| 250 | // That is necessary to backtrack to the last document! |
| 251 | this.inSameDoc = true; |
| 252 | this.embeddedDoc = wrapDoc; |
| 253 | // this.tryMatch = false; // already covered in nextSpanA |
| 254 | |
| 255 | this.nextSpanA(); |
| 256 | continue; |
| 257 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 258 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 259 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 260 | log.trace(" Forward embedded span to {}", |
| 261 | _currentEmbedded().toString()); |
| 262 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 263 | if (this.embeddedDoc != this.wrapDoc) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 264 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 265 | // Is this always a good idea? |
| 266 | /* |
| 267 | this.spanStore1.clear(); |
| 268 | this.spanStore2.clear(); |
| 269 | */ |
| 270 | |
| 271 | this.embeddedStart = -1; |
| 272 | this.embeddedEnd = -1; |
| 273 | this.embeddedPayload = null; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 274 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 275 | if (!this.toSameDoc()) { |
| 276 | this.more = false; |
| 277 | this.inSameDoc = false; |
| 278 | return false; |
| 279 | }; |
| 280 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 281 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 282 | this.more = true; |
| 283 | this.inSameDoc = true; |
| 284 | this.tryMatch = true; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 285 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 286 | this.nextSpanB(); |
| 287 | continue; |
| 288 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 289 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 290 | // Fetch from second store? |
| 291 | else { |
| 292 | /** TODO: Change this to a single embedded object! */ |
| 293 | this.embeddedStart = current.start; |
| 294 | this.embeddedEnd = current.end; |
| 295 | this.embeddedDoc = current.doc; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 296 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 297 | if (current.payload != null) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 298 | this.embeddedPayload = new ArrayList<byte[]>( |
| 299 | current.payload.size()); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 300 | this.embeddedPayload.addAll(current.payload); |
| 301 | } |
| 302 | else { |
| 303 | this.embeddedPayload = null; |
| 304 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 305 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 306 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 307 | log.trace("Fetch current from SpanStore 2: {}", |
| 308 | current.toString()); |
| 309 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 310 | this.tryMatch = true; |
| 311 | }; |
| 312 | continue; |
| 313 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 314 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 315 | // get next wrap |
| 316 | if (DEBUG) |
| 317 | log.trace("In the next wrap branch"); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 318 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 319 | this.tryMatch = true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 320 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 321 | if (DEBUG) |
| 322 | log.trace("Try next wrap"); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 323 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 324 | // shift the stored spans |
| 325 | if (!this.spanStore1.isEmpty()) { |
| 326 | if (DEBUG) { |
| 327 | log.trace("Move everything from SpanStore 1 to SpanStore 2:"); |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 328 | for (WithinSpan i : this.spanStore1) { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 329 | log.trace(" | {}", i.toString()); |
| 330 | }; |
| 331 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 332 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 333 | // Move everything to spanStore2 |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 334 | this.spanStore2.addAll(0, |
| 335 | (LinkedList<WithinSpan>) this.spanStore1.clone()); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 336 | this.spanStore1.clear(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 337 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 338 | if (DEBUG) { |
| 339 | log.trace("SpanStore 2 now is:"); |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 340 | for (WithinSpan i : this.spanStore2) { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 341 | log.trace(" | {}", i.toString()); |
| 342 | }; |
| 343 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 344 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 345 | } |
| 346 | else if (DEBUG) { |
| 347 | log.trace("spanStore 1 is empty"); |
| 348 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 349 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 350 | // Get next wrap |
| 351 | if (this.wrapSpans.next()) { |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 352 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 353 | // Reset wrapping information |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 354 | this.wrapStart = this.wrapSpans.start(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 355 | this.wrapEnd = -1; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 356 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 357 | // Retrieve doc information |
| 358 | this.wrapDoc = this.wrapSpans.doc(); |
| Nils Diewald | 20607ab | 2014-03-20 23:28:36 +0000 | [diff] [blame] | 359 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 360 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 361 | log.trace(" Forward wrap span to {}", _currentWrap() |
| 362 | .toString()); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 363 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 364 | if (this.embeddedDoc != this.wrapDoc) { |
| 365 | if (DEBUG) |
| 366 | log.trace("Delete all span stores"); |
| 367 | this.spanStore1.clear(); |
| 368 | this.spanStore2.clear(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 369 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 370 | // Reset embedded: |
| 371 | this.embeddedStart = -1; |
| 372 | this.embeddedEnd = -1; |
| 373 | this.embeddedPayload = null; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 374 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 375 | if (!this.toSameDoc()) { |
| 376 | this.inSameDoc = false; |
| 377 | this.more = false; |
| 378 | return false; |
| 379 | }; |
| 380 | } |
| 381 | else { |
| 382 | this.inSameDoc = true; |
| 383 | // Do not match with the current state |
| 384 | this.tryMatch = false; |
| 385 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 386 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 387 | this.nextSpanB(); |
| 388 | continue; |
| 389 | } |
| 390 | this.more = false; |
| 391 | this.inSameDoc = false; |
| 392 | this.spanStore1.clear(); |
| 393 | this.spanStore2.clear(); |
| 394 | return false; |
| 395 | }; |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 396 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 397 | // No more matches |
| 398 | return false; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 399 | }; |
| 400 | |
| 401 | |
| 402 | /** |
| 403 | * Skip to the next document |
| 404 | */ |
| 405 | private boolean toSameDoc () throws IOException { |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 406 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 407 | if (DEBUG) |
| 408 | log.trace("Forward to find same docs"); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 409 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 410 | /* |
| 411 | if (this.embeddedSpans == null) { |
| 412 | this.more = false; |
| 413 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| 414 | this.inSameDoc = false; |
| 415 | return false; |
| 416 | }; |
| 417 | */ |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 418 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 419 | this.more = true; |
| 420 | this.inSameDoc = true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 421 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 422 | this.wrapDoc = this.wrapSpans.doc(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 423 | this.embeddedDoc = this.embeddedSpans.doc(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 424 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 425 | // Clear all spanStores |
| 426 | if (this.wrapDoc != this.embeddedDoc) { |
| 427 | /* |
| 428 | if (DEBUG) |
| 429 | log.trace("Clear all spanStores when moving forward"); |
| 430 | // Why?? |
| 431 | this.spanStore1.clear(); |
| 432 | this.spanStore2.clear(); |
| 433 | */ |
| 434 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 435 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 436 | // Last doc was reached |
| 437 | else if (this.wrapDoc == DocIdSetIterator.NO_MORE_DOCS) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 438 | this.more = false; |
| 439 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 440 | this.inSameDoc = false; |
| 441 | return false; |
| 442 | } |
| 443 | else { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 444 | if (DEBUG) { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 445 | log.trace("Current position already is in the same doc"); |
| 446 | log.trace("Embedded: {}", _currentEmbedded().toString()); |
| 447 | }; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 448 | this.matchDoc = this.embeddedDoc; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 449 | return true; |
| 450 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 451 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 452 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 453 | // Forward till match |
| 454 | while (this.wrapDoc != this.embeddedDoc) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 455 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 456 | // Forward wrapInfo |
| 457 | if (this.wrapDoc < this.embeddedDoc) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 458 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 459 | // Set document information |
| 460 | if (!wrapSpans.skipTo(this.embeddedDoc)) { |
| 461 | this.more = false; |
| 462 | this.inSameDoc = false; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 463 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 464 | return false; |
| 465 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 466 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 467 | if (DEBUG) |
| 468 | log.trace("Skip wrap to doc {}", this.embeddedDoc); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 469 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 470 | this.wrapDoc = this.wrapSpans.doc(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 471 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 472 | if (wrapDoc == DocIdSetIterator.NO_MORE_DOCS) { |
| 473 | this.more = false; |
| 474 | this.inSameDoc = false; |
| 475 | this.embeddedDoc = DocIdSetIterator.NO_MORE_DOCS; |
| 476 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| 477 | return false; |
| 478 | }; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 479 | |
| 480 | /* |
| 481 | Remove stored information |
| 482 | */ |
| 483 | if (DEBUG) |
| 484 | log.trace("Delete all span stores"); |
| 485 | |
| 486 | this.spanStore1.clear(); |
| 487 | this.spanStore2.clear(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 488 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 489 | if (wrapDoc == embeddedDoc) { |
| 490 | this.wrapStart = this.wrapSpans.start(); |
| 491 | this.embeddedStart = this.embeddedSpans.start(); |
| 492 | this.matchDoc = this.embeddedDoc; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 493 | return true; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 494 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 495 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 496 | this.wrapStart = -1; |
| 497 | this.embeddedStart = -1; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 498 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 499 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 500 | // Forward embedInfo |
| 501 | else if (this.wrapDoc > this.embeddedDoc) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 502 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 503 | // Set document information |
| 504 | if (!this.embeddedSpans.skipTo(this.wrapDoc)) { |
| 505 | this.more = false; |
| 506 | this.inSameDoc = false; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 507 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 508 | return false; |
| 509 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 510 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 511 | this.embeddedDoc = this.embeddedSpans.doc(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 512 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 513 | if (this.embeddedDoc == DocIdSetIterator.NO_MORE_DOCS) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 514 | this.more = false; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 515 | this.inSameDoc = false; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 516 | this.wrapDoc = DocIdSetIterator.NO_MORE_DOCS; |
| 517 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 518 | return false; |
| 519 | }; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 520 | |
| 521 | if (DEBUG) |
| 522 | log.trace("Skip embedded to doc {}", this.embeddedDoc); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 523 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 524 | this.embeddedStart = this.embeddedSpans.start(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 525 | this.embeddedEnd = -1; |
| 526 | this.embeddedPayload = null; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 527 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 528 | if (this.wrapDoc == this.embeddedDoc) { |
| 529 | this.matchDoc = this.embeddedDoc; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 530 | return true; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 531 | }; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 532 | } |
| 533 | else { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 534 | this.matchDoc = DocIdSetIterator.NO_MORE_DOCS; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 535 | return false; |
| 536 | }; |
| 537 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 538 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 539 | this.matchDoc = this.wrapDoc; |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 540 | return true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | |
| 544 | // Initialize spans |
| 545 | private boolean init () throws IOException { |
| 546 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 547 | // There is a missing span |
| 548 | if (this.embeddedDoc >= 0) |
| 549 | return true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 550 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 551 | if (DEBUG) |
| 552 | log.trace("Initialize spans"); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 553 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 554 | // First tick for both spans |
| 555 | if (!(this.embeddedSpans.next() && this.wrapSpans.next())) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 556 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 557 | if (DEBUG) |
| 558 | log.trace("No spans initialized"); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 559 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 560 | this.embeddedDoc = -1; |
| 561 | this.more = false; |
| 562 | return false; |
| 563 | }; |
| 564 | this.more = true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 565 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 566 | // Store current positions for wrapping and embedded spans |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 567 | this.wrapDoc = this.wrapSpans.doc(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 568 | this.embeddedDoc = this.embeddedSpans.doc(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 569 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 570 | // Set inSameDoc to true, if it is true |
| 571 | if (this.embeddedDoc == this.wrapDoc) |
| 572 | this.inSameDoc = true; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 573 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 574 | return true; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 575 | }; |
| 576 | |
| 577 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 578 | /** |
| 579 | * Skips to the first match beyond the current, whose document |
| 580 | * number is |
| 581 | * greater than or equal to <i>target</i>. <p>Returns true iff |
| 582 | * there is such |
| 583 | * a match. <p>Behaves as if written: <pre class="prettyprint"> |
| 584 | * boolean skipTo(int target) { |
| 585 | * do { |
| 586 | * if (!next()) |
| 587 | * return false; |
| 588 | * } while (target > doc()); |
| 589 | * return true; |
| 590 | * } |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 591 | * </pre> |
| 592 | * Most implementations are considerably more efficient than that. |
| 593 | */ |
| 594 | public boolean skipTo (int target) throws IOException { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 595 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 596 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 597 | log.trace("skipTo document {}/{} -> {}", this.embeddedDoc, |
| 598 | this.wrapDoc, target); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 599 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 600 | // Initialize spans |
| 601 | if (!this.init()) |
| 602 | return false; |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 603 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 604 | assert target > this.embeddedDoc; |
| Nils Diewald | 82a4b86 | 2014-02-20 21:17:41 +0000 | [diff] [blame] | 605 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 606 | // Only forward embedded spans |
| 607 | if (this.more && (this.embeddedDoc < target)) { |
| 608 | if (this.embeddedSpans.skipTo(target)) { |
| 609 | this.inSameDoc = false; |
| 610 | this.embeddedStart = -1; |
| 611 | this.embeddedEnd = -1; |
| 612 | this.embeddedPayload = null; |
| 613 | this.embeddedDoc = this.embeddedSpans.doc(); |
| 614 | } |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 615 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 616 | // Can't be skipped to target |
| 617 | else { |
| 618 | this.inSameDoc = false; |
| 619 | this.more = false; |
| 620 | return false; |
| 621 | }; |
| 622 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 623 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 624 | // Move to same doc |
| 625 | return this.toSameDoc(); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 626 | }; |
| 627 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 628 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 629 | private void nextSpanA () { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 630 | if (DEBUG) |
| 631 | log.trace("Try wrap next time"); |
| 632 | this.tryMatch = false; |
| 633 | this.nextSpanB = false; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 634 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 635 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 636 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 637 | private void nextSpanB () { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 638 | if (DEBUG) |
| 639 | log.trace("Try embedded next time"); |
| 640 | this.nextSpanB = true; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 641 | }; |
| 642 | |
| 643 | |
| 644 | // Check if the current span constellation does match |
| 645 | // Store backtracking relevant data and say, how to proceed |
| 646 | private boolean doesMatch () { |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 647 | if (DEBUG) |
| 648 | log.trace("In the match test branch"); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 649 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 650 | if (this.wrapStart == -1) |
| 651 | this.wrapStart = this.wrapSpans.start(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 652 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 653 | if (this.embeddedStart == -1) { |
| 654 | this.embeddedStart = this.embeddedSpans.start(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 655 | this.embeddedEnd = this.embeddedSpans.end(); |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 656 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 657 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 658 | this.wrapEnd = -1; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 659 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 660 | // Shortcut to prevent lazyloading of .end() |
| 661 | if (this.wrapStart > this.embeddedStart) { |
| 662 | // Can't match for in, rin, ew, sw, and m |
| 663 | // and will always lead to next_b |
| 664 | if (flag >= WITHIN) { |
| 665 | this.nextSpanB(); |
| 666 | if (DEBUG) |
| 667 | _logCurrentCase((byte) 16); |
| 668 | return false; |
| 669 | }; |
| 670 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 671 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 672 | else if (this.wrapStart < this.embeddedStart) { |
| 673 | // Can't match for sw and m and will always |
| 674 | // lead to next_a |
| 675 | if (flag >= STARTSWITH) { |
| 676 | this.nextSpanA(); |
| 677 | if (DEBUG) |
| 678 | _logCurrentCase((byte) 15); |
| 679 | return false; |
| 680 | }; |
| 681 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 682 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 683 | // Now check correctly |
| 684 | byte currentCase = this.withinCase(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 685 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 686 | if (DEBUG) |
| 687 | _logCurrentCase(currentCase); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 688 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 689 | boolean match = false; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 690 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 691 | // Test case |
| 692 | if (currentCase >= (byte) 3 && currentCase <= (byte) 11) { |
| 693 | switch (flag) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 694 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 695 | case WITHIN: |
| 696 | if (currentCase >= 6 && currentCase <= 10 |
| 697 | && currentCase != 8) |
| 698 | match = true; |
| 699 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 700 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 701 | case REAL_WITHIN: |
| 702 | if (currentCase == 6 || currentCase == 9 |
| 703 | || currentCase == 10) |
| 704 | match = true; |
| 705 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 706 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 707 | case MATCH: |
| 708 | if (currentCase == 7) |
| 709 | match = true; |
| 710 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 711 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 712 | case STARTSWITH: |
| 713 | if (currentCase == 7 || currentCase == 6) |
| 714 | match = true; |
| 715 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 716 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 717 | case ENDSWITH: |
| 718 | if (currentCase == 7 || currentCase == 10) |
| 719 | match = true; |
| 720 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 721 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 722 | case OVERLAP: |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 723 | match = true; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 724 | break; |
| 725 | |
| 726 | case REAL_OVERLAP: |
| 727 | if (currentCase == 3 || currentCase == 11) |
| 728 | match = true; |
| 729 | break; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 730 | }; |
| 731 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 732 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 733 | try { |
| 734 | this.todo(currentCase); |
| 735 | } |
| 736 | catch (IOException e) { |
| 737 | return false; |
| 738 | } |
| 739 | return match; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 740 | }; |
| 741 | |
| 742 | |
| 743 | private void _logCurrentCase (byte currentCase) { |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 744 | log.trace("Current Case is {}", currentCase); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 745 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 746 | String _e = _currentEmbedded().toString(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 747 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 748 | log.trace(" |---| {}", _currentWrap().toString()); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 749 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 750 | switch (currentCase) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 751 | case 1: |
| 752 | log.trace("|-| {}", _e); |
| 753 | break; |
| 754 | case 2: |
| 755 | log.trace("|---| {}", _e); |
| 756 | break; |
| 757 | case 3: |
| 758 | log.trace(" |---| {}", _e); |
| 759 | break; |
| 760 | case 4: |
| 761 | log.trace(" |-----| {}", _e); |
| 762 | break; |
| 763 | case 5: |
| 764 | log.trace(" |-------| {}", _e); |
| 765 | break; |
| 766 | case 6: |
| 767 | log.trace(" |-| {}", _e); |
| 768 | break; |
| 769 | case 7: |
| 770 | log.trace(" |---| {}", _e); |
| 771 | break; |
| 772 | case 8: |
| 773 | log.trace(" |-----| {}", _e); |
| 774 | break; |
| 775 | case 9: |
| 776 | log.trace(" |-| {}", _e); |
| 777 | break; |
| 778 | case 10: |
| 779 | log.trace(" |-| {}", _e); |
| 780 | break; |
| 781 | case 11: |
| 782 | log.trace(" |---| {}", _e); |
| 783 | break; |
| 784 | case 12: |
| 785 | log.trace(" |-| {}", _e); |
| 786 | break; |
| 787 | case 13: |
| 788 | log.trace(" |-| {}", _e); |
| 789 | break; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 790 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 791 | case 15: |
| 792 | // Fake case |
| 793 | log.trace(" |---? {}", _e); |
| 794 | break; |
| 795 | |
| 796 | case 16: |
| 797 | // Fake case |
| 798 | log.trace(" |---? {}", _e); |
| 799 | break; |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 800 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 801 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 802 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 803 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 804 | private WithinSpan _currentWrap () { |
| 805 | WithinSpan _wrap = new WithinSpan(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 806 | _wrap.start = this.wrapStart != -1 ? this.wrapStart : this.wrapSpans |
| 807 | .start(); |
| 808 | _wrap.end = this.wrapEnd != -1 ? this.wrapEnd : this.wrapSpans.end(); |
| 809 | _wrap.doc = this.wrapDoc != -1 ? this.wrapDoc : this.wrapSpans.doc(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 810 | return _wrap; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 811 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 812 | |
| 813 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 814 | private WithinSpan _currentEmbedded () { |
| 815 | WithinSpan _embedded = new WithinSpan(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 816 | _embedded.start = this.embeddedStart != -1 ? this.embeddedStart |
| 817 | : this.embeddedSpans.start(); |
| 818 | _embedded.end = this.embeddedEnd != -1 ? this.embeddedEnd |
| 819 | : this.embeddedSpans.end(); |
| 820 | _embedded.doc = this.embeddedDoc != -1 ? this.embeddedDoc |
| 821 | : this.embeddedSpans.doc(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 822 | return _embedded; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 823 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 824 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 825 | |
| 826 | private void todo (byte currentCase) throws IOException { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 827 | /* |
| 828 | Check what to do next with the spans. |
| 829 | |
| 830 | The different follow up steps are: |
| 831 | - storeEmbedded -> store span B for later checks |
| 832 | - nextSpanA -> forward a |
| 833 | - nextSpanB -> forward b |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 834 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 835 | These rules were automatically generated |
| 836 | */ |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 837 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 838 | // Case 1, 2 |
| 839 | if (currentCase <= (byte) 2) { |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 840 | this.nextSpanB(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | // Case 12, 13 |
| 844 | else if (currentCase >= (byte) 12) { |
| 845 | this.storeEmbedded(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 846 | this.nextSpanA(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | // Case 3, 4, 5, 8 |
| 850 | else if (currentCase <= (byte) 5 || currentCase == (byte) 8) { |
| 851 | if (flag <= 2) |
| 852 | this.storeEmbedded(); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 853 | this.nextSpanB(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | // Case 11 |
| 857 | else if (currentCase == (byte) 11) { |
| 858 | if (this.flag == REAL_WITHIN) { |
| 859 | this.nextSpanB(); |
| 860 | } |
| 861 | else if (this.flag >= STARTSWITH) { |
| 862 | this.nextSpanA(); |
| 863 | } |
| 864 | else { |
| 865 | this.storeEmbedded(); |
| 866 | this.nextSpanB(); |
| 867 | }; |
| 868 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 869 | |
| 870 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 871 | // Case 6, 7, 9, 10 |
| 872 | else { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 873 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 874 | if ( |
| 875 | // Case 6 |
| 876 | (currentCase == (byte) 6 && this.flag == MATCH) || |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 877 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 878 | // Case 7 |
| 879 | (currentCase == (byte) 7 && this.flag == REAL_WITHIN) || |
| 880 | |
| 881 | // Case 9, 10 |
| 882 | (currentCase >= (byte) 9 && this.flag >= STARTSWITH)) { |
| 883 | |
| 884 | this.nextSpanA(); |
| 885 | } |
| 886 | else { |
| 887 | this.storeEmbedded(); |
| 888 | this.nextSpanB(); |
| 889 | }; |
| 890 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 891 | }; |
| 892 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 893 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 894 | // Store the current embedded span in the first spanStore |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 895 | private void storeEmbedded () throws IOException { |
| 896 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 897 | // Create a current copy |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 898 | WithinSpan embedded = new WithinSpan(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 899 | embedded.start = this.embeddedStart != -1 ? this.embeddedStart |
| 900 | : this.embeddedSpans.start(); |
| 901 | embedded.end = this.embeddedEnd != -1 ? this.embeddedEnd |
| 902 | : this.embeddedSpans.end(); |
| 903 | embedded.doc = this.embeddedDoc; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 904 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 905 | // Copy payloads |
| 906 | if (this.embeddedPayload != null) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 907 | embedded.payload = new ArrayList<byte[]>( |
| 908 | this.embeddedPayload.size()); |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 909 | embedded.payload.addAll(this.embeddedPayload); |
| 910 | } |
| 911 | else if (this.embeddedSpans.isPayloadAvailable()) { |
| 912 | embedded.payload = new ArrayList<byte[]>(3); |
| 913 | Collection<byte[]> payload = this.embeddedSpans.getPayload(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 914 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 915 | this.embeddedPayload = new ArrayList<byte[]>(payload.size()); |
| 916 | this.embeddedPayload.addAll(payload); |
| 917 | embedded.payload.addAll(payload); |
| 918 | }; |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 919 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 920 | this.spanStore1.add(embedded); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 921 | |
| Nils Diewald | 83c9b16 | 2015-02-03 21:05:07 +0000 | [diff] [blame] | 922 | if (DEBUG) |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 923 | log.trace("Pushed to spanStore 1 {} (in storeEmbedded)", |
| 924 | embedded.toString()); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 925 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 926 | |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 927 | |
| 928 | // Return case number |
| 929 | private byte withinCase () { |
| 930 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 931 | // case 1-5 |
| 932 | if (this.wrapStart > this.embeddedStart) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 933 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 934 | // Case 1 |
| 935 | // |-| |
| 936 | // |-| |
| 937 | if (this.wrapStart > this.embeddedEnd) { |
| 938 | return (byte) 1; |
| 939 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 940 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 941 | // Case 2 |
| 942 | // |-| |
| 943 | // |-| |
| 944 | else if (this.wrapStart == this.embeddedEnd) { |
| 945 | return (byte) 2; |
| 946 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 947 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 948 | // Load wrapEnd |
| 949 | this.wrapEnd = this.wrapSpans.end(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 950 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 951 | // Case 3 |
| 952 | // |---| |
| 953 | // |---| |
| 954 | if (this.wrapEnd > this.embeddedEnd) { |
| 955 | return (byte) 3; |
| 956 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 957 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 958 | // Case 4 |
| 959 | // |-| |
| 960 | // |---| |
| 961 | else if (this.wrapEnd == this.embeddedEnd) { |
| 962 | return (byte) 4; |
| 963 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 964 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 965 | // Case 5 |
| 966 | // |-| |
| 967 | // |---| |
| 968 | return (byte) 5; |
| 969 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 970 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 971 | // case 6-8 |
| 972 | else if (this.wrapStart == this.embeddedStart) { |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 973 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 974 | // Load wrapEnd |
| 975 | this.wrapEnd = this.wrapSpans.end(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 976 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 977 | // Case 6 |
| 978 | // |---| |
| 979 | // |-| |
| 980 | if (this.wrapEnd > this.embeddedEnd) { |
| 981 | return (byte) 6; |
| 982 | } |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 983 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 984 | // Case 7 |
| 985 | // |---| |
| 986 | // |---| |
| 987 | else if (this.wrapEnd == this.embeddedEnd) { |
| 988 | return (byte) 7; |
| 989 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 990 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 991 | // Case 8 |
| 992 | // |-| |
| 993 | // |---| |
| 994 | return (byte) 8; |
| 995 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 996 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 997 | // wrapStart < embeddedStart |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 998 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 999 | // Load wrapEnd |
| 1000 | this.wrapEnd = this.wrapSpans.end(); |
| Nils Diewald | 6802acd | 2014-03-18 18:29:30 +0000 | [diff] [blame] | 1001 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1002 | // Case 13 |
| 1003 | // |-| |
| 1004 | // |-| |
| 1005 | if (this.wrapEnd < this.embeddedStart) { |
| 1006 | return (byte) 13; |
| 1007 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1008 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1009 | // Case 9 |
| 1010 | // |---| |
| 1011 | // |-| |
| 1012 | else if (this.wrapEnd > this.embeddedEnd) { |
| 1013 | return (byte) 9; |
| 1014 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1015 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1016 | // Case 10 |
| 1017 | // |---| |
| 1018 | // |-| |
| 1019 | else if (this.wrapEnd == this.embeddedEnd) { |
| 1020 | return (byte) 10; |
| 1021 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1022 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1023 | // Case 11 |
| 1024 | // |---| |
| 1025 | // |---| |
| 1026 | else if (this.wrapEnd > this.embeddedStart) { |
| 1027 | return (byte) 11; |
| 1028 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1029 | |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1030 | // case 12 |
| 1031 | // |-| |
| 1032 | // |-| |
| 1033 | return (byte) 12; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1034 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1035 | |
| 1036 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1037 | /** |
| 1038 | * Returns the document number of the current match. Initially |
| 1039 | * invalid. |
| 1040 | */ |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1041 | @Override |
| 1042 | public int doc () { |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1043 | return matchDoc; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1044 | }; |
| 1045 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1046 | |
| 1047 | /** |
| 1048 | * Returns the start position of the embedding wrap. Initially |
| 1049 | * invalid. |
| 1050 | */ |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1051 | @Override |
| 1052 | public int start () { |
| Nils Diewald | cd22686 | 2015-02-11 22:27:45 +0000 | [diff] [blame] | 1053 | return matchStart; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1054 | }; |
| 1055 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1056 | |
| 1057 | /** |
| 1058 | * Returns the end position of the embedding wrap. Initially |
| 1059 | * invalid. |
| 1060 | */ |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1061 | @Override |
| 1062 | public int end () { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1063 | return matchEnd; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1064 | }; |
| 1065 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1066 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1067 | /** |
| 1068 | * Returns the payload data for the current span. |
| 1069 | * This is invalid until {@link #next()} is called for |
| 1070 | * the first time. |
| 1071 | * This method must not be called more than once after each call |
| 1072 | * of {@link #next()}. However, most payloads are loaded lazily, |
| 1073 | * so if the payload data for the current position is not needed, |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1074 | * this method may not be called at all for performance reasons. |
| 1075 | * An ordered |
| 1076 | * SpanQuery does not lazy load, so if you have payloads in your |
| 1077 | * index and |
| 1078 | * you do not want ordered SpanNearQuerys to collect payloads, you |
| 1079 | * can |
| Nils Diewald | e072501 | 2014-09-25 19:32:52 +0000 | [diff] [blame] | 1080 | * disable collection with a constructor option.<br> |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1081 | * <br> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1082 | * Note that the return type is a collection, thus the ordering |
| 1083 | * should not be relied upon. |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1084 | * <br/> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1085 | * |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1086 | * @lucene.experimental |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1087 | * |
| 1088 | * @return a List of byte arrays containing the data of this |
| 1089 | * payload, otherwise null if isPayloadAvailable is false |
| 1090 | * @throws IOException |
| 1091 | * if there is a low-level I/O error |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1092 | */ |
| 1093 | // public abstract Collection<byte[]> getPayload() throws IOException; |
| 1094 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1095 | public Collection<byte[]> getPayload () throws IOException { |
| 1096 | return matchPayload; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1097 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1098 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1099 | |
| 1100 | /** |
| 1101 | * Checks if a payload can be loaded at this position. |
| 1102 | * <p/> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1103 | * Payloads can only be loaded once per call to {@link #next()}. |
| 1104 | * |
| 1105 | * @return true if there is a payload available at this position |
| 1106 | * that can be loaded |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1107 | */ |
| 1108 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1109 | public boolean isPayloadAvailable () { |
| 1110 | return matchPayload.isEmpty() == false; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1111 | }; |
| 1112 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1113 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1114 | // Todo: This may be in the wrong version |
| 1115 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1116 | public long cost () { |
| 1117 | return wrapSpans.cost() + embeddedSpans.cost(); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1118 | }; |
| 1119 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1120 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1121 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1122 | public String toString () { |
| 1123 | return getClass().getName() |
| 1124 | + "(" |
| 1125 | + query.toString() |
| 1126 | + ")@" |
| 1127 | + (embeddedDoc <= 0 ? "START" : (more ? (doc() + ":" + start() |
| 1128 | + "-" + end()) : "END")); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1129 | }; |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1130 | |
| 1131 | |
| 1132 | // This was formerly the default candidate span class, |
| 1133 | // before it was refactored out |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1134 | private class WithinSpan implements Comparable<WithinSpan>, Cloneable { |
| 1135 | public int start = -1, end = -1, doc = -1; |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1136 | |
| 1137 | public Collection<byte[]> payload; |
| 1138 | |
| 1139 | public short elementRef = -1; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1140 | |
| 1141 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1142 | public void clear () { |
| 1143 | this.start = -1; |
| 1144 | this.end = -1; |
| 1145 | this.doc = -1; |
| 1146 | clearPayload(); |
| 1147 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1148 | |
| 1149 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1150 | @Override |
| 1151 | public int compareTo (WithinSpan o) { |
| 1152 | /* optimizable for short numbers to return o.end - this.end */ |
| 1153 | if (this.doc < o.doc) { |
| 1154 | return -1; |
| 1155 | } |
| 1156 | else if (this.doc == o.doc) { |
| 1157 | if (this.start < o.start) { |
| 1158 | return -1; |
| 1159 | } |
| 1160 | else if (this.start == o.start) { |
| 1161 | if (this.end < o.end) |
| 1162 | return -1; |
| 1163 | }; |
| 1164 | }; |
| 1165 | return 1; |
| 1166 | }; |
| 1167 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1168 | |
| 1169 | public short getElementRef () { |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1170 | return elementRef; |
| 1171 | } |
| 1172 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1173 | |
| 1174 | public void setElementRef (short elementRef) { |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1175 | this.elementRef = elementRef; |
| 1176 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1177 | |
| 1178 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1179 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1180 | public Object clone () { |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1181 | WithinSpan span = new WithinSpan(); |
| 1182 | span.start = this.start; |
| 1183 | span.end = this.end; |
| 1184 | span.doc = this.doc; |
| 1185 | span.payload.addAll(this.payload); |
| 1186 | return span; |
| 1187 | }; |
| 1188 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1189 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1190 | public WithinSpan copyFrom (WithinSpan o) { |
| 1191 | this.start = o.start; |
| 1192 | this.end = o.end; |
| 1193 | this.doc = o.doc; |
| 1194 | // this.clearPayload(); |
| 1195 | this.payload.addAll(o.payload); |
| 1196 | return this; |
| 1197 | }; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1198 | |
| 1199 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1200 | public void clearPayload () { |
| 1201 | if (this.payload != null) |
| 1202 | this.payload.clear(); |
| 1203 | }; |
| 1204 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1205 | |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1206 | public String toString () { |
| 1207 | StringBuilder sb = new StringBuilder("["); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 1208 | return sb.append(this.start).append('-').append(this.end) |
| 1209 | .append('(').append(this.doc).append(')').append(']') |
| 1210 | .toString(); |
| Nils Diewald | 41750bf | 2015-02-06 17:45:20 +0000 | [diff] [blame] | 1211 | }; |
| 1212 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1213 | }; |