use of org.apache.hadoop.io.ArrayWritable in project hadoop by apache.
the class TypedBytesWritableInput method readArray.
public ArrayWritable readArray(ArrayWritable aw) throws IOException {
if (aw == null) {
aw = new ArrayWritable(TypedBytesWritable.class);
} else if (!aw.getValueClass().equals(TypedBytesWritable.class)) {
throw new RuntimeException("value class has to be TypedBytesWritable");
}
int length = in.readVectorHeader();
Writable[] writables = new Writable[length];
for (int i = 0; i < length; i++) {
writables[i] = new TypedBytesWritable(in.readRaw());
}
aw.set(writables);
return aw;
}
use of org.apache.hadoop.io.ArrayWritable in project hive by apache.
the class TestAbstractParquetMapInspector method testNullContainer.
@Test
public void testNullContainer() {
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, null);
assertEquals("Wrong size", -1, inspector.getMapSize(map));
assertNull("Should be null", inspector.getMap(map));
}
use of org.apache.hadoop.io.ArrayWritable in project hive by apache.
the class TestAbstractParquetMapInspector method testEmptyContainer.
@Test
public void testEmptyContainer() {
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, new ArrayWritable[0]);
assertEquals("Wrong size", 0, inspector.getMapSize(map));
assertNotNull("Should not be null", inspector.getMap(map));
}
use of org.apache.hadoop.io.ArrayWritable in project hive by apache.
the class TestDeepParquetHiveMapInspector method testRegularMap.
@Test
public void testRegularMap() {
final Writable[] entry1 = new Writable[] { new IntWritable(0), new IntWritable(1) };
final Writable[] entry2 = new Writable[] { new IntWritable(2), new IntWritable(3) };
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, new Writable[] { new ArrayWritable(Writable.class, entry1), new ArrayWritable(Writable.class, entry2) });
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new IntWritable(0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new IntWritable(2)));
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new ShortWritable((short) 0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new ShortWritable((short) 2)));
}
use of org.apache.hadoop.io.ArrayWritable in project hive by apache.
the class TestParquetHiveArrayInspector method testNullContainer.
@Test
public void testNullContainer() {
final ArrayWritable list = new ArrayWritable(ArrayWritable.class, null);
assertEquals("Wrong size", -1, inspector.getListLength(list));
assertNull("Should be null", inspector.getList(list));
assertNull("Should be null", inspector.getListElement(list, 0));
}
Aggregations