Class: HBase::Scanner

Inherits:
Object
  • Object
show all
Includes:
XmlDecoder
Defined in:
lib/mandy/ruby-hbase/scanner.rb

Instance Method Summary collapse

Methods included from XmlDecoder

#parse_row_result

Constructor Details

#initialize(table, scanner_uri) ⇒ Scanner

Returns a new instance of Scanner.



5
6
7
# File 'lib/mandy/ruby-hbase/scanner.rb', line 5

def initialize(table, scanner_uri)
  @table, @scanner_uri = table, scanner_uri
end

Instance Method Details

#closeObject



9
10
11
# File 'lib/mandy/ruby-hbase/scanner.rb', line 9

def close
  
end

#eachObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mandy/ruby-hbase/scanner.rb', line 17

def each
  parsed_uri = URI.parse(@scanner_uri)
  Net::HTTP.start(parsed_uri.host, parsed_uri.port) do |session|
    while true
      response = session.post(@scanner_uri, "")

      case response.code.to_i
        when 404
          # over
          break
        when 200
          # item
          yield *parse_row_result(response.body)
        else
          # error
          raise "Unexpected response code #{response.code}, body:\n#{response.body}"
      end
    end
  end
end

#nextObject



13
14
15
# File 'lib/mandy/ruby-hbase/scanner.rb', line 13

def next
  
end