use of org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopSerializationWrapper in project ignite by apache.
the class HadoopSerializationWrapperSelfTest method testIntWritableSerialization.
/**
* Tests read/write of IntWritable via native WritableSerialization.
* @throws Exception If fails.
*/
public void testIntWritableSerialization() throws Exception {
HadoopSerialization ser = new HadoopSerializationWrapper(new WritableSerialization(), IntWritable.class);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(buf);
ser.write(out, new IntWritable(3));
ser.write(out, new IntWritable(-5));
assertEquals("[0, 0, 0, 3, -1, -1, -1, -5]", Arrays.toString(buf.toByteArray()));
DataInput in = new DataInputStream(new ByteArrayInputStream(buf.toByteArray()));
assertEquals(3, ((IntWritable) ser.read(in, null)).get());
assertEquals(-5, ((IntWritable) ser.read(in, null)).get());
}
use of org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopSerializationWrapper in project ignite by apache.
the class HadoopSerializationWrapperSelfTest method testIntJavaSerialization.
/**
* Tests read/write of Integer via native JavaleSerialization.
* @throws Exception If fails.
*/
public void testIntJavaSerialization() throws Exception {
HadoopSerialization ser = new HadoopSerializationWrapper(new JavaSerialization(), Integer.class);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(buf);
ser.write(out, 3);
ser.write(out, -5);
ser.close();
DataInput in = new DataInputStream(new ByteArrayInputStream(buf.toByteArray()));
assertEquals(3, ((Integer) ser.read(in, null)).intValue());
assertEquals(-5, ((Integer) ser.read(in, null)).intValue());
}
Aggregations