Sha256: dd47014b3a029e59831dca59908fde0ebd2c34e9096c741291e3d9b77802f4e5

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

Stored size: 819 Bytes

Contents

module HBase
  module Response
    class MetaResponse < BasicResponse
      attr_reader :method

      def initialize(raw_data, method)
        @method = method
        super(raw_data)
      end

      def parse_content(raw_data)
        case @method
        when :list_tables
          if raw_data.blank? || raw_data == "null" # "null" from json
            puts "There are no available tables in the HBase"
            return []
          end

          tables = []
          doc = JSON.parse(raw_data)

          doc["table"].each do |table|
            name = table["name"].strip rescue nil
            t = Model::TableDescriptor.new(:name => name)
            tables << t
          end

          tables
        else
            puts "method '#{@method}' not supported yet"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hbase-ruby-1.1.3 lib/hbase/response/meta_response.rb
hbase-ruby-1.1.2 lib/hbase/response/meta_response.rb
hbase-ruby-1.1.1 lib/hbase/response/meta_response.rb
hbase-ruby-1.1.0 lib/hbase/response/meta_response.rb