QueryUtil { public static int[] getMaskedByteRange(List<QueryDimension> queryDimensions, KeyGenerator keyGenerator) { Set<Integer> byteRangeSet = new TreeSet<Integer>(); int[] byteRange = null; for (int i = 0; i < queryDimensions.size(); i++) { if (queryDimensions.get(i).getDimension().getKeyOrdinal() == -1) { continue; } byteRange = keyGenerator.getKeyByteOffsets(queryDimensions.get(i).getDimension().getKeyOrdinal()); for (int j = byteRange[0]; j <= byteRange[1]; j++) { byteRangeSet.add(j); } } int[] maksedByteRange = new int[byteRangeSet.size()]; int index = 0; Iterator<Integer> iterator = byteRangeSet.iterator(); while (iterator.hasNext()) { maksedByteRange[index++] = iterator.next(); } return maksedByteRange; }  static int[] getMaskedByteRange(List<QueryDimension> queryDimensions,
      KeyGenerator keyGenerator); static int[] getMaskedByteRangeBasedOrdinal(List<Integer> ordinals,
      KeyGenerator keyGenerator); static byte[] getMaxKeyBasedOnOrinal(List<Integer> keyOrdinalList, KeyGenerator generator); static byte[] getMaxKeyBasedOnDimensions(List<QueryDimension> queryDimensions,
      KeyGenerator generator); static int[] getMaskedByte(int keySize, int[] maskedKeyRanges); static int[] getDimensionsBlockIndexes(List<QueryDimension> queryDimensions,
      Map<Integer, Integer> dimensionOrdinalToBlockMapping,
      List<CarbonDimension> customAggregationDimension); static Map<String, Dictionary> getDimensionDictionaryDetail(
      List<QueryDimension> queryDimensions,
      Set<CarbonDimension> filterComplexDimensions,
      AbsoluteTableIdentifier absoluteTableIdentifier); static int[] getMeasureBlockIndexes(List<QueryMeasure> queryMeasures,
      List<CarbonMeasure> expressionMeasure, Map<Integer, Integer> ordinalToBlockIndexMapping); static int[][] getMaskedByteRangeForSorting(List<QueryDimension> orderByDimensions,
      KeyGenerator generator, int[] maskedRanges); static byte[][] getMaksedKeyForSorting(List<QueryDimension> orderDimensions,
      KeyGenerator generator, int[][] maskedByteRangeForSorting, int[] maskedRanges); static byte[] getSortDimensionIndexes(List<QueryDimension> sortedDimensions,
      List<QueryDimension> queryDimensions); static Map<Integer, KeyStructureInfo> getColumnGroupKeyStructureInfo(
      List<QueryDimension> queryDimensions, SegmentProperties segmentProperties); static boolean searchInArray(int[] data, int key); static byte[] getMaskedKey(byte[] data, byte[] maxKey, int[] maskByteRanges,
      int byteCount); static void fillQueryDimensionsBlockIndexes(List<QueryDimension> queryDimensions,
      Map<Integer, Integer> columnOrdinalToBlockIndexMapping,
      Set<Integer> dictionaryDimensionBlockIndex, List<Integer> noDictionaryDimensionBlockIndex); static void resolveQueryModel(QueryModel queryModel); static int[] getNumberTypeIndex(List<String> aggType); static int[] getActualTypeIndex(List<String> aggType); static KeyStructureInfo getKeyStructureInfo(SegmentProperties segmentProperties,
      DimColumnResolvedFilterInfo dimColumnEvaluatorInfo); static int getColumnGroupId(SegmentProperties segmentProperties, int ordinal); static Map<Integer, GenericQueryType> getComplexDimensionsMap(
      List<QueryDimension> queryDimensions, Map<Integer, Integer> dimensionToBlockIndexMap,
      int[] eachComplexColumnValueSize, Map<String, Dictionary> columnIdToDictionaryMap,
      Set<CarbonDimension> filterDimensions); static Set<CarbonDimension> getAllFilterDimensions(FilterResolverIntf filterResolverTree);  }
@Test public void testGetMaskedByteRangeGivingProperMaksedByteRange() { QueryDimension dimension = new QueryDimension(segmentProperties.getDimensions().get(0).getColName()); dimension.setDimension(segmentProperties.getDimensions().get(0)); int[] maskedByteRange = QueryUtil .getMaskedByteRange(Arrays.asList(dimension), segmentProperties.getDimensionKeyGenerator()); int[] expectedMaskedByteRange = { 0 }; for (int i = 0; i < maskedByteRange.length; i++) { assertEquals(expectedMaskedByteRange[i], maskedByteRange[i]); } }
@Test public void testGetMaskedByteRangeGivingProperMaksedByteRangeOnlyForDictionaryKey() { List<QueryDimension> dimensions = new ArrayList<QueryDimension>(); for (int i = 0; i < 2; i++) { QueryDimension dimension = new QueryDimension(segmentProperties.getDimensions().get(i).getColName()); dimension.setDimension(segmentProperties.getDimensions().get(i)); dimensions.add(dimension); } int[] maskedByteRange = QueryUtil.getMaskedByteRange(dimensions, segmentProperties.getDimensionKeyGenerator()); int[] expectedMaskedByteRange = { 0 }; for (int i = 0; i < maskedByteRange.length; i++) { assertEquals(expectedMaskedByteRange[i], maskedByteRange[i]); } }