@Override
  public FetchContext planFetchForPruning(IndexSegment indexSegment, QueryContext queryContext) {
    // Extract columns in EQ/IN predicates.
    Set<String> eqInColumns = new HashSet<>();
    extractEqInColumns(Objects.requireNonNull(queryContext.getFilter()), eqInColumns);
    Map<String, List<IndexType<?, ?, ?>>> columnToIndexList = new HashMap<>();
    for (String column : eqInColumns) {
      DataSource dataSource = indexSegment.getDataSource(column);
      if (dataSource.getBloomFilter() != null) {
        columnToIndexList.put(column, Collections.singletonList(StandardIndexes.bloomFilter()));
      }
    }
    return new FetchContext(UUID.randomUUID(), indexSegment.getSegmentName(), columnToIndexList);
  }
@Test
  public void testPlanFetchForPruning() {
    DefaultFetchPlanner planner = new DefaultFetchPlanner();
    IndexSegment indexSegment = mock(IndexSegment.class);
    when(indexSegment.getSegmentName()).thenReturn("s0");
    when(indexSegment.getColumnNames()).thenReturn(ImmutableSet.of("c0", "c1", "c2"));
    String query = "SELECT COUNT(*) FROM testTable WHERE c0 = 0 OR (c1 < 10 AND c2 IN (1, 2))";
    QueryContext queryContext = QueryContextConverterUtils.getQueryContext(query);
    // No Bloomfilter for those columns.
    DataSource ds0 = mock(DataSource.class);
    when(indexSegment.getDataSource("c0")).thenReturn(ds0);
    when(ds0.getBloomFilter()).thenReturn(null);
    DataSource ds2 = mock(DataSource.class);
    when(indexSegment.getDataSource("c2")).thenReturn(ds2);
    when(ds2.getBloomFilter()).thenReturn(null);
    FetchContext fetchContext = planner.planFetchForPruning(indexSegment, queryContext);
    assertTrue(fetchContext.isEmpty());

    // Add Bloomfilter for column c0.
    BloomFilterReader bfReader = mock(BloomFilterReader.class);
    when(ds0.getBloomFilter()).thenReturn(bfReader);
    fetchContext = planner.planFetchForPruning(indexSegment, queryContext);
    assertFalse(fetchContext.isEmpty());
    assertEquals(fetchContext.getSegmentName(), "s0");
    Map<String, List<IndexType<?, ?, ?>>> columns = fetchContext.getColumnToIndexList();
    assertEquals(columns.size(), 1);
    List<IndexType<?, ?, ?>> idxTypes = columns.get("c0");
    assertEquals(idxTypes.size(), 1);
    assertEquals(idxTypes.get(0), StandardIndexes.bloomFilter());
  }