|
208 | 208 | import java.util.stream.LongStream; |
209 | 209 | import java.util.stream.Stream; |
210 | 210 |
|
| 211 | +import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; |
211 | 212 | import static java.util.Collections.emptyMap; |
212 | 213 | import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList; |
213 | 214 | import static org.hamcrest.Matchers.anyOf; |
@@ -2573,9 +2574,42 @@ public static void ensureAllContextsReleased(SearchService searchService) { |
2573 | 2574 | } |
2574 | 2575 | } |
2575 | 2576 |
|
2576 | | - // lucene 10 upgrade: this overwrites LuceneTestCase#newSearcher so we never get random INTRA_SEGMENT |
2577 | | - // concurrency. We want to slowly migrate of stuff out of using this method after we got a working branch |
| 2577 | + /** |
| 2578 | + * Create a new searcher over the reader. This searcher might randomly use threads. |
| 2579 | + * Provides the same functionality as {@link LuceneTestCase#newSearcher(IndexReader)}, |
| 2580 | + * with the only difference that concurrency will only ever be inter-segment and never intra-segment. |
| 2581 | + */ |
2578 | 2582 | public static IndexSearcher newSearcher(IndexReader r) { |
2579 | | - return newSearcher(r, true, true, Concurrency.INTER_SEGMENT); |
| 2583 | + return newSearcher(r, true); |
| 2584 | + } |
| 2585 | + |
| 2586 | + /** |
| 2587 | + * Create a new searcher over the reader. This searcher might randomly use threads. |
| 2588 | + * Provides the same functionality as {@link LuceneTestCase#newSearcher(IndexReader, boolean)}, |
| 2589 | + * with the only difference that concurrency will only ever be inter-segment and never intra-segment. |
| 2590 | + */ |
| 2591 | + public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap) { |
| 2592 | + return newSearcher(r, maybeWrap, true); |
| 2593 | + } |
| 2594 | + |
| 2595 | + /** |
| 2596 | + * Create a new searcher over the reader. This searcher might randomly use threads. |
| 2597 | + * Provides the same functionality as {@link LuceneTestCase#newSearcher(IndexReader, boolean, boolean)}, |
| 2598 | + * with the only difference that concurrency will only ever be inter-segment and never intra-segment. |
| 2599 | + */ |
| 2600 | + public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap, boolean wrapWithAssertions) { |
| 2601 | + return newSearcher(r, maybeWrap, wrapWithAssertions, randomBoolean()); |
| 2602 | + } |
| 2603 | + |
| 2604 | + /** |
| 2605 | + * Create a new searcher over the reader. |
| 2606 | + * Provides the same functionality as {@link LuceneTestCase#newSearcher(IndexReader, boolean, boolean, boolean)}, |
| 2607 | + * with the only difference that concurrency will only ever be inter-segment and never intra-segment. |
| 2608 | + */ |
| 2609 | + public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap, boolean wrapWithAssertions, boolean useThreads) { |
| 2610 | + if (useThreads) { |
| 2611 | + return newSearcher(r, maybeWrap, wrapWithAssertions, Concurrency.INTER_SEGMENT); |
| 2612 | + } |
| 2613 | + return newSearcher(r, maybeWrap, wrapWithAssertions, Concurrency.NONE); |
2580 | 2614 | } |
2581 | 2615 | } |
0 commit comments