public static final FilterStrategy randomFilterStrategy(final Random random) { switch(random.nextInt(6)) { case 5: case 4: return new FilteredQuery.RandomAccessFilterStrategy() { @Override protected boolean useRandomAccess(Bits bits, int firstFilterDoc) { return LuceneTestCase.random().nextBoolean(); } }; case 3: return FilteredQuery.RANDOM_ACCESS_FILTER_STRATEGY; case 2: return FilteredQuery.LEAP_FROG_FILTER_FIRST_STRATEGY; case 1: return FilteredQuery.LEAP_FROG_QUERY_FIRST_STRATEGY; case 0: return FilteredQuery.QUERY_FIRST_FILTER_STRATEGY; default: return FilteredQuery.RANDOM_ACCESS_FILTER_STRATEGY; } }
private static FilteredQuery.FilterStrategy randomFilterStrategy(Random random, final boolean useRandomAccess) { if (useRandomAccess) { return new FilteredQuery.RandomAccessFilterStrategy() { @Override protected boolean useRandomAccess(Bits bits, int firstFilterDoc) { return true; } }; } return TestUtil.randomFilterStrategy(random); }
private static FilteredQuery.FilterStrategy randomFilterStrategy(Random random, final boolean useRandomAccess) { if (useRandomAccess) { return new FilteredQuery.RandomAccessFilterStrategy() { @Override protected boolean useRandomAccess(Bits bits, int firstFilterDoc) { return useRandomAccess; } }; } return _TestUtil.randomFilterStrategy(random); }
private FilterStrategy randomFilterStrategy() { return randomFilterStrategy(random(), true); }
public void testGetFilterStrategy() { FilterStrategy randomFilterStrategy = randomFilterStrategy(); FilteredQuery filteredQuery = new FilteredQuery(new TermQuery(new Term("field", "one")), new PrefixFilter(new Term("field", "o")), randomFilterStrategy); assertSame(randomFilterStrategy, filteredQuery.getFilterStrategy()); }