This topic describes the DownloadSession interface that is used to download MaxCompute table data.

Definition

public class DownloadSession {
    DownloadSession(Configuration conf, String projectName, String tableName,
                    String partitionSpec) throws TunnelException
    DownloadSession(Configuration conf, String projectName, String tableName,
                    String partitionSpec, String downloadId) throws TunnelException
    public String getId()
    public long getRecordCount()
    public TableSchema getSchema()
    public TableTunnel.DownloadStatus getStatus()
    public RecordReader openRecordReader(long start, long count)
    public RecordReader openRecordReader(long start, long count, boolean compress)
}

Description

  • Lifecycle: This interface is used from the time when the data download instance is created to the time when the data is downloaded.
  • Create a download instance: You can create a data download instance by calling a constructor or using TableTunnel.
    • The request mode is synchronous.
    • The server creates a session for this download instance and generates a unique ID for this instance. The instance ID can be obtained by calling getId on the client.
    • The operation has a high overhead. The server creates indexes for data files. If multiple data files exist, the operation takes a long time.
    • The server returns the total number of data records. You can start concurrent downloads based on the number of data records.
  • Download data:
    • The request mode is asynchronous.
    • You can call openRecordReader to generate a RecordReader instance. The start parameter indicates the start position of the downloaded data record. The value of the start parameter is greater than or equal to 0. The count parameter indicates the number of downloaded data records. The value of the count parameter is greater than 0.
  • View the download status:
    • The request mode is synchronous.
    • You can call getStatus to query the status of the data download instance.
  • The instance can be in one of the following states:
    • UNKNOWN: the initial value when the server creates a session.
    • NORMAL: The data download instance is created.
    • CLOSED: The data download is complete.
    • EXPIRED: The download session times out.