hbase-jruby 0.6.4-java → 0.7.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +68 -72
- data/hbase-jruby.gemspec +1 -1
- data/lib/hbase-jruby/cell.rb +7 -2
- data/lib/hbase-jruby/dependency.rb +77 -194
- data/lib/hbase-jruby/hbase.rb +33 -20
- data/lib/hbase-jruby/row.rb +37 -21
- data/lib/hbase-jruby/schema.rb +6 -4
- data/lib/hbase-jruby/scoped.rb +4 -4
- data/lib/hbase-jruby/table/admin.rb +71 -81
- data/lib/hbase-jruby/table/checked_operation.rb +1 -1
- data/lib/hbase-jruby/table/inspection.rb +1 -0
- data/lib/hbase-jruby/table.rb +20 -4
- data/lib/hbase-jruby/util.rb +14 -17
- data/lib/hbase-jruby/version.rb +1 -1
- data/lib/hbase-jruby.rb +1 -1
- data/test/helper.rb +3 -6
- data/test/test_aggregation.rb +17 -17
- data/test/test_byte_array.rb +9 -9
- data/test/test_cell.rb +3 -2
- data/test/test_hbase.rb +13 -13
- data/test/test_schema.rb +9 -9
- data/test/test_scoped.rb +82 -79
- data/test/test_table.rb +31 -18
- data/test/test_table_admin.rb +140 -130
- data/test/test_util.rb +16 -11
- metadata +12 -11
data/test/test_table.rb
CHANGED
@@ -80,7 +80,7 @@ class TestTable < TestHBaseJRubyBase
|
|
80
80
|
assert_equal 'a', @table.get(row1).string('cf1:b')
|
81
81
|
assert_equal 'a', String.from_java_bytes(@table.get(row1).raw('cf1:b'))
|
82
82
|
assert_equal 'a', @table.get(row1).byte_array('cf1:b').as(:string)
|
83
|
-
assert_equal 3.14, @table.get(row1).
|
83
|
+
assert_equal 3.14, @table.get(row1).double('cf1:c')
|
84
84
|
assert_equal true, @table.get(row1).boolean('cf1:d')
|
85
85
|
assert_equal :sym, @table.get(row1).symbol('cf1:f')
|
86
86
|
assert_equal BigDecimal.new("123.456"), @table.get(row1).bigdecimal('cf1:g')
|
@@ -97,7 +97,7 @@ class TestTable < TestHBaseJRubyBase
|
|
97
97
|
assert_equal %w[a b], @table.versions(:all).get(row1).strings('cf1:b').values
|
98
98
|
assert_equal %w[a b], @table.versions(:all).get(row1).raws('cf1:b').values.map { |v| String.from_java_bytes v }
|
99
99
|
assert_equal %w[a b], @table.versions(:all).get(row1).byte_arrays('cf1:b').values.map { |v| v.as :string }
|
100
|
-
assert_equal [3.14, 6.28], @table.versions(:all).get(row1).
|
100
|
+
assert_equal [3.14, 6.28], @table.versions(:all).get(row1).doubles('cf1:c').values
|
101
101
|
assert_equal [true, false], @table.versions(:all).get(row1).booleans('cf1:d').values
|
102
102
|
assert_equal [:sym, :bol], @table.versions(:all).get(row1).symbols('cf1:f').values
|
103
103
|
assert_equal [
|
@@ -117,7 +117,7 @@ class TestTable < TestHBaseJRubyBase
|
|
117
117
|
# multi-get
|
118
118
|
assert_equal [row1, row2, row3], @table.get([row1, row2, row3]).map { |r| r.rowkey :string }
|
119
119
|
assert_equal [1, 2, 4 ], @table.get([row1, row2, row3]).map { |r| r.fixnum('cf1:a') }
|
120
|
-
assert_equal [3.14, 6.28, 6.28], @table.get([row1, row2, row3]).map { |r| r.
|
120
|
+
assert_equal [3.14, 6.28, 6.28], @table.get([row1, row2, row3]).map { |r| r.double('cf1:c') }
|
121
121
|
assert_equal [nil, nil ], @table.get(['xxx', 'yyy'])
|
122
122
|
|
123
123
|
# Unavailable columns
|
@@ -135,16 +135,16 @@ class TestTable < TestHBaseJRubyBase
|
|
135
135
|
# Put added after a delete is overshadowed if its timestamp is older than than that of the tombstone
|
136
136
|
# https://issues.apache.org/jira/browse/HBASE-2847
|
137
137
|
def test_put_delete_put
|
138
|
+
skip "https://issues.apache.org/jira/browse/HBASE-2847"
|
139
|
+
|
138
140
|
rowkey = next_rowkey
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
assert_equal 'A1', @table.get(rowkey).string('cf1:pdp')
|
147
|
-
end
|
141
|
+
data = { 'cf1:pdp' => { 1250000000000 => 'A1' } }
|
142
|
+
@table.put rowkey => data
|
143
|
+
assert_equal 'A1', @table.get(rowkey).string('cf1:pdp')
|
144
|
+
@table.delete rowkey
|
145
|
+
assert_nil @table.get(rowkey)
|
146
|
+
@table.put rowkey => data
|
147
|
+
assert_equal 'A1', @table.get(rowkey).string('cf1:pdp')
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_put_timestamp
|
@@ -339,8 +339,8 @@ class TestTable < TestHBaseJRubyBase
|
|
339
339
|
end
|
340
340
|
|
341
341
|
def test_check
|
342
|
-
|
343
|
-
|
342
|
+
assert_raises(ArgumentError) { @table.check(1, :a => 1, :b => 2) }
|
343
|
+
assert_raises(ArgumentError) { @table.check(1) }
|
344
344
|
end
|
345
345
|
|
346
346
|
def test_check_and_put
|
@@ -453,7 +453,7 @@ class TestTable < TestHBaseJRubyBase
|
|
453
453
|
assert_equal nil, row.string('cf1:c')
|
454
454
|
assert_equal nil, row['cf1:c']
|
455
455
|
assert_equal true, row.boolean('cf1:z')
|
456
|
-
assert_equal nil, row.
|
456
|
+
assert_equal nil, row.double('cf2:d')
|
457
457
|
assert_equal nil, row['cf2:d']
|
458
458
|
|
459
459
|
@table.mutate(rk) { |m| } # Nothing
|
@@ -462,7 +462,7 @@ class TestTable < TestHBaseJRubyBase
|
|
462
462
|
end
|
463
463
|
|
464
464
|
def test_invalid_column_key
|
465
|
-
|
465
|
+
assert_raises(ArgumentError) {
|
466
466
|
@table.put next_rowkey, :some_column => 1
|
467
467
|
}
|
468
468
|
end
|
@@ -543,8 +543,8 @@ class TestTable < TestHBaseJRubyBase
|
|
543
543
|
end
|
544
544
|
|
545
545
|
def test_thread_local_cache
|
546
|
-
cached = @hbase[TABLE
|
547
|
-
not_cached = @hbase[TABLE]
|
546
|
+
cached = @hbase[TABLE]
|
547
|
+
not_cached = @hbase[TABLE, :column_cache => 0]
|
548
548
|
|
549
549
|
cached.put next_rowkey, 'cf1:abc' => 100
|
550
550
|
not_cached.put next_rowkey, 'cf1:def' => 100
|
@@ -555,5 +555,18 @@ class TestTable < TestHBaseJRubyBase
|
|
555
555
|
# FIXME closing not_cached will also remove the cache
|
556
556
|
assert_nil Thread.current[:hbase_jruby][@hbase][TABLE.to_sym]
|
557
557
|
end
|
558
|
+
|
559
|
+
def test_thread_local_cache_limit
|
560
|
+
times = 20
|
561
|
+
cached = @hbase[TABLE, :column_cache => times]
|
562
|
+
times.times do |i|
|
563
|
+
cached.put next_rowkey, [:cf1, i] => 100
|
564
|
+
end
|
565
|
+
assert_equal times, Thread.current[:hbase_jruby][@hbase][TABLE.to_sym][:columns].length
|
566
|
+
assert_equal [:cf1, 0],
|
567
|
+
Thread.current[:hbase_jruby][@hbase][TABLE.to_sym][:columns].values.map { |triple|
|
568
|
+
triple[0, 2].zip([:symbol, :fixnum]).map { |(val, type)| HBase::Util.from_bytes type, val }
|
569
|
+
}. sort.first
|
570
|
+
end
|
558
571
|
end
|
559
572
|
|
data/test/test_table_admin.rb
CHANGED
@@ -4,40 +4,39 @@ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
|
4
4
|
require 'helper'
|
5
5
|
|
6
6
|
class TestTableAdmin < TestHBaseJRubyBase
|
7
|
-
def teardown
|
8
|
-
@table.drop! if @table.exists?
|
9
|
-
end
|
10
|
-
|
11
7
|
def test_create_table_symbol_string
|
12
|
-
t = @hbase.table(
|
8
|
+
t = @hbase.table("hbase_jruby_#{__method__}")
|
13
9
|
t.drop! if t.exists?
|
14
10
|
|
15
|
-
|
11
|
+
assert_raises(ArgumentError) do
|
16
12
|
t.create! :cf, :splits => :xxx
|
17
13
|
end
|
18
14
|
|
19
|
-
|
15
|
+
assert_raises(ArgumentError) do
|
20
16
|
t.create! :cf => { 1 => 2 }
|
21
17
|
end
|
22
18
|
|
23
|
-
|
19
|
+
assert_raises(ArgumentError) do
|
24
20
|
t.create! :cf, { 1 => 2 }
|
25
21
|
end
|
26
22
|
|
27
|
-
[ :cf, 'cf', {:cf => {}} ].
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
[ :cf, 'cf', {:cf => {}} ].map.with_index { |cf, idx|
|
24
|
+
Thread.new do
|
25
|
+
name = "hbase_jruby_#{__method__}_#{idx}"
|
26
|
+
table = @hbase[name]
|
27
|
+
assert_equal false, table.exists?
|
28
|
+
table.create! cf
|
29
|
+
assert table.exists?
|
30
|
+
table.drop!
|
31
|
+
end
|
32
|
+
}.each(&:join)
|
34
33
|
end
|
35
34
|
|
36
35
|
def test_disable_and_drop
|
37
36
|
@table.disable!
|
38
37
|
@table.disable!
|
39
38
|
@table.drop!
|
40
|
-
|
39
|
+
assert_equal false, @table.exists?
|
41
40
|
end
|
42
41
|
|
43
42
|
def test_create_table_props
|
@@ -55,17 +54,17 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
55
54
|
end
|
56
55
|
|
57
56
|
def test_create_table_invalid_input
|
58
|
-
@
|
59
|
-
|
60
|
-
|
57
|
+
table = @hbase[:hbase_jruby_xxx]
|
58
|
+
assert_raises(ArgumentError) do
|
59
|
+
table.create! 3.14
|
61
60
|
end
|
62
61
|
|
63
|
-
|
64
|
-
|
62
|
+
assert_raises(ArgumentError) do
|
63
|
+
table.create! :cf1 => { :bloom => 'by beach house' }
|
65
64
|
end
|
66
65
|
|
67
|
-
|
68
|
-
|
66
|
+
assert_raises(ArgumentError) do
|
67
|
+
table.create! :cf1 => { :bloomfilter => :xxx }
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
@@ -89,10 +88,10 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
89
88
|
# end
|
90
89
|
|
91
90
|
def test_table_properties
|
92
|
-
|
91
|
+
assert_raises(ArgumentError) do
|
93
92
|
@table.alter! :hello => :world
|
94
93
|
end
|
95
|
-
|
94
|
+
assert_raises(ArgumentError) do
|
96
95
|
# Splits not allowed
|
97
96
|
@table.alter! :readonly => :true, :splits => [1, 2, 3]
|
98
97
|
end
|
@@ -104,8 +103,7 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
104
103
|
@table.alter!(
|
105
104
|
:max_filesize => max_fs,
|
106
105
|
:memstore_flushsize => mem_fs,
|
107
|
-
:readonly => false
|
108
|
-
:deferred_log_flush => true
|
106
|
+
:readonly => false
|
109
107
|
) do |p, t|
|
110
108
|
progress = p
|
111
109
|
total = t
|
@@ -116,7 +114,6 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
116
114
|
assert_equal max_fs, @table.descriptor.get_max_file_size
|
117
115
|
assert_equal mem_fs, @table.descriptor.get_mem_store_flush_size
|
118
116
|
assert_equal false, @table.descriptor.is_read_only
|
119
|
-
assert_equal true, @table.descriptor.is_deferred_log_flush
|
120
117
|
|
121
118
|
@table.drop!
|
122
119
|
end
|
@@ -128,14 +125,21 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
128
125
|
@table.add_family! :cf4, {}
|
129
126
|
assert @table.descriptor.getFamilies.map(&:getNameAsString).include?('cf4')
|
130
127
|
|
131
|
-
# TODO: test more props
|
132
128
|
@table.alter_family! :cf4, :versions => 10
|
133
|
-
assert_equal 10, @table.descriptor.
|
129
|
+
assert_equal 10, @table.descriptor.getFamily('cf4'.to_java_bytes).getMaxVersions
|
130
|
+
|
131
|
+
@table.alter_family! :cf4, :bloomfilter => :rowcol,
|
132
|
+
:config => { 'foo' => 'bar' }
|
133
|
+
assert_equal 'ROWCOL', @table.descriptor.getFamily('cf4'.to_java_bytes).getBloomFilterType.to_s
|
134
|
+
assert_equal 10, @table.descriptor.getFamily('cf4'.to_java_bytes).getMaxVersions
|
135
|
+
|
136
|
+
# Method not available on 0.94
|
137
|
+
assert_equal 'bar', @table.descriptor.getFamily('cf4'.to_java_bytes).getConfigurationValue('foo')
|
134
138
|
|
135
|
-
|
139
|
+
assert_raises(ArgumentError) {
|
136
140
|
@table.alter_family! :cf4, :hello => 'world'
|
137
141
|
}
|
138
|
-
|
142
|
+
assert_raises(ArgumentError) {
|
139
143
|
@table.alter_family! :cf4, :bloomfilter => :xxx
|
140
144
|
}
|
141
145
|
|
@@ -143,18 +147,23 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
143
147
|
end
|
144
148
|
|
145
149
|
def test_add_coprocessor!
|
150
|
+
coproc = 'org.apache.hadoop.hbase.coprocessor.AggregateImplementation'
|
151
|
+
|
152
|
+
if @table.has_coprocessor? coproc
|
153
|
+
@table.remove_coprocessor! coproc
|
154
|
+
end
|
155
|
+
|
146
156
|
omit "AggregationClient not found" unless @aggregation
|
147
157
|
|
148
|
-
|
149
|
-
|
150
|
-
assert_raise(ArgumentError) {
|
158
|
+
assert_equal false, @table.has_coprocessor?(coproc)
|
159
|
+
assert_raises(ArgumentError) {
|
151
160
|
# :path is missing
|
152
161
|
@table.add_coprocessor! coproc, :priority => 100
|
153
162
|
}
|
154
163
|
@table.add_coprocessor! coproc
|
155
164
|
assert @table.has_coprocessor? coproc
|
156
165
|
|
157
|
-
@table.remove_coprocessor!
|
166
|
+
@table.remove_coprocessor! coproc
|
158
167
|
assert !@table.has_coprocessor?(coproc)
|
159
168
|
|
160
169
|
@table.drop!
|
@@ -165,12 +174,6 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
165
174
|
@table.drop!
|
166
175
|
assert @table.inspect.is_a?(String)
|
167
176
|
|
168
|
-
gz = begin
|
169
|
-
org.apache.hadoop.hbase.io.hfile.Compression::Algorithm::GZ
|
170
|
-
rescue Exception
|
171
|
-
org.apache.hadoop.hbase.io.compress.Compression::Algorithm::GZ
|
172
|
-
end
|
173
|
-
|
174
177
|
table_props = {
|
175
178
|
:max_filesize => 512 * 1024 ** 2,
|
176
179
|
:memstore_flushsize => 64 * 1024 ** 2,
|
@@ -189,92 +192,99 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
189
192
|
[
|
190
193
|
'GZ',
|
191
194
|
:gz,
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
:
|
209
|
-
:
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
195
|
+
begin
|
196
|
+
org.apache.hadoop.hbase.io.hfile.Compression::Algorithm::GZ
|
197
|
+
rescue Exception
|
198
|
+
org.apache.hadoop.hbase.io.compress.Compression::Algorithm::GZ
|
199
|
+
end
|
200
|
+
].map.with_index { |cmp, idx|
|
201
|
+
Thread.new do
|
202
|
+
table = @hbase["hbase_jruby_#{__method__}_#{idx}"]
|
203
|
+
table.create!({
|
204
|
+
:cf => {
|
205
|
+
:blockcache => true,
|
206
|
+
:blocksize => 128 * 1024,
|
207
|
+
:bloomfilter => :row, # as Symbol
|
208
|
+
:compression => cmp, # as String, Symbol, java.lang.Enum
|
209
|
+
:compression_compact => cmp, # as String, Symbol, java.lang.Enum
|
210
|
+
# TODO
|
211
|
+
# :data_block_encoding => :diff,
|
212
|
+
# :encode_on_disk => true,
|
213
|
+
# :keep_deleted_cells => true,
|
214
|
+
:in_memory => true,
|
215
|
+
:min_versions => 5,
|
216
|
+
:replication_scope => 0,
|
217
|
+
:ttl => 100,
|
218
|
+
:versions => 10,
|
219
|
+
'whatever' => 'works',
|
220
|
+
}
|
221
|
+
}, table_props)
|
222
|
+
|
223
|
+
# Initial region count
|
224
|
+
regions = table.regions
|
225
|
+
assert_equal 5, regions.count
|
226
|
+
|
227
|
+
# Table properties
|
228
|
+
props = table.properties
|
229
|
+
assert props[:deferred_log_flush] || props[:durability] == 'ASYNC_WAL'
|
230
|
+
assert_equal false, props[:readonly]
|
231
|
+
assert_equal 64 * 1024 ** 2, props[:memstore_flushsize]
|
232
|
+
assert_equal 512 * 1024 ** 2, props[:max_filesize]
|
233
|
+
assert_equal 'world', props['hello']
|
234
|
+
assert_equal 'org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy',
|
235
|
+
props[:split_policy]
|
236
|
+
|
237
|
+
rprops = table.raw_properties
|
238
|
+
assert rprops['DEFERRED_LOG_FLUSH'] == 'true' || rprops['DURABILITY'] == 'ASYNC_WAL'
|
239
|
+
|
240
|
+
assert_equal false.to_s, rprops['READONLY']
|
241
|
+
assert_equal((64 * 1024 ** 2).to_s, rprops['MEMSTORE_FLUSHSIZE'])
|
242
|
+
assert_equal((512 * 1024 ** 2).to_s, rprops['MAX_FILESIZE'])
|
243
|
+
assert_equal 'world', rprops['hello']
|
244
|
+
assert_equal 'org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy',
|
245
|
+
rprops['SPLIT_POLICY']
|
246
|
+
|
247
|
+
# Column family properties
|
248
|
+
cf = table.families['cf']
|
249
|
+
assert_equal 'ROW', cf[:bloomfilter]
|
250
|
+
assert_equal 0, cf[:replication_scope]
|
251
|
+
assert_equal 10, cf[:versions]
|
252
|
+
assert_equal 'GZ', cf[:compression]
|
253
|
+
assert_equal 5, cf[:min_versions]
|
254
|
+
assert_equal 100, cf[:ttl]
|
255
|
+
assert_equal 131072, cf[:blocksize]
|
256
|
+
assert_equal true, cf[:in_memory]
|
257
|
+
assert_equal true, cf[:blockcache]
|
258
|
+
assert_equal 'works', cf['whatever']
|
259
|
+
|
260
|
+
rcf = table.raw_families['cf']
|
261
|
+
assert_equal 'ROW', rcf['BLOOMFILTER']
|
262
|
+
assert_equal 0.to_s, rcf['REPLICATION_SCOPE']
|
263
|
+
assert_equal 10.to_s, rcf['VERSIONS']
|
264
|
+
assert_equal 'GZ', rcf['COMPRESSION']
|
265
|
+
assert_equal 5.to_s, rcf['MIN_VERSIONS']
|
266
|
+
assert_equal 100.to_s, rcf['TTL']
|
267
|
+
assert_equal 131072.to_s, rcf['BLOCKSIZE']
|
268
|
+
assert_equal true.to_s, rcf['IN_MEMORY']
|
269
|
+
assert_equal true.to_s, rcf['BLOCKCACHE']
|
270
|
+
assert_equal 'works', rcf['whatever']
|
271
|
+
|
272
|
+
table.put 31, 'cf:a' => 100
|
273
|
+
table.put 37, 'cf:a' => 100
|
274
|
+
table.split!(35)
|
275
|
+
wait_for_regions table, 6
|
276
|
+
|
277
|
+
table.put 39, 'cf:a' => 100
|
278
|
+
table.split!(38)
|
279
|
+
wait_for_regions table, 7
|
280
|
+
|
281
|
+
regions = table.regions
|
282
|
+
assert_equal [10, 20, 30, 35, 38, 40], regions.map { |r| HBase::Util.from_bytes :fixnum, r[:start_key] }.compact.sort
|
283
|
+
assert_equal [10, 20, 30, 35, 38, 40], regions.map { |r| HBase::Util.from_bytes :fixnum, r[:end_key] }.compact.sort
|
284
|
+
|
285
|
+
table.drop!
|
286
|
+
end
|
287
|
+
}.each(&:join)
|
278
288
|
end
|
279
289
|
|
280
290
|
def test_snapshots
|
@@ -310,10 +320,10 @@ class TestTableAdmin < TestHBaseJRubyBase
|
|
310
320
|
end
|
311
321
|
|
312
322
|
private
|
313
|
-
def wait_for_regions rnum, max_tries = 30
|
323
|
+
def wait_for_regions table, rnum, max_tries = 30
|
314
324
|
sleep 5
|
315
325
|
max_tries.times do |i|
|
316
|
-
if
|
326
|
+
if table.regions.count == rnum && table.regions.all? { |r| r[:online] }
|
317
327
|
return
|
318
328
|
end
|
319
329
|
sleep 1
|
data/test/test_util.rb
CHANGED
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
|
4
4
|
require 'helper'
|
5
5
|
require 'bigdecimal'
|
6
6
|
|
7
|
-
class TestUtil < Test
|
7
|
+
class TestUtil < Minitest::Test
|
8
8
|
Util = HBase::Util
|
9
9
|
|
10
10
|
def test_bytea_conversion
|
11
|
-
|
11
|
+
assert_raises(ArgumentError) { Util.to_bytes(10 ** 30) }
|
12
12
|
|
13
13
|
[:fixnum, :long].each do |type|
|
14
14
|
assert_equal 100, Util.from_bytes( type, Util.to_bytes(100) )
|
@@ -18,13 +18,18 @@ class TestUtil < Test::Unit::TestCase
|
|
18
18
|
assert_equal 100, Util.from_bytes( :byte, Util.to_bytes(:byte => 100) )
|
19
19
|
assert_equal 100, Util.from_bytes( :short, Util.to_bytes(:short => 100) )
|
20
20
|
assert_equal 100, Util.from_bytes( :int, Util.to_bytes(:int => 100) )
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
assert_raises(ArgumentError) { Util.to_bytes(:short => "Hello") }
|
22
|
+
assert_raises(ArgumentError) { Util.to_bytes(:xxx => 100) }
|
23
|
+
assert_raises(ArgumentError) { Util.to_bytes(:short => 100, :int => 200) }
|
24
24
|
|
25
25
|
[:float, :double].each do |type|
|
26
|
-
assert_equal
|
26
|
+
assert_equal 314, (Util.from_bytes( type, Util.to_bytes(type => 3.14) ) * 100).to_i
|
27
27
|
end
|
28
|
+
assert_equal 4, Util.to_bytes(:float => 3.14).length
|
29
|
+
assert_equal 8, Util.to_bytes(:double => 3.14).length
|
30
|
+
assert_equal 314, (Util.from_bytes(:float, Util.to_bytes(:float => 3.14)) * 100).to_i
|
31
|
+
assert_equal 3.14, Util.from_bytes(:double, Util.to_bytes(:double => 3.14))
|
32
|
+
|
28
33
|
[:string, :str].each do |type|
|
29
34
|
assert_equal "Hello", Util.from_bytes( type, Util.to_bytes("Hello") )
|
30
35
|
assert_equal "Hello", Util.from_bytes( type, Util.to_bytes(HBase::ByteArray("Hello")) )
|
@@ -53,8 +58,8 @@ class TestUtil < Test::Unit::TestCase
|
|
53
58
|
assert_instance_of HBase::ByteArray, byte_array
|
54
59
|
assert_equal "1234", byte_array.as(:string)
|
55
60
|
|
56
|
-
|
57
|
-
|
61
|
+
assert_raises(ArgumentError) { Util.from_bytes(:xxx, [].to_java(Java::byte)) }
|
62
|
+
assert_raises(ArgumentError) { Util.to_bytes({}) }
|
58
63
|
end
|
59
64
|
|
60
65
|
def test_parse_column_name
|
@@ -74,8 +79,8 @@ class TestUtil < Test::Unit::TestCase
|
|
74
79
|
|
75
80
|
assert_equal [:abc, :def], parse_to_str([:abc, :def], :symbol)
|
76
81
|
|
77
|
-
|
78
|
-
|
82
|
+
assert_raises(ArgumentError) { Util.parse_column_name(nil) }
|
83
|
+
assert_raises(ArgumentError) { Util.parse_column_name('') }
|
79
84
|
|
80
85
|
assert_equal nil, Util.from_bytes(:string, nil)
|
81
86
|
end
|
@@ -86,7 +91,7 @@ class TestUtil < Test::Unit::TestCase
|
|
86
91
|
|
87
92
|
def test_java_bytes
|
88
93
|
["Hello", 1234, :symbol].each do |v|
|
89
|
-
|
94
|
+
assert_equal false, Util.java_bytes?(v)
|
90
95
|
end
|
91
96
|
|
92
97
|
["Hello".to_java_bytes, Util.to_bytes(1234), Util.to_bytes(:symbol)].each do |v|
|
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hbase-jruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Junegunn Choi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: yard
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- -
|
22
|
+
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '0'
|
25
25
|
prerelease: false
|
@@ -28,12 +28,12 @@ dependencies:
|
|
28
28
|
name: simplecov
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
prerelease: false
|
@@ -45,7 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- CHANGELOG.md
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE.txt
|
@@ -92,17 +92,17 @@ require_paths:
|
|
92
92
|
- lib
|
93
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.4.8
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: A JRuby binding for HBase
|
@@ -117,3 +117,4 @@ test_files:
|
|
117
117
|
- test/test_table.rb
|
118
118
|
- test/test_table_admin.rb
|
119
119
|
- test/test_util.rb
|
120
|
+
has_rdoc:
|