hyper_record 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ $:.push(File.dirname(__FILE__) + '/gen-rb')
4
4
  require 'thrift'
5
5
  require 'thrift/protocol/binary_protocol_accelerated'
6
6
  require 'hql_service'
7
- require File.dirname(__FILE__) + '/thrift_transport_monkey_patch'
8
7
 
9
8
  module Hypertable
10
9
  class ThriftClient < ThriftGen::HqlService::Client
@@ -27,8 +26,8 @@ module Hypertable
27
26
 
28
27
  # more convenience methods
29
28
 
30
- def with_scanner(table, scan_spec)
31
- scanner = open_scanner(table, scan_spec, true)
29
+ def with_scanner(namespace, table, scan_spec, retry_table_not_found = true)
30
+ scanner = open_scanner(namespace, table, scan_spec, retry_table_not_found)
32
31
  begin
33
32
  yield scanner
34
33
  ensure
@@ -36,12 +35,12 @@ module Hypertable
36
35
  end
37
36
  end
38
37
 
39
- def with_mutator(table, flags=0, flush_interval=0)
40
- mutator = open_mutator(table, flags, flush_interval);
38
+ def with_mutator(namespace, table)
39
+ mutator = open_mutator(namespace, table, 0, 0);
41
40
  begin
42
41
  yield mutator
43
42
  ensure
44
- close_mutator(mutator, 0)
43
+ close_mutator(mutator, 1)
45
44
  end
46
45
  end
47
46
 
Binary file
@@ -4,9 +4,10 @@ class ThriftClientTest < Test::Unit::TestCase
4
4
  context "scanner methods" do
5
5
  setup do
6
6
  Hypertable.with_thrift_client("localhost", 38080) do |client|
