}
@Test
public void testGetBucketBoundary() {
SimpleDistribution dd = new SimpleDistribution(
new Key[][] {{new IntValue(1), new StringValue("A")},
{new IntValue(2), new StringValue("B")},
{new IntValue(3), new StringValue("C")},
{new IntValue(4), new StringValue("D")},
{new IntValue(5), new StringValue("E")},
{new IntValue(6), new StringValue("F")},
{new IntValue(7), new StringValue("G")}});
Key<?>[] boundRec = dd.getBucketBoundary(0, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 1);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("A"));
boundRec = dd.getBucketBoundary(1, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 2);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("B"));
boundRec = dd.getBucketBoundary(2, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 3);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("C"));
boundRec = dd.getBucketBoundary(3, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 4);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("D"));
boundRec = dd.getBucketBoundary(4, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 5);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("E"));
boundRec = dd.getBucketBoundary(5, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 6);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("F"));
boundRec = dd.getBucketBoundary(6, 8);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 7);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("G"));
boundRec = dd.getBucketBoundary(0, 4);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 2);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("B"));
boundRec = dd.getBucketBoundary(1, 4);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 4);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("D"));
boundRec = dd.getBucketBoundary(2, 4);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 6);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("F"));
boundRec = dd.getBucketBoundary(0, 2);
Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 4);
Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("D"));
try {
boundRec = dd.getBucketBoundary(0, 7);
Assert.fail();
} catch(IllegalArgumentException iae) {
// nothing to do
}
try {
boundRec = dd.getBucketBoundary(3, 4);
Assert.fail();
} catch(IllegalArgumentException iae) {
// nothing to do
}
try {
boundRec = dd.getBucketBoundary(-1, 4);
Assert.fail();
} catch(IllegalArgumentException iae) {
// nothing to do
}
try {
boundRec = dd.getBucketBoundary(0, 0);
Assert.fail();
} catch(IllegalArgumentException iae) {
// nothing to do
}
}