use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.
the class TestBatchValidator method testRepeatedBadArrayOffset.
@Test
public void testRepeatedBadArrayOffset() {
TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).buildSchema();
SingleRowSet batch = fixture.rowSetBuilder(schema).addRow((Object) strArray()).addRow((Object) strArray("fred", "barney", "wilma")).addRow((Object) strArray("dino")).build();
VectorAccessible va = batch.vectorAccessible();
ValueVector v = va.iterator().next().getValueVector();
RepeatedVarCharVector vc = (RepeatedVarCharVector) v;
UInt4Vector ov = vc.getOffsetVector();
ov.getMutator().set(3, 1);
checkForError(batch, BAD_OFFSETS);
batch.clear();
}
use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.
the class TestBatchValidator method testRepeatedBadValueOffset.
@Test
public void testRepeatedBadValueOffset() {
TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).buildSchema();
SingleRowSet batch = fixture.rowSetBuilder(schema).addRow((Object) strArray()).addRow((Object) strArray("fred", "barney", "wilma")).addRow((Object) strArray("dino")).build();
VectorAccessible va = batch.vectorAccessible();
ValueVector v = va.iterator().next().getValueVector();
RepeatedVarCharVector rvc = (RepeatedVarCharVector) v;
VarCharVector vc = rvc.getDataVector();
UInt4Vector ov = vc.getOffsetVector();
ov.getMutator().set(4, 100_000);
checkForError(batch, "Invalid offset");
batch.clear();
}
use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by axbaretto.
the class TestFillEmpties method testRepeatedVarChar.
@Test
public void testRepeatedVarChar() {
@SuppressWarnings("resource") RepeatedVarCharVector vector = new RepeatedVarCharVector(SchemaBuilder.columnSchema("a", MinorType.VARCHAR, DataMode.REPEATED), fixture.allocator());
vector.allocateNew();
// Create "foo", null, "bar", but omit the null.
RepeatedVarCharVector.Mutator mutator = vector.getMutator();
mutator.startNewValue(0);
byte[] value = makeValue("a");
mutator.addSafe(0, value, 0, value.length);
value = makeValue("b");
mutator.addSafe(0, value, 0, value.length);
// Work around: test fails without this. But, only the new column writers
// call this method.
mutator.fillEmpties(0, 2);
mutator.startNewValue(2);
value = makeValue("c");
mutator.addSafe(2, value, 0, value.length);
value = makeValue("d");
mutator.addSafe(2, value, 0, value.length);
visualize(vector, 3);
verifyOffsets(vector.getOffsetVector(), new int[] { 0, 2, 2, 4 });
verifyOffsets(vector.getDataVector().getOffsetVector(), new int[] { 0, 1, 2, 3, 4 });
vector.close();
}
use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.
the class TestFillEmpties method testRepeatedVarChar.
@Test
public void testRepeatedVarChar() {
RepeatedVarCharVector vector = new RepeatedVarCharVector(SchemaBuilder.columnSchema("a", MinorType.VARCHAR, DataMode.REPEATED), fixture.allocator());
vector.allocateNew();
// Create "foo", null, "bar", but omit the null.
RepeatedVarCharVector.Mutator mutator = vector.getMutator();
mutator.startNewValue(0);
byte[] value = makeValue("a");
mutator.addSafe(0, value, 0, value.length);
value = makeValue("b");
mutator.addSafe(0, value, 0, value.length);
// Work around: test fails without this. But, only the new column writers
// call this method.
mutator.fillEmpties(0, 2);
mutator.startNewValue(2);
value = makeValue("c");
mutator.addSafe(2, value, 0, value.length);
value = makeValue("d");
mutator.addSafe(2, value, 0, value.length);
visualize(vector, 3);
verifyOffsets(vector.getOffsetVector(), new int[] { 0, 2, 2, 4 });
verifyOffsets(vector.getDataVector().getOffsetVector(), new int[] { 0, 1, 2, 3, 4 });
vector.close();
}
use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.
the class TestRepeatedListAccessors method testSchema3DVector.
@Test
public void testSchema3DVector() {
final TupleMetadata schema = new SchemaBuilder().add("id", MinorType.INT).addRepeatedList("list2").addDimension().addArray(MinorType.VARCHAR).resumeList().resumeSchema().buildSchema();
final DirectRowSet rowSet = DirectRowSet.fromSchema(fixture.allocator(), schema);
final VectorContainer container = rowSet.container();
assertEquals(2, container.getNumberOfColumns());
assertTrue(container.getValueVector(1).getValueVector() instanceof RepeatedListVector);
final RepeatedListVector list = (RepeatedListVector) container.getValueVector(1).getValueVector();
assertEquals(1, list.getField().getChildren().size());
assertTrue(list.getDataVector() instanceof RepeatedListVector);
final RepeatedListVector child1 = (RepeatedListVector) list.getDataVector();
assertEquals(1, child1.getField().getChildren().size());
assertSame(list.getField().getChildren().iterator().next(), child1.getField());
final ValueVector child2 = child1.getDataVector();
assertTrue(child2 instanceof RepeatedVarCharVector);
assertSame(child1.getField().getChildren().iterator().next(), child2.getField());
rowSet.clear();
}
Aggregations