Java Code Examples for org.apache.arrow.vector.complex.StructVector#empty()
The following examples show how to use
org.apache.arrow.vector.complex.StructVector#empty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveParquetCopierTest.java From dremio-oss with Apache License 2.0 | 5 votes |
@Test public void testStructCopier() { try (final StructVector s1 = StructVector.empty("s1", allocator); final StructVector s2 = StructVector.empty("s2", allocator)) { int rowcount = 5000; s1.addOrGet("struct_child", FieldType.nullable(Types.MinorType.INT.getType()), IntVector.class); s2.addOrGet("struct_child", FieldType.nullable(Types.MinorType.INT.getType()), IntVector.class); s1.allocateNew(); BaseWriter.StructWriter structWriter = new NullableStructWriter(s1); IntWriter intWriter = structWriter.integer("struct_child"); for(int i = 0; i<rowcount; i++) { if (i % 10 == 0) { continue; } structWriter.setPosition(i); structWriter.start(); intWriter.writeInt(i); structWriter.end(); } s1.setValueCount(rowcount); HiveParquetCopier.StructCopier structCopier = new HiveParquetCopier.StructCopier(s1, s2); structCopier.copyNonDataBufferRefs(rowcount); Assert.assertEquals(rowcount, s2.getValueCount()); Assert.assertEquals(500, s1.getNullCount()); Assert.assertEquals(500, s2.getNullCount()); for(int i=0; i<rowcount; ++i) { Assert.assertEquals( i % 10 == 0, s2.isNull(i)); } } }