Class: HBase::Response::TableResponse

Inherits:
BasicResponse show all
Defined in:
lib/hbase/response/table_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
21
22
23
24
25
# File 'lib/hbase/response/table_response.rb', line 4

def parse_content(raw_data)
  doc = REXML::Document.new(raw_data)
  table = doc.elements["table"]

  name = table.elements["name"].text.strip
  column_families = []
  table.elements["columnfamilies"].elements.each("columnfamily") do |columnfamily|
    colname = columnfamily.elements["name"].text.strip
    compression = columnfamily.elements["compression"].text.strip
    bloomfilter = columnfamily.elements["bloomfilter"].text.strip.to_b
    max_versions = columnfamily.elements["max-versions"].text.strip.to_i
    maximum_cell_size = columnfamily.elements["max-length"].text.strip.to_i

    column_descriptor = Model::ColumnDescriptor.new(:name => colname,
                                                    :compression => Model::CompressionType.to_compression_type(compression),
                                                    :bloomfilter => bloomfilter,
                                                    :max_versions => max_versions,
                                                    :maximum_cell_size => maximum_cell_size)
    column_families << column_descriptor
  end
  Model::TableDescriptor.new(:name => name, :column_families => column_families)
end