Class: TreasureData::Table
Instance Attribute Summary collapse
- #count ⇒ Object readonly
- #db_name ⇒ Object (also: #database_name) readonly
- #estimated_storage_size ⇒ Object readonly
- #primary_key ⇒ Object readonly
-
#primary_key_type ⇒ Object
readonly
Returns the value of attribute primary_key_type.
- #schema ⇒ Object readonly
- #table_name ⇒ Object (also: #name) readonly
- #type ⇒ Object readonly
Attributes inherited from Model
Instance Method Summary collapse
- #created_at ⇒ Time?
- #database ⇒ Database
- #database=(database) ⇒ Object
- #delete ⇒ Symbol
- #estimated_storage_size_string ⇒ String
- #expire_days ⇒ Fixnum?
- #export(storage_type, opts = {}) ⇒ Job
- #identifier ⇒ String
- #import(format, stream, size) ⇒ Float
-
#initialize(client, db_name, table_name, type, schema, count, created_at = nil, updated_at = nil, estimated_storage_size = nil, last_import = nil, last_log_timestamp = nil, expire_days = nil, primary_key = nil, primary_key_type = nil) ⇒ Table
constructor
A new instance of Table.
- #last_import ⇒ Time?
- #last_log_timestamp ⇒ Time?
-
#permission ⇒ String
get the database’s permission as if they were the table’s.
- #tail(count, to = nil, from = nil) ⇒ Array?
- #update_database! ⇒ Object
- #updated_at ⇒ Time?
Constructor Details
#initialize(client, db_name, table_name, type, schema, count, created_at = nil, updated_at = nil, estimated_storage_size = nil, last_import = nil, last_log_timestamp = nil, expire_days = nil, primary_key = nil, primary_key_type = nil) ⇒ Table
Returns a new instance of Table.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/td/client/model.rb', line 164 def initialize(client, db_name, table_name, type, schema, count, created_at=nil, updated_at=nil, estimated_storage_size=nil, last_import=nil, =nil, expire_days=nil, primary_key=nil, primary_key_type=nil) super(client) @database = nil @db_name = db_name @table_name = table_name @type = type @schema = schema @count = count @created_at = created_at @updated_at = updated_at @estimated_storage_size = estimated_storage_size @last_import = last_import @last_log_timestamp = @expire_days = expire_days @primary_key = primary_key @primary_key_type = primary_key_type end |
Instance Attribute Details
#count ⇒ Object (readonly)
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#db_name ⇒ Object (readonly) Also known as: database_name
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#estimated_storage_size ⇒ Object (readonly)
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#primary_key ⇒ Object (readonly)
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#primary_key_type ⇒ Object (readonly)
Returns the value of attribute primary_key_type.
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#schema ⇒ Object (readonly)
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#table_name ⇒ Object (readonly) Also known as: name
190 |
# File 'lib/td/client/model.rb', line 190 attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size, :primary_key, :primary_key_type |
#type ⇒ Object (readonly)
190 191 192 |
# File 'lib/td/client/model.rb', line 190 def type @type end |
Instance Method Details
#created_at ⇒ Time?
201 202 203 |
# File 'lib/td/client/model.rb', line 201 def created_at @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil end |
#database ⇒ Database
226 227 228 229 |
# File 'lib/td/client/model.rb', line 226 def database update_database! unless @database @database end |
#database=(database) ⇒ Object
196 197 198 |
# File 'lib/td/client/model.rb', line 196 def database=(database) @database = database if database.instance_of?(Database) end |
#delete ⇒ Symbol
243 244 245 |
# File 'lib/td/client/model.rb', line 243 def delete @client.delete_table(@db_name, @table_name) end |
#estimated_storage_size_string ⇒ String
271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/td/client/model.rb', line 271 def estimated_storage_size_string if @estimated_storage_size <= 1024*1024 return "0.0 GB" elsif @estimated_storage_size <= 60*1024*1024 return "0.01 GB" elsif @estimated_storage_size <= 60*1024*1024*1024 "%.1f GB" % (@estimated_storage_size.to_f / (1024*1024*1024)) else "%d GB" % (@estimated_storage_size.to_f / (1024*1024*1024)).to_i end end |
#expire_days ⇒ Fixnum?
221 222 223 |
# File 'lib/td/client/model.rb', line 221 def expire_days @expire_days ? @expire_days.to_i : nil end |
#export(storage_type, opts = {}) ⇒ Job
266 267 268 |
# File 'lib/td/client/model.rb', line 266 def export(storage_type, opts={}) @client.export(@db_name, @table_name, storage_type, opts) end |
#identifier ⇒ String
238 239 240 |
# File 'lib/td/client/model.rb', line 238 def identifier "#{@db_name}.#{@table_name}" end |
#import(format, stream, size) ⇒ Float
259 260 261 |
# File 'lib/td/client/model.rb', line 259 def import(format, stream, size) @client.import(@db_name, @table_name, format, stream, size) end |
#last_import ⇒ Time?
211 212 213 |
# File 'lib/td/client/model.rb', line 211 def last_import @last_import && !@last_import.empty? ? Time.parse(@last_import) : nil end |
#last_log_timestamp ⇒ Time?
216 217 218 |
# File 'lib/td/client/model.rb', line 216 def @last_log_timestamp && !@last_log_timestamp.empty? ? Time.parse(@last_log_timestamp) : nil end |
#permission ⇒ String
get the database’s permission as if they were the table’s
233 234 235 |
# File 'lib/td/client/model.rb', line 233 def database. end |
#tail(count, to = nil, from = nil) ⇒ Array?
251 252 253 |
# File 'lib/td/client/model.rb', line 251 def tail(count, to=nil, from=nil) @client.tail(@db_name, @table_name, count, to, from) end |
#update_database! ⇒ Object
283 284 285 |
# File 'lib/td/client/model.rb', line 283 def update_database! @database = @client.database(@db_name) end |
#updated_at ⇒ Time?
206 207 208 |
# File 'lib/td/client/model.rb', line 206 def updated_at @updated_at && !@updated_at.empty? ? Time.parse(@updated_at) : nil end |