Search in sources :

Example 91 with SingleRowSet

use of org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet in project drill by apache.

the class TestHyperVectorReaders method testMap.

/**
 * Maps are an interesting case. The hyper-vector wrapper holds a mirror-image of the
 * map members. So, we can reach the map members either via the vector wrappers or
 * the original map vector.
 */
@Test
public void testMap() {
    TupleMetadata schema = new SchemaBuilder().addMap("m").add("a", MinorType.INT).add("b", MinorType.VARCHAR).resumeSchema().buildSchema();
    SingleRowSet rowSet1 = fixture.rowSetBuilder(schema).addSingleCol(mapValue(2, "second")).addSingleCol(mapValue(4, "fourth")).build();
    SingleRowSet rowSet2 = fixture.rowSetBuilder(schema).addSingleCol(mapValue(2, "first")).addSingleCol(mapValue(4, "third")).build();
    // Build the hyper batch
    HyperRowSet hyperSet = HyperRowSetImpl.fromRowSets(fixture.allocator(), rowSet1, rowSet2);
    assertEquals(4, hyperSet.rowCount());
    SelectionVector4 sv4 = hyperSet.getSv4();
    sv4.set(0, 1, 0);
    sv4.set(1, 0, 0);
    sv4.set(2, 1, 1);
    sv4.set(3, 0, 1);
    SingleRowSet expected = fixture.rowSetBuilder(schema).addSingleCol(mapValue(2, "first")).addSingleCol(mapValue(2, "second")).addSingleCol(mapValue(4, "third")).addSingleCol(mapValue(4, "fourth")).build();
    RowSetUtilities.verify(expected, hyperSet);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) HyperRowSet(org.apache.drill.exec.physical.rowSet.RowSet.HyperRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 92 with SingleRowSet

use of org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet in project drill by apache.

the class TestHyperVectorReaders method testScalarList.

@Test
public void testScalarList() {
    TupleMetadata schema = new SchemaBuilder().addList("a").addType(MinorType.VARCHAR).resumeSchema().buildSchema();
    schema.metadata("a").variantSchema().becomeSimple();
    SingleRowSet rowSet1 = fixture.rowSetBuilder(schema).addSingleCol(strArray("sixth", "6.1", "6.2")).addSingleCol(null).addSingleCol(strArray("fourth", "4.1")).build();
    SingleRowSet rowSet2 = fixture.rowSetBuilder(schema).addSingleCol(strArray("fifth", "51", "5.2")).addSingleCol(strArray("first", "1.1", "1.2", "1.3")).addSingleCol(strArray("third", "3.1")).build();
    // Build the hyper batch
    HyperRowSet hyperSet = HyperRowSetImpl.fromRowSets(fixture.allocator(), rowSet1, rowSet2);
    assertEquals(6, hyperSet.rowCount());
    SelectionVector4 sv4 = hyperSet.getSv4();
    sv4.set(0, 1, 1);
    sv4.set(1, 0, 1);
    sv4.set(2, 1, 2);
    sv4.set(3, 0, 2);
    sv4.set(4, 1, 0);
    sv4.set(5, 0, 0);
    SingleRowSet expected = fixture.rowSetBuilder(schema).addSingleCol(strArray("first", "1.1", "1.2", "1.3")).addSingleCol(null).addSingleCol(strArray("third", "3.1")).addSingleCol(strArray("fourth", "4.1")).addSingleCol(strArray("fifth", "51", "5.2")).addSingleCol(strArray("sixth", "6.1", "6.2")).build();
    RowSetUtilities.verify(expected, hyperSet);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) HyperRowSet(org.apache.drill.exec.physical.rowSet.RowSet.HyperRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 93 with SingleRowSet

use of org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet in project drill by apache.

the class TestHyperVectorReaders method testRepeatedMap.

@Test
public void testRepeatedMap() {
    TupleMetadata schema = new SchemaBuilder().add("a", MinorType.INT).addMapArray("ma").add("b", MinorType.INT).add("c", MinorType.VARCHAR).resumeSchema().buildSchema();
    SingleRowSet rowSet1 = fixture.rowSetBuilder(schema).addRow(2, mapArray(mapValue(21, "second.1"), mapValue(22, "second.2"))).addRow(4, mapArray(mapValue(41, "fourth.1"))).build();
    SingleRowSet rowSet2 = fixture.rowSetBuilder(schema).addRow(1, mapArray(mapValue(11, "first.1"), mapValue(12, "first.2"))).addRow(3, mapArray(mapValue(31, "third.1"), mapValue(32, "third.2"), mapValue(33, "third.3"))).build();
    // Build the hyper batch
    HyperRowSet hyperSet = HyperRowSetImpl.fromRowSets(fixture.allocator(), rowSet1, rowSet2);
    assertEquals(4, hyperSet.rowCount());
    SelectionVector4 sv4 = hyperSet.getSv4();
    sv4.set(0, 1, 0);
    sv4.set(1, 0, 0);
    sv4.set(2, 1, 1);
    sv4.set(3, 0, 1);
    SingleRowSet expected = fixture.rowSetBuilder(schema).addRow(1, mapArray(mapValue(11, "first.1"), mapValue(12, "first.2"))).addRow(2, mapArray(mapValue(21, "second.1"), mapValue(22, "second.2"))).addRow(3, mapArray(mapValue(31, "third.1"), mapValue(32, "third.2"), mapValue(33, "third.3"))).addRow(4, mapArray(mapValue(41, "fourth.1"))).build();
    RowSetUtilities.verify(expected, hyperSet);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) HyperRowSet(org.apache.drill.exec.physical.rowSet.RowSet.HyperRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 94 with SingleRowSet

use of org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet in project drill by apache.

the class TestHyperVectorReaders method testOptional.

/**
 * Test a nullable varchar. Requires multiple indirections:
 * <ul>
 * <li>From the SV4 to the nullable vector.</li>
 * <li>From the nullable vector to the bits vector.</li>
 * <li>From the nullable vector to the data vector.</li>
 * <li>From the data vector to the offset vector.</li>
 * <li>From the data vector to the values vector.</li>
 * </ul>
 * All are coordinated by the vector index and vector accessors.
 * This test verifies that each of the indirections does, in fact,
 * work as expected.
 */
@Test
public void testOptional() {
    TupleMetadata schema = new SchemaBuilder().addNullable("a", MinorType.VARCHAR).buildSchema();
    SingleRowSet rowSet1 = fixture.rowSetBuilder(schema).addSingleCol("sixth").addSingleCol(null).addSingleCol("fourth").build();
    SingleRowSet rowSet2 = fixture.rowSetBuilder(schema).addSingleCol(null).addSingleCol("first").addSingleCol("third").build();
    // Build the hyper batch
    HyperRowSet hyperSet = HyperRowSetImpl.fromRowSets(fixture.allocator(), rowSet1, rowSet2);
    assertEquals(6, hyperSet.rowCount());
    SelectionVector4 sv4 = hyperSet.getSv4();
    sv4.set(0, 1, 1);
    sv4.set(1, 0, 1);
    sv4.set(2, 1, 2);
    sv4.set(3, 0, 2);
    sv4.set(4, 1, 0);
    sv4.set(5, 0, 0);
    SingleRowSet expected = fixture.rowSetBuilder(schema).addSingleCol("first").addSingleCol(null).addSingleCol("third").addSingleCol("fourth").addSingleCol(null).addSingleCol("sixth").build();
    RowSetUtilities.verify(expected, hyperSet);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) HyperRowSet(org.apache.drill.exec.physical.rowSet.RowSet.HyperRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 95 with SingleRowSet

use of org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet in project drill by apache.

the class TestHyperVectorReaders method testVarWidth.

@Test
public void testVarWidth() {
    TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR).buildSchema();
    SingleRowSet rowSet1 = fixture.rowSetBuilder(schema).addSingleCol("second").addSingleCol("fourth").build();
    SingleRowSet rowSet2 = fixture.rowSetBuilder(schema).addSingleCol("first").addSingleCol("third").build();
    // Build the hyper batch
    HyperRowSet hyperSet = HyperRowSetImpl.fromRowSets(fixture.allocator(), rowSet1, rowSet2);
    assertEquals(4, hyperSet.rowCount());
    SelectionVector4 sv4 = hyperSet.getSv4();
    sv4.set(0, 1, 0);
    sv4.set(1, 0, 0);
    sv4.set(2, 1, 1);
    sv4.set(3, 0, 1);
    SingleRowSet expected = fixture.rowSetBuilder(schema).addRow("first").addRow("second").addRow("third").addRow("fourth").build();
    RowSetUtilities.verify(expected, hyperSet);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) HyperRowSet(org.apache.drill.exec.physical.rowSet.RowSet.HyperRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)257 Test (org.junit.Test)241 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)237 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)234 SubOperatorTest (org.apache.drill.test.SubOperatorTest)207 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)69 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)62 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)61 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)54 ValueVector (org.apache.drill.exec.vector.ValueVector)32 EvfTest (org.apache.drill.categories.EvfTest)30 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)29 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)27 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)27 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)27 ExtendableRowSet (org.apache.drill.exec.physical.rowSet.RowSet.ExtendableRowSet)25 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)24 BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)23 VectorContainer (org.apache.drill.exec.record.VectorContainer)22 ArrayReader (org.apache.drill.exec.vector.accessor.ArrayReader)22