L3Partitioner extends Partitioner<LongWritable, L3SpatialBin> implements Configurable { @Override public int getPartition(LongWritable binIndex, L3SpatialBin spatialBin, int numPartitions) { long idx = binIndex.get(); int partition; if (idx < 0) { partition = 0; } else { int row = planetaryGrid.getRowIndex(idx); partition = ((row - minRowIndex) * numPartitions) / numRowsCovered; if (partition < 0) { partition = 0; } else if (partition >= numPartitions) { partition = numPartitions - 1; } } return partition; }  @Override int getPartition(LongWritable binIndex, L3SpatialBin spatialBin, int numPartitions); @Override void setConf(Configuration conf); @Override Configuration getConf();  }
@Test public void testPartitionOfGeoRegion_6Rows2Partitions() throws Exception { L3Partitioner l3Partitioner = createPartitioner(6, "polygon((0.0 -31.0, 180.00 -31.0, 180.0 -90.0, 0.0 -90.00, 0.0 -31.0))"); int numPartitions = 2; assertEquals(0, l3Partitioner.getPartition(new LongWritable(3 + 8 + 12 + 12), null, numPartitions)); assertEquals(0, l3Partitioner.getPartition(new LongWritable(3 + 8 + 12 + 12 + 8 - 1), null, numPartitions)); assertEquals(1, l3Partitioner.getPartition(new LongWritable(3 + 8 + 12 + 12 + 8), null, numPartitions)); assertEquals(1, l3Partitioner.getPartition(new LongWritable(3 + 8 + 12 + 12 + 8 + 3 - 1), null, numPartitions)); }
@Test public void testLCCase() throws Exception { L3Partitioner l3Partitioner = createPartitioner(66792, "polygon((-7 54, -7 38.5, 5.5 38.5, 5.5 54, -7 54))"); int numPartitions = 4; assertEquals(3, l3Partitioner.getPartition(new LongWritable(1075911823), null, numPartitions)); }