code: private static long[][] getCounts(
        LongArray array, long numRecords, int startByteIndex, int endByteIndex) {
      long[][] counts = new long[8][];
      // Optimization: do a fast pre-pass to determine which byte indices we can skip for sorting.
      // If all the byte values at a particular index are the same we don't need to count it.
      long bitwiseMax = 0;
      long bitwiseMin = -1L;
      long maxOffset = array.getBaseOffset() + numRecords * 8L;
      Object baseObject = array.getBaseObject();
      for (long offset = array.getBaseOffset(); offset < maxOffset; offset += 8) {
        long value = Platform.getLong(baseObject, offset);
        bitwiseMax |= value;
        bitwiseMin &= value;
      }
      long bitsChanged = bitwiseMin ^ bitwiseMax;
      // Compute counts for each byte index.
      for (int i = startByteIndex; i <= endByteIndex; i++) {
        if (((bitsChanged >>> (i * 8)) & 0xff) != 0) {
          counts[i] = new long[256];
          // TODO(ekl) consider computing all the counts in one pass.
          for (long offset = array.getBaseOffset(); offset < maxOffset; offset += 8) {
            counts[i][(int)((Platform.getLong(baseObject, offset) >>> (i * 8)) & 0xff)]++;
          }
        }
      }
      return counts;
    }
docs: Computes a value histogram for each byte in the given array.
  
  @param array array to count records in.
  @param numRecords number of data records in the array.
  @param startByteIndex the first byte to compute counts for (the prior are skipped).
  @param endByteIndex the last byte to compute counts for.
  
  @return an array of eight 256-byte count arrays, one for each byte starting from the least
  significant byte. If the byte does not need sorting the array will be null.