Class: HbaseAdapter::Table
- Inherits:
-
Object
- Object
- HbaseAdapter::Table
- Defined in:
- lib/hbase_adapter/table.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #[](row_key) ⇒ Object
- #columns ⇒ Object
- #compact! ⇒ Object
- #delete_row!(key, options = {}) ⇒ Object
- #disable! ⇒ Object
- #enable! ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(connection, table_name) ⇒ Table
constructor
A new instance of Table.
- #major_compact! ⇒ Object
- #mutate!(options = {}, &blk) ⇒ Object
- #name ⇒ Object
- #regions ⇒ Object
Constructor Details
#initialize(connection, table_name) ⇒ Table
Returns a new instance of Table.
8 9 10 11 |
# File 'lib/hbase_adapter/table.rb', line 8 def initialize(connection, table_name) @connection = connection @table_name = table_name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/hbase_adapter/table.rb', line 6 def connection @connection end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/hbase_adapter/table.rb', line 6 def table_name @table_name end |
Instance Method Details
#[](row_key) ⇒ Object
48 49 50 |
# File 'lib/hbase_adapter/table.rb', line 48 def [](row_key) HbaseAdapter::Row.new(connection, self, row_key) end |
#columns ⇒ Object
37 38 39 40 41 42 |
# File 'lib/hbase_adapter/table.rb', line 37 def columns connection.client.getColumnDescriptors(table_name).inject({}) do|hash, (col_name, col)| hash[col_name.to_sym] = HbaseAdapter::ColumnFamily.new(col) hash end end |
#compact! ⇒ Object
29 30 31 |
# File 'lib/hbase_adapter/table.rb', line 29 def compact! connection.client.compact(table_name) end |
#delete_row!(key, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/hbase_adapter/table.rb', line 52 def delete_row!(key, = {}) = [:timestamp] if .nil? connection.client.deleteAllRow(table_name, key.to_s) else connection.client.deleteAllRowTs(table_name, key.to_s, .to_i64) end end |
#disable! ⇒ Object
21 22 23 |
# File 'lib/hbase_adapter/table.rb', line 21 def disable! connection.client.disableTable(table_name) end |
#enable! ⇒ Object
17 18 19 |
# File 'lib/hbase_adapter/table.rb', line 17 def enable! connection.client.enableTable(table_name) end |
#enabled? ⇒ Boolean
25 26 27 |
# File 'lib/hbase_adapter/table.rb', line 25 def enabled? connection.client.isTableEnabled(table_name) end |
#major_compact! ⇒ Object
33 34 35 |
# File 'lib/hbase_adapter/table.rb', line 33 def major_compact! connection.client.majorCompact(table_name) end |
#mutate!(options = {}, &blk) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hbase_adapter/table.rb', line 62 def mutate!( = {}, &blk) = [:timestamp] ml = HbaseAdapter::MutationList.new(&blk) if .nil? connection.client.mutateRows(table_name, ml.to_thrift) else connection.client.mutateRowsTs(table_name, ml.to_thrift, .to_i64) end end |
#name ⇒ Object
13 14 15 |
# File 'lib/hbase_adapter/table.rb', line 13 def name table_name end |
#regions ⇒ Object
44 45 46 |
# File 'lib/hbase_adapter/table.rb', line 44 def regions connection.client.getTableRegions(table_name) end |