hyper_record 0.2.8
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.
- data/.gitignore +3 -0
- data/CHANGELOG +83 -0
- data/LICENSE +20 -0
- data/README +49 -0
- data/Rakefile +43 -0
- data/VERSION.yml +4 -0
- data/benchmark/save.rb +58 -0
- data/hyper_record.gemspec +76 -0
- data/init.rb +1 -0
- data/lib/active_record/connection_adapters/hyper_table_definition.rb +26 -0
- data/lib/active_record/connection_adapters/hypertable_adapter.rb +680 -0
- data/lib/active_record/connection_adapters/qualified_column.rb +57 -0
- data/lib/associations/hyper_has_and_belongs_to_many_association_extension.rb +107 -0
- data/lib/associations/hyper_has_many_association_extension.rb +87 -0
- data/lib/hyper_record.rb +636 -0
- data/lib/hypertable/gen-rb/client_constants.rb +12 -0
- data/lib/hypertable/gen-rb/client_service.rb +1436 -0
- data/lib/hypertable/gen-rb/client_types.rb +253 -0
- data/lib/hypertable/gen-rb/hql_constants.rb +12 -0
- data/lib/hypertable/gen-rb/hql_service.rb +281 -0
- data/lib/hypertable/gen-rb/hql_types.rb +73 -0
- data/lib/hypertable/thrift_client.rb +94 -0
- data/lib/hypertable/thrift_transport_monkey_patch.rb +29 -0
- data/pkg/hyper_record-0.2.8.gem +0 -0
- data/spec/fixtures/pages.yml +8 -0
- data/spec/fixtures/qualified_pages.yml +1 -0
- data/spec/lib/associations_spec.rb +235 -0
- data/spec/lib/hyper_record_spec.rb +948 -0
- data/spec/lib/hypertable_adapter_spec.rb +121 -0
- data/spec/spec_helper.rb +130 -0
- data/test/test_helper.rb +10 -0
- data/test/thrift_client_test.rb +590 -0
- metadata +99 -0
@@ -0,0 +1,590 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ThriftClientTest < Test::Unit::TestCase
|
4
|
+
context "scanner methods" do
|
5
|
+
setup do
|
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 \
|
10
|
+
('2008-11-11 11:11:11', 'k1', 'col1', 'v1c1'), \
|
11
|
+
('2008-11-11 11:11:11', 'k1', 'col2', 'v1c2'), \
|
12
|
+
('2008-11-11 11:11:11', 'k2', 'col1', 'v2c1'), \
|
13
|
+
('2008-11-11 11:11:11', 'k2', 'col2', 'v2c2'), \
|
14
|
+
('2008-11-11 11:11:11', 'k3', 'col1', 'v3c1'), \
|
15
|
+
('2008-11-11 11:11:11', 'k3', 'col2', 'v3c2')");
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "each cell" do
|
20
|
+
should "return cells individually" do
|
21
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
22
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
23
|
+
client.with_scanner("thrift_test", scan_spec) do |scanner|
|
24
|
+
cell_count = 0
|
25
|
+
client.each_cell(scanner) do |cell|
|
26
|
+
assert_equal Hypertable::ThriftGen::Cell, cell.class
|
27
|
+
cell_count += 1
|
28
|
+
end
|
29
|
+
assert_equal 6, cell_count
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "each cell as arrays" do
|
36
|
+
should "return cells individually in native array format" do
|
37
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
38
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
39
|
+
client.with_scanner("thrift_test", scan_spec) do |scanner|
|
40
|
+
cell_count = 0
|
41
|
+
client.each_cell_as_arrays(scanner) do |cell|
|
42
|
+
assert_equal Array, cell.class
|
43
|
+
cell_count += 1
|
44
|
+
end
|
45
|
+
assert_equal 6, cell_count
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "each row" do
|
52
|
+
should "return rows individually" do
|
53
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
54
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
55
|
+
client.with_scanner("thrift_test", scan_spec) do |scanner|
|
56
|
+
cell_count = 0
|
57
|
+
row_count = 0
|
58
|
+
client.each_row(scanner) do |row|
|
59
|
+
assert_equal Array, row.class
|
60
|
+
assert_equal 2, row.length
|
61
|
+
row.each do |cell|
|
62
|
+
assert_equal Hypertable::ThriftGen::Cell, cell.class
|
63
|
+
cell_count +=1
|
64
|
+
end
|
65
|
+
row_count += 1
|
66
|
+
end
|
67
|
+
assert_equal 6, cell_count
|
68
|
+
assert_equal 3, row_count
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "each row as arrays" do
|
75
|
+
should "return rows individually in native array format" do
|
76
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
77
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
78
|
+
client.with_scanner("thrift_test", scan_spec) do |scanner|
|
79
|
+
cell_count = 0
|
80
|
+
row_count = 0
|
81
|
+
client.each_row_as_arrays(scanner) do |row|
|
82
|
+
assert_equal Array, row.class
|
83
|
+
assert_equal 2, row.length
|
84
|
+
row.each do |cell|
|
85
|
+
assert_equal Array, cell.class
|
86
|
+
cell_count +=1
|
87
|
+
end
|
88
|
+
row_count += 1
|
89
|
+
end
|
90
|
+
assert_equal 6, cell_count
|
91
|
+
assert_equal 3, row_count
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "scan spec" do
|
98
|
+
should "return all rows on empty scan spec" do
|
99
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
100
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
101
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
102
|
+
assert_equal 6, cells.length
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "limit" do
|
107
|
+
should "return just the first rows on empty scan spec with limit of 1" do
|
108
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
109
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
110
|
+
scan_spec.row_limit = 1
|
111
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
112
|
+
assert_equal 2, cells.length
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "cell interval" do
|
118
|
+
should "return matching cells on cell interval" do
|
119
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
120
|
+
cell_interval = Hypertable::ThriftGen::CellInterval.new
|
121
|
+
cell_interval.start_row = 'k1'
|
122
|
+
cell_interval.start_column = 'col2'
|
123
|
+
cell_interval.start_inclusive = true
|
124
|
+
cell_interval.end_row = 'k3'
|
125
|
+
cell_interval.end_column = 'col1'
|
126
|
+
cell_interval.end_inclusive = true
|
127
|
+
|
128
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
129
|
+
scan_spec.cell_intervals = [cell_interval]
|
130
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
131
|
+
assert_equal 4, cells.length
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "row interval" do
|
137
|
+
should "return matching rows on row interval with start row and start inclusive" do
|
138
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
139
|
+
row_interval = Hypertable::ThriftGen::RowInterval.new
|
140
|
+
row_interval.start_row = 'k2'
|
141
|
+
row_interval.start_inclusive = true
|
142
|
+
row_interval.end_row = 'k3'
|
143
|
+
row_interval.end_inclusive = true
|
144
|
+
|
145
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
146
|
+
scan_spec.row_intervals = [row_interval]
|
147
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
148
|
+
assert_equal 4, cells.length
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
should "return matching rows on row interval with start row and start exclusive" do
|
153
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
154
|
+
row_interval = Hypertable::ThriftGen::RowInterval.new
|
155
|
+
row_interval.start_row = 'k2'
|
156
|
+
row_interval.start_inclusive = false
|
157
|
+
row_interval.end_row = 'k3'
|
158
|
+
row_interval.end_inclusive = true
|
159
|
+
|
160
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
161
|
+
scan_spec.row_intervals = [row_interval]
|
162
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
163
|
+
assert_equal 2, cells.length
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
should "return matching rows on row interval with end row and end inclusive" do
|
168
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
169
|
+
row_interval = Hypertable::ThriftGen::RowInterval.new
|
170
|
+
row_interval.start_row = 'k1'
|
171
|
+
row_interval.start_inclusive = true
|
172
|
+
row_interval.end_row = 'k2'
|
173
|
+
row_interval.end_inclusive = true
|
174
|
+
|
175
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
176
|
+
scan_spec.row_intervals = [row_interval]
|
177
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
178
|
+
assert_equal 4, cells.length
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
should "return matching rows on row interval with end row and end exclusive" do
|
183
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
184
|
+
row_interval = Hypertable::ThriftGen::RowInterval.new
|
185
|
+
row_interval.start_row = 'k1'
|
186
|
+
row_interval.start_inclusive = true
|
187
|
+
row_interval.end_row = 'k2'
|
188
|
+
row_interval.end_inclusive = false
|
189
|
+
|
190
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
191
|
+
scan_spec.row_intervals = [row_interval]
|
192
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
193
|
+
assert_equal 2, cells.length
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context "set cell" do
|
201
|
+
setup do
|
202
|
+
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 )')
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
should "insert a cell using hql_query" do
|
209
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
210
|
+
client.hql_query("insert into thrift_test values \
|
211
|
+
('2008-11-11 11:11:11', 'k1', 'col', 'v1')");
|
212
|
+
|
213
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
214
|
+
assert_equal 1, query.cells.length
|
215
|
+
assert_equal 'k1', query.cells[0].row_key
|
216
|
+
assert_equal 'col', query.cells[0].column_family
|
217
|
+
assert_equal 'v1', query.cells[0].value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
should "insert a cell using set_cell" do
|
222
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
223
|
+
mutator = client.open_mutator('thrift_test', 0, 0)
|
224
|
+
cell1 = Hypertable::ThriftGen::Cell.new
|
225
|
+
cell1.row_key = 'k1'
|
226
|
+
cell1.column_family = 'col'
|
227
|
+
cell1.value = 'v1'
|
228
|
+
client.set_cell(mutator, cell1)
|
229
|
+
client.close_mutator(mutator, true)
|
230
|
+
|
231
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
232
|
+
assert_equal 1, query.cells.length
|
233
|
+
assert_equal 'k1', query.cells[0].row_key
|
234
|
+
assert_equal 'col', query.cells[0].column_family
|
235
|
+
assert_equal 'v1', query.cells[0].value
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
should "work with mutator flush_interval" do
|
240
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
241
|
+
mutator = client.open_mutator('thrift_test', 0, 500)
|
242
|
+
cell1 = Hypertable::ThriftGen::Cell.new
|
243
|
+
cell1.row_key = 'k1'
|
244
|
+
cell1.column_family = 'col'
|
245
|
+
cell1.value = 'v1'
|
246
|
+
client.set_cell(mutator, cell1)
|
247
|
+
|
248
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
249
|
+
assert_equal 0, query.cells.length
|
250
|
+
|
251
|
+
sleep 1
|
252
|
+
|
253
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
254
|
+
assert_equal 1, query.cells.length
|
255
|
+
assert_equal 'k1', query.cells[0].row_key
|
256
|
+
assert_equal 'col', query.cells[0].column_family
|
257
|
+
assert_equal 'v1', query.cells[0].value
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
context "set cells" do
|
263
|
+
setup do
|
264
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
265
|
+
client.hql_query('drop table if exists thrift_test')
|
266
|
+
client.hql_query('create table thrift_test ( col )')
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
should "insert cells using hql_query" do
|
271
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
272
|
+
client.hql_query("insert into thrift_test values \
|
273
|
+
('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
|
274
|
+
('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
|
275
|
+
('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
|
276
|
+
|
277
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
278
|
+
assert_equal 3, query.cells.length
|
279
|
+
assert_equal 'k1', query.cells[0].row_key
|
280
|
+
assert_equal 'col', query.cells[0].column_family
|
281
|
+
assert_equal 'v1', query.cells[0].value
|
282
|
+
|
283
|
+
assert_equal 'k2', query.cells[1].row_key
|
284
|
+
assert_equal 'col', query.cells[1].column_family
|
285
|
+
assert_equal 'v2', query.cells[1].value
|
286
|
+
|
287
|
+
assert_equal 'k3', query.cells[2].row_key
|
288
|
+
assert_equal 'col', query.cells[2].column_family
|
289
|
+
assert_equal 'v3', query.cells[2].value
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
should "insert cells using set_cells" do
|
294
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
295
|
+
mutator = client.open_mutator('thrift_test', 0, 0)
|
296
|
+
cell1 = Hypertable::ThriftGen::Cell.new
|
297
|
+
cell1.row_key = 'k1'
|
298
|
+
cell1.column_family = 'col'
|
299
|
+
cell1.value = 'v1'
|
300
|
+
|
301
|
+
cell2 = Hypertable::ThriftGen::Cell.new
|
302
|
+
cell2.row_key = 'k2'
|
303
|
+
cell2.column_family = 'col'
|
304
|
+
cell2.value = 'v2'
|
305
|
+
|
306
|
+
cell3 = Hypertable::ThriftGen::Cell.new
|
307
|
+
cell3.row_key = 'k3'
|
308
|
+
cell3.column_family = 'col'
|
309
|
+
cell3.value = 'v3'
|
310
|
+
|
311
|
+
client.set_cells(mutator, [cell1, cell2, cell3])
|
312
|
+
client.close_mutator(mutator, true)
|
313
|
+
|
314
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
315
|
+
assert_equal 3, query.cells.length
|
316
|
+
assert_equal 'k1', query.cells[0].row_key
|
317
|
+
assert_equal 'col', query.cells[0].column_family
|
318
|
+
assert_equal 'v1', query.cells[0].value
|
319
|
+
|
320
|
+
assert_equal 'k2', query.cells[1].row_key
|
321
|
+
assert_equal 'col', query.cells[1].column_family
|
322
|
+
assert_equal 'v2', query.cells[1].value
|
323
|
+
|
324
|
+
assert_equal 'k3', query.cells[2].row_key
|
325
|
+
assert_equal 'col', query.cells[2].column_family
|
326
|
+
assert_equal 'v3', query.cells[2].value
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context "with mutator" do
|
332
|
+
setup do
|
333
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
334
|
+
client.hql_query('drop table if exists thrift_test')
|
335
|
+
client.hql_query('create table thrift_test ( col )')
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
should "yield a mutator object and close after block" do
|
340
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
341
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
342
|
+
assert_equal 0, query.cells.length
|
343
|
+
|
344
|
+
client.with_mutator('thrift_test') do |mutator|
|
345
|
+
cell1 = Hypertable::ThriftGen::Cell.new
|
346
|
+
cell1.row_key = 'k1'
|
347
|
+
cell1.column_family = 'col'
|
348
|
+
cell1.value = 'v1'
|
349
|
+
client.set_cells(mutator, [cell1])
|
350
|
+
end
|
351
|
+
|
352
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
353
|
+
assert_equal 1, query.cells.length
|
354
|
+
assert_equal 'k1', query.cells[0].row_key
|
355
|
+
assert_equal 'col', query.cells[0].column_family
|
356
|
+
assert_equal 'v1', query.cells[0].value
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
context "get cell" do
|
362
|
+
setup do
|
363
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
364
|
+
client.hql_query('drop table if exists thrift_test')
|
365
|
+
client.hql_query('create table thrift_test ( col )')
|
366
|
+
client.hql_query("insert into thrift_test values \
|
367
|
+
('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
|
368
|
+
('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
|
369
|
+
('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
should "return a single cell using hql_query" do
|
374
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
375
|
+
query = client.hql_query("SELECT * FROM thrift_test WHERE CELL = 'k1','col'")
|
376
|
+
assert_equal 1, query.cells.length
|
377
|
+
assert_equal 'k1', query.cells[0].row_key
|
378
|
+
assert_equal 'col', query.cells[0].column_family
|
379
|
+
assert_equal 'v1', query.cells[0].value
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
should "return a single cell using get_cell" do
|
384
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
385
|
+
value = client.get_cell("thrift_test", 'k1', 'col')
|
386
|
+
assert_equal 'v1', value
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
context "get row" do
|
392
|
+
setup do
|
393
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
394
|
+
client.hql_query('drop table if exists thrift_test')
|
395
|
+
client.hql_query('create table thrift_test ( col )')
|
396
|
+
client.hql_query("insert into thrift_test values \
|
397
|
+
('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
|
398
|
+
('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
|
399
|
+
('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
should "return a single row using hql_query" do
|
404
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
405
|
+
query = client.hql_query("SELECT * FROM thrift_test WHERE ROW = 'k1'")
|
406
|
+
assert_equal 1, query.cells.length
|
407
|
+
assert_equal 'k1', query.cells[0].row_key
|
408
|
+
assert_equal 'col', query.cells[0].column_family
|
409
|
+
assert_equal 'v1', query.cells[0].value
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
should "return a single row using get_row" do
|
414
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
415
|
+
cells = client.get_row("thrift_test", 'k1')
|
416
|
+
assert_equal 1, cells.length
|
417
|
+
assert_equal 'k1', cells[0].row_key
|
418
|
+
assert_equal 'col', cells[0].column_family
|
419
|
+
assert_equal 'v1', cells[0].value
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
context "get cells" do
|
425
|
+
setup do
|
426
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
427
|
+
client.hql_query('drop table if exists thrift_test')
|
428
|
+
client.hql_query('create table thrift_test ( col )')
|
429
|
+
client.hql_query("insert into thrift_test values \
|
430
|
+
('2008-11-11 11:11:11', 'k1', 'col', 'v1'), \
|
431
|
+
('2008-11-11 11:11:11', 'k2', 'col', 'v2'), \
|
432
|
+
('2008-11-11 11:11:11', 'k3', 'col', 'v3')");
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
should "return a list of cells using hql_query" do
|
437
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
438
|
+
query = client.hql_query("SELECT * FROM thrift_test")
|
439
|
+
assert_equal 3, query.cells.length
|
440
|
+
assert_equal 'k1', query.cells[0].row_key
|
441
|
+
assert_equal 'col', query.cells[0].column_family
|
442
|
+
assert_equal 'v1', query.cells[0].value
|
443
|
+
|
444
|
+
assert_equal 'k2', query.cells[1].row_key
|
445
|
+
assert_equal 'col', query.cells[1].column_family
|
446
|
+
assert_equal 'v2', query.cells[1].value
|
447
|
+
|
448
|
+
assert_equal 'k3', query.cells[2].row_key
|
449
|
+
assert_equal 'col', query.cells[2].column_family
|
450
|
+
assert_equal 'v3', query.cells[2].value
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
should "return a list of cells using get_cells" do
|
455
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
456
|
+
scan_spec = Hypertable::ThriftGen::ScanSpec.new
|
457
|
+
cells = client.get_cells("thrift_test", scan_spec)
|
458
|
+
|
459
|
+
assert_equal 3, cells.length
|
460
|
+
assert_equal 'k1', cells[0].row_key
|
461
|
+
assert_equal 'col', cells[0].column_family
|
462
|
+
assert_equal 'v1', cells[0].value
|
463
|
+
|
464
|
+
assert_equal 'k2', cells[1].row_key
|
465
|
+
assert_equal 'col', cells[1].column_family
|
466
|
+
assert_equal 'v2', cells[1].value
|
467
|
+
|
468
|
+
assert_equal 'k3', cells[2].row_key
|
469
|
+
assert_equal 'col', cells[2].column_family
|
470
|
+
assert_equal 'v3', cells[2].value
|
471
|
+
end
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
context "get schema" do
|
476
|
+
setup do
|
477
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
478
|
+
client.hql_query('drop table if exists thrift_test')
|
479
|
+
query = client.hql_query('show tables')
|
480
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
481
|
+
client.hql_query('create table thrift_test ( col )')
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
should "return the table definition using hql_query" do
|
486
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
487
|
+
query = client.hql_query('show create table thrift_test')
|
488
|
+
assert query.results.first.include?('CREATE TABLE thrift_test')
|
489
|
+
assert query.results.first.include?('col')
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
should "return the table definition using get_schema" do
|
494
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
495
|
+
results = client.get_schema('thrift_test')
|
496
|
+
assert results.include?('<Name>col</Name>')
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
context "get tables" do
|
502
|
+
setup do
|
503
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
504
|
+
client.hql_query('drop table if exists thrift_test')
|
505
|
+
query = client.hql_query('show tables')
|
506
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
507
|
+
client.hql_query('create table thrift_test ( col )')
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
should "return a list of table using hql_query" do
|
512
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
513
|
+
query = client.hql_query('show tables')
|
514
|
+
assert query.results.include?('thrift_test'), "table does not exist after create"
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
should "return a list of table using get_tables" do
|
519
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
520
|
+
results = client.get_tables
|
521
|
+
assert results.include?('thrift_test'), "table does not exist after create"
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
context "drop table" do
|
527
|
+
setup do
|
528
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
529
|
+
client.hql_query('drop table if exists thrift_test')
|
530
|
+
query = client.hql_query('show tables')
|
531
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
532
|
+
|
533
|
+
client.hql_query('create table thrift_test ( col )')
|
534
|
+
query = client.hql_query('show tables')
|
535
|
+
assert query.results.include?('thrift_test'), "table does not exist after create"
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
should "drop a table if one exists using hql_query" do
|
540
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
541
|
+
client.hql_query('drop table if exists thrift_test')
|
542
|
+
query = client.hql_query('show tables')
|
543
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
should "drop a table if one exists using drop_table" do
|
548
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
549
|
+
client.drop_table('thrift_test', true)
|
550
|
+
query = client.hql_query('show tables')
|
551
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
552
|
+
end
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
context "create table" do
|
557
|
+
setup do
|
558
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
559
|
+
client.hql_query('drop table if exists thrift_test')
|
560
|
+
query = client.hql_query('show tables')
|
561
|
+
assert !query.results.include?('thrift_test'), "table exists after drop"
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
should "create a table that matches the supplied schema with hql_query" do
|
566
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
567
|
+
client.hql_query('create table thrift_test ( col )')
|
568
|
+
query = client.hql_query('show tables')
|
569
|
+
assert query.results.include?('thrift_test'), "table does not exist after create"
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
should "create a table that matches the supplied schema with create_table" do
|
574
|
+
Hypertable.with_thrift_client("localhost", 38080) do |client|
|
575
|
+
table_schema =<<EOF
|
576
|
+
<Schema>
|
577
|
+
<AccessGroup name="default">
|
578
|
+
<ColumnFamily>
|
579
|
+
<Name>col</Name>
|
580
|
+
</ColumnFamily>
|
581
|
+
</AccessGroup>
|
582
|
+
</Schema>
|
583
|
+
EOF
|
584
|
+
client.create_table('thrift_test', table_schema)
|
585
|
+
query = client.hql_query('show tables')
|
586
|
+
assert query.results.include?('thrift_test'), "table does not exist after create"
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end
|
590
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hyper_record
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 8
|
9
|
+
version: 0.2.8
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- tylerkovacs
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-01 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: See README
|
22
|
+
email: tyler.kovacs@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- CHANGELOG
|
33
|
+
- LICENSE
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- VERSION.yml
|
37
|
+
- benchmark/save.rb
|
38
|
+
- hyper_record.gemspec
|
39
|
+
- init.rb
|
40
|
+
- lib/active_record/connection_adapters/hyper_table_definition.rb
|
41
|
+
- lib/active_record/connection_adapters/hypertable_adapter.rb
|
42
|
+
- lib/active_record/connection_adapters/qualified_column.rb
|
43
|
+
- lib/associations/hyper_has_and_belongs_to_many_association_extension.rb
|
44
|
+
- lib/associations/hyper_has_many_association_extension.rb
|
45
|
+
- lib/hyper_record.rb
|
46
|
+
- lib/hypertable/gen-rb/client_constants.rb
|
47
|
+
- lib/hypertable/gen-rb/client_service.rb
|
48
|
+
- lib/hypertable/gen-rb/client_types.rb
|
49
|
+
- lib/hypertable/gen-rb/hql_constants.rb
|
50
|
+
- lib/hypertable/gen-rb/hql_service.rb
|
51
|
+
- lib/hypertable/gen-rb/hql_types.rb
|
52
|
+
- lib/hypertable/thrift_client.rb
|
53
|
+
- lib/hypertable/thrift_transport_monkey_patch.rb
|
54
|
+
- pkg/hyper_record-0.2.8.gem
|
55
|
+
- spec/fixtures/pages.yml
|
56
|
+
- spec/fixtures/qualified_pages.yml
|
57
|
+
- spec/lib/associations_spec.rb
|
58
|
+
- spec/lib/hyper_record_spec.rb
|
59
|
+
- spec/lib/hypertable_adapter_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- test/test_helper.rb
|
62
|
+
- test/thrift_client_test.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://github.com/tylerkovacs/hyper_record
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --charset=UTF-8
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.6
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Fully integrates ActiveRecord with Hypertable.
|
93
|
+
test_files:
|
94
|
+
- spec/lib/hypertable_adapter_spec.rb
|
95
|
+
- spec/lib/hyper_record_spec.rb
|
96
|
+
- spec/lib/associations_spec.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
- test/thrift_client_test.rb
|
99
|
+
- test/test_helper.rb
|