DownloadSession
DownloadSession 用于从 MaxCompute 表下载数据,支持分块并行读取、列投影和 Arrow 格式。
获取实例
通过 TableTunnel.buildDownloadSession 构建(推荐):
DownloadSession session = tunnel.buildDownloadSession("my_project", "my_table")
.setPartitionSpec(new PartitionSpec("dt=20231001"))
.build();
DownloadSessionBuilder 配置
| 方法 | 参数类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
setProjectName(String) | String | 是 | - | 项目名称 |
setTableName(String) | String | 是 | - | 表名称 |
setSchemaName(String) | String | 否 | null | Schema 名称(三层模型) |
setPartitionSpec(PartitionSpec) | PartitionSpec | 否 | null | 分区表达式 |
setShardId(Long) | Long | 否 | null | 指定分片 ID |
setAsyncMode(boolean) | boolean | 否 | false | 启用异步初始化 |
setWaitAsyncBuild(boolean) | boolean | 否 | false | 阻塞等待异步会话就绪 |
setDownloadId(String) | String | 否 | null | 复用已有会话 ID |
异步 模式示例:
DownloadSessionBuilder builder = tunnel.buildDownloadSession("my_project", "my_table")
.setAsyncMode(true);
DownloadSession session = builder.build();
boolean ready = builder.wait(session, 5, 300); // 每5秒检查,最长5分钟