コード例 #1
0
  public int getPartition(TetherData key, NullWritable value, int numPartitions) {
    Integer result = CACHE.get();
    if (result != null) // return cached value
    return result;

    ByteBuffer b = key.buffer();
    int p = b.position();
    int hashCode = BinaryData.hashCode(b.array(), p, b.limit() - p, schema);
    if (hashCode < 0) hashCode = -hashCode;
    return hashCode % numPartitions;
  }
コード例 #2
0
 @Override
 public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
   return BinaryData.compare(b1, s1, l1, b2, s2, l2, schema);
 }