List of usage examples for org.apache.hadoop.io IntWritable hashCode
@Override public int hashCode()
From source file:org.apache.crunch.lib.TupleWritablePartitionerTest.java
License:Apache License
@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)); }
From source file:org.apache.crunch.lib.TupleWritablePartitionerTest.java
License:Apache License
@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)); }
From source file:org.shadowmask.engine.hive.udf.UDFHashTest.java
License:Apache License
@Test public void testUDFHash() { UDFHash udfHash = new UDFHash(); Text data1 = new Text("hello"); IntWritable result = udfHash.evaluate(data1); assertEquals(data1.hashCode(), result.get()); LongWritable data2 = new LongWritable(80000000000L); result = udfHash.evaluate(data2);/*w ww . j a v a 2 s . c o m*/ assertEquals(data2.hashCode(), result.get()); IntWritable data3 = new IntWritable(345); result = udfHash.evaluate(data3); assertEquals(data3.hashCode(), result.get()); data3 = null; result = udfHash.evaluate(data3); assertNull(result); }