use of org.apache.crunch.types.writable.TupleWritable in project crunch by cloudera.
the class TupleWritablePartitionerTest method testGetPartition.
@Test
public void testGetPartition() {
IntWritable intWritable = new IntWritable(3);
TupleWritable key = new TupleWritable(new Writable[] { intWritable });
assertEquals(3, tupleWritableParitioner.getPartition(key, NullWritable.get(), 5));
assertEquals(1, tupleWritableParitioner.getPartition(key, NullWritable.get(), 2));
}
use of org.apache.crunch.types.writable.TupleWritable in project crunch by cloudera.
the class TupleWritablePartitionerTest method testGetPartition_NegativeHashValue.
@Test
public void testGetPartition_NegativeHashValue() {
IntWritable intWritable = new IntWritable(-3);
// Sanity check, if this doesn't work then the premise of this test is wrong
assertEquals(-3, intWritable.hashCode());
TupleWritable key = new TupleWritable(new Writable[] { intWritable });
assertEquals(3, tupleWritableParitioner.getPartition(key, NullWritable.get(), 5));
assertEquals(1, tupleWritableParitioner.getPartition(key, NullWritable.get(), 2));
}
use of org.apache.crunch.types.writable.TupleWritable in project crunch by cloudera.
the class TupleWritablePartitionerTest method testGetPartition_IntegerMinValue.
@Test
public void testGetPartition_IntegerMinValue() {
IntWritable intWritable = new IntWritable(Integer.MIN_VALUE);
// Sanity check, if this doesn't work then the premise of this test is wrong
assertEquals(Integer.MIN_VALUE, intWritable.hashCode());
TupleWritable key = new TupleWritable(new Writable[] { intWritable });
assertEquals(0, tupleWritableParitioner.getPartition(key, NullWritable.get(), Integer.MAX_VALUE));
}
Aggregations