Class: ActiveRecordHiveAdapter::HiveConnector
- Inherits:
-
Object
- Object
- ActiveRecordHiveAdapter::HiveConnector
- Defined in:
- lib/activerecord_hive_adapter/hive_connector.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
Instance Method Summary collapse
- #close ⇒ Object
- #execute(sql) ⇒ Object
- #fetch_all ⇒ Object
- #get_schema ⇒ Object
-
#initialize(host, port, database, timeout) ⇒ HiveConnector
constructor
A new instance of HiveConnector.
- #open(database) ⇒ Object
- #open? ⇒ Boolean
- #reconnect! ⇒ Object
Constructor Details
#initialize(host, port, database, timeout) ⇒ HiveConnector
Returns a new instance of HiveConnector.
6 7 8 9 10 11 12 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 6 def initialize(host, port, database, timeout) socket = Thrift::Socket.new(host, port, timeout) @transport = Thrift::BufferedTransport.new(socket) protocol = Thrift::BinaryProtocol.new(@transport) @client = ThriftHive::Client.new(protocol) open(database) end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
4 5 6 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 4 def database @database end |
Instance Method Details
#close ⇒ Object
24 25 26 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 24 def close @transport.close rescue IOError end |
#execute(sql) ⇒ Object
32 33 34 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 32 def execute(sql) @client.execute(sql) end |
#fetch_all ⇒ Object
36 37 38 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 36 def fetch_all @client.fetchAll() end |
#get_schema ⇒ Object
40 41 42 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 40 def get_schema @client.getSchema() end |
#open(database) ⇒ Object
14 15 16 17 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 14 def open(database) @transport.open self.database = database end |
#open? ⇒ Boolean
28 29 30 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 28 def open? @transport.open? end |
#reconnect! ⇒ Object
19 20 21 22 |
# File 'lib/activerecord_hive_adapter/hive_connector.rb', line 19 def reconnect! close open(self.database) end |