Class: Hypertable::ThriftClient

Inherits:
Hypertable::ThriftGen::HqlService::Client show all
Defined in:
lib/hypertable/thrift_client.rb

Instance Method Summary collapse

Methods inherited from Hypertable::ThriftGen::HqlService::Client

#hql_exec, #hql_exec2, #hql_query, #hql_query2, #recv_hql_exec, #recv_hql_exec2, #recv_hql_query, #recv_hql_query2, #send_hql_exec, #send_hql_exec2, #send_hql_query, #send_hql_query2

Methods inherited from Hypertable::ThriftGen::ClientService::Client

#close_mutator, #close_namespace, #close_scanner, #create_namespace, #create_table, #drop_namespace, #drop_table, #exists_namespace, #exists_table, #flush_mutator, #get_cell, #get_cells, #get_cells_as_arrays, #get_cells_serialized, #get_listing, #get_row, #get_row_as_arrays, #get_row_serialized, #get_schema, #get_schema_str, #get_table_id, #get_table_splits, #get_tables, #next_cells, #next_cells_as_arrays, #next_cells_serialized, #next_row, #next_row_as_arrays, #next_row_serialized, #offer_cell, #offer_cell_as_array, #offer_cells, #offer_cells_as_arrays, #open_mutator, #open_namespace, #open_scanner, #recv_close_mutator, #recv_close_namespace, #recv_close_scanner, #recv_create_namespace, #recv_create_table, #recv_drop_namespace, #recv_drop_table, #recv_exists_namespace, #recv_exists_table, #recv_flush_mutator, #recv_get_cell, #recv_get_cells, #recv_get_cells_as_arrays, #recv_get_cells_serialized, #recv_get_listing, #recv_get_row, #recv_get_row_as_arrays, #recv_get_row_serialized, #recv_get_schema, #recv_get_schema_str, #recv_get_table_id, #recv_get_table_splits, #recv_get_tables, #recv_next_cells, #recv_next_cells_as_arrays, #recv_next_cells_serialized, #recv_next_row, #recv_next_row_as_arrays, #recv_next_row_serialized, #recv_offer_cell, #recv_offer_cell_as_array, #recv_offer_cells, #recv_offer_cells_as_arrays, #recv_open_mutator, #recv_open_namespace, #recv_open_scanner, #recv_refresh_shared_mutator, #recv_rename_table, #recv_set_cell, #recv_set_cell_as_array, #recv_set_cells, #recv_set_cells_as_arrays, #recv_set_cells_serialized, #refresh_shared_mutator, #rename_table, #send_close_mutator, #send_close_namespace, #send_close_scanner, #send_create_namespace, #send_create_table, #send_drop_namespace, #send_drop_table, #send_exists_namespace, #send_exists_table, #send_flush_mutator, #send_get_cell, #send_get_cells, #send_get_cells_as_arrays, #send_get_cells_serialized, #send_get_listing, #send_get_row, #send_get_row_as_arrays, #send_get_row_serialized, #send_get_schema, #send_get_schema_str, #send_get_table_id, #send_get_table_splits, #send_get_tables, #send_next_cells, #send_next_cells_as_arrays, #send_next_cells_serialized, #send_next_row, #send_next_row_as_arrays, #send_next_row_serialized, #send_offer_cell, #send_offer_cell_as_array, #send_offer_cells, #send_offer_cells_as_arrays, #send_open_mutator, #send_open_namespace, #send_open_scanner, #send_refresh_shared_mutator, #send_rename_table, #send_set_cell, #send_set_cell_as_array, #send_set_cells, #send_set_cells_as_arrays, #send_set_cells_serialized, #set_cell, #set_cell_as_array, #set_cells, #set_cells_as_arrays, #set_cells_serialized

Constructor Details

#initialize(host, port = 38080, timeout_ms = 20000, do_open = true) ⇒ ThriftClient

Returns a new instance of ThriftClient.



10
11
12
13
14
15
16
# File 'lib/hypertable/thrift_client.rb', line 10

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

Instance Method Details

#closeObject



23
24
25
# File 'lib/hypertable/thrift_client.rb', line 23

def close()
  @transport.close() if @do_close
end

#each_cell(scanner) ⇒ Object

scanner iterator



48
49
50
51
52
53
54
55
# File 'lib/hypertable/thrift_client.rb', line 48

def each_cell(scanner)
  cells = next_cells(scanner);

  while (cells.size > 0)
    cells.each {|cell| yield cell}
    cells = next_cells(scanner);
  end
end

#each_cell_as_arrays(scanner) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/hypertable/thrift_client.rb', line 57

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

#each_row(scanner) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/hypertable/thrift_client.rb', line 66

def each_row(scanner)
  row = next_row(scanner);

  while (row && row.size > 0)
    yield row
    row = next_row(scanner);
  end
end

#each_row_as_arrays(scanner) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/hypertable/thrift_client.rb', line 75

def each_row_as_arrays(scanner)
  row = next_row_as_arrays(scanner);

  while (row && row.size > 0)
    yield row
    row = next_row_as_arrays(scanner);
  end
end

#openObject



18
19
20
21
# File 'lib/hypertable/thrift_client.rb', line 18

def open()
  @transport.open()
  @do_close = true
end

#with_mutator(namespace, table) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/hypertable/thrift_client.rb', line 38

def with_mutator(namespace, table)
  mutator = open_mutator(namespace, table, 0, 0);
  begin
    yield mutator
  ensure
    close_mutator(mutator, 1)
  end
end

#with_scanner(namespace, table, scan_spec, retry_table_not_found = true) ⇒ Object

more convenience methods



29
30
31
32
33
34
35
36
# File 'lib/hypertable/thrift_client.rb', line 29

def with_scanner(namespace, table, scan_spec, retry_table_not_found = true)
  scanner = open_scanner(namespace, table, scan_spec, retry_table_not_found)
  begin
    yield scanner
  ensure
    close_scanner(scanner)
  end
end