Commit 229cfad6ba23f711f71e71654f8a3202ecdeae2d
1 parent
9b57f64c
update
Showing
51 changed files
with
5295 additions
and
5402 deletions
Too many changes to show.
To preserve performance only 14 of 51 files are displayed.
junit/mtas/parser/MtasCQLParserTestSentence.java
... | ... | @@ -16,6 +16,7 @@ import mtas.parser.cql.MtasCQLParser; |
16 | 16 | import mtas.parser.cql.ParseException; |
17 | 17 | import mtas.parser.cql.util.MtasCQLParserGroupQuery; |
18 | 18 | import mtas.parser.cql.util.MtasCQLParserWordQuery; |
19 | +import mtas.search.spans.MtasSpanMatchAllQuery; | |
19 | 20 | import mtas.search.spans.MtasSpanOrQuery; |
20 | 21 | import mtas.search.spans.MtasSpanRecurrenceQuery; |
21 | 22 | import mtas.search.spans.MtasSpanSequenceItem; |
... | ... | @@ -70,6 +71,8 @@ public class MtasCQLParserTestSentence { |
70 | 71 | basicTest14(); |
71 | 72 | basicTest15(); |
72 | 73 | basicTest16(); |
74 | + basicTest17(); | |
75 | + basicTest18(); | |
73 | 76 | } |
74 | 77 | |
75 | 78 | private void basicTest1() { |
... | ... | @@ -258,4 +261,31 @@ public class MtasCQLParserTestSentence { |
258 | 261 | testCQLParse(field, cql, q); |
259 | 262 | } |
260 | 263 | |
264 | + private void basicTest17() { | |
265 | + String field = "testveld"; | |
266 | + String cql = "[]<entity=\"loc\"/>{1,2}[]"; | |
267 | + SpanQuery q1 = new MtasCQLParserGroupQuery(field,"entity","loc"); | |
268 | + SpanQuery q2 = new MtasSpanRecurrenceQuery(q1,1,2); | |
269 | + List<MtasSpanSequenceItem> items = new ArrayList<MtasSpanSequenceItem>(); | |
270 | + items.add(new MtasSpanSequenceItem(new MtasSpanMatchAllQuery(field), false)); | |
271 | + items.add(new MtasSpanSequenceItem(q2, false)); | |
272 | + items.add(new MtasSpanSequenceItem(new MtasSpanMatchAllQuery(field), false)); | |
273 | + SpanQuery q = new MtasSpanSequenceQuery(items); | |
274 | + testCQLParse(field, cql, q); | |
275 | + } | |
276 | + | |
277 | + private void basicTest18() { | |
278 | + String field = "testveld"; | |
279 | + String cql = "([]<entity=\"loc\"/>{1,2}[]){3,4}"; | |
280 | + SpanQuery q1 = new MtasCQLParserGroupQuery(field,"entity","loc"); | |
281 | + SpanQuery q2 = new MtasSpanRecurrenceQuery(q1,1,2); | |
282 | + List<MtasSpanSequenceItem> items = new ArrayList<MtasSpanSequenceItem>(); | |
283 | + items.add(new MtasSpanSequenceItem(new MtasSpanMatchAllQuery(field), false)); | |
284 | + items.add(new MtasSpanSequenceItem(q2, false)); | |
285 | + items.add(new MtasSpanSequenceItem(new MtasSpanMatchAllQuery(field), false)); | |
286 | + SpanQuery q3 = new MtasSpanSequenceQuery(items); | |
287 | + SpanQuery q = new MtasSpanRecurrenceQuery(q3,3,4); | |
288 | + testCQLParse(field, cql, q); | |
289 | + } | |
290 | + | |
261 | 291 | } |
... | ... |
junit/mtas/parser/MtasCQLParserTestWord.java
... | ... | @@ -66,6 +66,7 @@ public class MtasCQLParserTestWord { |
66 | 66 | basicTest9(); |
67 | 67 | basicTest10(); |
68 | 68 | basicTest11(); |
69 | + basicTest12(); | |
69 | 70 | } |
70 | 71 | |
71 | 72 | private void basicNotTest1() { |
... | ... | @@ -232,6 +233,15 @@ public class MtasCQLParserTestWord { |
232 | 233 | SpanQuery q3b = new MtasCQLParserWordPositionQuery(field, 110); |
233 | 234 | SpanQuery q3 = new MtasSpanOrQuery(q3a, q3b); |
234 | 235 | testCQLParse(field, cql3, q3); |
235 | - } | |
236 | - | |
236 | + } | |
237 | + | |
238 | + private void basicTest12() { | |
239 | + String field = "testveld"; | |
240 | + String cql = "[(t_lc=\"de\"|t_lc=\"het\"|t_lc=\"paard\")]"; | |
241 | + SpanQuery q1 = new MtasCQLParserWordQuery(field,"t_lc","de"); | |
242 | + SpanQuery q2 = new MtasCQLParserWordQuery(field,"t_lc","het"); | |
243 | + SpanQuery q3 = new MtasCQLParserWordQuery(field,"t_lc","paard"); | |
244 | + SpanQuery q = new MtasSpanOrQuery(new SpanQuery[]{q1,q2,q3}); | |
245 | + testCQLParse(field, cql, q); | |
246 | + } | |
237 | 247 | } |
... | ... |
junit/mtas/parser/MtasFunctionParserTest.java
... | ... | @@ -330,7 +330,6 @@ public class MtasFunctionParserTest { |
330 | 330 | pf = p.parse(); |
331 | 331 | args = getArgs(10 + generator.nextInt(20), 0, 2); |
332 | 332 | double answer = (double)(k1+k2) / (args[0]+1+k3-2); |
333 | - System.out.println(pf); | |
334 | 333 | testFunction(pf, args, n, |
335 | 334 | new MtasFunctionParserFunctionResponseDouble(answer, true)); |
336 | 335 | } catch (ParseException e) { |
... | ... |
src/mtas/analysis/MtasTokenizer.java
... | ... | @@ -15,16 +15,13 @@ import mtas.analysis.token.MtasTokenCollection; |
15 | 15 | import mtas.analysis.util.MtasConfigException; |
16 | 16 | import mtas.analysis.util.MtasConfiguration; |
17 | 17 | import mtas.analysis.util.MtasParserException; |
18 | -import mtas.codec.payload.MtasPayloadDecoder; | |
19 | 18 | import mtas.codec.payload.MtasPayloadEncoder; |
20 | - | |
21 | 19 | import org.apache.lucene.analysis.Tokenizer; |
22 | 20 | import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; |
23 | 21 | import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; |
24 | 22 | import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; |
25 | 23 | import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; |
26 | 24 | import org.apache.lucene.util.AttributeFactory; |
27 | -import org.apache.lucene.util.BytesRef; | |
28 | 25 | |
29 | 26 | /** |
30 | 27 | * The Class MtasTokenizer. |
... | ... |
src/mtas/codec/MtasFieldsConsumer.java
... | ... | @@ -35,8 +35,6 @@ import org.apache.lucene.index.TermsEnum; |
35 | 35 | import org.apache.lucene.search.DocIdSetIterator; |
36 | 36 | import org.apache.lucene.store.IndexInput; |
37 | 37 | import org.apache.lucene.store.IndexOutput; |
38 | -import org.apache.lucene.store.Lock; | |
39 | -import org.apache.lucene.store.LockObtainFailedException; | |
40 | 38 | import org.apache.lucene.util.BytesRef; |
41 | 39 | |
42 | 40 | /** |
... | ... |
src/mtas/codec/tree/IntervalRBTree.java
... | ... | @@ -8,10 +8,10 @@ import mtas.codec.util.CodecSearchTree.MtasTreeHit; |
8 | 8 | /** |
9 | 9 | * The Class IntervalRBTree. |
10 | 10 | */ |
11 | -public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { | |
11 | +public class IntervalRBTree<T> extends IntervalTree<T, IntervalRBTreeNode<T>> { | |
12 | 12 | |
13 | 13 | /** The index. */ |
14 | - private final HashMap<String, IntervalRBTreeNode> index; | |
14 | + private final HashMap<String, IntervalRBTreeNode<T>> index; | |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Instantiates a new interval rb tree. |
... | ... | @@ -26,9 +26,9 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
26 | 26 | * |
27 | 27 | * @param positionsHits the positions hits |
28 | 28 | */ |
29 | - public IntervalRBTree(ArrayList<IntervalTreeNodeData> positionsHits) { | |
29 | + public IntervalRBTree(ArrayList<IntervalTreeNodeData<T>> positionsHits) { | |
30 | 30 | this(); |
31 | - for (IntervalTreeNodeData positionsHit : positionsHits) { | |
31 | + for (IntervalTreeNodeData<T> positionsHit : positionsHits) { | |
32 | 32 | addRange(positionsHit.start, positionsHit.end, positionsHit.list); |
33 | 33 | } |
34 | 34 | close(); |
... | ... | @@ -54,7 +54,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
54 | 54 | */ |
55 | 55 | @Override |
56 | 56 | final protected void addSinglePoint(int position, |
57 | - ArrayList<MtasTreeHit<?>> list) { | |
57 | + ArrayList<MtasTreeHit<T>> list) { | |
58 | 58 | addRange(position, position, list); |
59 | 59 | } |
60 | 60 | |
... | ... | @@ -63,7 +63,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
63 | 63 | */ |
64 | 64 | @Override |
65 | 65 | final protected void addRange(int left, int right, |
66 | - ArrayList<MtasTreeHit<?>> list) { | |
66 | + ArrayList<MtasTreeHit<T>> list) { | |
67 | 67 | String key = ((Integer) left).toString() + "_" |
68 | 68 | + ((Integer) right).toString(); |
69 | 69 | if (index.containsKey(key)) { |
... | ... | @@ -73,6 +73,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
73 | 73 | root.color = IntervalRBTreeNode.BLACK; |
74 | 74 | } |
75 | 75 | } |
76 | + | |
76 | 77 | |
77 | 78 | /** |
78 | 79 | * Adds the range. |
... | ... | @@ -83,11 +84,11 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
83 | 84 | * @param list the list |
84 | 85 | * @return the interval rb tree node |
85 | 86 | */ |
86 | - private IntervalRBTreeNode addRange(IntervalRBTreeNode n, Integer left, | |
87 | - Integer right, ArrayList<MtasTreeHit<?>> list) { | |
87 | + private IntervalRBTreeNode<T> addRange(IntervalRBTreeNode<T> n, Integer left, | |
88 | + Integer right, ArrayList<MtasTreeHit<T>> list) { | |
88 | 89 | if (n == null) { |
89 | 90 | String key = left.toString() + "_" + right.toString(); |
90 | - n = new IntervalRBTreeNode(left, right, IntervalRBTreeNode.RED, 1); | |
91 | + n = new IntervalRBTreeNode<T>(left, right, IntervalRBTreeNode.RED, 1); | |
91 | 92 | n.addList(list); |
92 | 93 | index.put(key, n); |
93 | 94 | } else { |
... | ... | @@ -118,7 +119,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
118 | 119 | * @param n the n |
119 | 120 | * @param c the c |
120 | 121 | */ |
121 | - private void updateMaxMin(IntervalRBTreeNode n, IntervalRBTreeNode c) { | |
122 | + private void updateMaxMin(IntervalRBTreeNode<T> n, IntervalRBTreeNode<T> c) { | |
122 | 123 | if (c != null) { |
123 | 124 | if (n.max < c.max) { |
124 | 125 | n.max = c.max; |
... | ... | @@ -136,9 +137,9 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
136 | 137 | * @param n the n |
137 | 138 | * @return the interval rb tree node |
138 | 139 | */ |
139 | - private IntervalRBTreeNode rotateRight(IntervalRBTreeNode n) { | |
140 | + private IntervalRBTreeNode<T> rotateRight(IntervalRBTreeNode<T> n) { | |
140 | 141 | assert (n != null) && isRed(n.leftChild); |
141 | - IntervalRBTreeNode x = n.leftChild; | |
142 | + IntervalRBTreeNode<T> x = n.leftChild; | |
142 | 143 | n.leftChild = x.rightChild; |
143 | 144 | x.rightChild = n; |
144 | 145 | x.color = x.rightChild.color; |
... | ... | @@ -157,9 +158,9 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
157 | 158 | * @param n the n |
158 | 159 | * @return the interval rb tree node |
159 | 160 | */ |
160 | - private IntervalRBTreeNode rotateLeft(IntervalRBTreeNode n) { | |
161 | + private IntervalRBTreeNode<T> rotateLeft(IntervalRBTreeNode<T> n) { | |
161 | 162 | assert (n != null) && isRed(n.rightChild); |
162 | - IntervalRBTreeNode x = n.rightChild; | |
163 | + IntervalRBTreeNode<T> x = n.rightChild; | |
163 | 164 | n.rightChild = x.leftChild; |
164 | 165 | x.leftChild = n; |
165 | 166 | x.color = x.leftChild.color; |
... | ... | @@ -177,7 +178,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
177 | 178 | * |
178 | 179 | * @param n the n |
179 | 180 | */ |
180 | - private void flipColors(IntervalRBTreeNode n) { | |
181 | + private void flipColors(IntervalRBTreeNode<T> n) { | |
181 | 182 | // n must have opposite color of its two children |
182 | 183 | assert (n != null) && (n.leftChild != null) && (n.rightChild != null); |
183 | 184 | assert (!isRed(n) && isRed(n.leftChild) && isRed(n.rightChild)) |
... | ... | @@ -193,7 +194,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
193 | 194 | * @param n the n |
194 | 195 | * @return true, if is red |
195 | 196 | */ |
196 | - private boolean isRed(IntervalRBTreeNode n) { | |
197 | + private boolean isRed(IntervalRBTreeNode<T> n) { | |
197 | 198 | if (n == null) { |
198 | 199 | return false; |
199 | 200 | } |
... | ... | @@ -206,7 +207,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
206 | 207 | * @param n the n |
207 | 208 | * @return the int |
208 | 209 | */ |
209 | - private int size(IntervalRBTreeNode n) { | |
210 | + private int size(IntervalRBTreeNode<T> n) { | |
210 | 211 | if (n == null) |
211 | 212 | return 0; |
212 | 213 | return n.n; |
... | ... | @@ -217,7 +218,7 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
217 | 218 | * |
218 | 219 | * @param n the new max min |
219 | 220 | */ |
220 | - private void setMaxMin(IntervalRBTreeNode n) { | |
221 | + private void setMaxMin(IntervalRBTreeNode<T> n) { | |
221 | 222 | n.min = n.left; |
222 | 223 | n.max = n.right; |
223 | 224 | if (n.leftChild != null) { |
... | ... | @@ -230,4 +231,6 @@ public class IntervalRBTree extends IntervalTree<IntervalRBTreeNode> { |
230 | 231 | } |
231 | 232 | } |
232 | 233 | |
234 | + | |
235 | + | |
233 | 236 | } |
... | ... |
src/mtas/codec/tree/IntervalRBTreeNode.java
... | ... | @@ -3,7 +3,7 @@ package mtas.codec.tree; |
3 | 3 | /** |
4 | 4 | * The Class IntervalRBTreeNode. |
5 | 5 | */ |
6 | -public class IntervalRBTreeNode extends IntervalTreeNode<IntervalRBTreeNode> { | |
6 | +public class IntervalRBTreeNode<T> extends IntervalTreeNode<T, IntervalRBTreeNode<T>> { | |
7 | 7 | |
8 | 8 | /** The Constant BLACK. */ |
9 | 9 | static final int BLACK = 1; |
... | ... | @@ -36,7 +36,7 @@ public class IntervalRBTreeNode extends IntervalTreeNode<IntervalRBTreeNode> { |
36 | 36 | * @see mtas.codec.tree.MtasTreeNode#self() |
37 | 37 | */ |
38 | 38 | @Override |
39 | - protected IntervalRBTreeNode self() { | |
39 | + protected IntervalRBTreeNode<T> self() { | |
40 | 40 | return self(); |
41 | 41 | } |
42 | 42 | |
... | ... |
src/mtas/codec/tree/IntervalTree.java
... | ... | @@ -8,20 +8,17 @@ import mtas.codec.util.CodecSearchTree.MtasTreeHit; |
8 | 8 | * |
9 | 9 | * @param <N> the number type |
10 | 10 | */ |
11 | -abstract public class IntervalTree<N extends IntervalTreeNode<N>> { | |
11 | +abstract public class IntervalTree<T, N extends IntervalTreeNode<T, N>> { | |
12 | 12 | |
13 | 13 | /** The current. */ |
14 | 14 | protected N root, current; |
15 | 15 | |
16 | - /** The closed. */ | |
17 | - private Boolean closed; | |
18 | 16 | |
19 | 17 | /** |
20 | 18 | * Instantiates a new interval tree. |
21 | 19 | */ |
22 | 20 | public IntervalTree() { |
23 | 21 | root = null; |
24 | - closed = false; | |
25 | 22 | } |
26 | 23 | |
27 | 24 | /** |
... | ... | @@ -33,7 +30,6 @@ abstract public class IntervalTree<N extends IntervalTreeNode<N>> { |
33 | 30 | if(root==null) { |
34 | 31 | addRangeEmpty(0,0); |
35 | 32 | } |
36 | - closed = true; | |
37 | 33 | return root; |
38 | 34 | } |
39 | 35 | |
... | ... | @@ -43,7 +39,7 @@ abstract public class IntervalTree<N extends IntervalTreeNode<N>> { |
43 | 39 | * @param position the position |
44 | 40 | * @param list the list |
45 | 41 | */ |
46 | - abstract protected void addSinglePoint(int position, ArrayList<MtasTreeHit<?>> list); | |
42 | + abstract protected void addSinglePoint(int position, ArrayList<MtasTreeHit<T>> list); | |
47 | 43 | |
48 | 44 | /** |
49 | 45 | * Adds the range. |
... | ... | @@ -52,7 +48,7 @@ abstract public class IntervalTree<N extends IntervalTreeNode<N>> { |
52 | 48 | * @param right the right |
53 | 49 | * @param list the list |
54 | 50 | */ |
55 | - abstract protected void addRange(int left, int right, ArrayList<MtasTreeHit<?>> list); | |
51 | + abstract protected void addRange(int left, int right, ArrayList<MtasTreeHit<T>> list); | |
56 | 52 | |
57 | 53 | /** |
58 | 54 | * Adds the range empty. |
... | ... |
src/mtas/codec/tree/IntervalTreeNode.java
... | ... | @@ -9,7 +9,7 @@ import mtas.codec.util.CodecSearchTree.MtasTreeHit; |
9 | 9 | * |
10 | 10 | * @param <N> the number type |
11 | 11 | */ |
12 | -abstract public class IntervalTreeNode<N extends IntervalTreeNode<N>> { | |
12 | +abstract public class IntervalTreeNode<T, N extends IntervalTreeNode<T, N>> { | |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Self. |
... | ... | @@ -38,7 +38,7 @@ abstract public class IntervalTreeNode<N extends IntervalTreeNode<N>> { |
38 | 38 | |
39 | 39 | |
40 | 40 | /** The lists. */ |
41 | - public ArrayList<ArrayList<MtasTreeHit<?>>> lists; | |
41 | + public ArrayList<ArrayList<MtasTreeHit<T>>> lists; | |
42 | 42 | |
43 | 43 | // node with start and end position |
44 | 44 | /** |
... | ... | @@ -52,7 +52,7 @@ abstract public class IntervalTreeNode<N extends IntervalTreeNode<N>> { |
52 | 52 | this.right = right; |
53 | 53 | min = left; |
54 | 54 | max = right; |
55 | - lists = new ArrayList<ArrayList<MtasTreeHit<?>>>(); | |
55 | + lists = new ArrayList<ArrayList<MtasTreeHit<T>>>(); | |
56 | 56 | } |
57 | 57 | |
58 | 58 | // add id to node |
... | ... | @@ -61,7 +61,7 @@ abstract public class IntervalTreeNode<N extends IntervalTreeNode<N>> { |
61 | 61 | * |
62 | 62 | * @param list the list |
63 | 63 | */ |
64 | - final public void addList(ArrayList<MtasTreeHit<?>> list) { | |
64 | + final public void addList(ArrayList<MtasTreeHit<T>> list) { | |
65 | 65 | if(list!=null) { |
66 | 66 | lists.add(list); |
67 | 67 | } |
... | ... |
src/mtas/codec/util/CodecCollector.java
... | ... | @@ -12,7 +12,6 @@ import java.util.List; |
12 | 12 | import java.util.ListIterator; |
13 | 13 | import java.util.TreeMap; |
14 | 14 | import java.util.regex.Pattern; |
15 | - | |
16 | 15 | import mtas.analysis.token.MtasToken; |
17 | 16 | import mtas.codec.MtasCodecPostingsFormat; |
18 | 17 | import mtas.codec.tree.IntervalTreeNodeData; |
... | ... | @@ -34,7 +33,6 @@ import mtas.codec.util.CodecComponent.Match; |
34 | 33 | import mtas.codec.util.DataCollector.MtasDataCollector; |
35 | 34 | import mtas.codec.util.CodecInfo.IndexDoc; |
36 | 35 | import mtas.codec.util.CodecSearchTree.MtasTreeHit; |
37 | - | |
38 | 36 | import org.apache.commons.lang.ArrayUtils; |
39 | 37 | import org.apache.lucene.document.Document; |
40 | 38 | import org.apache.lucene.index.FieldInfo; |
... | ... | @@ -62,30 +60,18 @@ public class CodecCollector { |
62 | 60 | /** |
63 | 61 | * Collect. |
64 | 62 | * |
65 | - * @param field | |
66 | - * the field | |
67 | - * @param searcher | |
68 | - * the searcher | |
69 | - * @param reader | |
70 | - * the reader | |
71 | - * @param rawReader | |
72 | - * the raw reader | |
73 | - * @param fullDocList | |
74 | - * the full doc list | |
75 | - * @param fullDocSet | |
76 | - * the full doc set | |
77 | - * @param fieldInfo | |
78 | - * the field info | |
79 | - * @param spansQueryWeight | |
80 | - * the spans query weight | |
81 | - * @throws IllegalAccessException | |
82 | - * the illegal access exception | |
83 | - * @throws IllegalArgumentException | |
84 | - * the illegal argument exception | |
85 | - * @throws InvocationTargetException | |
86 | - * the invocation target exception | |
87 | - * @throws IOException | |
88 | - * Signals that an I/O exception has occurred. | |
63 | + * @param field the field | |
64 | + * @param searcher the searcher | |
65 | + * @param reader the reader | |
66 | + * @param rawReader the raw reader | |
67 | + * @param fullDocList the full doc list | |
68 | + * @param fullDocSet the full doc set | |
69 | + * @param fieldInfo the field info | |
70 | + * @param spansQueryWeight the spans query weight | |
71 | + * @throws IllegalAccessException the illegal access exception | |
72 | + * @throws IllegalArgumentException the illegal argument exception | |
73 | + * @throws InvocationTargetException the invocation target exception | |
74 | + * @throws IOException Signals that an I/O exception has occurred. | |
89 | 75 | */ |
90 | 76 | public static void collect(String field, IndexSearcher searcher, |
91 | 77 | IndexReader reader, IndexReader rawReader, ArrayList<Integer> fullDocList, |
... | ... | @@ -180,28 +166,17 @@ public class CodecCollector { |
180 | 166 | /** |
181 | 167 | * Collect spans positions and tokens. |
182 | 168 | * |
183 | - * @param spansQueryWeight | |
184 | - * the spans query weight | |
185 | - * @param searcher | |
186 | - * the searcher | |
187 | - * @param mtasCodecInfo | |
188 | - * the mtas codec info | |
189 | - * @param r | |
190 | - * the r | |
191 | - * @param lrc | |
192 | - * the lrc | |
193 | - * @param field | |
194 | - * the field | |
195 | - * @param t | |
196 | - * the t | |
197 | - * @param docSet | |
198 | - * the doc set | |
199 | - * @param docList | |
200 | - * the doc list | |
201 | - * @param fieldInfo | |
202 | - * the field info | |
203 | - * @throws IOException | |
204 | - * Signals that an I/O exception has occurred. | |
169 | + * @param spansQueryWeight the spans query weight | |
170 | + * @param searcher the searcher | |
171 | + * @param mtasCodecInfo the mtas codec info | |
172 | + * @param r the r | |
173 | + * @param lrc the lrc | |
174 | + * @param field the field | |
175 | + * @param t the t | |
176 | + * @param docSet the doc set | |
177 | + * @param docList the doc list | |
178 | + * @param fieldInfo the field info | |
179 | + * @throws IOException Signals that an I/O exception has occurred. | |
205 | 180 | */ |
206 | 181 | private static void collectSpansPositionsAndTokens( |
207 | 182 | HashMap<SpanQuery, SpanWeight> spansQueryWeight, IndexSearcher searcher, |
... | ... | @@ -580,14 +555,10 @@ public class CodecCollector { |
580 | 555 | /** |
581 | 556 | * Collect prefixes. |
582 | 557 | * |
583 | - * @param fieldInfos | |
584 | - * the field infos | |
585 | - * @param field | |
586 | - * the field | |
587 | - * @param fieldInfo | |
588 | - * the field info | |
589 | - * @throws IOException | |
590 | - * Signals that an I/O exception has occurred. | |
558 | + * @param fieldInfos the field infos | |
559 | + * @param field the field | |
560 | + * @param fieldInfo the field info | |
561 | + * @throws IOException Signals that an I/O exception has occurred. | |
591 | 562 | */ |
592 | 563 | private static void collectPrefixes(FieldInfos fieldInfos, String field, |
593 | 564 | ComponentField fieldInfo) throws IOException { |
... | ... | @@ -616,6 +587,18 @@ public class CodecCollector { |
616 | 587 | } |
617 | 588 | } |
618 | 589 | |
590 | + /** | |
591 | + * Compute positions. | |
592 | + * | |
593 | + * @param mtasCodecInfo the mtas codec info | |
594 | + * @param r the r | |
595 | + * @param lrc the lrc | |
596 | + * @param field the field | |
597 | + * @param t the t | |
598 | + * @param docSet the doc set | |
599 | + * @return the hash map | |
600 | + * @throws IOException Signals that an I/O exception has occurred. | |
601 | + */ | |
619 | 602 | private static HashMap<Integer, Integer> computePositions( |
620 | 603 | CodecInfo mtasCodecInfo, LeafReader r, LeafReaderContext lrc, |
621 | 604 | String field, Terms t, List<Integer> docSet) throws IOException { |
... | ... | @@ -650,12 +633,9 @@ public class CodecCollector { |
650 | 633 | /** |
651 | 634 | * Compute arguments. |
652 | 635 | * |
653 | - * @param spansNumberData | |
654 | - * the spans number data | |
655 | - * @param queries | |
656 | - * the queries | |
657 | - * @param docSet | |
658 | - * the doc set | |
636 | + * @param spansNumberData the spans number data | |
637 | + * @param queries the queries | |
638 | + * @param docSet the doc set | |
659 | 639 | * @return the hash map |
660 | 640 | */ |
661 | 641 | private static HashMap<Integer, long[]> computeArguments( |
... | ... | @@ -686,10 +666,8 @@ public class CodecCollector { |
686 | 666 | /** |
687 | 667 | * Intersected doc list. |
688 | 668 | * |
689 | - * @param facetDocList | |
690 | - * the facet doc list | |
691 | - * @param docSet | |
692 | - * the doc set | |
669 | + * @param facetDocList the facet doc list | |
670 | + * @param docSet the doc set | |
693 | 671 | * @return the integer[] |
694 | 672 | */ |
695 | 673 | private static Integer[] intersectedDocList(int[] facetDocList, |
... | ... | @@ -720,14 +698,10 @@ public class CodecCollector { |
720 | 698 | /** |
721 | 699 | * Creates the positions. |
722 | 700 | * |
723 | - * @param statsPositionList | |
724 | - * the stats position list | |
725 | - * @param positionsData | |
726 | - * the positions data | |
727 | - * @param docSet | |
728 | - * the doc set | |
729 | - * @throws IOException | |
730 | - * Signals that an I/O exception has occurred. | |
701 | + * @param statsPositionList the stats position list | |
702 | + * @param positionsData the positions data | |
703 | + * @param docSet the doc set | |
704 | + * @throws IOException Signals that an I/O exception has occurred. | |
731 | 705 | */ |
732 | 706 | private static void createPositions(List<ComponentPosition> statsPositionList, |
733 | 707 | HashMap<Integer, Integer> positionsData, List<Integer> docSet) |
... | ... | @@ -760,14 +734,10 @@ public class CodecCollector { |
760 | 734 | /** |
761 | 735 | * Creates the tokens. |
762 | 736 | * |
763 | - * @param statsTokenList | |
764 | - * the stats token list | |
765 | - * @param tokensData | |
766 | - * the tokens data | |
767 | - * @param docSet | |
768 | - * the doc set | |
769 | - * @throws IOException | |
770 | - * Signals that an I/O exception has occurred. | |
737 | + * @param statsTokenList the stats token list | |
738 | + * @param tokensData the tokens data | |
739 | + * @param docSet the doc set | |
740 | + * @throws IOException Signals that an I/O exception has occurred. | |
771 | 741 | */ |
772 | 742 | private static void createTokens(List<ComponentToken> statsTokenList, |
773 | 743 | HashMap<Integer, Integer> tokensData, List<Integer> docSet) |
... | ... | @@ -801,16 +771,11 @@ public class CodecCollector { |
801 | 771 | /** |
802 | 772 | * Creates the stats. |
803 | 773 | * |
804 | - * @param statsSpanList | |
805 | - * the stats span list | |
806 | - * @param positionsData | |
807 | - * the positions data | |
808 | - * @param spansNumberData | |
809 | - * the spans number data | |
810 | - * @param docSet | |
811 | - * the doc set | |
812 | - * @throws IOException | |
813 | - * Signals that an I/O exception has occurred. | |
774 | + * @param statsSpanList the stats span list | |
775 | + * @param positionsData the positions data | |
776 | + * @param spansNumberData the spans number data | |
777 | + * @param docSet the doc set | |
778 | + * @throws IOException Signals that an I/O exception has occurred. | |
814 | 779 | */ |
815 | 780 | private static void createStats(List<ComponentSpan> statsSpanList, |
816 | 781 | HashMap<Integer, Integer> positionsData, |
... | ... | @@ -940,26 +905,16 @@ public class CodecCollector { |
940 | 905 | /** |
941 | 906 | * Creates the list. |
942 | 907 | * |
943 | - * @param listList | |
944 | - * the list list | |
945 | - * @param spansNumberData | |
946 | - * the spans number data | |
947 | - * @param spansMatchData | |
948 | - * the spans match data | |
949 | - * @param docSet | |
950 | - * the doc set | |
951 | - * @param field | |
952 | - * the field | |
953 | - * @param docBase | |
954 | - * the doc base | |
955 | - * @param uniqueKeyField | |
956 | - * the unique key field | |
957 | - * @param mtasCodecInfo | |
958 | - * the mtas codec info | |
959 | - * @param searcher | |
960 | - * the searcher | |
961 | - * @throws IOException | |
962 | - * Signals that an I/O exception has occurred. | |
908 | + * @param listList the list list | |
909 | + * @param spansNumberData the spans number data | |
910 | + * @param spansMatchData the spans match data | |
911 | + * @param docSet the doc set | |
912 | + * @param field the field | |
913 | + * @param docBase the doc base | |
914 | + * @param uniqueKeyField the unique key field | |
915 | + * @param mtasCodecInfo the mtas codec info | |
916 | + * @param searcher the searcher | |
917 | + * @throws IOException Signals that an I/O exception has occurred. | |
963 | 918 | */ |
964 | 919 | private static void createList(List<ComponentList> listList, |
965 | 920 | HashMap<SpanQuery, HashMap<Integer, Integer>> spansNumberData, |
... | ... | @@ -1123,20 +1078,13 @@ public class CodecCollector { |
1123 | 1078 | /** |
1124 | 1079 | * Creates the group. |
1125 | 1080 | * |
1126 | - * @param groupList | |
1127 | - * the group list | |
1128 | - * @param spansMatchData | |
1129 | - * the spans match data | |
1130 | - * @param docSet | |
1131 | - * the doc set | |
1132 | - * @param field | |
1133 | - * the field | |
1134 | - * @param docBase | |
1135 | - * the doc base | |
1136 | - * @param mtasCodecInfo | |
1137 | - * the mtas codec info | |
1138 | - * @throws IOException | |
1139 | - * Signals that an I/O exception has occurred. | |
1081 | + * @param groupList the group list | |
1082 | + * @param spansMatchData the spans match data | |
1083 | + * @param docSet the doc set | |
1084 | + * @param field the field | |
1085 | + * @param docBase the doc base | |
1086 | + * @param mtasCodecInfo the mtas codec info | |
1087 | + * @throws IOException Signals that an I/O exception has occurred. | |
1140 | 1088 | */ |
1141 | 1089 | private static void createGroup(List<ComponentGroup> groupList, |
1142 | 1090 | HashMap<SpanQuery, HashMap<Integer, ArrayList<Match>>> spansMatchData, |
... | ... | @@ -1160,7 +1108,7 @@ public class CodecCollector { |
1160 | 1108 | HashMap<String, Long> occurences = new HashMap<String, Long>(); |
1161 | 1109 | // loop over matches |
1162 | 1110 | Iterator<Match> it = matchList.listIterator(); |
1163 | - ArrayList<IntervalTreeNodeData> positionsHits = new ArrayList<IntervalTreeNodeData>(); | |
1111 | + ArrayList<IntervalTreeNodeData<String>> positionsHits = new ArrayList<IntervalTreeNodeData<String>>(); | |
1164 | 1112 | while (it.hasNext()) { |
1165 | 1113 | Match m = it.next(); |
1166 | 1114 | if (group.hitInside != null) { |
... | ... | @@ -1280,24 +1228,15 @@ public class CodecCollector { |
1280 | 1228 | /** |
1281 | 1229 | * Creates the kwic. |
1282 | 1230 | * |
1283 | - * @param kwicList | |
1284 | - * the kwic list | |
1285 | - * @param spansMatchData | |
1286 | - * the spans match data | |
1287 | - * @param docList | |
1288 | - * the doc list | |
1289 | - * @param field | |
1290 | - * the field | |
1291 | - * @param docBase | |
1292 | - * the doc base | |
1293 | - * @param uniqueKeyField | |
1294 | - * the unique key field | |
1295 | - * @param mtasCodecInfo | |
1296 | - * the mtas codec info | |
1297 | - * @param searcher | |
1298 | - * the searcher | |
1299 | - * @throws IOException | |
1300 | - * Signals that an I/O exception has occurred. | |
1231 | + * @param kwicList the kwic list | |
1232 | + * @param spansMatchData the spans match data | |
1233 | + * @param docList the doc list | |
1234 | + * @param field the field | |
1235 | + * @param docBase the doc base | |
1236 | + * @param uniqueKeyField the unique key field | |
1237 | + * @param mtasCodecInfo the mtas codec info | |
1238 | + * @param searcher the searcher | |
1239 | + * @throws IOException Signals that an I/O exception has occurred. | |
1301 | 1240 | */ |
1302 | 1241 | private static void createKwic(List<ComponentKwic> kwicList, |
1303 | 1242 | HashMap<SpanQuery, HashMap<Integer, ArrayList<Match>>> spansMatchData, |
... | ... | @@ -1415,22 +1354,14 @@ public class CodecCollector { |
1415 | 1354 | /** |
1416 | 1355 | * Creates the facet base. |
1417 | 1356 | * |
1418 | - * @param cf | |
1419 | - * the cf | |
1420 | - * @param level | |
1421 | - * the level | |
1422 | - * @param dataCollector | |
1423 | - * the data collector | |
1424 | - * @param positionsData | |
1425 | - * the positions data | |
1426 | - * @param spansNumberData | |
1427 | - * the spans number data | |
1428 | - * @param facetData | |
1429 | - * the facet data | |
1430 | - * @param docSet | |
1431 | - * the doc set | |
1432 | - * @throws IOException | |
1433 | - * Signals that an I/O exception has occurred. | |
1357 | + * @param cf the cf | |
1358 | + * @param level the level | |
1359 | + * @param dataCollector the data collector | |
1360 | + * @param positionsData the positions data | |
1361 | + * @param spansNumberData the spans number data | |
1362 | + * @param facetData the facet data | |
1363 | + * @param docSet the doc set | |
1364 | + * @throws IOException Signals that an I/O exception has occurred. | |
1434 | 1365 | */ |
1435 | 1366 | private static void createFacetBase(ComponentFacet cf, int level, |
1436 | 1367 | MtasDataCollector<?, ?> dataCollector, |
... | ... | @@ -1661,28 +1592,17 @@ public class CodecCollector { |
1661 | 1592 | /** |
1662 | 1593 | * Creates the facet. |
1663 | 1594 | * |
1664 | - * @param facetList | |
1665 | - * the facet list | |
1666 | - * @param positionsData | |
1667 | - * the positions data | |
1668 | - * @param spansNumberData | |
1669 | - * the spans number data | |
1670 | - * @param facetData | |
1671 | - * the facet data | |
1672 | - * @param docSet | |
1673 | - * the doc set | |
1674 | - * @param field | |
1675 | - * the field | |
1676 | - * @param docBase | |
1677 | - * the doc base | |
1678 | - * @param uniqueKeyField | |
1679 | - * the unique key field | |
1680 | - * @param mtasCodecInfo | |
1681 | - * the mtas codec info | |
1682 | - * @param searcher | |
1683 | - * the searcher | |
1684 | - * @throws IOException | |
1685 | - * Signals that an I/O exception has occurred. | |
1595 | + * @param facetList the facet list | |
1596 | + * @param positionsData the positions data | |
1597 | + * @param spansNumberData the spans number data | |
1598 | + * @param facetData the facet data | |
1599 | + * @param docSet the doc set | |
1600 | + * @param field the field | |
1601 | + * @param docBase the doc base | |
1602 | + * @param uniqueKeyField the unique key field | |
1603 | + * @param mtasCodecInfo the mtas codec info | |
1604 | + * @param searcher the searcher | |
1605 | + * @throws IOException Signals that an I/O exception has occurred. | |
1686 | 1606 | */ |
1687 | 1607 | private static void createFacet(List<ComponentFacet> facetList, |
1688 | 1608 | HashMap<Integer, Integer> positionsData, |
... | ... | @@ -1702,6 +1622,18 @@ public class CodecCollector { |
1702 | 1622 | } |
1703 | 1623 | } |
1704 | 1624 | |
1625 | + /** | |
1626 | + * Creates the termvector. | |
1627 | + * | |
1628 | + * @param termVectorList the term vector list | |
1629 | + * @param positionsData the positions data | |
1630 | + * @param docSet the doc set | |
1631 | + * @param field the field | |
1632 | + * @param t the t | |
1633 | + * @param r the r | |
1634 | + * @param lrc the lrc | |
1635 | + * @throws IOException Signals that an I/O exception has occurred. | |
1636 | + */ | |
1705 | 1637 | private static void createTermvector(List<ComponentTermVector> termVectorList, |
1706 | 1638 | HashMap<Integer, Integer> positionsData, List<Integer> docSet, |
1707 | 1639 | String field, Terms t, LeafReader r, LeafReaderContext lrc) |
... | ... | @@ -1710,6 +1642,18 @@ public class CodecCollector { |
1710 | 1642 | r, lrc); |
1711 | 1643 | } |
1712 | 1644 | |
1645 | + /** | |
1646 | + * Creates the termvector first round. | |
1647 | + * | |
1648 | + * @param termVectorList the term vector list | |
1649 | + * @param positionsData the positions data | |
1650 | + * @param docSet the doc set | |
1651 | + * @param field the field | |
1652 | + * @param t the t | |
1653 | + * @param r the r | |
1654 | + * @param lrc the lrc | |
1655 | + * @throws IOException Signals that an I/O exception has occurred. | |
1656 | + */ | |
1713 | 1657 | private static void createTermvectorFirstRound( |
1714 | 1658 | List<ComponentTermVector> termVectorList, |
1715 | 1659 | HashMap<Integer, Integer> positionsData, List<Integer> docSet, |
... | ... | @@ -1828,6 +1772,18 @@ public class CodecCollector { |
1828 | 1772 | |
1829 | 1773 | } |
1830 | 1774 | |
1775 | + /** | |
1776 | + * Creates the termvector second round. | |
1777 | + * | |
1778 | + * @param termVectorList the term vector list | |
1779 | + * @param positionsData the positions data | |
1780 | + * @param docSet the doc set | |
1781 | + * @param field the field | |
1782 | + * @param t the t | |
1783 | + * @param r the r | |
1784 | + * @param lrc the lrc | |
1785 | + * @throws IOException Signals that an I/O exception has occurred. | |
1786 | + */ | |
1831 | 1787 | private static void createTermvectorSecondRound( |
1832 | 1788 | List<ComponentTermVector> termVectorList, |
1833 | 1789 | HashMap<Integer, Integer> positionsData, List<Integer> docSet, |
... | ... | @@ -1903,6 +1859,12 @@ public class CodecCollector { |
1903 | 1859 | } |
1904 | 1860 | } |
1905 | 1861 | |
1862 | + /** | |
1863 | + * Need second round termvector. | |
1864 | + * | |
1865 | + * @param termVectorList the term vector list | |
1866 | + * @return true, if successful | |
1867 | + */ | |
1906 | 1868 | private static boolean needSecondRoundTermvector( |
1907 | 1869 | List<ComponentTermVector> termVectorList) { |
1908 | 1870 | boolean needSecondRound = false; |
... | ... | @@ -1918,21 +1880,45 @@ public class CodecCollector { |
1918 | 1880 | return needSecondRound; |
1919 | 1881 | } |
1920 | 1882 | |
1883 | + /** | |
1884 | + * The Class TermvectorNumberBasic. | |
1885 | + */ | |
1921 | 1886 | private static class TermvectorNumberBasic { |
1887 | + | |
1888 | + /** The value sum. */ | |
1922 | 1889 | public long[] valueSum; |
1890 | + | |
1891 | + /** The doc number. */ | |
1923 | 1892 | public int docNumber; |
1924 | 1893 | |
1894 | + /** | |
1895 | + * Instantiates a new termvector number basic. | |
1896 | + */ | |
1925 | 1897 | TermvectorNumberBasic() { |
1926 | 1898 | valueSum = new long[] { 0 }; |
1927 | 1899 | docNumber = 0; |
1928 | 1900 | } |
1929 | 1901 | } |
1930 | 1902 | |
1903 | + /** | |
1904 | + * The Class TermvectorNumberFull. | |
1905 | + */ | |
1931 | 1906 | private static class TermvectorNumberFull { |
1907 | + | |
1908 | + /** The args. */ | |
1932 | 1909 | public long[] args; |
1910 | + | |
1911 | + /** The positions. */ | |
1933 | 1912 | public int[] positions; |
1913 | + | |
1914 | + /** The doc number. */ | |
1934 | 1915 | public int docNumber; |
1935 | 1916 | |
1917 | + /** | |
1918 | + * Instantiates a new termvector number full. | |
1919 | + * | |
1920 | + * @param maxSize the max size | |
1921 | + */ | |
1936 | 1922 | TermvectorNumberFull(int maxSize) { |
1937 | 1923 | args = new long[maxSize]; |
1938 | 1924 | positions = new int[maxSize]; |
... | ... | @@ -1940,6 +1926,16 @@ public class CodecCollector { |
1940 | 1926 | } |
1941 | 1927 | } |
1942 | 1928 | |
1929 | + /** | |
1930 | + * Register basic value. | |
1931 | + * | |
1932 | + * @param keys the keys | |
1933 | + * @param termVector the term vector | |
1934 | + * @param numbers the numbers | |
1935 | + * @param termNumberMaximum the term number maximum | |
1936 | + * @param segmentNumber the segment number | |
1937 | + * @throws IOException Signals that an I/O exception has occurred. | |
1938 | + */ | |
1943 | 1939 | private static void registerBasicValue(String[] keys, |
1944 | 1940 | ComponentTermVector termVector, TermvectorNumberBasic numbers, |
1945 | 1941 | Integer termNumberMaximum, Integer segmentNumber) throws IOException { |
... | ... | @@ -2000,6 +1996,16 @@ public class CodecCollector { |
2000 | 1996 | } |
2001 | 1997 | } |
2002 | 1998 | |
1999 | + /** | |
2000 | + * Register full values. | |
2001 | + * | |
2002 | + * @param keys the keys | |
2003 | + * @param termVector the term vector | |
2004 | + * @param numbers the numbers | |
2005 | + * @param termNumberMaximum the term number maximum | |
2006 | + * @param segmentNumber the segment number | |
2007 | + * @throws IOException Signals that an I/O exception has occurred. | |
2008 | + */ | |
2003 | 2009 | private static void registerFullValues(String[] keys, |
2004 | 2010 | ComponentTermVector termVector, TermvectorNumberFull numbers, |
2005 | 2011 | Integer termNumberMaximum, Integer segmentNumber) throws IOException { |
... | ... | @@ -2121,6 +2127,18 @@ public class CodecCollector { |
2121 | 2127 | } |
2122 | 2128 | } |
2123 | 2129 | |
2130 | + /** | |
2131 | + * Compute termvector number basic. | |
2132 | + * | |
2133 | + * @param docSet the doc set | |
2134 | + * @param termDocId the term doc id | |
2135 | + * @param termsEnum the terms enum | |
2136 | + * @param r the r | |
2137 | + * @param lrc the lrc | |
2138 | + * @param postingsEnum the postings enum | |
2139 | + * @return the termvector number basic | |
2140 | + * @throws IOException Signals that an I/O exception has occurred. | |
2141 | + */ | |
2124 | 2142 | private static TermvectorNumberBasic computeTermvectorNumberBasic( |
2125 | 2143 | List<Integer> docSet, int termDocId, TermsEnum termsEnum, LeafReader r, |
2126 | 2144 | LeafReaderContext lrc, PostingsEnum postingsEnum) throws IOException { |
... | ... | @@ -2154,6 +2172,19 @@ public class CodecCollector { |
2154 | 2172 | return result; |
2155 | 2173 | } |
2156 | 2174 | |
2175 | + /** | |
2176 | + * Compute termvector number full. | |
2177 | + * | |
2178 | + * @param docSet the doc set | |
2179 | + * @param termDocId the term doc id | |
2180 | + * @param termsEnum the terms enum | |
2181 | + * @param r the r | |
2182 | + * @param lrc the lrc | |
2183 | + * @param postingsEnum the postings enum | |
2184 | + * @param positionsData the positions data | |
2185 | + * @return the termvector number full | |
2186 | + * @throws IOException Signals that an I/O exception has occurred. | |
2187 | + */ | |
2157 | 2188 | private static TermvectorNumberFull computeTermvectorNumberFull( |
2158 | 2189 | List<Integer> docSet, int termDocId, TermsEnum termsEnum, LeafReader r, |
2159 | 2190 | LeafReaderContext lrc, PostingsEnum postingsEnum, |
... | ... | @@ -2178,24 +2209,16 @@ public class CodecCollector { |
2178 | 2209 | } |
2179 | 2210 | |
2180 | 2211 | /** |
2181 | - * Creates the termvector. | |
2212 | + * Creates the termvector classic. | |
2182 | 2213 | * |
2183 | - * @param termVectorList | |
2184 | - * the term vector list | |
2185 | - * @param positionsData | |
2186 | - * the positions data | |
2187 | - * @param docSet | |
2188 | - * the doc set | |
2189 | - * @param field | |
2190 | - * the field | |
2191 | - * @param t | |
2192 | - * the t | |
2193 | - * @param r | |
2194 | - * the r | |
2195 | - * @param lrc | |
2196 | - * the lrc | |
2197 | - * @throws IOException | |
2198 | - * Signals that an I/O exception has occurred. | |
2214 | + * @param termVectorList the term vector list | |
2215 | + * @param positionsData the positions data | |
2216 | + * @param docSet the doc set | |
2217 | + * @param field the field | |
2218 | + * @param t the t | |
2219 | + * @param r the r | |
2220 | + * @param lrc the lrc | |
2221 | + * @throws IOException Signals that an I/O exception has occurred. | |
2199 | 2222 | */ |
2200 | 2223 | private static void createTermvectorClassic( |
2201 | 2224 | List<ComponentTermVector> termVectorList, |
... | ... |
src/mtas/codec/util/CodecComponent.java
... | ... | @@ -21,9 +21,7 @@ import mtas.parser.function.MtasFunctionParser; |
21 | 21 | import mtas.parser.function.ParseException; |
22 | 22 | import mtas.parser.function.util.MtasFunctionParserFunction; |
23 | 23 | import mtas.parser.function.util.MtasFunctionParserFunctionDefault; |
24 | - | |
25 | 24 | import org.apache.commons.lang.ArrayUtils; |
26 | -import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption; | |
27 | 25 | import org.apache.lucene.search.spans.SpanQuery; |
28 | 26 | import org.apache.lucene.util.automaton.CompiledAutomaton; |
29 | 27 | import org.apache.lucene.util.automaton.RegExp; |
... | ... | @@ -141,10 +139,8 @@ public class CodecComponent { |
141 | 139 | /** |
142 | 140 | * Instantiates a new component field. |
143 | 141 | * |
144 | - * @param field | |
145 | - * the field | |
146 | - * @param uniqueKeyField | |
147 | - * the unique key field | |
142 | + * @param field the field | |
143 | + * @param uniqueKeyField the unique key field | |
148 | 144 | */ |
149 | 145 | public ComponentField(String field, String uniqueKeyField) { |
150 | 146 | this.field = field; |
... | ... | @@ -179,8 +175,7 @@ public class CodecComponent { |
179 | 175 | /** |
180 | 176 | * Instantiates a new component prefix. |
181 | 177 | * |
182 | - * @param key | |
183 | - * the key | |
178 | + * @param key the key | |
184 | 179 | */ |
185 | 180 | public ComponentPrefix(String key) { |
186 | 181 | this.key = key; |
... | ... | @@ -191,8 +186,7 @@ public class CodecComponent { |
191 | 186 | /** |
192 | 187 | * Adds the single position. |
193 | 188 | * |
194 | - * @param prefix | |
195 | - * the prefix | |
189 | + * @param prefix the prefix | |
196 | 190 | */ |
197 | 191 | public void addSinglePosition(String prefix) { |
198 | 192 | if (!singlePositionList.contains(prefix) |
... | ... | @@ -204,8 +198,7 @@ public class CodecComponent { |
204 | 198 | /** |
205 | 199 | * Adds the multiple position. |
206 | 200 | * |
207 | - * @param prefix | |
208 | - * the prefix | |
201 | + * @param prefix the prefix | |
209 | 202 | */ |
210 | 203 | public void addMultiplePosition(String prefix) { |
211 | 204 | if (!singlePositionList.contains(prefix)) { |
... | ... | @@ -269,24 +262,15 @@ public class CodecComponent { |
269 | 262 | /** |
270 | 263 | * Instantiates a new component kwic. |
271 | 264 | * |
272 | - * @param query | |
273 | - * the query | |
274 | - * @param key | |
275 | - * the key | |
276 | - * @param prefixes | |
277 | - * the prefixes | |
278 | - * @param number | |
279 | - * the number | |
280 | - * @param start | |
281 | - * the start | |
282 | - * @param left | |
283 | - * the left | |
284 | - * @param right | |
285 | - * the right | |
286 | - * @param output | |
287 | - * the output | |
288 | - * @throws IOException | |
289 | - * Signals that an I/O exception has occurred. | |
265 | + * @param query the query | |
266 | + * @param key the key | |
267 | + * @param prefixes the prefixes | |
268 | + * @param number the number | |
269 | + * @param start the start | |
270 | + * @param left the left | |
271 | + * @param right the right | |
272 | + * @param output the output | |
273 | + * @throws IOException Signals that an I/O exception has occurred. | |
290 | 274 | */ |
291 | 275 | public ComponentKwic(SpanQuery query, String key, String prefixes, |
292 | 276 | Integer number, int start, int left, int right, String output) |
... | ... | @@ -376,30 +360,18 @@ public class CodecComponent { |
376 | 360 | /** |
377 | 361 | * Instantiates a new component list. |
378 | 362 | * |
379 | - * @param spanQuery | |
380 | - * the span query | |
381 | - * @param field | |
382 | - * the field | |
383 | - * @param queryValue | |
384 | - * the query value | |
385 | - * @param queryType | |
386 | - * the query type | |
387 | - * @param key | |
388 | - * the key | |
389 | - * @param prefix | |
390 | - * the prefix | |
391 | - * @param start | |
392 | - * the start | |
393 | - * @param number | |
394 | - * the number | |
395 | - * @param left | |
396 | - * the left | |
397 | - * @param right | |
398 | - * the right | |
399 | - * @param output | |
400 | - * the output | |
401 | - * @throws IOException | |
402 | - * Signals that an I/O exception has occurred. | |
363 | + * @param spanQuery the span query | |
364 | + * @param field the field | |
365 | + * @param queryValue the query value | |
366 | + * @param queryType the query type | |
367 | + * @param key the key | |
368 | + * @param prefix the prefix | |
369 | + * @param start the start | |
370 | + * @param number the number | |
371 | + * @param left the left | |
372 | + * @param right the right | |
373 | + * @param output the output | |
374 | + * @throws IOException Signals that an I/O exception has occurred. | |
403 | 375 | */ |
404 | 376 | public ComponentList(SpanQuery spanQuery, String field, String queryValue, |
405 | 377 | String queryType, String key, String prefix, int start, int number, |
... | ... | @@ -482,44 +454,25 @@ public class CodecComponent { |
482 | 454 | /** |
483 | 455 | * Instantiates a new component group. |
484 | 456 | * |
485 | - * @param spanQuery | |
486 | - * the span query | |
487 | - * @param field | |
488 | - * the field | |
489 | - * @param queryValue | |
490 | - * the query value | |
491 | - * @param queryType | |
492 | - * the query type | |
493 | - * @param key | |
494 | - * the key | |
495 | - * @param groupingHitInsidePrefixes | |
496 | - * the grouping hit inside prefixes | |
497 | - * @param groupingHitInsideLeftPosition | |
498 | - * the grouping hit inside left position | |
499 | - * @param groupingHitInsideLeftPrefixes | |
500 | - * the grouping hit inside left prefixes | |
501 | - * @param groupingHitInsideRightPosition | |
502 | - * the grouping hit inside right position | |
503 | - * @param groupingHitInsideRightPrefixes | |
504 | - * the grouping hit inside right prefixes | |
505 | - * @param groupingHitLeftPosition | |
506 | - * the grouping hit left position | |
507 | - * @param groupingHitLeftPrefixes | |
508 | - * the grouping hit left prefixes | |
509 | - * @param groupingHitRightPosition | |
510 | - * the grouping hit right position | |
511 | - * @param groupingHitRightPrefixes | |
512 | - * the grouping hit right prefixes | |
513 | - * @param groupingLeftPosition | |
514 | - * the grouping left position | |
515 | - * @param groupingLeftPrefixes | |
516 | - * the grouping left prefixes | |
517 | - * @param groupingRightPosition | |
518 | - * the grouping right position | |
519 | - * @param groupingRightPrefixes | |
520 | - * the grouping right prefixes | |
521 | - * @throws IOException | |
522 | - * Signals that an I/O exception has occurred. | |
457 | + * @param spanQuery the span query | |
458 | + * @param field the field | |
459 | + * @param queryValue the query value | |
460 | + * @param queryType the query type | |
461 | + * @param key the key | |
462 | + * @param groupingHitInsidePrefixes the grouping hit inside prefixes | |
463 | + * @param groupingHitInsideLeftPosition the grouping hit inside left position | |
464 | + * @param groupingHitInsideLeftPrefixes the grouping hit inside left prefixes | |
465 | + * @param groupingHitInsideRightPosition the grouping hit inside right position | |
466 | + * @param groupingHitInsideRightPrefixes the grouping hit inside right prefixes | |
467 | + * @param groupingHitLeftPosition the grouping hit left position | |
468 | + * @param groupingHitLeftPrefixes the grouping hit left prefixes | |
469 | + * @param groupingHitRightPosition the grouping hit right position | |
470 | + * @param groupingHitRightPrefixes the grouping hit right prefixes | |
471 | + * @param groupingLeftPosition the grouping left position | |
472 | + * @param groupingLeftPrefixes the grouping left prefixes | |
473 | + * @param groupingRightPosition the grouping right position | |
474 | + * @param groupingRightPrefixes the grouping right prefixes | |
475 | + * @throws IOException Signals that an I/O exception has occurred. | |
523 | 476 | */ |
524 | 477 | public ComponentGroup(SpanQuery spanQuery, String field, String queryValue, |
525 | 478 | String queryType, String key, String groupingHitInsidePrefixes, |
... | ... | @@ -584,15 +537,11 @@ public class CodecComponent { |
584 | 537 | /** |
585 | 538 | * Creates the positioned prefixes. |
586 | 539 | * |
587 | - * @param prefixList | |
588 | - * the prefix list | |
589 | - * @param position | |
590 | - * the position | |
591 | - * @param prefixes | |
592 | - * the prefixes | |
540 | + * @param prefixList the prefix list | |
541 | + * @param position the position | |
542 | + * @param prefixes the prefixes | |
593 | 543 | * @return the hash set[] |
594 | - * @throws IOException | |
595 | - * Signals that an I/O exception has occurred. | |
544 | + * @throws IOException Signals that an I/O exception has occurred. | |
596 | 545 | */ |
597 | 546 | private static HashSet<String>[] createPositionedPrefixes( |
598 | 547 | HashSet<String> prefixList, String[] position, String[] prefixes) |
... | ... | @@ -714,34 +663,20 @@ public class CodecComponent { |
714 | 663 | /** |
715 | 664 | * Instantiates a new component facet. |
716 | 665 | * |
717 | - * @param spanQueries | |
718 | - * the span queries | |
719 | - * @param field | |
720 | - * the field | |
721 | - * @param key | |
722 | - * the key | |
723 | - * @param baseFields | |
724 | - * the base fields | |
725 | - * @param baseFieldTypes | |
726 | - * the base field types | |
727 | - * @param baseTypes | |
728 | - * the base types | |
729 | - * @param baseSortTypes | |
730 | - * the base sort types | |
731 | - * @param baseSortDirections | |
732 | - * the base sort directions | |
733 | - * @param baseNumbers | |
734 | - * the base numbers | |
735 | - * @param baseMinimumDoubles | |
736 | - * the base minimum doubles | |
737 | - * @param baseMaximumDoubles | |
738 | - * the base maximum doubles | |
739 | - * @param baseFunctions | |
740 | - * the base functions | |
741 | - * @throws IOException | |
742 | - * Signals that an I/O exception has occurred. | |
743 | - * @throws ParseException | |
744 | - * the parse exception | |
666 | + * @param spanQueries the span queries | |
667 | + * @param field the field | |
668 | + * @param key the key | |
669 | + * @param baseFields the base fields | |
670 | + * @param baseFieldTypes the base field types | |
671 | + * @param baseTypes the base types | |
672 | + * @param baseSortTypes the base sort types | |
673 | + * @param baseSortDirections the base sort directions | |
674 | + * @param baseNumbers the base numbers | |
675 | + * @param baseMinimumDoubles the base minimum doubles | |
676 | + * @param baseMaximumDoubles the base maximum doubles | |
677 | + * @param baseFunctions the base functions | |
678 | + * @throws IOException Signals that an I/O exception has occurred. | |
679 | + * @throws ParseException the parse exception | |
745 | 680 | */ |
746 | 681 | public ComponentFacet(SpanQuery[] spanQueries, String field, String key, |
747 | 682 | String[] baseFields, String[] baseFieldTypes, String[] baseTypes, |
... | ... | @@ -854,7 +789,7 @@ public class CodecComponent { |
854 | 789 | public String key, defaultDataType, functionDataType, defaultStatsType, |
855 | 790 | functionStatsType, prefix, regexp, sortType, sortDirection; |
856 | 791 | |
857 | - /** The stats default items. */ | |
792 | + /** The default stats items. */ | |
858 | 793 | public TreeSet<String> functionStatsItems, defaultStatsItems; |
859 | 794 | |
860 | 795 | /** The number. */ |
... | ... | @@ -881,28 +816,17 @@ public class CodecComponent { |
881 | 816 | /** |
882 | 817 | * Instantiates a new component term vector. |
883 | 818 | * |
884 | - * @param key | |
885 | - * the key | |
886 | - * @param prefix | |
887 | - * the prefix | |
888 | - * @param regexp | |
889 | - * the regexp | |
890 | - * @param statsType | |
891 | - * the stats type | |
892 | - * @param sortType | |
893 | - * the sort type | |
894 | - * @param sortDirection | |
895 | - * the sort direction | |
896 | - * @param startValue | |
897 | - * the start value | |
898 | - * @param number | |
899 | - * the number | |
900 | - * @param function | |
901 | - * the function | |
902 | - * @throws IOException | |
903 | - * Signals that an I/O exception has occurred. | |
904 | - * @throws ParseException | |
905 | - * the parse exception | |
819 | + * @param key the key | |
820 | + * @param prefix the prefix | |
821 | + * @param regexp the regexp | |
822 | + * @param statsType the stats type | |
823 | + * @param sortType the sort type | |
824 | + * @param sortDirection the sort direction | |
825 | + * @param startValue the start value | |
826 | + * @param number the number | |
827 | + * @param function the function | |
828 | + * @throws IOException Signals that an I/O exception has occurred. | |
829 | + * @throws ParseException the parse exception | |
906 | 830 | */ |
907 | 831 | public ComponentTermVector(String key, String prefix, String regexp, |
908 | 832 | String statsType, String sortType, String sortDirection, |
... | ... | @@ -1023,20 +947,13 @@ public class CodecComponent { |
1023 | 947 | /** |
1024 | 948 | * Instantiates a new component span. |
1025 | 949 | * |
1026 | - * @param queries | |
1027 | - * the queries | |
1028 | - * @param key | |
1029 | - * the key | |
1030 | - * @param minimumDouble | |
1031 | - * the minimum double | |
1032 | - * @param maximumDouble | |
1033 | - * the maximum double | |
1034 | - * @param type | |
1035 | - * the type | |
1036 | - * @param function | |
1037 | - * the function | |
1038 | - * @throws IOException | |
1039 | - * Signals that an I/O exception has occurred. | |
950 | + * @param queries the queries | |
951 | + * @param key the key | |
952 | + * @param minimumDouble the minimum double | |
953 | + * @param maximumDouble the maximum double | |
954 | + * @param type the type | |
955 | + * @param function the function | |
956 | + * @throws IOException Signals that an I/O exception has occurred. | |
1040 | 957 | */ |
1041 | 958 | public ComponentSpan(SpanQuery[] queries, String key, Double minimumDouble, |
1042 | 959 | Double maximumDouble, String type, String function) throws IOException { |
... | ... | @@ -1109,20 +1026,13 @@ public class CodecComponent { |
1109 | 1026 | /** |
1110 | 1027 | * Instantiates a new component position. |
1111 | 1028 | * |
1112 | - * @param field | |
1113 | - * the field | |
1114 | - * @param key | |
1115 | - * the key | |
1116 | - * @param minimumDouble | |
1117 | - * the minimum double | |
1118 | - * @param maximumDouble | |
1119 | - * the maximum double | |
1120 | - * @param statsType | |
1121 | - * the stats type | |
1122 | - * @throws IOException | |
1123 | - * Signals that an I/O exception has occurred. | |
1124 | - * @throws ParseException | |
1125 | - * the parse exception | |
1029 | + * @param field the field | |
1030 | + * @param key the key | |
1031 | + * @param minimumDouble the minimum double | |
1032 | + * @param maximumDouble the maximum double | |
1033 | + * @param statsType the stats type | |
1034 | + * @throws IOException Signals that an I/O exception has occurred. | |
1035 | + * @throws ParseException the parse exception | |
1126 | 1036 | */ |
1127 | 1037 | public ComponentPosition(String field, String key, Double minimumDouble, |
1128 | 1038 | Double maximumDouble, String statsType) |
... | ... | @@ -1186,20 +1096,13 @@ public class CodecComponent { |
1186 | 1096 | /** |
1187 | 1097 | * Instantiates a new component token. |
1188 | 1098 | * |
1189 | - * @param field | |
1190 | - * the field | |
1191 | - * @param key | |
1192 | - * the key | |
1193 | - * @param minimumDouble | |
1194 | - * the minimum double | |
1195 | - * @param maximumDouble | |
1196 | - * the maximum double | |
1197 | - * @param statsType | |
1198 | - * the stats type | |
1199 | - * @throws IOException | |
1200 | - * Signals that an I/O exception has occurred. | |
1201 | - * @throws ParseException | |
1202 | - * the parse exception | |
1099 | + * @param field the field | |
1100 | + * @param key the key | |
1101 | + * @param minimumDouble the minimum double | |
1102 | + * @param maximumDouble the maximum double | |
1103 | + * @param statsType the stats type | |
1104 | + * @throws IOException Signals that an I/O exception has occurred. | |
1105 | + * @throws ParseException the parse exception | |
1203 | 1106 | */ |
1204 | 1107 | public ComponentToken(String field, String key, Double minimumDouble, |
1205 | 1108 | Double maximumDouble, String statsType) |
... | ... | @@ -1248,10 +1151,8 @@ public class CodecComponent { |
1248 | 1151 | /** |
1249 | 1152 | * Instantiates a new kwic token. |
1250 | 1153 | * |
1251 | - * @param match | |
1252 | - * the match | |
1253 | - * @param tokens | |
1254 | - * the tokens | |
1154 | + * @param match the match | |
1155 | + * @param tokens the tokens | |
1255 | 1156 | */ |
1256 | 1157 | public KwicToken(Match match, ArrayList<MtasToken<String>> tokens) { |
1257 | 1158 | startPosition = match.startPosition; |
... | ... | @@ -1277,10 +1178,8 @@ public class CodecComponent { |
1277 | 1178 | /** |
1278 | 1179 | * Instantiates a new kwic hit. |
1279 | 1180 | * |
1280 | - * @param match | |
1281 | - * the match | |
1282 | - * @param hits | |
1283 | - * the hits | |
1181 | + * @param match the match | |
1182 | + * @param hits the hits | |
1284 | 1183 | */ |
1285 | 1184 | public KwicHit(Match match, HashMap<Integer, ArrayList<String>> hits) { |
1286 | 1185 | startPosition = match.startPosition; |
... | ... | @@ -1303,8 +1202,7 @@ public class CodecComponent { |
1303 | 1202 | /** |
1304 | 1203 | * Sort. |
1305 | 1204 | * |
1306 | - * @param data | |
1307 | - * the data | |
1205 | + * @param data the data | |
1308 | 1206 | * @return the array list |
1309 | 1207 | */ |
1310 | 1208 | private ArrayList<MtasTreeHit<String>> sort( |
... | ... | @@ -1321,8 +1219,7 @@ public class CodecComponent { |
1321 | 1219 | /** |
1322 | 1220 | * Creates the hash. |
1323 | 1221 | * |
1324 | - * @param data | |
1325 | - * the data | |
1222 | + * @param data the data | |
1326 | 1223 | * @return the string |
1327 | 1224 | */ |
1328 | 1225 | private String createHash(ArrayList<MtasTreeHit<String>> data) { |
... | ... | @@ -1337,18 +1234,12 @@ public class CodecComponent { |
1337 | 1234 | /** |
1338 | 1235 | * Instantiates a new group hit. |
1339 | 1236 | * |
1340 | - * @param list | |
1341 | - * the list | |
1342 | - * @param start | |
1343 | - * the start | |
1344 | - * @param end | |
1345 | - * the end | |
1346 | - * @param hitStart | |
1347 | - * the hit start | |
1348 | - * @param hitEnd | |
1349 | - * the hit end | |
1350 | - * @param group | |
1351 | - * the group | |
1237 | + * @param list the list | |
1238 | + * @param start the start | |
1239 | + * @param end the end | |
1240 | + * @param hitStart the hit start | |
1241 | + * @param hitEnd the hit end | |
1242 | + * @param group the group | |
1352 | 1243 | */ |
1353 | 1244 | public GroupHit(ArrayList<MtasTreeHit<String>> list, int start, int end, |
1354 | 1245 | int hitStart, int hitEnd, ComponentGroup group) { |
... | ... | @@ -1501,8 +1392,7 @@ public class CodecComponent { |
1501 | 1392 | /** |
1502 | 1393 | * Data to string. |
1503 | 1394 | * |
1504 | - * @param data | |
1505 | - * the data | |
1395 | + * @param data the data | |
1506 | 1396 | * @return the string |
1507 | 1397 | */ |
1508 | 1398 | private String dataToString(ArrayList<String>[] data) { |
... | ... | @@ -1553,14 +1443,10 @@ public class CodecComponent { |
1553 | 1443 | /** |
1554 | 1444 | * Instantiates a new list token. |
1555 | 1445 | * |
1556 | - * @param docId | |
1557 | - * the doc id | |
1558 | - * @param docPosition | |
1559 | - * the doc position | |
1560 | - * @param match | |
1561 | - * the match | |
1562 | - * @param tokens | |
1563 | - * the tokens | |
1446 | + * @param docId the doc id | |
1447 | + * @param docPosition the doc position | |
1448 | + * @param match the match | |
1449 | + * @param tokens the tokens | |
1564 | 1450 | */ |
1565 | 1451 | public ListToken(Integer docId, Integer docPosition, Match match, |
1566 | 1452 | ArrayList<MtasToken<String>> tokens) { |
... | ... | @@ -1589,14 +1475,10 @@ public class CodecComponent { |
1589 | 1475 | /** |
1590 | 1476 | * Instantiates a new list hit. |
1591 | 1477 | * |
1592 | - * @param docId | |
1593 | - * the doc id | |
1594 | - * @param docPosition | |
1595 | - * the doc position | |
1596 | - * @param match | |
1597 | - * the match | |
1598 | - * @param hits | |
1599 | - * the hits | |
1478 | + * @param docId the doc id | |
1479 | + * @param docPosition the doc position | |
1480 | + * @param match the match | |
1481 | + * @param hits the hits | |
1600 | 1482 | */ |
1601 | 1483 | public ListHit(Integer docId, Integer docPosition, Match match, |
1602 | 1484 | HashMap<Integer, ArrayList<String>> hits) { |
... | ... | @@ -1622,10 +1504,8 @@ public class CodecComponent { |
1622 | 1504 | /** |
1623 | 1505 | * Instantiates a new match. |
1624 | 1506 | * |
1625 | - * @param startPosition | |
1626 | - * the start position | |
1627 | - * @param endPosition | |
1628 | - * the end position | |
1507 | + * @param startPosition the start position | |
1508 | + * @param endPosition the end position | |
1629 | 1509 | */ |
1630 | 1510 | public Match(int startPosition, int endPosition) { |
1631 | 1511 | this.startPosition = startPosition; |
... | ... |
src/mtas/codec/util/CodecInfo.java
... | ... | @@ -4,16 +4,13 @@ import java.io.IOException; |
4 | 4 | import java.lang.reflect.Method; |
5 | 5 | import java.util.ArrayList; |
6 | 6 | import java.util.HashMap; |
7 | -import java.util.HashSet; | |
8 | 7 | import java.util.LinkedHashMap; |
9 | 8 | import java.util.List; |
10 | 9 | import mtas.analysis.token.MtasToken; |
11 | 10 | import mtas.codec.MtasCodecPostingsFormat; |
12 | 11 | import mtas.codec.tree.IntervalRBTree; |
13 | 12 | import mtas.codec.tree.IntervalTreeNodeData; |
14 | -import mtas.codec.util.CodecComponent.ComponentGroup; | |
15 | 13 | import mtas.codec.util.CodecSearchTree.MtasTreeHit; |
16 | - | |
17 | 14 | import org.apache.lucene.index.Terms; |
18 | 15 | import org.apache.lucene.store.IndexInput; |
19 | 16 | |
... | ... | @@ -339,14 +336,14 @@ public class CodecInfo { |
339 | 336 | */ |
340 | 337 | public void collectTermsByPrefixesForListOfHitPositions(String field, |
341 | 338 | int docId, ArrayList<String> prefixes, |
342 | - ArrayList<IntervalTreeNodeData> positionsHits) throws IOException { | |
339 | + ArrayList<IntervalTreeNodeData<String>> positionsHits) throws IOException { | |
343 | 340 | IndexDoc doc = getDoc(field, docId); |
344 | 341 | IndexInput inIndexObjectPosition = indexInputList |
345 | 342 | .get("indexObjectPosition"); |
346 | 343 | IndexInput inObject = indexInputList.get("object"); |
347 | 344 | IndexInput inTerm = indexInputList.get("term"); |
348 | 345 | // create tree interval hits |
349 | - IntervalRBTree positionTree = new IntervalRBTree(positionsHits); | |
346 | + IntervalRBTree<String> positionTree = new IntervalRBTree<String>(positionsHits); | |
350 | 347 | if (version == MtasCodecPostingsFormat.VERSION_OLD_1) { |
351 | 348 | CodecSearchTree.searchMtasTreeWithIntervalTree(null, positionTree, |
352 | 349 | inIndexObjectPosition, doc.fpIndexObjectPosition, |
... | ... | @@ -360,7 +357,7 @@ public class CodecInfo { |
360 | 357 | doc.smallestObjectFilepointer); |
361 | 358 | } |
362 | 359 | for(IntervalTreeNodeData<String> positionHit : positionsHits) { |
363 | - for(MtasTreeHit hit : positionHit.list) { | |
360 | + for(MtasTreeHit<String> hit : positionHit.list) { | |
364 | 361 | if(hit.data==null) { |
365 | 362 | MtasToken<String> token = MtasCodecPostingsFormat.getToken(inObject, |
366 | 363 | inTerm, hit.ref); |
... | ... |
src/mtas/codec/util/CodecSearchTree.java
... | ... | @@ -3,15 +3,11 @@ package mtas.codec.util; |
3 | 3 | import java.io.IOException; |
4 | 4 | import java.util.ArrayList; |
5 | 5 | import java.util.Collection; |
6 | -import java.util.HashMap; | |
7 | 6 | import java.util.concurrent.atomic.AtomicBoolean; |
8 | 7 | import java.util.concurrent.atomic.AtomicLong; |
9 | - | |
10 | 8 | import mtas.codec.tree.IntervalTree; |
11 | 9 | import mtas.codec.tree.IntervalTreeNode; |
12 | 10 | import mtas.codec.tree.MtasTree; |
13 | -import mtas.codec.util.CodecSearchTree.MtasTreeHit; | |
14 | - | |
15 | 11 | import org.apache.lucene.store.IndexInput; |
16 | 12 | |
17 | 13 | /** |
... | ... | @@ -392,6 +388,8 @@ public class CodecSearchTree { |
392 | 388 | /** |
393 | 389 | * Search mtas tree with interval tree. |
394 | 390 | * |
391 | + * @param <T> the generic type | |
392 | + * @param <N> the number type | |
395 | 393 | * @param additionalIds the additional ids |
396 | 394 | * @param intervalTree the interval tree |
397 | 395 | * @param in the in |
... | ... | @@ -399,20 +397,19 @@ public class CodecSearchTree { |
399 | 397 | * @param objectRefApproxOffset the object ref approx offset |
400 | 398 | * @throws IOException Signals that an I/O exception has occurred. |
401 | 399 | */ |
402 | - public static void searchMtasTreeWithIntervalTree( | |
403 | - Collection<Integer> additionalIds, IntervalTree<?> intervalTree, IndexInput in, long ref, | |
400 | + public static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeWithIntervalTree( | |
401 | + Collection<Integer> additionalIds, IntervalTree<T,N> intervalTree, IndexInput in, long ref, | |
404 | 402 | long objectRefApproxOffset) throws IOException { |
405 | - ArrayList<IntervalItem> checkList = new ArrayList<IntervalItem>(); | |
403 | + ArrayList<IntervalItem<T,N>> checkList = new ArrayList<IntervalItem<T,N>>(); | |
406 | 404 | AtomicBoolean isSinglePoint = new AtomicBoolean(false); |
407 | 405 | AtomicBoolean isStoreAdditionalId = new AtomicBoolean(false); |
408 | 406 | AtomicLong nodeRefApproxOffset = new AtomicLong(-1); |
409 | - checkList.add(new IntervalItem( | |
407 | + checkList.add(new IntervalItem<T,N>( | |
410 | 408 | getMtasTreeItem(ref, isSinglePoint, isStoreAdditionalId, |
411 | 409 | nodeRefApproxOffset, in, objectRefApproxOffset), |
412 | 410 | intervalTree.getRoot())); |
413 | - IntervalTreeNode<?> intervalTreeNode = intervalTree.getRoot(); | |
414 | 411 | do { |
415 | - IntervalItem checkItem = checkList.remove(checkList.size() - 1); | |
412 | + IntervalItem<T,N> checkItem = checkList.remove(checkList.size() - 1); | |
416 | 413 | searchMtasTreeWithIntervalTree(additionalIds, checkItem, in, isSinglePoint, |
417 | 414 | isStoreAdditionalId, objectRefApproxOffset, nodeRefApproxOffset, |
418 | 415 | checkList); |
... | ... | @@ -422,6 +419,8 @@ public class CodecSearchTree { |
422 | 419 | /** |
423 | 420 | * Search mtas tree with interval tree. |
424 | 421 | * |
422 | + * @param <T> the generic type | |
423 | + * @param <N> the number type | |
425 | 424 | * @param additionalIds the additional ids |
426 | 425 | * @param checkItem the check item |
427 | 426 | * @param in the in |
... | ... | @@ -432,13 +431,13 @@ public class CodecSearchTree { |
432 | 431 | * @param checkList the check list |
433 | 432 | * @throws IOException Signals that an I/O exception has occurred. |
434 | 433 | */ |
435 | - private static void searchMtasTreeWithIntervalTree(Collection<Integer> additionalIds, IntervalItem checkItem, | |
434 | + private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeWithIntervalTree(Collection<Integer> additionalIds, IntervalItem<T,N> checkItem, | |
436 | 435 | IndexInput in, AtomicBoolean isSinglePoint, |
437 | 436 | AtomicBoolean isStoreAdditionalId, long objectRefApproxOffset, |
438 | - AtomicLong nodeRefApproxOffset, ArrayList<IntervalItem> checkList) | |
437 | + AtomicLong nodeRefApproxOffset, ArrayList<IntervalItem<T,N>> checkList) | |
439 | 438 | throws IOException { |
440 | 439 | MtasTreeItem treeItem = checkItem.mtasTreeItem; |
441 | - IntervalTreeNode<?> intervalTreeNode = checkItem.intervalTreeNode; | |
440 | + IntervalTreeNode<T,N> intervalTreeNode = checkItem.intervalTreeNode; | |
442 | 441 | if (intervalTreeNode.min <= treeItem.max) { |
443 | 442 | // advance intervalTree |
444 | 443 | while (intervalTreeNode.left > treeItem.max) { |
... | ... | @@ -465,14 +464,14 @@ public class CodecSearchTree { |
465 | 464 | MtasTreeItem treeItemLeft = getMtasTreeItem(treeItem.leftChild, |
466 | 465 | isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, |
467 | 466 | objectRefApproxOffset); |
468 | - checkList.add(new IntervalItem(treeItemLeft, intervalTreeNode)); | |
467 | + checkList.add(new IntervalItem<T,N>(treeItemLeft, intervalTreeNode)); | |
469 | 468 | } |
470 | 469 | // check rightChild |
471 | 470 | if (!treeItem.rightChild.equals(treeItem.ref)) { |
472 | 471 | MtasTreeItem treeItemRight = getMtasTreeItem(treeItem.rightChild, |
473 | 472 | isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, |
474 | 473 | objectRefApproxOffset); |
475 | - checkList.add(new IntervalItem(treeItemRight, intervalTreeNode)); | |
474 | + checkList.add(new IntervalItem<T,N>(treeItemRight, intervalTreeNode)); | |
476 | 475 | } |
477 | 476 | } |
478 | 477 | } |
... | ... | @@ -480,16 +479,18 @@ public class CodecSearchTree { |
480 | 479 | /** |
481 | 480 | * Search mtas tree item with interval tree. |
482 | 481 | * |
482 | + * @param <T> the generic type | |
483 | + * @param <N> the number type | |
483 | 484 | * @param additionalIds the additional ids |
484 | 485 | * @param treeItem the tree item |
485 | 486 | * @param intervalTreeNode the interval tree node |
486 | 487 | */ |
487 | - private static void searchMtasTreeItemWithIntervalTree(Collection<Integer> additionalIds, MtasTreeItem treeItem, | |
488 | - IntervalTreeNode<?> intervalTreeNode) { | |
489 | - ArrayList<IntervalTreeNode<?>> checkList = new ArrayList<IntervalTreeNode<?>>(); | |
488 | + private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeItemWithIntervalTree(Collection<Integer> additionalIds, MtasTreeItem treeItem, | |
489 | + IntervalTreeNode<T,N> intervalTreeNode) { | |
490 | + ArrayList<IntervalTreeNode<T,N>> checkList = new ArrayList<IntervalTreeNode<T,N>>(); | |
490 | 491 | checkList.add(intervalTreeNode); |
491 | 492 | do { |
492 | - IntervalTreeNode<?> checkItem = checkList.remove(checkList.size() - 1); | |
493 | + IntervalTreeNode<T,N> checkItem = checkList.remove(checkList.size() - 1); | |
493 | 494 | searchMtasTreeItemWithIntervalTree(additionalIds, checkItem, treeItem.left, |
494 | 495 | treeItem.right, treeItem.objectRefs, treeItem.objectIds, checkList); |
495 | 496 | } while (checkList.size() > 0); |
... | ... | @@ -498,6 +499,8 @@ public class CodecSearchTree { |
498 | 499 | /** |
499 | 500 | * Search mtas tree item with interval tree. |
500 | 501 | * |
502 | + * @param <T> the generic type | |
503 | + * @param <N> the number type | |
501 | 504 | * @param requiredAdditionalIds the required additional ids |
502 | 505 | * @param intervalTreeItem the interval tree item |
503 | 506 | * @param startPosition the start position |
... | ... | @@ -506,10 +509,10 @@ public class CodecSearchTree { |
506 | 509 | * @param additionalIds the additional ids |
507 | 510 | * @param checkList the check list |
508 | 511 | */ |
509 | - private static void searchMtasTreeItemWithIntervalTree(Collection<Integer> requiredAdditionalIds, | |
510 | - IntervalTreeNode<?> intervalTreeItem, int startPosition, int endPosition, | |
512 | + private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeItemWithIntervalTree(Collection<Integer> requiredAdditionalIds, | |
513 | + IntervalTreeNode<T,N> intervalTreeItem, int startPosition, int endPosition, | |
511 | 514 | long[] refs, int[] additionalIds, |
512 | - ArrayList<IntervalTreeNode<?>> checkList) { | |
515 | + ArrayList<IntervalTreeNode<T,N>> checkList) { | |
513 | 516 | if (startPosition <= intervalTreeItem.max) { |
514 | 517 | // match current node |
515 | 518 | if ((endPosition >= intervalTreeItem.left) |
... | ... | @@ -517,17 +520,17 @@ public class CodecSearchTree { |
517 | 520 | //System.out.print("[" + startPosition + "-" + endPosition + "] "); |
518 | 521 | if(requiredAdditionalIds==null || additionalIds==null) { |
519 | 522 | for (int i = 0; i < refs.length; i++) { |
520 | - MtasTreeHit<?> hit = new MtasTreeHit<String>(startPosition, | |
523 | + MtasTreeHit<T> hit = new MtasTreeHit<T>(startPosition, | |
521 | 524 | endPosition, refs[i], 0, null); |
522 | - for (ArrayList<MtasTreeHit<?>> list : intervalTreeItem.lists) { | |
525 | + for (ArrayList<MtasTreeHit<T>> list : intervalTreeItem.lists) { | |
523 | 526 | list.add(hit); |
524 | 527 | } |
525 | 528 | } |
526 | 529 | } else { |
527 | 530 | for (int i = 0; i < refs.length; i++) { |
528 | - MtasTreeHit<?> hit = new MtasTreeHit<String>(startPosition, | |
531 | + MtasTreeHit<T> hit = new MtasTreeHit<T>(startPosition, | |
529 | 532 | endPosition, refs[i], additionalIds[i], null); |
530 | - for (ArrayList<MtasTreeHit<?>> list : intervalTreeItem.lists) { | |
533 | + for (ArrayList<MtasTreeHit<T>> list : intervalTreeItem.lists) { | |
531 | 534 | list.add(hit); |
532 | 535 | } |
533 | 536 | } |
... | ... | @@ -535,7 +538,7 @@ public class CodecSearchTree { |
535 | 538 | } |
536 | 539 | // check leftChild |
537 | 540 | if (intervalTreeItem.leftChild != null) { |
538 | - IntervalTreeNode treeItemLeft = intervalTreeItem.leftChild; | |
541 | + IntervalTreeNode<T,N> treeItemLeft = intervalTreeItem.leftChild; | |
539 | 542 | if (treeItemLeft.max >= startPosition) { |
540 | 543 | checkList.add(treeItemLeft); |
541 | 544 | } |
... | ... | @@ -543,7 +546,7 @@ public class CodecSearchTree { |
543 | 546 | // check rightChild |
544 | 547 | if (intervalTreeItem.left < endPosition) { |
545 | 548 | if (intervalTreeItem.rightChild != null) { |
546 | - IntervalTreeNode treeItemRight = intervalTreeItem.rightChild; | |
549 | + IntervalTreeNode<T,N> treeItemRight = intervalTreeItem.rightChild; | |
547 | 550 | if ((treeItemRight.left >= endPosition) |
548 | 551 | || (treeItemRight.max >= startPosition)) { |
549 | 552 | checkList.add(treeItemRight); |
... | ... | @@ -556,14 +559,17 @@ public class CodecSearchTree { |
556 | 559 | |
557 | 560 | /** |
558 | 561 | * The Class IntervalItem. |
562 | + * | |
563 | + * @param <T> the generic type | |
564 | + * @param <N> the number type | |
559 | 565 | */ |
560 | - private static class IntervalItem { | |
566 | + private static class IntervalItem<T, N extends IntervalTreeNode<T, N>> { | |
561 | 567 | |
562 | 568 | /** The mtas tree item. */ |
563 | 569 | public MtasTreeItem mtasTreeItem; |
564 | 570 | |
565 | 571 | /** The interval tree node. */ |
566 | - public IntervalTreeNode<?> intervalTreeNode; | |
572 | + public IntervalTreeNode<T,N> intervalTreeNode; | |
567 | 573 | |
568 | 574 | /** |
569 | 575 | * Instantiates a new interval item. |
... | ... | @@ -572,7 +578,7 @@ public class CodecSearchTree { |
572 | 578 | * @param intervalTreeNode the interval tree node |
573 | 579 | */ |
574 | 580 | public IntervalItem(MtasTreeItem mtasTreeItem, |
575 | - IntervalTreeNode<?> intervalTreeNode) { | |
581 | + IntervalTreeNode<T,N> intervalTreeNode) { | |
576 | 582 | this.mtasTreeItem = mtasTreeItem; |
577 | 583 | this.intervalTreeNode = intervalTreeNode; |
578 | 584 | } |
... | ... |
src/mtas/codec/util/CodecUtil.java
... | ... | @@ -2,7 +2,6 @@ package mtas.codec.util; |
2 | 2 | |
3 | 3 | import java.io.IOException; |
4 | 4 | import java.lang.reflect.InvocationTargetException; |
5 | -import java.lang.reflect.Method; | |
6 | 5 | import java.util.ArrayList; |
7 | 6 | import java.util.Arrays; |
8 | 7 | import java.util.HashMap; |
... | ... | @@ -10,19 +9,15 @@ import java.util.List; |
10 | 9 | import java.util.TreeSet; |
11 | 10 | import java.util.regex.Matcher; |
12 | 11 | import java.util.regex.Pattern; |
13 | - | |
14 | 12 | import mtas.analysis.token.MtasToken; |
15 | 13 | import mtas.codec.MtasCodecPostingsFormat; |
16 | 14 | import mtas.parser.function.util.MtasFunctionParserFunction; |
17 | 15 | import mtas.codec.util.CodecComponent.ComponentField; |
18 | - | |
19 | 16 | import org.apache.lucene.index.FieldInfo; |
20 | 17 | import org.apache.lucene.index.IndexReader; |
21 | -import org.apache.lucene.index.Terms; | |
22 | 18 | import org.apache.lucene.search.IndexSearcher; |
23 | 19 | import org.apache.lucene.search.spans.SpanQuery; |
24 | 20 | import org.apache.lucene.search.spans.SpanWeight; |
25 | -import org.apache.lucene.store.IndexInput; | |
26 | 21 | |
27 | 22 | /** |
28 | 23 | * The Class CodecUtil. |
... | ... |