use of org.apache.hadoop.io.BooleanWritable in project hadoop by apache.
the class TestTupleWritable method testWritable.
@Test
public void testWritable() throws Exception {
Random r = new Random();
Writable[] writs = { new BooleanWritable(r.nextBoolean()), new FloatWritable(r.nextFloat()), new FloatWritable(r.nextFloat()), new IntWritable(r.nextInt()), new LongWritable(r.nextLong()), new BytesWritable("dingo".getBytes()), new LongWritable(r.nextLong()), new IntWritable(r.nextInt()), new BytesWritable("yak".getBytes()), new IntWritable(r.nextInt()) };
TupleWritable sTuple = makeTuple(writs);
ByteArrayOutputStream out = new ByteArrayOutputStream();
sTuple.write(new DataOutputStream(out));
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
TupleWritable dTuple = new TupleWritable();
dTuple.readFields(new DataInputStream(in));
assertTrue("Failed to write/read tuple", sTuple.equals(dTuple));
}
use of org.apache.hadoop.io.BooleanWritable in project hadoop by apache.
the class TestTupleWritable method testIterable.
@Test
public void testIterable() throws Exception {
Random r = new Random();
Writable[] writs = { new BooleanWritable(r.nextBoolean()), new FloatWritable(r.nextFloat()), new FloatWritable(r.nextFloat()), new IntWritable(r.nextInt()), new LongWritable(r.nextLong()), new BytesWritable("dingo".getBytes()), new LongWritable(r.nextLong()), new IntWritable(r.nextInt()), new BytesWritable("yak".getBytes()), new IntWritable(r.nextInt()) };
TupleWritable t = new TupleWritable(writs);
for (int i = 0; i < 6; ++i) {
t.setWritten(i);
}
verifIter(writs, t, 0);
}
use of org.apache.hadoop.io.BooleanWritable in project hadoop by apache.
the class TestJoinTupleWritable method makeRandomWritables.
private Writable[] makeRandomWritables() {
Random r = new Random();
Writable[] writs = { new BooleanWritable(r.nextBoolean()), new FloatWritable(r.nextFloat()), new FloatWritable(r.nextFloat()), new IntWritable(r.nextInt()), new LongWritable(r.nextLong()), new BytesWritable("dingo".getBytes()), new LongWritable(r.nextLong()), new IntWritable(r.nextInt()), new BytesWritable("yak".getBytes()), new IntWritable(r.nextInt()) };
return writs;
}
use of org.apache.hadoop.io.BooleanWritable in project hadoop by apache.
the class TestJoinTupleWritable method testIterable.
@Test
public void testIterable() throws Exception {
Random r = new Random();
Writable[] writs = { new BooleanWritable(r.nextBoolean()), new FloatWritable(r.nextFloat()), new FloatWritable(r.nextFloat()), new IntWritable(r.nextInt()), new LongWritable(r.nextLong()), new BytesWritable("dingo".getBytes()), new LongWritable(r.nextLong()), new IntWritable(r.nextInt()), new BytesWritable("yak".getBytes()), new IntWritable(r.nextInt()) };
TupleWritable t = new TupleWritable(writs);
for (int i = 0; i < 6; ++i) {
t.setWritten(i);
}
verifIter(writs, t, 0);
}
use of org.apache.hadoop.io.BooleanWritable in project presto by prestodb.
the class OrcFileRewriter method uncompressedSize.
private static int uncompressedSize(Object object) throws IOException {
if (object instanceof OrcStruct) {
OrcStruct struct = (OrcStruct) object;
int size = 0;
for (int i = 0; i < struct.getNumFields(); i++) {
size += uncompressedSize(getFieldValue(struct, i));
}
return size;
}
if ((object == null) || (object instanceof BooleanWritable)) {
return SIZE_OF_BYTE;
}
if (object instanceof LongWritable) {
return SIZE_OF_LONG;
}
if (object instanceof DoubleWritable) {
return SIZE_OF_DOUBLE;
}
if (object instanceof Text) {
return ((Text) object).getLength();
}
if (object instanceof BytesWritable) {
return ((BytesWritable) object).getLength();
}
if (object instanceof List<?>) {
int size = 0;
for (Object element : (Iterable<?>) object) {
size += uncompressedSize(element);
}
return size;
}
if (object instanceof Map<?, ?>) {
int size = 0;
for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
size += uncompressedSize(entry.getKey());
size += uncompressedSize(entry.getValue());
}
return size;
}
throw new IOException("Unhandled ORC object: " + object.getClass().getName());
}
Aggregations