|
33 | 33 |
|
34 | 34 | import com.carrotsearch.randomizedtesting.generators.RandomStrings; |
35 | 35 |
|
36 | | -import org.apache.logging.log4j.LogManager; |
37 | | -import org.apache.logging.log4j.Logger; |
38 | 36 | import org.apache.lucene.analysis.Analyzer; |
39 | 37 | import org.apache.lucene.analysis.LowerCaseFilter; |
40 | 38 | import org.apache.lucene.analysis.TokenFilter; |
|
79 | 77 | import java.io.IOException; |
80 | 78 | import java.util.ArrayList; |
81 | 79 | import java.util.Arrays; |
82 | | -import java.util.Collection; |
83 | 80 | import java.util.Collections; |
84 | 81 | import java.util.List; |
85 | 82 | import java.util.Map; |
86 | | -import java.util.Random; |
87 | | -import java.util.SortedSet; |
88 | | -import java.util.stream.Stream; |
89 | | - |
90 | | -import org.mockito.MockedConstruction; |
91 | | -import org.mockito.stubbing.Answer; |
92 | | - |
93 | | -import static org.mockito.Mockito.mockConstructionWithAnswer; |
94 | 83 |
|
95 | 84 | public class KeywordFieldTypeTests extends FieldTypeTestCase { |
96 | 85 |
|
@@ -229,57 +218,6 @@ public void testTermsSortedQuery() { |
229 | 218 | assertEquals(expectedDocValues, onlyDocValues.termsQuery(sortedStrings, null)); |
230 | 219 | } |
231 | 220 |
|
232 | | - @AwaitsFix(bugUrl = "no commit") |
233 | | - public void testMockTermsSortedQuery() { |
234 | | - String[] seedStrings = generateRandomStringArray(10, 10, false, false); |
235 | | - if (seedStrings.length == 1) { |
236 | | - seedStrings = Stream.concat(Arrays.stream(seedStrings), Arrays.stream(generateRandomStringArray(10, 10, false, false))) |
237 | | - .toArray(String[]::new); |
238 | | - } |
239 | | - List<BytesRef> bytesRefList = Arrays.stream(seedStrings).map(BytesRef::new).toList(); |
240 | | - List<String> sortedStrings = bytesRefList.stream().sorted().map(BytesRef::utf8ToString).toList(); |
241 | | - Answer asseretSortedSetArg = invocationOnMock -> { |
242 | | - Object[] args = invocationOnMock.getArguments(); |
243 | | - for (int i = 0; i < args.length; i++) { |
244 | | - if (args[i] instanceof Collection<?>) { |
245 | | - assertTrue(args[i] instanceof SortedSet<?>); |
246 | | - return invocationOnMock.callRealMethod(); |
247 | | - } |
248 | | - } |
249 | | - fail(); |
250 | | - return null; |
251 | | - }; |
252 | | - try (MockedConstruction<TermInSetQuery> ignored = mockConstructionWithAnswer(TermInSetQuery.class, asseretSortedSetArg)) { |
253 | | - MappedFieldType ft = new KeywordFieldType("field"); |
254 | | - assertNotNull(ft.termsQuery(sortedStrings, MOCK_QSC_ENABLE_INDEX_DOC_VALUES)); |
255 | | - MappedFieldType onlyIndexed = new KeywordFieldType("field", true, false, Collections.emptyMap()); |
256 | | - assertNotNull(onlyIndexed.termsQuery(sortedStrings, null)); |
257 | | - MappedFieldType onlyDocValues = new KeywordFieldType("field", false, true, Collections.emptyMap()); |
258 | | - assertNotNull(onlyDocValues.termsQuery(sortedStrings, null)); |
259 | | - } |
260 | | - } |
261 | | - |
262 | | - @AwaitsFix(bugUrl = "no commit") |
263 | | - public void testHeavyWeight() { |
264 | | - int arraySize = 10000000; |
265 | | - BytesRef[] array = new BytesRef[arraySize]; |
266 | | - Random random = random(); |
267 | | - for (int i = 0; i < arraySize; i++) { |
268 | | - String str = RandomStrings.randomAsciiOfLength(random, 10); |
269 | | - array[i] = new BytesRef(str); |
270 | | - } |
271 | | - BytesRefsCollectionBuilder outofOrder = new BytesRefsCollectionBuilder(arraySize); |
272 | | - BytesRefsCollectionBuilder inOrder = new BytesRefsCollectionBuilder(arraySize); |
273 | | - Arrays.stream(array).forEach(outofOrder); |
274 | | - Arrays.stream(array).sorted().forEachOrdered(inOrder); |
275 | | - Logger logger = LogManager.getLogger(KeywordFieldTypeTests.class); |
276 | | - long start = System.currentTimeMillis(), intermid; |
277 | | - new TermInSetQuery("foo", outofOrder.get()); |
278 | | - logger.info("out of order {} ms", (intermid = System.currentTimeMillis()) - start); |
279 | | - new TermInSetQuery("foo", inOrder.get()); |
280 | | - logger.info("in order{} ms", System.currentTimeMillis() - intermid); |
281 | | - } |
282 | | - |
283 | 221 | public void testExistsQuery() { |
284 | 222 | { |
285 | 223 | KeywordFieldType ft = new KeywordFieldType("field"); |
|
0 commit comments