Search in sources :

Example 6 with VectorOverflowException

use of org.apache.drill.exec.vector.VectorOverflowException in project drill by axbaretto.

the class TestVectorLimits method testNullableFixedVector.

@Test
public void testNullableFixedVector() {
    @SuppressWarnings("resource") NullableIntVector vector = new NullableIntVector(makeField(MinorType.INT, DataMode.OPTIONAL), fixture.allocator());
    vector.allocateNew();
    NullableIntVector.Mutator mutator = vector.getMutator();
    for (int i = 0; i < 2 * ValueVector.MAX_ROW_COUNT; i++) {
        try {
            mutator.setScalar(i, i);
        } catch (VectorOverflowException e) {
            assertEquals(IntVector.MAX_SCALAR_COUNT, i);
            break;
        }
    }
    vector.close();
}
Also used : NullableIntVector(org.apache.drill.exec.vector.NullableIntVector) VectorOverflowException(org.apache.drill.exec.vector.VectorOverflowException) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest) DrillTest(org.apache.drill.test.DrillTest)

Example 7 with VectorOverflowException

use of org.apache.drill.exec.vector.VectorOverflowException in project drill by axbaretto.

the class TestVectorLimits method testNullableWideVariableVector.

@Test
public void testNullableWideVariableVector() {
    @SuppressWarnings("resource") NullableVarCharVector vector = new NullableVarCharVector(makeField(MinorType.VARCHAR, DataMode.OPTIONAL), fixture.allocator());
    vector.allocateNew();
    byte[] dummyValue = makeVarCharValue(512);
    NullableVarCharVector.Mutator mutator = vector.getMutator();
    int count = 0;
    for (; count < 2 * ValueVector.MAX_ROW_COUNT; count++) {
        try {
            mutator.setScalar(count, dummyValue, 0, dummyValue.length);
        } catch (VectorOverflowException e) {
            break;
        }
    }
    mutator.setValueCount(count);
    assertEquals(ValueVector.MAX_BUFFER_SIZE, vector.getValuesVector().getBuffer().getActualMemoryConsumed());
    assertTrue(count < ValueVector.MAX_ROW_COUNT);
    vector.close();
}
Also used : NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) VectorOverflowException(org.apache.drill.exec.vector.VectorOverflowException) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest) DrillTest(org.apache.drill.test.DrillTest)

Example 8 with VectorOverflowException

use of org.apache.drill.exec.vector.VectorOverflowException in project drill by axbaretto.

the class TestVectorLimits method testNarrowVariableVector.

/**
 * Test a vector directly using the vector mutator to ensure
 * that the <tt>setScalar</tt> method works for the maximum
 * value count.
 */
@Test
public void testNarrowVariableVector() {
    @SuppressWarnings("resource") VarCharVector vector = new VarCharVector(makeField(MinorType.VARCHAR, DataMode.REQUIRED), fixture.allocator());
    vector.allocateNew();
    // Write small values that fit into 16 MB. We should stop writing
    // when we reach the value count limit.
    byte[] dummyValue = makeVarCharValue(254);
    VarCharVector.Mutator mutator = vector.getMutator();
    int count = 0;
    for (; count < 2 * ValueVector.MAX_ROW_COUNT; count++) {
        try {
            mutator.setScalar(count, dummyValue, 0, dummyValue.length);
        } catch (VectorOverflowException e) {
            break;
        }
    }
    // Buffer size should be at or below the maximum, with count
    // at the maximum.
    mutator.setValueCount(count);
    assertTrue(vector.getBuffer().getActualMemoryConsumed() <= ValueVector.MAX_BUFFER_SIZE);
    assertEquals(ValueVector.MAX_ROW_COUNT, count);
    vector.close();
}
Also used : NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) VarCharVector(org.apache.drill.exec.vector.VarCharVector) VectorOverflowException(org.apache.drill.exec.vector.VectorOverflowException) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest) DrillTest(org.apache.drill.test.DrillTest)

Example 9 with VectorOverflowException

use of org.apache.drill.exec.vector.VectorOverflowException in project drill by axbaretto.

the class TestVectorLimits method testRepeatedFixedVectorBufferLimit.

/**
 * Repeated fixed vector. Using an int vector, each column array can hold
 * 256 / 4 = 64 values. We write 100. The vector becomes full when we
 * exceed the 16 MB size limit.
 */
@Test
public void testRepeatedFixedVectorBufferLimit() {
    @SuppressWarnings("resource") RepeatedIntVector vector = new RepeatedIntVector(makeField(MinorType.INT, DataMode.REPEATED), fixture.allocator());
    vector.allocateNew();
    RepeatedIntVector.Mutator mutator = vector.getMutator();
    top: for (int i = 0; i < 2 * ValueVector.MAX_ROW_COUNT; i++) {
        // We'll never hit the value count limit
        assertTrue(mutator.startNewValueBounded(i));
        for (int j = 0; j < 100; j++) {
            try {
                mutator.addEntry(i, i * 100 + j);
            } catch (VectorOverflowException e) {
                // We should have hit the buffer limit before the value limit.
                assertTrue(i < ValueVector.MAX_ROW_COUNT);
                mutator.setValueCount(i);
                break top;
            }
        }
    }
    vector.close();
}
Also used : RepeatedIntVector(org.apache.drill.exec.vector.RepeatedIntVector) VectorOverflowException(org.apache.drill.exec.vector.VectorOverflowException) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest) DrillTest(org.apache.drill.test.DrillTest)

Aggregations

VectorTest (org.apache.drill.categories.VectorTest)9 VectorOverflowException (org.apache.drill.exec.vector.VectorOverflowException)9 DrillTest (org.apache.drill.test.DrillTest)9 Test (org.junit.Test)9 NullableVarCharVector (org.apache.drill.exec.vector.NullableVarCharVector)5 RepeatedIntVector (org.apache.drill.exec.vector.RepeatedIntVector)3 VarCharVector (org.apache.drill.exec.vector.VarCharVector)3 DrillBuf (io.netty.buffer.DrillBuf)2 NullableIntVector (org.apache.drill.exec.vector.NullableIntVector)2 IntVector (org.apache.drill.exec.vector.IntVector)1