Search in sources :

Example 1 with VectorOverflowException

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

the class TestVectorLimits method testRepeatedFixedVectorCountLimit.

/**
 * Repeated fixed vector. Using an int vector, each column array can hold
 * 256 / 4 = 64 values. We write only 10. The vector becomes full when we
 * exceed 64K items.
 */
@Test
public void testRepeatedFixedVectorCountLimit() {
    @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++) {
        if (!mutator.startNewValueBounded(i)) {
            assertEquals(ValueVector.MAX_ROW_COUNT, i);
        // Continue, let's check the addBounded method also
        }
        for (int j = 0; j < 10; j++) {
            try {
                mutator.addEntry(i, i * 100 + j);
            } catch (VectorOverflowException e) {
                assertEquals(ValueVector.MAX_ROW_COUNT, i);
                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)

Example 2 with VectorOverflowException

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

the class TestVectorLimits method testWideVariableVector.

/**
 * Test a vector directly using the vector mutator to ensure
 * that the <tt>setScalar</tt> method works for the maximum
 * vector size.
 */
@Test
public void testWideVariableVector() {
    @SuppressWarnings("resource") VarCharVector vector = new VarCharVector(makeField(MinorType.VARCHAR, DataMode.REQUIRED), fixture.allocator());
    vector.allocateNew();
    // A 16 MB value can hold 64K values of up to 256 bytes each.
    // To force a size overflow, write values much larger.
    // Write to the vector until it complains. At that point,
    // we should have written up to the maximum buffer size.
    byte[] dummyValue = makeVarCharValue(512);
    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;
        }
    }
    // The vector should be at the allocation limit. If it wasn't, we
    // should have grown it to hold more data. The value count will
    // be below the maximum.
    mutator.setValueCount(count);
    assertEquals(ValueVector.MAX_BUFFER_SIZE, vector.getBuffer().getActualMemoryConsumed());
    assertTrue(count < ValueVector.MAX_ROW_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 3 with VectorOverflowException

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

the class TestVectorLimits method testFixedVector.

/**
 * Test a vector directly using the vector mutator to ensure
 * that the <tt>setScalar</tt> method works for the maximum
 * row count.
 * <p>
 * This test is a proxy for all the other fixed types, since all
 * share the same code template.
 */
@Test
public void testFixedVector() {
    // Create a non-nullable int vector: a typical fixed-size vector
    @SuppressWarnings("resource") IntVector vector = new IntVector(makeField(MinorType.INT, DataMode.REQUIRED), fixture.allocator());
    // Sanity test of generated constants.
    assertTrue(IntVector.MAX_SCALAR_COUNT <= ValueVector.MAX_ROW_COUNT);
    assertEquals(4, IntVector.VALUE_WIDTH);
    assertTrue(IntVector.NET_MAX_SCALAR_SIZE <= ValueVector.MAX_BUFFER_SIZE);
    // Allocate a default size, small vector. Forces test of
    // the auto-grow (setSafe()) aspect of setScalar().
    vector.allocateNew();
    // Write to the vector until it complains. At that point,
    // we should have written up to the static fixed value count
    // (which is computed to stay below the capacity limit.)
    IntVector.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;
        }
    }
    // The vector should be below the allocation limit. Since this
    // is an int vector, in practice the size will be far below
    // the overall limit (if the limit stays at 16 MB.) But, it should
    // be at the type-specific limit since we filled up the vector.
    assertEquals(IntVector.NET_MAX_SCALAR_SIZE, vector.getBuffer().getActualMemoryConsumed());
    vector.close();
}
Also used : NullableIntVector(org.apache.drill.exec.vector.NullableIntVector) IntVector(org.apache.drill.exec.vector.IntVector) 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)

Example 4 with VectorOverflowException

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

the class TestVectorLimits method testDirectVariableVector.

/**
 * Test a vector directly using the vector mutator to ensure
 * that the <tt>setScalar</tt> method works for the maximum
 * value count. Uses a DrillBuf as input.
 */
@Test
public void testDirectVariableVector() {
    @SuppressWarnings("resource") VarCharVector vector = new VarCharVector(makeField(MinorType.VARCHAR, DataMode.REQUIRED), fixture.allocator());
    vector.allocateNew();
    // Repeat the big-value test, but with data coming from a DrillBuf
    // (direct memory) rather than a heap array.
    @SuppressWarnings("resource") DrillBuf drillBuf = makeVarCharValueDirect(260);
    VarCharVector.Mutator mutator = vector.getMutator();
    int count = 0;
    for (; count < 2 * ValueVector.MAX_ROW_COUNT; count++) {
        try {
            mutator.setScalar(count, drillBuf, 0, 260);
        } catch (VectorOverflowException e) {
            break;
        }
    }
    drillBuf.close();
    // Again, vector should be at the size limit, count below the
    // value limit.
    mutator.setValueCount(count);
    assertEquals(ValueVector.MAX_BUFFER_SIZE, vector.getBuffer().getActualMemoryConsumed());
    assertTrue(count < ValueVector.MAX_ROW_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) DrillBuf(io.netty.buffer.DrillBuf) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest) DrillTest(org.apache.drill.test.DrillTest)

Example 5 with VectorOverflowException

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

the class TestVectorLimits method testDirectNullableVariableVector.

@Test
public void testDirectNullableVariableVector() {
    @SuppressWarnings("resource") NullableVarCharVector vector = new NullableVarCharVector(makeField(MinorType.VARCHAR, DataMode.OPTIONAL), fixture.allocator());
    vector.allocateNew();
    @SuppressWarnings("resource") DrillBuf drillBuf = makeVarCharValueDirect(260);
    NullableVarCharVector.Mutator mutator = vector.getMutator();
    int count = 0;
    for (; count < 2 * ValueVector.MAX_ROW_COUNT; count++) {
        try {
            mutator.setScalar(count, drillBuf, 0, 260);
        } catch (VectorOverflowException e) {
            break;
        }
    }
    drillBuf.close();
    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) DrillBuf(io.netty.buffer.DrillBuf) 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