class TreasureData::Table

Attributes

count[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

database_name[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

db_name[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

estimated_storage_size[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

include_v[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

name[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

schema[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

table_name[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

type[R]

@!attribute [r] type @!attribute [r] db_name @!attribute [r] table_name @!attribute [r] schema @!attribute [r] count @!attribute [r] estimated_storage_size

Public Class Methods

new(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, include_v=false) click to toggle source

@param [TreasureData::Client] client @param [String] db_name @param [String] table_name @param [String] type @param [String] schema @param [Fixnum] count @param [String] created_at @param [String] updated_at @param [Fixnum] estimated_storage_size @param [String] last_import @param [String] last_log_timestamp @param [Fixnum, String] expire_days

Calls superclass method TreasureData::Model::new
# File lib/td/client/model.rb, line 156
def 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, include_v=false)
  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 = last_log_timestamp
  @expire_days = expire_days
  @include_v = include_v
end

Public Instance Methods

created_at() click to toggle source

@return [Time, nil]

# File lib/td/client/model.rb, line 190
def created_at
  @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil
end
database() click to toggle source

@return [Database]

# File lib/td/client/model.rb, line 215
def database
  update_database! unless @database
  @database
end
database=(database) click to toggle source

@param [String] database

# File lib/td/client/model.rb, line 185
def database=(database)
  @database = database if database.instance_of?(Database)
end
delete() click to toggle source

@return [Symbol]

# File lib/td/client/model.rb, line 232
def delete
  @client.delete_table(@db_name, @table_name)
end
estimated_storage_size_string() click to toggle source

@return [String]

# File lib/td/client/model.rb, line 258
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() click to toggle source

@return [Fixnum, nil]

# File lib/td/client/model.rb, line 210
def expire_days
  @expire_days ? @expire_days.to_i : nil
end
export(storage_type, opts={}) click to toggle source

@param [String] storage_type @param [Hash] opts @return [Job]

# File lib/td/client/model.rb, line 253
def export(storage_type, opts={})
  @client.export(@db_name, @table_name, storage_type, opts)
end
identifier() click to toggle source

@return [String]

# File lib/td/client/model.rb, line 227
def identifier
  "#{@db_name}.#{@table_name}"
end
import(format, stream, size) click to toggle source

@param [String] format @param [String, StringIO] stream @param [Fixnum] size @return [Float]

# File lib/td/client/model.rb, line 246
def import(format, stream, size)
  @client.import(@db_name, @table_name, format, stream, size)
end
inspect() click to toggle source

@return [String]

# File lib/td/client/model.rb, line 275
def inspect
  %[#<%s:%#0#{1.size*2}x @db_name="%s" @table_name="%s">] %
  [self.class.name, self.__id__*2, @db_name, @table_name]
end
last_import() click to toggle source

@return [Time, nil]

# File lib/td/client/model.rb, line 200
def last_import
  @last_import && !@last_import.empty? ? Time.parse(@last_import) : nil
end
last_log_timestamp() click to toggle source

@return [Time, nil]

# File lib/td/client/model.rb, line 205
def last_log_timestamp
  @last_log_timestamp && !@last_log_timestamp.empty? ? Time.parse(@last_log_timestamp) : nil
end
permission() click to toggle source

get the database's permission as if they were the table's @return [String]

# File lib/td/client/model.rb, line 222
def permission
  database.permission
end
tail(count) click to toggle source

@param [Fixnum] count @return [Array, nil]

# File lib/td/client/model.rb, line 238
def tail(count)
  @client.tail(@db_name, @table_name, count)
end
update_database!() click to toggle source
# File lib/td/client/model.rb, line 270
def update_database!
  @database = @client.database(@db_name)
end
updated_at() click to toggle source

@return [Time, nil]

# File lib/td/client/model.rb, line 195
def updated_at
  @updated_at && !@updated_at.empty? ? Time.parse(@updated_at) : nil
end