Github user BryanCutler commented on a diff in the pull request:
    --- Diff: 
    @@ -65,15 +65,35 @@
       final Row row;
       public static ColumnarBatch allocate(StructType schema, MemoryMode 
memMode) {
    -    return new ColumnarBatch(schema, DEFAULT_BATCH_SIZE, memMode);
    +    return allocate(schema, memMode, DEFAULT_BATCH_SIZE);
       public static ColumnarBatch allocate(StructType type) {
    -    return new ColumnarBatch(type, DEFAULT_BATCH_SIZE, 
    +    return allocate(type, DEFAULT_MEMORY_MODE, DEFAULT_BATCH_SIZE);
       public static ColumnarBatch allocate(StructType schema, MemoryMode 
memMode, int maxRows) {
    -    return new ColumnarBatch(schema, maxRows, memMode);
    +    ColumnVector[] columns = allocateCols(schema, maxRows, memMode);
    +    return new ColumnarBatch(schema, columns, maxRows);
    +  }
    +  private static ColumnVector[] allocateCols(StructType schema, int 
maxRows, MemoryMode memMode) {
    +    ColumnVector[] columns = new ColumnVector[schema.size()];
    +    for (int i = 0; i < schema.fields().length; ++i) {
    +      StructField field = schema.fields()[i];
    +      columns[i] = ColumnVector.allocate(maxRows, field.dataType(), 
    +    }
    +    return columns;
    +  }
    +  public static ColumnarBatch createReadOnly(
    +      StructType schema,
    +      ReadOnlyColumnVector[] columns,
    +      int numRows) {
    +    assert(schema.length() == columns.length);
    +    ColumnarBatch batch = new ColumnarBatch(schema, columns, numRows);
    --- End diff --
    The max `capacity` only has meaning when allocating `ColumnVectors` so it 
doesn't really do 
     anything for read-only vectors.  You need to call`setNumRows` to tell the 
batch how many rows there for the given columns, it doesn't look at the 
capacity in the individual vectors.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to