Class RowSetBuilder
java.lang.Object
org.apache.drill.exec.physical.rowSet.RowSetBuilder
Fluent builder to quickly build up an row set (record batch)
programmatically.
-
Constructor Summary
ConstructorDescriptionRowSetBuilder
(BufferAllocator allocator, BatchSchema schema) Deprecated.RowSetBuilder
(BufferAllocator allocator, TupleMetadata schema) RowSetBuilder
(BufferAllocator allocator, TupleMetadata schema, int capacity) -
Method Summary
Modifier and TypeMethodDescriptionAdd a new row using column values passed as variable-length arguments.addSelection
(boolean selected, Object... values) addSingleCol
(boolean selected, Object value) addSingleCol
(Object value) TheaddRow(Object...)
method uses Java variable-length arguments to pass a row of values.build()
static RowSet
emptyBatch
(BufferAllocator allocator, TupleMetadata schema) withSv2()
Build the row set with a selection vector 2.writer()
-
Constructor Details
-
RowSetBuilder
Deprecated.UseRowSetBuilder(BufferAllocator, TupleMetadata)
instead.Creates aRowSetBuilder
. SinceBatchSchema
does not handle complex types well, this has been deprecated in favor of the other constructors.- Parameters:
allocator
- An allocator.schema
- ABatchSchema
.
-
RowSetBuilder
-
RowSetBuilder
-
-
Method Details
-
emptyBatch
-
writer
-
addRow
Add a new row using column values passed as variable-length arguments. Expects map values to be flattened. a schema of (a:int, b:map(c:varchar)) would be> set as
add(10, "foo");
Values of arrays can be expressed as a Java array. A schema of (a:int, b:int[]) can be set as
add(10, new int[] {100, 200});- Parameters:
values
- column values in column index order- Returns:
- this builder
- Throws:
IllegalStateException
- if the batch, or any vector in the batch, becomes full. This method is designed to be used in tests where we will seldom create a full vector of data.
-
addSelection
-
addSingleCol
TheaddRow(Object...)
method uses Java variable-length arguments to pass a row of values. But, when the row consists of a single array, Java gets confused: is that an array for variable-arguments or is it the value of the first argument? This method clearly states that the single value (including an array) is meant to be the value of the first (and only) column.Examples:
RowSetBuilder twoColsBuilder = ... // Fine, second item is an array of strings for a repeated Varchar // column. twoColsBuilder.add("First", new String[] {"a", "b", "c"}); ... RowSetBuilder oneColBuilder = ... // Ambiguous: is this a varargs array of three items? // That is how Java will perceive it. oneColBuilder.add(new String[] {"a", "b", "c"}); // Unambiguous: this is a single column value for the // repeated Varchar column. oneColBuilder.addSingleCol(new String[] {"a", "b", "c"});
- Parameters:
value
- value of the first column, which may be an array for a repeated column- Returns:
- this builder
-
addSingleCol
-
withSv2
Build the row set with a selection vector 2. The SV2 is initialized to have a 1:1 index to the rows: SV2 0 points to row 1, SV2 position 1 points to row 1 and so on.- Returns:
- this builder
-
build
-
RowSetBuilder(BufferAllocator, TupleMetadata)
instead.