Class: Aliyun::Odps::DownloadSession

Inherits:
Struct::Base show all
Defined in:
lib/aliyun/odps/tunnel/download_session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct::Base

#initialize, property, #update_attrs

Constructor Details

This class inherits a constructor from Aliyun::Odps::Struct::Base

Instance Attribute Details

#clientClient

Returns:



8
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 8

property :client, Client, required: true

#download_idString

Returns:

  • (String)


10
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 10

property :download_id, String, required: true

#initiatedDateTime

Returns:

  • (DateTime)


16
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 16

property :initiated, DateTime

#ownerString

Returns:

  • (String)


15
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 15

property :owner, String

#partition_specString

Returns:

  • (String)


12
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 12

property :partition_spec, String

#projectProject

Returns:



7
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 7

property :project, Project, required: true

#record_countInteger

Returns:

  • (Integer)


13
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 13

property :record_count, Integer

#schemaHash

Returns:

  • (Hash)


17
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 17

property :schema, Hash

#statusString

Returns:

  • (String)


14
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 14

property :status, String

#table_nameString

Returns:

  • (String)


11
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 11

property :table_name, String, required: true

Instance Method Details

#download(start, count, columns, encoding = 'raw') ⇒ Raw Data

Download data

Parameters:

  • start (String)

    specify start download row number

  • count (String)

    specify download row count

  • columns (Array)

    specify columns need download in array

  • encoding (String) (defaults to: 'raw')

    specify the data compression format, supported value: raw, deflate

Returns:

  • (Raw Data)

    return the raw data from ODPS

See Also:



29
30
31
32
33
34
35
36
37
# File 'lib/aliyun/odps/tunnel/download_session.rb', line 29

def download(start, count, columns, encoding = 'raw')
  path = "/projects/#{project.name}/tables/#{table_name}"

  query = build_download_query(start, count, columns)
  headers = build_download_headers(encoding)

  resp = client.get(path, query: query, headers: headers)
  protobufed2records(resp.parsed_response, resp.headers['content-encoding'], columns)
end