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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations