Lines 132-142
Link Here
|
132 |
} |
132 |
} |
133 |
return results; |
133 |
return results; |
134 |
} |
134 |
} |
135 |
private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, CategoryTable wordsToDocNumbers, MemoryIndex memoryIndex) throws IOException { |
135 |
private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, CategoryTable wordsToDocNumbers, MemoryIndex memoryIndex, boolean prevResults) throws IOException { |
136 |
// must skip over documents which have been added/changed/deleted in the memory index |
136 |
// must skip over documents which have been added/changed/deleted in the memory index |
137 |
if (results == null) |
137 |
if (results == null) |
138 |
results = new HashtableOfObject(13); |
138 |
results = new HashtableOfObject(13); |
139 |
EntryResult result = (EntryResult) results.get(word); |
139 |
EntryResult result = prevResults ? (EntryResult) results.get(word) : null; |
140 |
if (memoryIndex == null) { |
140 |
if (memoryIndex == null) { |
141 |
if (result == null) |
141 |
if (result == null) |
142 |
results.putUnsafely(word, new EntryResult(word, wordsToDocNumbers)); |
142 |
results.putUnsafely(word, new EntryResult(word, wordsToDocNumbers)); |
Lines 161-166
Link Here
|
161 |
if (this.categoryOffsets == null) return null; // file is empty |
161 |
if (this.categoryOffsets == null) return null; // file is empty |
162 |
|
162 |
|
163 |
HashtableOfObject results = null; // initialized if needed |
163 |
HashtableOfObject results = null; // initialized if needed |
|
|
164 |
|
165 |
// No need to check the results table for duplicacy while processing the |
166 |
// first category table or if the first category tables doesn't have any results. |
167 |
boolean prevResults = false; |
164 |
if (key == null) { |
168 |
if (key == null) { |
165 |
for (int i = 0, l = categories.length; i < l; i++) { |
169 |
for (int i = 0, l = categories.length; i < l; i++) { |
166 |
CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match |
170 |
CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match |
Lines 170-177
Link Here
|
170 |
results = new HashtableOfObject(wordsToDocNumbers.elementSize); |
174 |
results = new HashtableOfObject(wordsToDocNumbers.elementSize); |
171 |
for (int j = 0, m = words.length; j < m; j++) |
175 |
for (int j = 0, m = words.length; j < m; j++) |
172 |
if (words[j] != null) |
176 |
if (words[j] != null) |
173 |
results = addQueryResult(results, words[j], wordsToDocNumbers, memoryIndex); |
177 |
results = addQueryResult(results, words[j], wordsToDocNumbers, memoryIndex, prevResults); |
174 |
} |
178 |
} |
|
|
179 |
prevResults = results != null; |
175 |
} |
180 |
} |
176 |
if (results != null && this.cachedChunks == null) |
181 |
if (results != null && this.cachedChunks == null) |
177 |
cacheDocumentNames(); |
182 |
cacheDocumentNames(); |
Lines 181-187
Link Here
|
181 |
for (int i = 0, l = categories.length; i < l; i++) { |
186 |
for (int i = 0, l = categories.length; i < l; i++) { |
182 |
CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], false); |
187 |
CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], false); |
183 |
if (wordsToDocNumbers != null && wordsToDocNumbers.containsKey(key)) |
188 |
if (wordsToDocNumbers != null && wordsToDocNumbers.containsKey(key)) |
184 |
results = addQueryResult(results, key, wordsToDocNumbers, memoryIndex); |
189 |
results = addQueryResult(results, key, wordsToDocNumbers, memoryIndex, prevResults); |
|
|
190 |
prevResults = results != null; |
185 |
} |
191 |
} |
186 |
break; |
192 |
break; |
187 |
case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE: |
193 |
case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE: |
Lines 192-200
Link Here
|
192 |
for (int j = 0, m = words.length; j < m; j++) { |
198 |
for (int j = 0, m = words.length; j < m; j++) { |
193 |
char[] word = words[j]; |
199 |
char[] word = words[j]; |
194 |
if (word != null && key[0] == word[0] && CharOperation.prefixEquals(key, word)) |
200 |
if (word != null && key[0] == word[0] && CharOperation.prefixEquals(key, word)) |
195 |
results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex); |
201 |
results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex, prevResults); |
196 |
} |
202 |
} |
197 |
} |
203 |
} |
|
|
204 |
prevResults = results != null; |
198 |
} |
205 |
} |
199 |
break; |
206 |
break; |
200 |
default: |
207 |
default: |
Lines 205-213
Link Here
|
205 |
for (int j = 0, m = words.length; j < m; j++) { |
212 |
for (int j = 0, m = words.length; j < m; j++) { |
206 |
char[] word = words[j]; |
213 |
char[] word = words[j]; |
207 |
if (word != null && Index.isMatch(key, word, matchRule)) |
214 |
if (word != null && Index.isMatch(key, word, matchRule)) |
208 |
results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex); |
215 |
results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex, prevResults); |
209 |
} |
216 |
} |
210 |
} |
217 |
} |
|
|
218 |
prevResults = results != null; |
211 |
} |
219 |
} |
212 |
} |
220 |
} |
213 |
} |
221 |
} |