Class: Aliyun::Odps::UploadSession
Instance Attribute Summary collapse
Instance Method Summary
collapse
#initialize, property, #update_attrs
Instance Attribute Details
#blocks ⇒ :Array
17
18
19
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 17
property :blocks, :Array, init_with: ->(value) do
value.map { |v| UploadBlock.new(v) }
end
|
#client ⇒ :Client
8
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 8
property :client, :Client, required: true
|
#initiated ⇒ :DateTime
15
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 15
property :initiated, :DateTime
|
#owner ⇒ :String
14
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 14
property :owner, :String
|
#partition_spec ⇒ :String
12
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 12
property :partition_spec, :String
|
#project ⇒ :Project
7
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 7
property :project, :Project, required: true
|
#schema ⇒ :Hash
16
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 16
property :schema, :Hash
|
#status ⇒ :String
13
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 13
property :status, :String
|
#table_name ⇒ :String
11
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 11
property :table_name, :String, required: true
|
#upload_id ⇒ :String
10
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 10
property :upload_id, :String, required: true
|
Instance Method Details
#complete ⇒ true
Complete the upload session
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 76
def complete
path = "/projects/#{project.name}/tables/#{table_name}"
query = { uploadid: upload_id }
query.merge!(partition: partition_spec) if partition_spec
= { 'x-odps-tunnel-version' => TableTunnels::TUNNEL_VERSION }
!!client.post(path, query: query, headers: )
end
|
66
67
68
69
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 66
def list_blocks
reload
blocks
end
|
reload this upload session
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 49
def reload
path = "/projects/#{project.name}/tables/#{table_name}"
query = { uploadid: upload_id }
query.merge!(partition: partition_spec) if partition_spec
resp = client.get(path, query: query)
result = resp.parsed_response
attrs = result.is_a?(String) ? JSON.parse(result) : result
update_attrs(attrs)
end
|
#upload(block_id, record_values, encoding = 'raw') ⇒ true
Upload data with block id
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/aliyun/odps/tunnel/upload_session.rb', line 32
def upload(block_id, record_values, encoding = 'raw')
path = "/projects/#{project.name}/tables/#{table_name}"
query = { blockid: block_id, uploadid: upload_id }
query[:partition] = partition_spec if partition_spec
= (encoding)
body = generate_upload_body(record_values, encoding)
!!client.put(path, query: query, headers: , body: body)
end
|