Search in sources :

Example 16 with VarCharColumnWriter

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

the class TestVariableWidthWriter method testRestartRow.

@Test
public void testRestartRow() {
    try (VarCharVector vector = allocVector(1000)) {
        TestIndex index = new TestIndex();
        VarCharColumnWriter writer = makeWriter(vector, index);
        writer.startWrite();
        // Write rows, rewriting every other row.
        String base = "sample-value";
        writer.startRow();
        index.index = 0;
        for (int i = 0; i < 50; i++) {
            writer.setString(base + i);
            if (i % 2 == 0) {
                writer.saveRow();
                writer.startRow();
                index.index++;
            } else {
                writer.restartRow();
            }
        }
        writer.endWrite();
        for (int i = 0; i < 25; i++) {
            assertEquals(base + (2 * i), stringAt(vector, i));
        }
    }
}
Also used : TestIndex(org.apache.drill.exec.physical.rowSet.TestFixedWidthWriter.TestIndex) VarCharColumnWriter(org.apache.drill.exec.vector.accessor.ColumnAccessors.VarCharColumnWriter) VarCharVector(org.apache.drill.exec.vector.VarCharVector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

VarCharColumnWriter (org.apache.drill.exec.vector.accessor.ColumnAccessors.VarCharColumnWriter)16 VarCharVector (org.apache.drill.exec.vector.VarCharVector)14 SubOperatorTest (org.apache.drill.test.SubOperatorTest)14 Test (org.junit.Test)14 TestIndex (org.apache.drill.exec.physical.rowSet.TestFixedWidthWriter.TestIndex)7 TestIndex (org.apache.drill.test.rowSet.test.TestFixedWidthWriter.TestIndex)7 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