public class TableReadSession extends Object implements AutoCloseable
TableReadSession for the MaxCompute Storage API.
This class represents a read session for a MaxCompute table, allowing clients to read data in a distributed manner using input splits. Each session is associated with a specific table and provides methods to get the session ID, Arrow schema, and input splits for parallel processing.
Example usage:
TableIdentifier tableId = TableIdentifier.of("my_project", "my_table");
try (TableReadSession session = client.createReadSessionBuilder(tableId).build()) {
List<InputSplit> splits = session.getSplits();
for (InputSplit split : splits) {
try (ArrowReader reader = session.createArrowReaderBuilder(split).build()) {
// Process data from reader
}
}
}
| Constructor and Description |
|---|
TableReadSession(StorageStub storageStub,
TableIdentifier tableId,
org.apache.arrow.memory.BufferAllocator allocator,
CreateTableReadSessionResponse response,
TableReadSessionBuilder builder)
Constructs a new TableReadSession with the provided parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
TableReaderBuilder |
createReaderBuilder(InputSplit split)
Creates a new builder for an Arrow reader for the specified input split.
|
org.apache.arrow.vector.types.pojo.Schema |
getArrowSchema()
Gets the Arrow schema for the data in this read session.
|
String |
getId()
Gets the unique identifier of this read session.
|
List<InputSplit> |
getSplits()
Gets the input splits for this read session.
|
TableSchema |
getTableSchema() |
public TableReadSession(StorageStub storageStub, TableIdentifier tableId, org.apache.arrow.memory.BufferAllocator allocator, CreateTableReadSessionResponse response, TableReadSessionBuilder builder)
storageStub - The storage stub for communicating with the MaxCompute servicetableId - The identifier of the table to read fromallocator - The buffer allocator for Arrow memory managementresponse - The response from the create table read session API callpublic String getId()
public org.apache.arrow.vector.types.pojo.Schema getArrowSchema()
This method converts the MaxCompute table schema to an Arrow schema, which is used for efficient data processing and columnar format support.
public TableSchema getTableSchema()
public List<InputSplit> getSplits()
Input splits are used to divide the data into chunks that can be processed in parallel. Each split represents a portion of the data that can be read independently using an Arrow reader.
public TableReaderBuilder createReaderBuilder(InputSplit split)
This method initializes an Arrow reader builder that can be configured with various options before creating the actual Arrow reader. The reader allows reading data from a specific input split in Arrow format.
split - The input split to read data frompublic void close()
close in interface AutoCloseableCopyright © 2026 Alibaba Cloud Computing. All rights reserved.