@@ -73,11 +73,11 @@ public static ColumnarBatch allocate(StructType type) {
7373 }
7474
7575 public static ColumnarBatch allocate (StructType schema , MemoryMode memMode , int maxRows ) {
76- ColumnVector [] columns = allocateVectors (schema , maxRows , memMode );
77- return create (schema , columns , maxRows );
76+ ColumnVector [] columns = allocateCols (schema , maxRows , memMode );
77+ return new ColumnarBatch (schema , columns , maxRows );
7878 }
7979
80- private static ColumnVector [] allocateVectors (StructType schema , int maxRows , MemoryMode memMode ) {
80+ private static ColumnVector [] allocateCols (StructType schema , int maxRows , MemoryMode memMode ) {
8181 ColumnVector [] columns = new ColumnVector [schema .size ()];
8282 for (int i = 0 ; i < schema .fields ().length ; ++i ) {
8383 StructField field = schema .fields ()[i ];
@@ -90,19 +90,12 @@ public static ColumnarBatch createReadOnly(
9090 StructType schema ,
9191 ReadOnlyColumnVector [] columns ,
9292 int numRows ) {
93- for (ReadOnlyColumnVector c : columns ) {
94- assert (c .capacity >= numRows );
95- }
96- ColumnarBatch batch = create (schema , columns , numRows );
93+ assert (schema .length () == columns .length );
94+ ColumnarBatch batch = new ColumnarBatch (schema , columns , numRows );
9795 batch .setNumRows (numRows );
9896 return batch ;
9997 }
10098
101- private static ColumnarBatch create (StructType schema , ColumnVector [] columns , int capacity ) {
102- assert (schema .length () == columns .length );
103- return new ColumnarBatch (schema , columns , capacity );
104- }
105-
10699 /**
107100 * Called to close all the columns in this batch. It is not valid to access the data after
108101 * calling this. This must be called at the end to clean up memory allocations.
0 commit comments