Search in sources :

Example 21 with RowSetBuilder

use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.

the class TestRecordBatchSizer method testSizerNullableVariableWidth.

@Test
public void testSizerNullableVariableWidth() {
    BatchSchema schema = new SchemaBuilder().addNullable("b", MinorType.VARCHAR).build();
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    StringBuilder stringBuilder = new StringBuilder();
    for (long i = 0; i < 10; i++) {
        stringBuilder.append("a");
        builder.addRow((Object) stringBuilder.toString());
    }
    RowSet rows = builder.build();
    // Run the record batch sizer on the resulting batch.
    RecordBatchSizer sizer = new RecordBatchSizer(rows.container());
    assertEquals(1, sizer.columns().size());
    /**
     * stdDataSize:50, stdNetSize:50+4+1, dataSizePerEntry:ceil((10*11)/2)*10),
     * netSizePerEntry: dataSizePerEntry+4+1,
     * totalDataSize:(10*11)/2, totalNetSize: (10*11)/2 + (4*10) + (1*10),
     * valueCount:10,
     * elementCount:10, estElementCountPerArray:1, isVariableWidth:true
     */
    verifyColumnValues(sizer.columns().get("b"), 50, 55, 6, 11, 55, 105, 10, 10, 1, true);
    SingleRowSet empty = fixture.rowSet(schema);
    VectorAccessible accessible = empty.vectorAccessible();
    ValueVector bitVector, valueVector;
    VariableWidthVector vwVector;
    UInt4Vector offsetVector;
    for (VectorWrapper<?> vw : accessible) {
        ValueVector v = vw.getValueVector();
        RecordBatchSizer.ColumnSize colSize = sizer.getColumn(v.getField().getName());
        // Allocates to nearest power of two
        colSize.allocateVector(v, testRowCount);
        bitVector = ((NullableVector) v).getBitsVector();
        assertEquals((Integer.highestOneBit(testRowCount) << 1), bitVector.getValueCapacity());
        vwVector = (VariableWidthVector) ((NullableVector) v).getValuesVector();
        offsetVector = vwVector.getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCount) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCount << 1) - 1, vwVector.getValueCapacity());
        // Allocates the same as value passed since it is already power of two.
        colSize.allocateVector(v, testRowCountPowerTwo - 1);
        bitVector = ((NullableVector) v).getBitsVector();
        assertEquals(Integer.highestOneBit(testRowCountPowerTwo), bitVector.getValueCapacity());
        vwVector = (VariableWidthVector) ((NullableVector) v).getValuesVector();
        offsetVector = vwVector.getOffsetVector();
        assertEquals(testRowCountPowerTwo, offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCountPowerTwo) - 1, vwVector.getValueCapacity());
        // Allocate for max rows.
        colSize.allocateVector(v, ValueVector.MAX_ROW_COUNT - 1);
        bitVector = ((NullableVector) v).getBitsVector();
        assertEquals((Integer.highestOneBit(ValueVector.MAX_ROW_COUNT)), bitVector.getValueCapacity());
        vwVector = (VariableWidthVector) ((NullableVector) v).getValuesVector();
        offsetVector = vwVector.getOffsetVector();
        assertEquals(ValueVector.MAX_ROW_COUNT, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MAX_ROW_COUNT - 1, vwVector.getValueCapacity());
        // Allocate for 0 rows. should atleast do allocation for 1 row.
        colSize.allocateVector(v, 0);
        bitVector = ((NullableVector) v).getBitsVector();
        assertEquals((Integer.highestOneBit(ValueVector.MIN_ROW_COUNT)), bitVector.getValueCapacity());
        vwVector = (VariableWidthVector) ((NullableVector) v).getValuesVector();
        offsetVector = vwVector.getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MIN_ROW_COUNT, vwVector.getValueCapacity());
    }
    empty.clear();
    rows.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) VariableWidthVector(org.apache.drill.exec.vector.VariableWidthVector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) NullableVector(org.apache.drill.exec.vector.NullableVector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 22 with RowSetBuilder

use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.

the class TestRecordBatchSizer method testSizerNestedMap.

@Test
public void testSizerNestedMap() {
    BatchSchema schema = new SchemaBuilder().addMap("map").add("key", MinorType.INT).add("value", MinorType.VARCHAR).addMap("childMap").add("childKey", MinorType.INT).add("childValue", MinorType.VARCHAR).resumeMap().resumeSchema().build();
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    for (int i = 0; i < 10; i++) {
        builder.addRow((Object) (new Object[] { 10, "a", new Object[] { 5, "b" } }));
    }
    RowSet rows = builder.build();
    // Run the record batch sizer on the resulting batch.
    RecordBatchSizer sizer = new RecordBatchSizer(rows.container());
    assertEquals(1, sizer.columns().size());
    /**
     * stdDataSize:(50+4)*2, stdNetSize:(50+4)*2+4+4, dataSizePerEntry:(4+1)*2,
     * netSizePerEntry: 4*2+1*2+4*2,
     * totalDataSize:5*2*10, totalNetSize:netSizePerEntry*2,
     * valueCount:10,
     * elementCount:10, estElementCountPerArray:1, isVariableWidth:true
     */
    verifyColumnValues(sizer.columns().get("map"), 108, 116, 10, 18, 100, 180, 10, 10, 1, false);
    SingleRowSet empty = fixture.rowSet(schema);
    VectorAccessible accessible = empty.vectorAccessible();
    UInt4Vector offsetVector;
    for (VectorWrapper<?> vw : accessible) {
        ValueVector v = vw.getValueVector();
        RecordBatchSizer.ColumnSize colSize = sizer.getColumn(v.getField().getName());
        // Allocates to nearest power of two
        colSize.allocateVector(v, testRowCount);
        MapVector mapVector = (MapVector) v;
        ValueVector keyVector = mapVector.getChild("key");
        ValueVector valueVector1 = mapVector.getChild("value");
        assertEquals((Integer.highestOneBit(testRowCount) << 1), keyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCount) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCount << 1) - 1, valueVector1.getValueCapacity());
        MapVector childMapVector = (MapVector) mapVector.getChild("childMap");
        ValueVector childKeyVector = childMapVector.getChild("childKey");
        ValueVector childValueVector1 = childMapVector.getChild("childValue");
        assertEquals((Integer.highestOneBit(testRowCount) << 1), childKeyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCount) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCount << 1) - 1, childValueVector1.getValueCapacity());
        // Allocates the same as value passed since it is already power of two.
        colSize.allocateVector(v, testRowCountPowerTwo - 1);
        mapVector = (MapVector) v;
        keyVector = mapVector.getChild("key");
        valueVector1 = mapVector.getChild("value");
        assertEquals(testRowCountPowerTwo, keyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(testRowCountPowerTwo, offsetVector.getValueCapacity());
        assertEquals(testRowCountPowerTwo - 1, valueVector1.getValueCapacity());
        childMapVector = (MapVector) mapVector.getChild("childMap");
        childKeyVector = childMapVector.getChild("childKey");
        childValueVector1 = childMapVector.getChild("childValue");
        assertEquals(testRowCountPowerTwo, childKeyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(testRowCountPowerTwo, offsetVector.getValueCapacity());
        assertEquals(testRowCountPowerTwo - 1, childValueVector1.getValueCapacity());
        // Allocate for max rows.
        colSize.allocateVector(v, ValueVector.MAX_ROW_COUNT - 1);
        mapVector = (MapVector) v;
        keyVector = mapVector.getChild("key");
        valueVector1 = mapVector.getChild("value");
        assertEquals(ValueVector.MAX_ROW_COUNT, keyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(ValueVector.MAX_ROW_COUNT, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MAX_ROW_COUNT - 1, valueVector1.getValueCapacity());
        childMapVector = (MapVector) mapVector.getChild("childMap");
        childKeyVector = childMapVector.getChild("childKey");
        childValueVector1 = childMapVector.getChild("childValue");
        assertEquals(ValueVector.MAX_ROW_COUNT, childKeyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(ValueVector.MAX_ROW_COUNT, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MAX_ROW_COUNT - 1, childValueVector1.getValueCapacity());
        // Allocate for 0 rows. should atleast do allocation for 1 row.
        colSize.allocateVector(v, 0);
        mapVector = (MapVector) v;
        keyVector = mapVector.getChild("key");
        valueVector1 = mapVector.getChild("value");
        assertEquals(ValueVector.MIN_ROW_COUNT, keyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MIN_ROW_COUNT, valueVector1.getValueCapacity());
        childMapVector = (MapVector) mapVector.getChild("childMap");
        childKeyVector = childMapVector.getChild("childKey");
        childValueVector1 = childMapVector.getChild("childValue");
        assertEquals(ValueVector.MIN_ROW_COUNT, childKeyVector.getValueCapacity());
        offsetVector = ((VariableWidthVector) valueVector1).getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MIN_ROW_COUNT, childValueVector1.getValueCapacity());
        v.clear();
    }
    empty.clear();
    rows.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) RepeatedMapVector(org.apache.drill.exec.vector.complex.RepeatedMapVector) MapVector(org.apache.drill.exec.vector.complex.MapVector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 23 with RowSetBuilder

use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.

the class TestRecordBatchSizer method testSizerRepeatedVariableWidth.

@Test
public void testSizerRepeatedVariableWidth() {
    BatchSchema schema = new SchemaBuilder().addArray("b", MinorType.VARCHAR).build();
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    // size = (5*6)/2 = 15
    String[] newString = new String[] { "a", "aa", "aaa", "aaaa", "aaaaa" };
    for (long i = 0; i < 10; i++) {
        builder.addRow((Object) (newString));
    }
    RowSet rows = builder.build();
    // Run the record batch sizer on the resulting batch.
    RecordBatchSizer sizer = new RecordBatchSizer(rows.container());
    assertEquals(1, sizer.columns().size());
    ColumnSize bColumn = sizer.columns().get("b");
    /**
     * stdDataSize:50*10, stdNetSize:50*10+4*10+4, dataSizePerEntry:(5*6)/2, netSizePerEntry:(5*6)/2+5*4+4,
     * totalDataSize:(5*6)/2 * 10, totalNetSize: ((5*6)/2+5*4+4)*10, valueCount:10,
     * elementCount:50, estElementCountPerArray:5, isVariableWidth:true
     */
    verifyColumnValues(bColumn, 500, 544, 15, 39, 150, 390, 10, 50, 5, true);
    SingleRowSet empty = fixture.rowSet(schema);
    VectorAccessible accessible = empty.vectorAccessible();
    for (VectorWrapper<?> vw : accessible) {
        ValueVector v = vw.getValueVector();
        RecordBatchSizer.ColumnSize colSize = sizer.getColumn(v.getField().getName());
        // Allocates to nearest power of two
        colSize.allocateVector(v, testRowCount - 1);
        UInt4Vector offsetVector = ((RepeatedValueVector) v).getOffsetVector();
        assertEquals(Integer.highestOneBit(testRowCount) << 1, offsetVector.getValueCapacity());
        VariableWidthVector vwVector = ((VariableWidthVector) ((RepeatedValueVector) v).getDataVector());
        offsetVector = vwVector.getOffsetVector();
        assertEquals((Integer.highestOneBit((testRowCount - 1) * 5) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit((testRowCount - 1) * 5 << 1) - 1, vwVector.getValueCapacity());
        v.clear();
        // Allocates the same as value passed since it is already power of two.
        colSize.allocateVector(v, testRowCountPowerTwo);
        offsetVector = ((RepeatedValueVector) v).getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCountPowerTwo) << 1), offsetVector.getValueCapacity());
        vwVector = ((VariableWidthVector) ((RepeatedValueVector) v).getDataVector());
        offsetVector = vwVector.getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCountPowerTwo * 5) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCountPowerTwo * 5 << 1) - 1, vwVector.getValueCapacity());
        v.clear();
        // Allocate for max rows.
        colSize.allocateVector(v, ValueVector.MAX_ROW_COUNT);
        offsetVector = ((RepeatedValueVector) v).getOffsetVector();
        assertEquals(ValueVector.MAX_ROW_COUNT << 1, offsetVector.getValueCapacity());
        vwVector = ((VariableWidthVector) ((RepeatedValueVector) v).getDataVector());
        offsetVector = vwVector.getOffsetVector();
        assertEquals((Integer.highestOneBit(ValueVector.MAX_ROW_COUNT * 5) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(ValueVector.MAX_ROW_COUNT * 5 << 1) - 1, vwVector.getValueCapacity());
        v.clear();
        // Allocate for 0 rows. should atleast do allocation for 1 row.
        colSize.allocateVector(v, 0);
        offsetVector = ((RepeatedValueVector) v).getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        vwVector = ((VariableWidthVector) ((RepeatedValueVector) v).getDataVector());
        offsetVector = vwVector.getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MIN_ROW_COUNT, vwVector.getValueCapacity());
        v.clear();
    }
    empty.clear();
    rows.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) VariableWidthVector(org.apache.drill.exec.vector.VariableWidthVector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 24 with RowSetBuilder

use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.

the class TestRecordBatchSizer method testSizerFixedWidth.

@Test
public void testSizerFixedWidth() {
    BatchSchema schema = new SchemaBuilder().add("a", MinorType.BIGINT).add("b", MinorType.FLOAT8).build();
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    for (long i = 0; i < 10; i++) {
        builder.addRow(i, i * 0.1);
    }
    RowSet rows = builder.build();
    // Run the record batch sizer on the resulting batch.
    RecordBatchSizer sizer = new RecordBatchSizer(rows.container());
    assertEquals(2, sizer.columns().size());
    ColumnSize aColumn = sizer.columns().get("a");
    /**
     * stdDataSize:8, stdNetSize:8, dataSizePerEntry:8, netSizePerEntry:8,
     * totalDataSize:8*10, totalNetSize:8*10, valueCount:10,
     * elementCount:10, estElementCountPerArray:1, isVariableWidth:false
     */
    verifyColumnValues(aColumn, 8, 8, 8, 8, 80, 80, 10, 10, 1, false);
    ColumnSize bColumn = sizer.columns().get("b");
    verifyColumnValues(bColumn, 8, 8, 8, 8, 80, 80, 10, 10, 1, false);
    SingleRowSet empty = fixture.rowSet(schema);
    VectorAccessible accessible = empty.vectorAccessible();
    for (VectorWrapper<?> vw : accessible) {
        ValueVector v = vw.getValueVector();
        RecordBatchSizer.ColumnSize colSize = sizer.getColumn(v.getField().getName());
        // Allocates to nearest power of two
        colSize.allocateVector(v, testRowCount);
        assertEquals((Integer.highestOneBit(testRowCount) << 1), v.getValueCapacity());
        v.clear();
        // Allocates the same as value passed since it is already power of two.
        colSize.allocateVector(v, testRowCountPowerTwo);
        assertEquals(testRowCountPowerTwo, v.getValueCapacity());
        v.clear();
        // Allocate for max rows.
        colSize.allocateVector(v, ValueVector.MAX_ROW_COUNT);
        assertEquals(ValueVector.MAX_ROW_COUNT, v.getValueCapacity());
        v.clear();
        // Allocate for 0 rows. should atleast do allocation for 1 row.
        colSize.allocateVector(v, 0);
        assertEquals(ValueVector.MIN_ROW_COUNT, v.getValueCapacity());
        v.clear();
    }
    rows.clear();
    empty.clear();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 25 with RowSetBuilder

use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.

the class TestRecordBatchSizer method testSizerVariableWidth.

@Test
public void testSizerVariableWidth() {
    BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).build();
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    StringBuilder stringBuilder = new StringBuilder();
    // a, aa, aaa, ... aaaaaaaaaa. totalSize = (10*11)/2 = 55
    for (long i = 0; i < 10; i++) {
        stringBuilder.append("a");
        builder.addRow(stringBuilder.toString());
    }
    RowSet rows = builder.build();
    // Run the record batch sizer on the resulting batch.
    RecordBatchSizer sizer = new RecordBatchSizer(rows.container());
    assertEquals(1, sizer.columns().size());
    ColumnSize aColumn = sizer.columns().get("a");
    /**
     * stdDataSize:50, stdNetSize:50+4, dataSizePerEntry:8, netSizePerEntry:8,
     * totalDataSize:(10*11)/2, totalNetSize:(10*11)/2 + 4*10, valueCount:10,
     * elementCount:10, estElementCountPerArray:1, isVariableWidth:true
     */
    verifyColumnValues(aColumn, 50, 54, 6, 10, 55, 95, 10, 10, 1, true);
    SingleRowSet empty = fixture.rowSet(schema);
    VectorAccessible accessible = empty.vectorAccessible();
    UInt4Vector offsetVector;
    for (VectorWrapper<?> vw : accessible) {
        ValueVector v = vw.getValueVector();
        RecordBatchSizer.ColumnSize colSize = sizer.getColumn(v.getField().getName());
        // Allocates to nearest power of two
        colSize.allocateVector(v, testRowCount);
        offsetVector = ((VariableWidthVector) v).getOffsetVector();
        assertEquals((Integer.highestOneBit(testRowCount) << 1), offsetVector.getValueCapacity());
        assertEquals(Integer.highestOneBit(testRowCount << 1) - 1, v.getValueCapacity());
        v.clear();
        // Allocates the same as value passed since it is already power of two.
        // -1 is done for adjustment needed for offset vector.
        colSize.allocateVector(v, testRowCountPowerTwo - 1);
        offsetVector = ((VariableWidthVector) v).getOffsetVector();
        assertEquals(testRowCountPowerTwo, offsetVector.getValueCapacity());
        assertEquals(testRowCountPowerTwo - 1, v.getValueCapacity());
        v.clear();
        // Allocate for max rows.
        colSize.allocateVector(v, ValueVector.MAX_ROW_COUNT - 1);
        offsetVector = ((VariableWidthVector) v).getOffsetVector();
        assertEquals(ValueVector.MAX_ROW_COUNT, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MAX_ROW_COUNT - 1, v.getValueCapacity());
        v.clear();
        // Allocate for 0 rows. should atleast do allocation for 1 row.
        colSize.allocateVector(v, 0);
        offsetVector = ((VariableWidthVector) v).getOffsetVector();
        assertEquals(ValueVector.MIN_ROW_COUNT + 1, offsetVector.getValueCapacity());
        assertEquals(ValueVector.MIN_ROW_COUNT, v.getValueCapacity());
        v.clear();
    }
    empty.clear();
    rows.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) ColumnSize(org.apache.drill.exec.record.RecordBatchSizer.ColumnSize) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

RowSetBuilder (org.apache.drill.test.rowSet.RowSetBuilder)27 RowSet (org.apache.drill.test.rowSet.RowSet)23 Test (org.junit.Test)23 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)18 BatchSchema (org.apache.drill.exec.record.BatchSchema)17 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)14 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)11 SubOperatorTest (org.apache.drill.test.SubOperatorTest)11 ValueVector (org.apache.drill.exec.vector.ValueVector)10 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)9 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)8 UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)7 ClusterTest (org.apache.drill.test.ClusterTest)5 File (java.io.File)4 OperatorTest (org.apache.drill.categories.OperatorTest)4 RootAllocator (org.apache.drill.exec.memory.RootAllocator)4 VectorContainer (org.apache.drill.exec.record.VectorContainer)4 JsonFileBuilder (org.apache.drill.test.rowSet.file.JsonFileBuilder)4 VariableWidthVector (org.apache.drill.exec.vector.VariableWidthVector)3 RepeatedMapVector (org.apache.drill.exec.vector.complex.RepeatedMapVector)3