Module: HBase::Operation::RowOperation
- Included in:
- Client
- Defined in:
- lib/hbase/operation/row_operation.rb
Instance Method Summary collapse
- #create_row(table_name, name, timestamp = nil, columns = nil) ⇒ Object
- #delete_row(table_name, name, timestamp = nil, columns = nil) ⇒ Object
- #row_timestamps(table_name, name) ⇒ Object
- #show_row(table_name, name, timestamp = nil, columns = nil, version = nil) ⇒ Object
Instance Method Details
#create_row(table_name, name, timestamp = nil, columns = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hbase/operation/row_operation.rb', line 25 def create_row(table_name, name, = nil, columns = nil) begin request = Request::RowRequest.new(table_name, name, ) data = [] if columns.instance_of? Array data = columns elsif columns.instance_of? Hash data = [columns] else raise StandardError, "Only Array or Hash data accepted" end xml_data ="<?xml version='1.0' encoding='UTF-8'?><columns>" data.each do |d| xml_data << "<column><name>#{d[:name]}</name>" xml_data << "<value>#{[d[:value]].pack("m") rescue ''}</value></column>" end xml_data << "</columns>" Response::RowResponse.new(post(request.create, xml_data)) rescue Net::ProtocolError => e if e.to_s.include?("Table") raise TableNotFoundError, "Table '#{table_name}' Not Found" elsif e.to_s.include?("Row") raise RowNotFoundError, "Row '#{name}' Not Found" end end end |
#delete_row(table_name, name, timestamp = nil, columns = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hbase/operation/row_operation.rb', line 53 def delete_row(table_name, name, = nil, columns = nil) begin request = Request::RowRequest.new(table_name, name, ) Response::RowResponse.new(delete(request.delete(columns))) rescue Net::ProtocolError => e if e.to_s.include?("Table") raise TableNotFoundError, "Table '#{table_name}' Not Found" elsif e.to_s.include?("Row") raise RowNotFoundError, "Row '#{name}' Not Found" end end end |
#row_timestamps(table_name, name) ⇒ Object
4 5 6 |
# File 'lib/hbase/operation/row_operation.rb', line 4 def (table_name, name) raise NotImplementedError, "Currently not supported in native hbase client" end |
#show_row(table_name, name, timestamp = nil, columns = nil, version = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hbase/operation/row_operation.rb', line 8 def show_row(table_name, name, = nil, columns = nil, version = nil) begin request = Request::RowRequest.new(table_name, name, ) row = Response::RowResponse.new(get(request.show(columns, version))).parse row.table_name = table_name row.name = name row. = row rescue Net::ProtocolError => e if e.to_s.include?("Table") raise TableNotFoundError, "Table '#{table_name}' Not Found" elsif e.to_s.include?("Row") raise RowNotFoundError, "Row '#{name}' Not Found" end end end |