7
- client.hql_query('drop table if exists thrift_test')
8
- client.hql_query('create table thrift_test ( col1, col2 )')
9
- client.hql_query("insert into thrift_test values \
7
+ ns = client.open_namespace("/")
8
+ client.hql_query(ns, 'drop table if exists thrift_test')
9
+ client.hql_query(ns, 'create table thrift_test ( col1, col2 )')
10
+ client.hql_query(ns, "insert into thrift_test values \
10
11
  ('2008-11-11 11:11:11', 'k1', 'col1', 'v1c1'), \
11
12
  ('2008-11-11 11:11:11', 'k1', 'col2', 'v1c2'), \
12
13
  ('2008-11-11 11:11:11', 'k2', 'col1', 'v2c1'), \
@@ -19,8 +20,9 @@ class ThriftClientTest < Test::Unit::TestCase
19
20
  context "each cell" do
20
21
  should "return cells individually" do
21
22
  Hypertable.with_thrift_client("localhost", 38080) do |client|
23
+ ns = client.open_namespace("/")
22
24
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
23
- client.with_scanner("thrift_test", scan_spec) do |scanner|
25
+ client.with_scanner(ns, "thrift_test", scan_spec) do |scanner|
24
26
  cell_count = 0
25
27
  client.each_cell(scanner) do |cell|
26
28
  assert_equal Hypertable::ThriftGen::Cell, cell.class
@@ -35,8 +37,9 @@ class ThriftClientTest < Test::Unit::TestCase
35
37
  context "each cell as arrays" do
36
38
  should "return cells individually in native array format" do
37
39
  Hypertable.with_thrift_client("localhost", 38080) do |client|
40
+ ns = client.open_namespace("/")
38
41
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
39
- client.with_scanner("thrift_test", scan_spec) do |scanner|
42
+ client.with_scanner(ns, "thrift_test", scan_spec) do |scanner|
40
43
  cell_count = 0
41
44
  client.each_cell_as_arrays(scanner) do |cell|
42
45
  assert_equal Array, cell.class
@@ -51,8 +54,9 @@ class ThriftClientTest < Test::Unit::TestCase
51
54
  context "each row" do
52
55
  should "return rows individually" do
53
56
  Hypertable.with_thrift_client("localhost", 38080) do |client|
57
+ ns = client.open_namespace("/")
54
58
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
55
- client.with_scanner("thrift_test", scan_spec) do |scanner|
59
+ client.with_scanner(ns, "thrift_test", scan_spec) do |scanner|
56
60
  cell_count = 0
57
61
  row_count = 0
58
62
  client.each_row(scanner) do |row|
@@ -74,8 +78,9 @@ class ThriftClientTest < Test::Unit::TestCase
74
78
  context "each row as arrays" do
75
79
  should "return rows individually in native array format" do
76
80
  Hypertable.with_thrift_client("localhost", 38080) do |client|
81
+ ns = client.open_namespace("/")
77
82
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
78
- client.with_scanner("thrift_test", scan_spec) do |scanner|
83
+ client.with_scanner(ns, "thrift_test", scan_spec) do |scanner|
79
84
  cell_count = 0
80
85
  row_count = 0
81
86
  client.each_row_as_arrays(scanner) do |row|
@@ -97,8 +102,9 @@ class ThriftClientTest < Test::Unit::TestCase
97
102
  context "scan spec" do
98
103
  should "return all rows on empty scan spec" do
99
104
  Hypertable.with_thrift_client("localhost", 38080) do |client|
105
+ ns = client.open_namespace("/")
100
106
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
101
- cells = client.get_cells("thrift_test", scan_spec)
107
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
102
108
  assert_equal 6, cells.length
103
109
  end
104
110
  end
@@ -106,9 +112,10 @@ class ThriftClientTest < Test::Unit::TestCase
106
112
  context "limit" do
107
113
  should "return just the first rows on empty scan spec with limit of 1" do
108
114
  Hypertable.with_thrift_client("localhost", 38080) do |client|
115
+ ns = client.open_namespace("/")
109
116
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
110
117
  scan_spec.row_limit = 1
111
- cells = client.get_cells("thrift_test", scan_spec)
118
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
112
119
  assert_equal 2, cells.length
113
120
  end
114
121
  end
@@ -117,6 +124,7 @@ class ThriftClientTest < Test::Unit::TestCase
117
124
  context "cell interval" do
118
125
  should "return matching cells on cell interval" do
119
126
  Hypertable.with_thrift_client("localhost", 38080) do |client|
127
+ ns = client.open_namespace("/")
120
128
  cell_interval = Hypertable::ThriftGen::CellInterval.new
121
129
  cell_interval.start_row = 'k1'
122
130
  cell_interval.start_column = 'col2'
@@ -127,7 +135,7 @@ class ThriftClientTest < Test::Unit::TestCase
127
135
 
128
136
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
129
137
  scan_spec.cell_intervals = [cell_interval]
130
- cells = client.get_cells("thrift_test", scan_spec)
138
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
131
139
  assert_equal 4, cells.length
132
140
  end
133
141
  end
@@ -136,6 +144,7 @@ class ThriftClientTest < Test::Unit::TestCase
136
144
  context "row interval" do
137
145
  should "return matching rows on row interval with start row and start inclusive" do
138
146
  Hypertable.with_thrift_client("localhost", 38080) do |client|
147
+ ns = client.open_namespace("/")
139
148
  row_interval = Hypertable::ThriftGen::RowInterval.new
140
149
  row_interval.start_row = 'k2'
141
150
  row_interval.start_inclusive = true
@@ -144,13 +153,14 @@ class ThriftClientTest < Test::Unit::TestCase
144
153
 
145
154
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
146
155
  scan_spec.row_intervals = [row_interval]
147
- cells = client.get_cells("thrift_test", scan_spec)
156
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
148
157
  assert_equal 4, cells.length
149
158
  end
150
159
  end
151
160
 
152
161
  should "return matching rows on row interval with start row and start exclusive" do
153
162
  Hypertable.with_thrift_client("localhost", 38080) do |client|
163
+ ns = client.open_namespace("/")
154
164
  row_interval = Hypertable::ThriftGen::RowInterval.new
155
165
  row_interval.start_row = 'k2'
156
166
  row_interval.start_inclusive = false
@@ -159,13 +169,14 @@ class ThriftClientTest < Test::Unit::TestCase
159
169
 
160
170
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
161
171
  scan_spec.row_intervals = [row_interval]
162
- cells = client.get_cells("thrift_test", scan_spec)
172
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
163
173
  assert_equal 2, cells.length
164
174
  end
165
175
  end
166
176
 
167
177
  should "return matching rows on row interval with end row and end inclusive" do
168
178
  Hypertable.with_thrift_client("localhost", 38080) do |client|
179
+ ns = client.open_namespace("/")
169
180
  row_interval = Hypertable::ThriftGen::RowInterval.new
170
181
  row_interval.start_row = 'k1'
171
182
  row_interval.start_inclusive = true
@@ -174,13 +185,14 @@ class ThriftClientTest < Test::Unit::TestCase
174
185
 
175
186
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
176
187
  scan_spec.row_intervals = [row_interval]
177
- cells = client.get_cells("thrift_test", scan_spec)
188
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
178
189
  assert_equal 4, cells.length
179
190
  end
180
191
  end
181
192
 
182
193
  should "return matching rows on row interval with end row and end exclusive" do
183
194
  Hypertable.with_thrift_client("localhost", 38080) do |client|
195
+ ns = client.open_namespace("/")
184
196
  row_interval = Hypertable::ThriftGen::RowInterval.new
185
197
  row_interval.start_row = 'k1'
186
198
  row_interval.start_inclusive = true
@@ -189,7 +201,7 @@ class ThriftClientTest < Test::Unit::TestCase
189
201
 
190
202
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
191
203
  scan_spec.row_intervals = [row_interval]
192
- cells = client.get_cells("thrift_test", scan_spec)
204
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
193
205
  assert_equal 2, cells.length
194
206
  end
195
207
  end
@@ -200,17 +212,19 @@ class ThriftClientTest < Test::Unit::TestCase
200
212
  context "set cell" do
201
213
  setup do
202
214
  Hypertable.with_thrift_client("localhost", 38080) do |client|
203
- client.hql_query('drop table if exists thrift_test')
204
- client.hql_query('create table thrift_test ( col )')
215
+ ns = client.open_namespace("/")
216
+ client.hql_query(ns, 'drop table if exists thrift_test')
217
+ client.hql_query(ns, 'create table thrift_test ( col )')
205
218
  end
206
219
  end
207
220
 
208
221
  should "insert a cell using hql_query" do
209
222
  Hypertable.with_thrift_client("localhost", 38080) do |client|
210
- client.hql_query("insert into thrift_test values \
223
+ ns = client.open_namespace("/")
224
+ client.hql_query(ns, "insert into thrift_test values \
211
225
  ('2008-11-11 11:11:11', 'k1', 'col', 'v1')");
212
226
 
213
- query = client.hql_query("SELECT * FROM thrift_test")
227
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
214
228
  assert_equal 1, query.cells.length
215
229
  assert_equal 'k1', query.cells[0].key.row
216
230
  assert_equal 'col', query.cells[0].key.column_family
@@ -220,7 +234,8 @@ class ThriftClientTest < Test::Unit::TestCase
220
234
 
221
235
  should "insert a cell using set_cell" do
222
236
  Hypertable.with_thrift_client("localhost", 38080) do |client|
223
- mutator = client.open_mutator('thrift_test', 0, 0)
237
+ ns = client.open_namespace("/")
238
+ mutator = client.open_mutator(ns, 'thrift_test', 0, 0)
224
239
  cell1 = Hypertable::ThriftGen::Cell.new
225
240
  cell1.key = Hypertable::ThriftGen::Key.new
226
241
  cell1.key.row = 'k1'
@@ -229,7 +244,7 @@ class ThriftClientTest < Test::Unit::TestCase
229
244
  client.set_cell(mutator, cell1)
230
245
  client.close_mutator(mutator, true)
231
246
 
232
- query = client.hql_query("SELECT * FROM thrift_test")
247
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
233
248
  assert_equal 1, query.cells.length
234
249
  assert_equal 'k1', query.cells[0].key.row
235
250
  assert_equal 'col', query.cells[0].key.column_family
@@ -239,7 +254,8 @@ class ThriftClientTest < Test::Unit::TestCase
239
254
 
240
255
  should "work with mutator flush_interval" do
241
256
  Hypertable.with_thrift_client("localhost", 38080) do |client|
242
- mutator = client.open_mutator('thrift_test', 0, 500)
257
+ ns = client.open_namespace("/")
258
+ mutator = client.open_mutator(ns, 'thrift_test', 0, 500)
243
259
  cell1 = Hypertable::ThriftGen::Cell.new
244
260
  cell1.key = Hypertable::ThriftGen::Key.new
245
261
  cell1.key.row = 'k1'
@@ -247,12 +263,12 @@ class ThriftClientTest < Test::Unit::TestCase
247
263
  cell1.value = 'v1'
248
264
  client.set_cell(mutator, cell1)
249
265
 
250
- query = client.hql_query("SELECT * FROM thrift_test")
266
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
251
267
  assert_equal 0, query.cells.length
252
268
 
253
269
  sleep 1
254
270
 
255
- query = client.hql_query("SELECT * FROM thrift_test")
271
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
256
272
  assert_equal 1, query.cells.length
257
273
  assert_equal 'k1', query.cells[0].key.row
258
274
  assert_equal 'col', query.cells[0].key.column_family
@@ -264,19 +280,21 @@ class ThriftClientTest < Test::Unit::TestCase
264
280
  context "set cells" do
265
281
  setup do
266
282
  Hypertable.with_thrift_client("localhost", 38080) do |client|
267
- client.hql_query('drop table if exists thrift_test')
268
- client.hql_query('create table thrift_test ( col )')
283
+ ns = client.open_namespace("/")
284
+ client.hql_query(ns, 'drop table if exists thrift_test')
285
+ client.hql_query(ns, 'create table thrift_test ( col )')
269
286
  end
270
287
  end
271
288
 
272
289
  should "insert cells using hql_query" do
273
290
  Hypertable.with_thrift_client("localhost", 38080) do |client|
274
- client.hql_query("insert into thrift_test values \
291
+ ns = client.open_namespace("/")
292
+ client.hql_query(ns, "insert into thrift_test values \
275
293
  ('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
276
294
  ('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
277
295
  ('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
278
296
 
279
- query = client.hql_query("SELECT * FROM thrift_test")
297
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
280
298
  assert_equal 3, query.cells.length
281
299
  assert_equal 'k1', query.cells[0].key.row
282
300
  assert_equal 'col', query.cells[0].key.column_family
@@ -294,7 +312,8 @@ class ThriftClientTest < Test::Unit::TestCase
294
312
 
295
313
  should "insert cells using set_cells" do
296
314
  Hypertable.with_thrift_client("localhost", 38080) do |client|
297
- mutator = client.open_mutator('thrift_test', 0, 0)
315
+ ns = client.open_namespace("/")
316
+ mutator = client.open_mutator(ns, 'thrift_test', 0, 0)
298
317
  cell1 = Hypertable::ThriftGen::Cell.new
299
318
  cell1.key = Hypertable::ThriftGen::Key.new
300
319
  cell1.key.row = 'k1'
@@ -316,7 +335,7 @@ class ThriftClientTest < Test::Unit::TestCase
316
335
  client.set_cells(mutator, [cell1, cell2, cell3])
317
336
  client.close_mutator(mutator, true)
318
337
 
319
- query = client.hql_query("SELECT * FROM thrift_test")
338
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
320
339
  assert_equal 3, query.cells.length
321
340
  assert_equal 'k1', query.cells[0].key.row
322
341
  assert_equal 'col', query.cells[0].key.column_family
@@ -336,17 +355,19 @@ class ThriftClientTest < Test::Unit::TestCase
336
355
  context "with mutator" do
337
356
  setup do
338
357
  Hypertable.with_thrift_client("localhost", 38080) do |client|
339
- client.hql_query('drop table if exists thrift_test')
340
- client.hql_query('create table thrift_test ( col )')
358
+ ns = client.open_namespace("/")
359
+ client.hql_query(ns, 'drop table if exists thrift_test')
360
+ client.hql_query(ns, 'create table thrift_test ( col )')
341
361
  end
342
362
  end
343
363
 
344
364
  should "yield a mutator object and close after block" do
345
365
  Hypertable.with_thrift_client("localhost", 38080) do |client|
346
- query = client.hql_query("SELECT * FROM thrift_test")
366
+ ns = client.open_namespace("/")
367
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
347
368
  assert_equal 0, query.cells.length
348
369
 
349
- client.with_mutator('thrift_test') do |mutator|
370
+ client.with_mutator(ns, 'thrift_test') do |mutator|
350
371
  cell1 = Hypertable::ThriftGen::Cell.new
351
372
  cell1.key = Hypertable::ThriftGen::Key.new
352
373
  cell1.key.row = 'k1'
@@ -355,7 +376,7 @@ class ThriftClientTest < Test::Unit::TestCase
355
376
  client.set_cells(mutator, [cell1])
356
377
  end
357
378
 
358
- query = client.hql_query("SELECT * FROM thrift_test")
379
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
359
380
  assert_equal 1, query.cells.length
360
381
  assert_equal 'k1', query.cells[0].key.row
361
382
  assert_equal 'col', query.cells[0].key.column_family
@@ -367,9 +388,10 @@ class ThriftClientTest < Test::Unit::TestCase
367
388
  context "get cell" do
368
389
  setup do
369
390
  Hypertable.with_thrift_client("localhost", 38080) do |client|
370
- client.hql_query('drop table if exists thrift_test')
371
- client.hql_query('create table thrift_test ( col )')
372
- client.hql_query("insert into thrift_test values \
391
+ ns = client.open_namespace("/")
392
+ client.hql_query(ns, 'drop table if exists thrift_test')
393
+ client.hql_query(ns, 'create table thrift_test ( col )')
394
+ client.hql_query(ns, "insert into thrift_test values \
373
395
  ('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
374
396
  ('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
375
397
  ('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
@@ -378,7 +400,8 @@ class ThriftClientTest < Test::Unit::TestCase
378
400
 
379
401
  should "return a single cell using hql_query" do
380
402
  Hypertable.with_thrift_client("localhost", 38080) do |client|
381
- query = client.hql_query("SELECT * FROM thrift_test WHERE CELL = 'k1','col'")
403
+ ns = client.open_namespace("/")
404
+ query = client.hql_query(ns, "SELECT * FROM thrift_test WHERE CELL = 'k1','col'")
382
405
  assert_equal 1, query.cells.length
383
406
  assert_equal 'k1', query.cells[0].key.row
384
407
  assert_equal 'col', query.cells[0].key.column_family
@@ -388,7 +411,8 @@ class ThriftClientTest < Test::Unit::TestCase
388
411
 
389
412
  should "return a single cell using get_cell" do
390
413
  Hypertable.with_thrift_client("localhost", 38080) do |client|
391
- value = client.get_cell("thrift_test", 'k1', 'col')
414
+ ns = client.open_namespace("/")
415
+ value = client.get_cell(ns, "thrift_test", 'k1', 'col')
392
416
  assert_equal 'v1', value
393
417
  end
394
418
  end
@@ -397,9 +421,10 @@ class ThriftClientTest < Test::Unit::TestCase
397
421
  context "get row" do
398
422
  setup do
399
423
  Hypertable.with_thrift_client("localhost", 38080) do |client|
400
- client.hql_query('drop table if exists thrift_test')
401
- client.hql_query('create table thrift_test ( col )')
402
- client.hql_query("insert into thrift_test values \
424
+ ns = client.open_namespace("/")
425
+ client.hql_query(ns, 'drop table if exists thrift_test')
426
+ client.hql_query(ns, 'create table thrift_test ( col )')
427
+ client.hql_query(ns, "insert into thrift_test values \
403
428
  ('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
404
429
  ('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
405
430
  ('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
@@ -408,7 +433,8 @@ class ThriftClientTest < Test::Unit::TestCase
408
433
 
409
434
  should "return a single row using hql_query" do
410
435
  Hypertable.with_thrift_client("localhost", 38080) do |client|
411
- query = client.hql_query("SELECT * FROM thrift_test WHERE ROW = 'k1'")
436
+ ns = client.open_namespace("/")
437
+ query = client.hql_query(ns, "SELECT * FROM thrift_test WHERE ROW = 'k1'")
412
438
  assert_equal 1, query.cells.length
413
439
  assert_equal 'k1', query.cells[0].key.row
414
440
  assert_equal 'col', query.cells[0].key.column_family
@@ -418,7 +444,8 @@ class ThriftClientTest < Test::Unit::TestCase
418
444
 
419
445
  should "return a single row using get_row" do
420
446
  Hypertable.with_thrift_client("localhost", 38080) do |client|
421
- cells = client.get_row("thrift_test", 'k1')
447
+ ns = client.open_namespace("/")
448
+ cells = client.get_row(ns, "thrift_test", 'k1')
422
449
  assert_equal 1, cells.length
423
450
  assert_equal 'k1', cells[0].key.row
424
451
  assert_equal 'col', cells[0].key.column_family
@@ -430,9 +457,10 @@ class ThriftClientTest < Test::Unit::TestCase
430
457
  context "get cells" do
431
458
  setup do
432
459
  Hypertable.with_thrift_client("localhost", 38080) do |client|
433
- client.hql_query('drop table if exists thrift_test')
434
- client.hql_query('create table thrift_test ( col )')
435
- client.hql_query("insert into thrift_test values \
460
+ ns = client.open_namespace("/")
461
+ client.hql_query(ns, 'drop table if exists thrift_test')
462
+ client.hql_query(ns, 'create table thrift_test ( col )')
463
+ client.hql_query(ns, "insert into thrift_test values \
436
464
  ('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
437
465
  ('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
438
466
  ('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
@@ -441,7 +469,8 @@ class ThriftClientTest < Test::Unit::TestCase
441
469
 
442
470
  should "return a list of cells using hql_query" do
443
471
  Hypertable.with_thrift_client("localhost", 38080) do |client|
444
- query = client.hql_query("SELECT * FROM thrift_test")
472
+ ns = client.open_namespace("/")
473
+ query = client.hql_query(ns, "SELECT * FROM thrift_test")
445
474
  assert_equal 3, query.cells.length
446
475
  assert_equal 'k1', query.cells[0].key.row
447
476
  assert_equal 'col', query.cells[0].key.column_family
@@ -459,8 +488,9 @@ class ThriftClientTest < Test::Unit::TestCase
459
488
 
460
489
  should "return a list of cells using get_cells" do
461
490
  Hypertable.with_thrift_client("localhost", 38080) do |client|
491
+ ns = client.open_namespace("/")
462
492
  scan_spec = Hypertable::ThriftGen::ScanSpec.new
463
- cells = client.get_cells("thrift_test", scan_spec)
493
+ cells = client.get_cells(ns, "thrift_test", scan_spec)
464
494
 
465
495
  assert_equal 3, cells.length
466
496
  assert_equal 'k1', cells[0].key.row
@@ -481,24 +511,27 @@ class ThriftClientTest < Test::Unit::TestCase
481
511
  context "get schema" do
482
512
  setup do
483
513
  Hypertable.with_thrift_client("localhost", 38080) do |client|
484
- client.hql_query('drop table if exists thrift_test')
485
- query = client.hql_query('show tables')
514
+ ns = client.open_namespace("/")
515
+ client.hql_query(ns, 'drop table if exists thrift_test')
516
+ query = client.hql_query(ns, 'show tables')
486
517
  assert !query.results.include?('thrift_test'), "table exists after drop"
487
- client.hql_query('create table thrift_test ( col )')
518
+ client.hql_query(ns, 'create table thrift_test ( col )')
488
519
  end
489
520
  end
490
521
 
491
522
  should "return the table definition using hql_query" do
492
523
  Hypertable.with_thrift_client("localhost", 38080) do |client|
493
- query = client.hql_query('show create table thrift_test')
524
+ ns = client.open_namespace("/")
525
+ query = client.hql_query(ns, 'show create table thrift_test')
494
526
  assert query.results.first.include?('CREATE TABLE thrift_test')
495
527
  assert query.results.first.include?('col')
496
528
  end
497
529
  end
498
530
 
499
- should "return the table definition using get_schema" do
531
+ should "return the table definition using get_schema_str" do
500
532
  Hypertable.with_thrift_client("localhost", 38080) do |client|
501
- results = client.get_schema('thrift_test')
533
+ ns = client.open_namespace("/")
534
+ results = client.get_schema_str(ns, 'thrift_test')
502
535
  assert results.include?('<Name>col</Name>')
503
536
  end
504
537
  end
@@ -507,23 +540,26 @@ class ThriftClientTest < Test::Unit::TestCase
507
540
  context "get tables" do
508
541
  setup do
509
542
  Hypertable.with_thrift_client("localhost", 38080) do |client|
510
- client.hql_query('drop table if exists thrift_test')
511
- query = client.hql_query('show tables')
543
+ ns = client.open_namespace("/")
544
+ client.hql_query(ns, 'drop table if exists thrift_test')
545
+ query = client.hql_query(ns, 'show tables')
512
546
  assert !query.results.include?('thrift_test'), "table exists after drop"
513
- client.hql_query('create table thrift_test ( col )')
547
+ client.hql_query(ns, 'create table thrift_test ( col )')
514
548
  end
515
549
  end
516
550
 
517
551
  should "return a list of table using hql_query" do
518
552
  Hypertable.with_thrift_client("localhost", 38080) do |client|
519
- query = client.hql_query('show tables')
553
+ ns = client.open_namespace("/")
554
+ query = client.hql_query(ns, 'show tables')
520
555
  assert query.results.include?('thrift_test'), "table does not exist after create"
521
556
  end
522
557
  end
523
558
 
524
559
  should "return a list of table using get_tables" do
525
560
  Hypertable.with_thrift_client("localhost", 38080) do |client|
526
- results = client.get_tables
561
+ ns = client.open_namespace("/")
562
+ results = client.get_tables(ns)
527
563
  assert results.include?('thrift_test'), "table does not exist after create"
528
564
  end
529
565
  end
@@ -532,28 +568,31 @@ class ThriftClientTest < Test::Unit::TestCase
532
568
  context "drop table" do
533
569
  setup do
534
570
  Hypertable.with_thrift_client("localhost", 38080) do |client|
535
- client.hql_query('drop table if exists thrift_test')
536
- query = client.hql_query('show tables')
571
+ ns = client.open_namespace("/")
572
+ client.hql_query(ns, 'drop table if exists thrift_test')
573
+ query = client.hql_query(ns, 'show tables')
537
574
  assert !query.results.include?('thrift_test'), "table exists after drop"
538
575
 
539
- client.hql_query('create table thrift_test ( col )')
540
- query = client.hql_query('show tables')
576
+ client.hql_query(ns, 'create table thrift_test ( col )')
577
+ query = client.hql_query(ns, 'show tables')
541
578
  assert query.results.include?('thrift_test'), "table does not exist after create"
542
579
  end
543
580
  end
544
581
 
545
582
  should "drop a table if one exists using hql_query" do
546
583
  Hypertable.with_thrift_client("localhost", 38080) do |client|
547
- client.hql_query('drop table if exists thrift_test')
548
- query = client.hql_query('show tables')
584
+ ns = client.open_namespace("/")
585
+ client.hql_query(ns, 'drop table if exists thrift_test')
586
+ query = client.hql_query(ns, 'show tables')
549
587
  assert !query.results.include?('thrift_test'), "table exists after drop"
550
588
  end
551
589
  end
552
590
 
553
591
  should "drop a table if one exists using drop_table" do
554
592
  Hypertable.with_thrift_client("localhost", 38080) do |client|
555
- client.drop_table('thrift_test', true)
556
- query = client.hql_query('show tables')
593
+ ns = client.open_namespace("/")
594
+ client.drop_table(ns, 'thrift_test', true)
595
+ query = client.hql_query(ns, 'show tables')
557
596
  assert !query.results.include?('thrift_test'), "table exists after drop"
558
597
  end
559
598
  end
@@ -562,22 +601,25 @@ class ThriftClientTest < Test::Unit::TestCase
562
601
  context "create table" do
563
602
  setup do
564
603
  Hypertable.with_thrift_client("localhost", 38080) do |client|
565
- client.hql_query('drop table if exists thrift_test')
566
- query = client.hql_query('show tables')
604
+ ns = client.open_namespace("/")
605
+ client.hql_query(ns, 'drop table if exists thrift_test')
606
+ query = client.hql_query(ns, 'show tables')
567
607
  assert !query.results.include?('thrift_test'), "table exists after drop"
568
608
  end
569
609
  end
570
610
 
571
611
  should "create a table that matches the supplied schema with hql_query" do
572
612
  Hypertable.with_thrift_client("localhost", 38080) do |client|
573
- client.hql_query('create table thrift_test ( col )')
574
- query = client.hql_query('show tables')
613
+ ns = client.open_namespace("/")
614
+ client.hql_query(ns, 'create table thrift_test ( col )')
615
+ query = client.hql_query(ns, 'show tables')
575
616
  assert query.results.include?('thrift_test'), "table does not exist after create"
576
617
  end
577
618
  end
578
619
 
579
620
  should "create a table that matches the supplied schema with create_table" do
580
621
  Hypertable.with_thrift_client("localhost", 38080) do |client|
622
+ ns = client.open_namespace("/")
581
623
  table_schema =<<EOF
582
624
  <Schema>
583
625
  <AccessGroup name="default">
@@ -587,8 +629,8 @@ class ThriftClientTest < Test::Unit::TestCase
587
629
  </AccessGroup>
588
630
  </Schema>
589
631
  EOF
590
- client.create_table('thrift_test', table_schema)
591
- query = client.hql_query('show tables')
632
+ client.create_table(ns, 'thrift_test', table_schema)
633
+ query = client.hql_query(ns, 'show tables')
592
634
  assert query.results.include?('thrift_test'), "table does not exist after create"
593
635
  end
594
636
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- version: 0.9.3
8
+ - 4
9
+ version: 0.9.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - tylerkovacs
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-30 00:00:00 -07:00
17
+ date: 2010-10-27 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -30,9 +30,9 @@ extra_rdoc_files:
30
30
  files:
31
31
  - .gitignore
32
32
  - CHANGELOG
33
+ - HOW_TO_RUN_TESTS
33
34
  - LICENSE
34
35
  - README
35
- - HOW_TO_RUN_TESTS
36
36
  - Rakefile
37
37
  - VERSION.yml
38
38
  - benchmark/save.rb
@@ -52,6 +52,7 @@ files:
52
52
  - lib/hypertable/gen-rb/hql_types.rb
53
53
  - lib/hypertable/thrift_client.rb
54
54
  - lib/hypertable/thrift_transport_monkey_patch.rb
55
+ - pkg/hyper_record-0.9.3.gem
55
56
  - spec/fixtures/pages.yml
56
57
  - spec/fixtures/qualified_pages.yml
57
58
  - spec/lib/associations_spec.rb
@@ -91,9 +92,9 @@ signing_key:
91
92
  specification_version: 3
92
93
  summary: Fully integrates ActiveRecord with Hypertable.
93
94
  test_files:
95
+ - spec/lib/associations_spec.rb
94
96
  - spec/lib/hypertable_adapter_spec.rb
95
97
  - spec/lib/hyper_record_spec.rb
96
- - spec/lib/associations_spec.rb
97
98
  - spec/spec_helper.rb
98
99
  - test/thrift_client_test.rb
99
100
  - test/test_helper.rb