public class TableReadSessionBuilder extends Object
TableReadSessionBuilder for the MaxCompute Storage API.
This builder allows configuration of various read session settings including:
Example usage:
TableIdentifier tableId = TableIdentifier.of("my_project", "my_table");
TableReadSessionBuilder builder = client.createReadSessionBuilder(tableId)
.withRequiredDataColumns(Arrays.asList("col1", "col2"))
.withRequiredPartitions(Arrays.asList("pt='20250101'"))
.withSplitOptions(SplitOptions.newBuilder().build());
TableReadSession session = builder.build();
| Constructor and Description |
|---|
TableReadSessionBuilder(StorageStub storageStub,
org.apache.arrow.memory.BufferAllocator allocator,
TableIdentifier table)
Constructs a new TableReadSessionBuilder with the provided parameters.
|
| Modifier and Type | Method and Description |
|---|---|
TableReadSession |
build()
Builds and returns a new TableReadSession instance with the configured settings.
|
TableReadSessionBuilder |
enableFilterFallback(boolean enable)
Sets whether to fallback to no filter if specific filtering fails.
|
SplitOptions |
getSplitOptions() |
TableIdentifier |
getTable()
Gets the table identifier for this builder.
|
TableReadSessionBuilder |
withArrowOptions(ArrowOptions arrowOptions)
Sets the Arrow options for data processing.
|
TableReadSessionBuilder |
withBucketIds(List<Integer> requiredBucketIds)
Sets the required bucket IDs to read from the table.
|
TableReadSessionBuilder |
withColumns(List<String> requiredDataColumns)
Sets the required data columns to read from the table.
|
TableReadSessionBuilder |
withFilter(String filterPredicate)
Sets the filter for server-side data filtering.
|
TableReadSessionBuilder |
withIncrementalReadEnabled(boolean incrementalRead)
Sets whether to enable incremental read mode for the session.
|
TableReadSessionBuilder |
withIncrementalReadOptions(IncrementalReadOptions incrementalReadOptions)
Sets the incremental read options for the read session.
|
TableReadSessionBuilder |
withMaxFilesPerSplit(int maxFilesPerSplit)
Sets the maximum number of files per split for reading.
|
TableReadSessionBuilder |
withPartitionColumns(List<String> requiredPartitionColumns)
Sets the required partition columns to read from the table.
|
TableReadSessionBuilder |
withPartitions(List<PartitionSpec> requiredPartitions)
Sets the required partitions to read from the table.
|
TableReadSessionBuilder |
withSessionId(String sessionId) |
TableReadSessionBuilder |
withSessionReadyTimeout(long timeoutSeconds)
Sets the maximum time to wait for the session to be ready.
|
TableReadSessionBuilder |
withSplitOptions(SplitOptions splitOptions)
Sets the split options for parallel processing.
|
public TableReadSessionBuilder(StorageStub storageStub, org.apache.arrow.memory.BufferAllocator allocator, TableIdentifier table)
storageStub - The storage stub for communicating with the MaxCompute serviceallocator - The buffer allocator for Arrow memory managementtable - The identifier of the table to read fromIllegalArgumentException - if table is nullpublic TableReadSessionBuilder withSessionId(String sessionId)
public TableReadSessionBuilder withColumns(List<String> requiredDataColumns)
By specifying only the columns needed, network traffic and processing overhead can be reduced.
requiredDataColumns - The list of data column names to readpublic TableReadSessionBuilder withPartitionColumns(List<String> requiredPartitionColumns)
requiredPartitionColumns - The list of partition column names to readpublic TableReadSessionBuilder withPartitions(List<PartitionSpec> requiredPartitions)
This allows filtering data by specific partition values, reducing the amount of data that needs to be processed.
requiredPartitions - The list of partition specifications to read (e.g., "pt='20250101'")public TableReadSessionBuilder withBucketIds(List<Integer> requiredBucketIds)
This allows filtering data by specific bucket IDs, which is useful for clustered tables.
requiredBucketIds - The list of bucket IDs to readpublic TableReadSessionBuilder withSplitOptions(SplitOptions splitOptions)
These options control how the data is split into chunks for parallel processing, including split size and other parameters.
splitOptions - The split options configurationpublic TableReadSessionBuilder withArrowOptions(ArrowOptions arrowOptions)
These options control Arrow-specific behavior such as memory allocation and serialization settings.
arrowOptions - The Arrow options configurationpublic TableReadSessionBuilder enableFilterFallback(boolean enable)
enable - Whether to fallback to no filterpublic TableReadSessionBuilder withFilter(String filterPredicate)
This allows filtering data at the server side, reducing the amount of data transferred over the network.
filterPredicate - The filter predicate expressionpublic TableReadSessionBuilder withMaxFilesPerSplit(int maxFilesPerSplit)
maxFilesPerSplit - The maximum number of files per splitpublic TableReadSessionBuilder withIncrementalReadOptions(IncrementalReadOptions incrementalReadOptions)
incrementalReadOptions - The incremental read options configurationpublic TableReadSessionBuilder withIncrementalReadEnabled(boolean incrementalRead)
incrementalRead - Whether to enable incremental read modepublic TableReadSessionBuilder withSessionReadyTimeout(long timeoutSeconds)
When creating a session, it may take some time for the session to transition from INIT to NORMAL state. This method controls the maximum time to wait for the session to become ready.
timeoutSeconds - The maximum time to wait in seconds (default is 3600 seconds / 1 hour)public TableReadSession build()
This method makes an API call to the MaxCompute service to create a read session with the specified configuration. The session can then be used to read data from the table in a distributed manner.
If the session is in INIT state, this method will poll the session status
until it becomes NORMAL or the timeout is reached. The default wait time is
3600 seconds (1 hour), but can be customized using
withSessionReadyTimeout(long).
ClientException - if the session creation fails or times outMaxStorageException - if the session cannot be created due to server-side errorspublic TableIdentifier getTable()
public SplitOptions getSplitOptions()
Copyright © 2026 Alibaba Cloud Computing. All rights reserved.