Class: HBase::Response::RowResponse

Inherits:
BasicResponse show all
Defined in:
lib/hbase/response/row_response.rb

Instance Method Summary collapse

Methods inherited from BasicResponse

#initialize, #parse

Constructor Details

This class inherits a constructor from HBase::Response::BasicResponse

Instance Method Details

#parse_content(raw_data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hbase/response/row_response.rb', line 4

def parse_content(raw_data)
  doc = REXML::Document.new(raw_data)
  row = doc.elements["row"]
  rname = row.elements["name"].text.strip.unpack("m").first
  columns = []
  # Need fix in the server side
  count = row.elements["count"].text.strip.to_i rescue 0
  row.elements["columns"].elements.each("column") do |col|
    name = col.elements["name"].text.strip.unpack("m").first
    value = col.elements["value"].text.strip.unpack("m").first rescue nil
    timestamp = col.elements["timestamp"].text.strip.to_i
    columns << Model::Column.new(:name => name,
                                 :value => value,
                                 :timestamp => timestamp)
  end
  Model::Row.new(:name => rname, :total_count => count, :columns => columns)
end