/**
  * Method will scan the block and finds the range start index from which all members will be
  * considered for applying range filters. this method will be called if the column is sorted
  * default so column index mapping will be present for accesing the members from the block.
  *
  * @param dimensionColumnDataChunk
  * @param numerOfRows
  * @return BitSet.
  */
 private BitSet setFilterdIndexToBitSet(
     DimensionColumnDataChunk dimensionColumnDataChunk, int numerOfRows, byte[] defaultValue) {
   BitSet bitSet = new BitSet(numerOfRows);
   if (dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
     int start = 0;
     int last = 0;
     int startIndex = 0;
     int skip = 0;
     byte[][] filterValues = this.filterRangeValues;
     // find the number of default values to skip the null value in case of direct dictionary
     if (null != defaultValue) {
       start =
           CarbonUtil.getFirstIndexUsingBinarySearch(
               (FixedLengthDimensionDataChunk) dimensionColumnDataChunk,
               startIndex,
               numerOfRows - 1,
               defaultValue,
               false);
       if (start < 0) {
         skip = -(start + 1);
         // end of block
         if (skip == numerOfRows) {
           return bitSet;
         }
       } else {
         skip = start;
       }
       startIndex = skip;
     }
     for (int k = 0; k < filterValues.length; k++) {
       start =
           CarbonUtil.getFirstIndexUsingBinarySearch(
               (FixedLengthDimensionDataChunk) dimensionColumnDataChunk,
               startIndex,
               numerOfRows - 1,
               filterValues[k],
               false);
       start =
           CarbonUtil.nextLesserValueToTarget(
               start, (FixedLengthDimensionDataChunk) dimensionColumnDataChunk, filterValues[k]);
       if (start < 0) {
         start = -(start + 1);
         if (start >= numerOfRows) {
           start = numerOfRows - 1;
         }
         // Method will compare the tentative index value after binary search, this tentative
         // index needs to be compared by the filter member if its < filter then from that
         // index the bitset will be considered for filtering process.
         if (ByteUtil.compare(filterValues[k], dimensionColumnDataChunk.getChunkData(start)) < 0) {
           start = start - 1;
         }
       }
       last = start;
       for (int j = start; j >= skip; j--) {
         bitSet.set(j);
         last--;
       }
       startIndex = last;
       if (startIndex <= 0) {
         break;
       }
     }
   }
   return bitSet;
 }
  /**
   * Method will scan the block and finds the range start index from which all members will be
   * considered for applying range filters. this method will be called if the column is not
   * supported by default so column index mapping will be present for accesing the members from the
   * block.
   *
   * @param dimensionColumnDataChunk
   * @param numerOfRows
   * @return BitSet.
   */
  private BitSet setFilterdIndexToBitSetWithColumnIndex(
      FixedLengthDimensionDataChunk dimensionColumnDataChunk,
      int numerOfRows,
      byte[] defaultValue) {
    BitSet bitSet = new BitSet(numerOfRows);
    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
    int start = 0;
    int last = 0;
    int startIndex = 0;
    int skip = 0;
    byte[][] filterValues = this.filterRangeValues;

    // find the number of default values to skip the null value in case of direct dictionary
    if (null != defaultValue) {
      start =
          CarbonUtil.getFirstIndexUsingBinarySearch(
              dimensionColumnDataChunk, startIndex, numerOfRows - 1, defaultValue, false);
      if (start < 0) {
        skip = -(start + 1);
        // end of block
        if (skip == numerOfRows) {
          return bitSet;
        }
      } else {
        skip = start;
      }
      startIndex = skip;
    }

    for (int i = 0; i < filterValues.length; i++) {
      start =
          CarbonUtil.getFirstIndexUsingBinarySearch(
              dimensionColumnDataChunk, startIndex, numerOfRows - 1, filterValues[i], false);
      // Logic will handle the case where the range filter member is not present in block
      // in this case the binary search will return the index from where the bit sets will be
      // set inorder to apply filters. this is Lesser than filter so the range will be taken
      // from the prev element which is Lesser than filter member.
      start = CarbonUtil.nextLesserValueToTarget(start, dimensionColumnDataChunk, filterValues[i]);
      if (start < 0) {
        start = -(start + 1);
        if (start == numerOfRows) {
          start = start - 1;
        }
        // Method will compare the tentative index value after binary search, this tentative
        // index needs to be compared by the filter member if its < filter then from that
        // index the bitset will be considered for filtering process.
        if (ByteUtil.compare(
                filterValues[i], dimensionColumnDataChunk.getChunkData(columnIndex[start]))
            < 0) {
          start = start - 1;
        }
      }
      last = start;
      for (int j = start; j >= skip; j--) {
        bitSet.set(columnIndex[j]);
        last--;
      }
      startIndex = last;
      if (startIndex >= 0) {
        break;
      }
    }
    return bitSet;
  }