Exemple #1
0
 private static List<byte[]> getPointKeys(
     List<List<KeyRange>> ranges, int[] slotSpan, RowKeySchema schema, Integer bucketNum) {
   if (ranges == null || ranges.isEmpty()) {
     return Collections.emptyList();
   }
   boolean isSalted = bucketNum != null;
   int count = 1;
   int offset = isSalted ? 1 : 0;
   // Skip salt byte range in the first position if salted
   for (int i = offset; i < ranges.size(); i++) {
     count *= ranges.get(i).size();
   }
   List<byte[]> keys = Lists.newArrayListWithExpectedSize(count);
   int[] position = new int[ranges.size()];
   int maxKeyLength = SchemaUtil.getMaxKeyLength(schema, ranges);
   int length;
   byte[] key = new byte[maxKeyLength];
   do {
     length =
         ScanUtil.setKey(
             schema,
             ranges,
             slotSpan,
             position,
             Bound.LOWER,
             key,
             offset,
             offset,
             ranges.size(),
             offset);
     if (isSalted) {
       key[0] = SaltingUtil.getSaltingByte(key, offset, length, bucketNum);
     }
     keys.add(Arrays.copyOf(key, length + offset));
   } while (incrementKey(ranges, position));
   return keys;
 }