Sha256: d421911ebe6ebc1f21749d6eb961e1373894a3e95b7bd050af5aaa469eb928ea
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
# include path hack $:.push(File.dirname(__FILE__) + '/gen-rb') require 'thrift' require 'thrift/protocol/binaryprotocolaccelerated' require 'HqlService' module Hypertable class ThriftClient < ThriftGen::HqlService::Client def initialize(host, port = 38080, timeout_ms = 20000, do_open = true) socket = Thrift::Socket.new(host, port, timeout_ms) @transport = Thrift::FramedTransport.new(socket) protocol = Thrift::BinaryProtocolAccelerated.new(@transport) super(protocol) open() if do_open end def open() @transport.open() @do_close = true end def close() @transport.close() if @do_close end # buffered query def hql_query(hql) hql_exec(hql, false, false); end # more convenience methods def with_scanner(table, scan_spec) scanner = open_scanner(table, scan_spec) begin yield scanner ensure close_scanner(scanner) end end def with_mutator(table) mutator = open_mutator(table); begin yield mutator ensure close_mutator(mutator, 1) end end # scanner iterator def each_cell(scanner) cells = next_cells(scanner); while (cells.size > 0) cells.each {|cell| yield cell} cells = next_cells(scanner); end end end def self.with_thrift_client(host, port, timeout_ms = 20000) client = ThriftClient.new(host, port, timeout_ms) begin yield client ensure client.close() end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tylerkovacs-hyper_record-0.2.0 | lib/hypertable/thrift_client.rb |
tylerkovacs-hyper_record-0.2.1 | lib/hypertable/thrift_client.rb |