SenseiTermFilter extends SenseiFilter { public SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize){ _name = name; _vals = vals != null ? vals : new String[0]; _not = not != null ? not : new String[0]; _isAnd = isAnd || vals == null || vals.length == 0; _noAutoOptimize = noAutoOptimize; } SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize); String planString(String type, String[] vals, String[] nots, List<String> optimizedVals, List<String> optimizedNots); @Override SenseiDocIdSet getSenseiDocIdSet(IndexReader reader); static final Comparator<Pair<String, DocIdSetCardinality>> INCREASING_CARDINALITY_COMPARATOR; }
@Test public void testSenseiTermFilter() throws IOException { SenseiTermFilter orTermFilter = new SenseiTermFilter("column", vals, null, false, false); BoboIndexReader indexReader = createMock(BoboIndexReader.class); MultiValueFacetDataCache facetDataCache = new MultiValueFacetDataCache(); facetDataCache.valArray = dictionary; facetDataCache.freqs = freqs; FacetHandler facetHandler = new MultiValueFacetHandler("column", 32); expect(indexReader.maxDoc()).andReturn(1000).anyTimes(); expect(indexReader.getFacetHandler("column")).andReturn(facetHandler); expect(indexReader.getFacetData("column")).andReturn(facetDataCache).anyTimes(); replay(indexReader); SenseiDocIdSet orDocIdSet = orTermFilter.getSenseiDocIdSet(indexReader); DocSetAssertions.assertRange(26, 72, 1000, orDocIdSet.getCardinalityEstimate()); SenseiTermFilter andTermFilter = new SenseiTermFilter("column", vals, null, true, false); reset(indexReader); expect(indexReader.maxDoc()).andReturn(1000).anyTimes(); expect(indexReader.getFacetHandler("column")).andReturn(facetHandler); expect(indexReader.getFacetData("column")).andReturn(facetDataCache).anyTimes(); replay(indexReader); SenseiDocIdSet andDocIdSet = andTermFilter.getSenseiDocIdSet(indexReader); DocSetAssertions.assertRange(0, 22, 1000, andDocIdSet.getCardinalityEstimate()); }