Package io.delta.kernel.data
Interface ColumnarBatch
Represents zero or more rows of records with same schema type.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptiongetColumnVector(int ordinal) Return theColumnVectorfor the given ordinal in the columnar batch.default CloseableIterator<Row>getRows()intgetSize()default ColumnarBatchslice(int start, int end) Return a slice of the current batch.default ColumnarBatchwithDeletedColumnAt(int ordinal) Return a copy of thisColumnarBatchwith the column at givenordinalremoved.default ColumnarBatchwithNewColumn(int ordinal, StructField columnSchema, ColumnVector columnVector) Return a copy of theColumnarBatchwith given new column vector inserted at the givencolumnVectorat givenordinal.default ColumnarBatchwithNewSchema(StructType newSchema) Generate a copy of thisColumnarBatchwith the givennewSchema.
-
Method Details
-
getSchema
StructType getSchema()- Returns:
- the schema of the data in this batch.
-
getColumnVector
Return theColumnVectorfor the given ordinal in the columnar batch. If the ordinal is not valid throws error.- Parameters:
ordinal- the ordinal of the column to retrieve- Returns:
- the
ColumnVectorfor the given ordinal in the columnar batch
-
getSize
int getSize()- Returns:
- the number of rows/records in the columnar batch
-
withNewColumn
default ColumnarBatch withNewColumn(int ordinal, StructField columnSchema, ColumnVector columnVector) Return a copy of theColumnarBatchwith given new column vector inserted at the givencolumnVectorat givenordinal. Shift the existingColumnVectors located at fromordinalto the end by one position. The schema of the newColumnarBatchwill also be changed to reflect the newly inserted vector.- Parameters:
ordinal-columnSchema- Column name and schema details of the new column vector.columnVector-- Returns:
ColumnarBatchwith new vector inserted.- Throws:
IllegalArgumentException- If the ordinal is not valid (ie less than zero or greater than the current number of vectors).
-
withDeletedColumnAt
Return a copy of thisColumnarBatchwith the column at givenordinalremoved. All columns after theordinalwill be shifted to left by one position.- Parameters:
ordinal- Column ordinal to delete.- Returns:
ColumnarBatchwith a column vector deleted.
-
withNewSchema
Generate a copy of thisColumnarBatchwith the givennewSchema. The data types of elements in the given new schema and existing schema should be the same. Rest of the details such as name of the column or column metadata could be different.- Parameters:
newSchema-- Returns:
ColumnarBatchwith given new schema.
-
slice
Return a slice of the current batch.- Parameters:
start- Starting record index to include in the returned columnar batchend- Ending record index (exclusive) to include in the returned columnar batch- Returns:
- a columnar batch containing the records between [start, end)
-
getRows
- Returns:
- iterator of
Rows in this batch
-