Class: Dag::TableCollection
- Includes:
- Client::ClusterValidation, Enumerable
- Defined in:
- lib/dag/client/model/table_collection.rb
Constant Summary
Constants included from Client::ClusterValidation
Client::ClusterValidation::VALID_WHERE_KEYS
Instance Attribute Summary collapse
-
#cluster_name ⇒ Object
readonly
Returns the value of attribute cluster_name.
Attributes inherited from Model
Instance Method Summary collapse
-
#create(table: '', format: nil, schema: nil, comment: nil) ⇒ Object
parameters == *
table
- table name *format
- ‘csv’ or ‘tsv’ or ‘json’ or ‘json_agent’ *schema/tt> - schema * <tt>comment
- comment. - #each ⇒ Object
-
#initialize(api, cluster_name, db_name) ⇒ TableCollection
constructor
A new instance of TableCollection.
Methods included from Client::ClusterValidation
#cluster_norm?, #cluster_norm_or_ptfailed?, #cluster_restart_status?, #cluster_status, #valid_cluster_info_list_status?, #valid_cluster_status?, #validate_cluster, #validate_cluster_param_keys
Constructor Details
#initialize(api, cluster_name, db_name) ⇒ TableCollection
Returns a new instance of TableCollection.
8 9 10 11 12 13 |
# File 'lib/dag/client/model/table_collection.rb', line 8 def initialize(api, cluster_name, db_name) super(api) @cluster_name = cluster_name @db_name = db_name end |
Instance Attribute Details
#cluster_name ⇒ Object (readonly)
Returns the value of attribute cluster_name.
6 7 8 |
# File 'lib/dag/client/model/table_collection.rb', line 6 def cluster_name @cluster_name end |
Instance Method Details
#create(table: '', format: nil, schema: nil, comment: nil) ⇒ Object
parameters ==
-
table
- table name -
format
- ‘csv’ or ‘tsv’ or ‘json’ or ‘json_agent’ -
<tt>schema/tt> - schema
-
comment
- comment
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dag/client/model/table_collection.rb', line 34 def create(table: '', format: nil, schema: nil, comment: nil) params = { table: table, schema: schema, create_api: true } params.merge!({ format: format }) if format params.merge!({ comment: comment }) if comment @api.create_table(@cluster_name, @db_name, params: params) table_info = @api.table(@cluster_name, @db_name, table) Dag::Table.new(@api, @cluster_name, @db_name, params: table_info) end |
#each ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dag/client/model/table_collection.rb', line 15 def each marker = nil truncated = false begin table_info_list = @api.table_info_list(@cluster_name, @db_name, (marker)) table_info_list['tables'].each do |table_info| yield Dag::Table.new(@api, @cluster_name, @db_name, params: table_info) end truncated = table_info_list['isTruncated'] marker = table_info_list['nextMarker'] end while truncated end |