public class InstanceReadSession extends Object
This class represents a read session for a MaxCompute Instance result, allowing clients to read data in a distributed manner using input splits. Each session is associated with a specific instance and provides methods to get the session ID, Arrow schema, and input splits for parallel processing.
Example usage:
InstanceIdentifier instanceId = InstanceIdentifier.of("my_project", "my_instance_id");
try (InstanceReadSession session = client.createInstanceReadSession(instanceId)) {
List<InputSplit> splits = session.getSplits();
for (InputSplit split : splits) {
try (MaxInstanceArrowReader reader = session.createArrowReaderBuilder(split).build()) {
// Process data from reader
}
}
}
| Constructor and Description |
|---|
InstanceReadSession(StorageStub storageStub,
InstanceIdentifier instanceId,
org.apache.arrow.memory.BufferAllocator allocator,
CreateInstanceReadSessionResponse response)
Constructs a new InstanceReadSession with the provided parameters.
|
| Modifier and Type | Method and Description |
|---|---|
InstanceReaderBuilder |
createReaderBuilder()
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.
|
long |
getRecordCount() |
TableSchema |
getTableSchema() |
public InstanceReadSession(StorageStub storageStub, InstanceIdentifier instanceId, org.apache.arrow.memory.BufferAllocator allocator, CreateInstanceReadSessionResponse response)
storageStub - The storage stub for communicating with the MaxCompute serviceinstanceId - The identifier of the instance to read fromallocator - The buffer allocator for Arrow memory managementresponse - The response from the create instance 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 long getRecordCount()
public InstanceReaderBuilder createReaderBuilder()
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.
Copyright © 2026 Alibaba Cloud Computing. All rights reserved.