Class: HipsterSqlToHbase::ResultTree

Inherits:
Hash
  • Object
show all
Defined in:
lib/hipster_sql_to_hbase.rb

Overview

This class provides the initial parsed result with the methods necessary to be transformed into HBase (Thrift) or JSON, as well as to be executed as a Thrift method.

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ ResultTree

Returns a new instance of ResultTree.



49
50
51
# File 'lib/hipster_sql_to_hbase.rb', line 49

def initialize(hash)
  hash.each { |k,v| self[k] = v }
end

Instance Method Details

#execute(host = nil, port = nil) ⇒ Object

Executes itself as an HBase (Thrift) method. Short for running .to_hbase and then sending the result to the executor.

example:

my_call = HipsterSqlToHbase::ResultTree.new({...})
my_call.execute

if no arguments are passed the executor will use any previously set host and port.



80
81
82
# File 'lib/hipster_sql_to_hbase.rb', line 80

def execute(host=nil,port=nil)
  self.to_hbase.execute(host,port)
end

#to_hbaseObject

Transforms itself into an HBase (Thrift) method.

example:

rt = HipsterSqlToHbase::ResultTree.new({...})
rt.to_hbase #=> {:method => 'mutateRow', :arguments => {...}}


58
59
60
# File 'lib/hipster_sql_to_hbase.rb', line 58

def to_hbase
  HipsterSqlToHbase::ResultTreeToHbaseConverter.new().convert self
end

#to_jsonObject

Transforms itself into a JSON object.

example:

user = HipsterSqlToHbase::ResultTree.new({...})
user.to_json #=> {:user => {:user_name => 'bob', :pass => 'bob1234', ...}}


67
68
69
# File 'lib/hipster_sql_to_hbase.rb', line 67

def to_json
  HipsterSqlToHbase::ResultTreeToJsonConverter.new().convert self
end