コード例 #1
0
ファイル: OWL2MergeListsMapper.java プロジェクト: jrbn/webpie
  public void map(BytesWritable key, BytesWritable value, Context context)
      throws IOException, InterruptedException {
    long start = NumberUtils.decodeLong(key.getBytes(), 0);
    long end = NumberUtils.decodeLong(key.getBytes(), 8);

    oKey.set(start);
    oValue.setSize(value.getLength() + 9);
    oValue.getBytes()[0] = 0;
    NumberUtils.encodeLong(oValue.getBytes(), 1, end);
    System.arraycopy(value.getBytes(), 0, oValue.getBytes(), 9, value.getLength());
    context.write(oKey, oValue);

    oKey.set(end);
    oValue.getBytes()[0] = 1;
    NumberUtils.encodeLong(oValue.getBytes(), 1, start);
    System.arraycopy(value.getBytes(), 0, oValue.getBytes(), 9, value.getLength());
    context.write(oKey, oValue);
  }
コード例 #2
0
ファイル: NaivePartitioner.java プロジェクト: jrbn/webpie
 @Override
 public int getPartition(BytesWritable key, NullWritable value, int numPartitions) {
   // The task number is on the first three bytes, not 4.
   long resource = NumberUtils.decodeLong(key.getBytes(), 0);
   int number = (int) (resource >> 40);
   /*
    * int partition = Math.round((number / partitionSize)); if (partition
    * >= numPartitions) { log.error("Resource = " + resource + " number = "
    * + number + " partition = " + partition); partition = numPartitions -
    * 1; }
    */
   return number % numPartitions;
 }