Class: HBaseRb::Client
- Inherits:
-
Object
- Object
- HBaseRb::Client
- Defined in:
- lib/hbaserb/client.rb
Instance Method Summary collapse
- #close ⇒ Object
- #create_table(tablename, *column_family_names) ⇒ Object
- #get_table(tablename) ⇒ Object
- #has_table?(name) ⇒ Boolean
-
#initialize(server, port = 9090) ⇒ Client
constructor
A new instance of Client.
- #table_names ⇒ Object
Constructor Details
#initialize(server, port = 9090) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 |
# File 'lib/hbaserb/client.rb', line 4 def initialize(server, port=9090) socket = Thrift::Socket.new(server, port) @transport = Thrift::BufferedTransport.new(socket) @transport.open protocol = Thrift::BinaryProtocol.new(@transport) @client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(protocol) end |
Instance Method Details
#close ⇒ Object
31 32 33 |
# File 'lib/hbaserb/client.rb', line 31 def close @transport.close end |
#create_table(tablename, *column_family_names) ⇒ Object
25 26 27 28 29 |
# File 'lib/hbaserb/client.rb', line 25 def create_table(tablename, *column_family_names) column_family_names.map! { |name| Apache::Hadoop::Hbase::Thrift::ColumnDescriptor.new(:name => name) } @client.createTable tablename, column_family_names get_table tablename end |
#get_table(tablename) ⇒ Object
20 21 22 23 |
# File 'lib/hbaserb/client.rb', line 20 def get_table(tablename) raise HBaseRb::NoSuchTable if not has_table? tablename HBaseRb::Table.new @client, tablename end |
#has_table?(name) ⇒ Boolean
16 17 18 |
# File 'lib/hbaserb/client.rb', line 16 def has_table?(name) table_names.include? name end |
#table_names ⇒ Object
12 13 14 |
# File 'lib/hbaserb/client.rb', line 12 def table_names @client.getTableNames end |