IsinPartitioner extends Partitioner<LongWritable, L3SpatialBin> implements Configurable { @Override public int getPartition(LongWritable binIndex, L3SpatialBin spatialBin, int numPartitions) { long idx = binIndex.get(); final IsinPoint isinPoint = IsinPlanetaryGrid.toIsinPoint(idx); return (isinPoint.getTile_line() * NUM_TILE_COLUMNS + isinPoint.getTile_col()) % numPartitions; }  @Override int getPartition(LongWritable binIndex, L3SpatialBin spatialBin, int numPartitions); @Override void setConf(Configuration conf); @Override Configuration getConf();  }
@Test public void test_3_partitions() { final int numPartitions = 3; assertEquals(0, isinPartitioner.getPartition(new LongWritable(10001L), null, numPartitions)); assertEquals(1, isinPartitioner.getPartition(new LongWritable(100020002L), null, numPartitions)); assertEquals(2, isinPartitioner.getPartition(new LongWritable(200030003L), null, numPartitions)); assertEquals(0, isinPartitioner.getPartition(new LongWritable(300040004L), null, numPartitions)); assertEquals(1, isinPartitioner.getPartition(new LongWritable(160400050005L), null, numPartitions)); assertEquals(2, isinPartitioner.getPartition(new LongWritable(160500060006L), null, numPartitions)); assertEquals(0, isinPartitioner.getPartition(new LongWritable(160600070007L), null, numPartitions)); }
@Test public void test_4_partitions() { final int numPartitions = 4; assertEquals(0, isinPartitioner.getPartition(new LongWritable(80008L), null, numPartitions)); assertEquals(1, isinPartitioner.getPartition(new LongWritable(100090009L), null, numPartitions)); assertEquals(2, isinPartitioner.getPartition(new LongWritable(200100010L), null, numPartitions)); assertEquals(3, isinPartitioner.getPartition(new LongWritable(300110011L), null, numPartitions)); assertEquals(0, isinPartitioner.getPartition(new LongWritable(400120012L), null, numPartitions)); assertEquals(1, isinPartitioner.getPartition(new LongWritable(170500130013L), null, numPartitions)); assertEquals(2, isinPartitioner.getPartition(new LongWritable(170600140014L), null, numPartitions)); assertEquals(3, isinPartitioner.getPartition(new LongWritable(170700150015L), null, numPartitions)); assertEquals(0, isinPartitioner.getPartition(new LongWritable(170800160016L), null, numPartitions)); }