Sha256: c62aa3901752ec275e0354f98fca04d4e4aa3acb1e52c00a3963806476396bed
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
# include path hack $:.push(File.dirname(__FILE__) + '/gen-rb') require 'thrift' require 'thrift/protocol/binary_protocol_accelerated' require 'hql_service' 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 # 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 def each_cell_as_arrays(scanner) cells = next_cells_as_arrays(scanner); while (cells.size > 0) cells.each {|cell| yield cell} cells = next_cells_as_arrays(scanner); end end def each_row(scanner) row = next_row(scanner); while row yield row row = next_row(scanner); end end def each_row_as_arrays(scanner) row = next_row_as_arrays(scanner); while row yield row row = next_row_as_arrays(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tylerkovacs-hyper_record-0.2.5 | lib/hypertable/thrift_client.rb |