Search in sources :

Example 16 with IntColumnWriter

use of org.apache.drill.exec.vector.accessor.ColumnAccessors.IntColumnWriter in project drill by apache.

the class TestFixedWidthWriter method testWrite.

/**
 * Basic test to write a contiguous set of values, enough to cause
 * the vector to double in size twice, then read back the values.
 */
@Test
public void testWrite() {
    try (IntVector vector = allocVector(1000)) {
        TestIndex index = new TestIndex();
        IntColumnWriter writer = makeWriter(vector, index);
        writer.startWrite();
        // Write integers.
        // Write enough that the vector is resized.
        long origAddr = vector.getBuffer().addr();
        for (int i = 0; i < 3000; i++) {
            index.index = i;
            writer.setInt(i * 10);
        }
        writer.endWrite();
        // Should have been reallocated.
        assertNotEquals(origAddr, vector.getBuffer().addr());
        for (int i = 0; i < 3000; i++) {
            assertEquals(i * 10, vector.getAccessor().get(i));
        }
    }
}
Also used : IntVector(org.apache.drill.exec.vector.IntVector) IntColumnWriter(org.apache.drill.exec.vector.accessor.ColumnAccessors.IntColumnWriter) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

IntColumnWriter (org.apache.drill.exec.vector.accessor.ColumnAccessors.IntColumnWriter)16 IntVector (org.apache.drill.exec.vector.IntVector)14 SubOperatorTest (org.apache.drill.test.SubOperatorTest)14 Test (org.junit.Test)14 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)2 ColumnWriterListener (org.apache.drill.exec.vector.accessor.ScalarWriter.ColumnWriterListener)1 ColumnWriterListener (org.apache.drill.exec.vector.accessor.writer.WriterEvents.ColumnWriterListener)1