protected void cleanup(Context context) throws IOException, InterruptedException { key.set(CustomKey.PARTITION_SET); for (int c = 0; c < offset.length - 1; c++) { if (offset[c] > 0) { value.setOffset(offset[c]); value.setPartition(c + 1); context.write(key, value); } offset[c + 1] += offset[c]; } }