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.
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).float('cf1:c')
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).floats('cf1:c').values
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.float('cf1:c') }
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
- pend("https://issues.apache.org/jira/browse/HBASE-2847") do
140
- data = { 'cf1:pdp' => { 1250000000000 => 'A1' } }
141
- @table.put rowkey => data
142
- assert_equal 'A1', @table.get(rowkey).string('cf1:pdp')
143
- @table.delete rowkey
144
- assert_nil @table.get(rowkey)
145
- @table.put rowkey => data
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
- assert_raise(ArgumentError) { @table.check(1, :a => 1, :b => 2) }
343
- assert_raise(ArgumentError) { @table.check(1) }
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.float('cf2:d')
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
- assert_raise(ArgumentError) {
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, :cache => true]
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
 
@@ -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(:test_hbase_jruby_create_table)
8
+ t = @hbase.table("hbase_jruby_#{__method__}")
13
9
  t.drop! if t.exists?
14
10
 
15
- assert_raise(ArgumentError) do
11
+ assert_raises(ArgumentError) do
16
12
  t.create! :cf, :splits => :xxx
17
13
  end
18
14
 
19
- assert_raise(ArgumentError) do
15
+ assert_raises(ArgumentError) do
20
16
  t.create! :cf => { 1 => 2 }
21
17
  end
22
18
 
23
- assert_raise(ArgumentError) do
19
+ assert_raises(ArgumentError) do
24
20
  t.create! :cf, { 1 => 2 }
25
21
  end
26
22
 
27
- [ :cf, 'cf', {:cf => {}} ].each do |cf|
28
- assert_false t.exists?
29
- t.create! cf
30
- assert t.exists?
31
- t.drop!
32
-
33
- end
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
- assert_false @table.exists?
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
- @table.drop!
59
- assert_raise(ArgumentError) do
60
- @table.create! 3.14
57
+ table = @hbase[:hbase_jruby_xxx]
58
+ assert_raises(ArgumentError) do
59
+ table.create! 3.14
61
60
  end
62
61
 
63
- assert_raise(ArgumentError) do
64
- @table.create! :cf1 => { :bloom => 'by beach house' }
62
+ assert_raises(ArgumentError) do
63
+ table.create! :cf1 => { :bloom => 'by beach house' }
65
64
  end
66
65
 
67
- assert_raise(ArgumentError) do
68
- @table.create! :cf1 => { :bloomfilter => :xxx }
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
- assert_raise(ArgumentError) do
91
+ assert_raises(ArgumentError) do
93
92
  @table.alter! :hello => :world
94
93
  end
95
- assert_raise(ArgumentError) do
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.getFamilies.select { |cf| cf.getNameAsString == 'cf4' }.first.getMaxVersions
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
- assert_raise(ArgumentError) {
139
+ assert_raises(ArgumentError) {
136
140
  @table.alter_family! :cf4, :hello => 'world'
137
141
  }
138
- assert_raise(ArgumentError) {
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
- coproc = 'org.apache.hadoop.hbase.coprocessor.AggregateImplementation'
149
- assert_false @table.has_coprocessor? coproc
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! 'org.apache.hadoop.hbase.coprocessor.AggregateImplementation'
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
- gz
193
- ].each do |cmp|
194
- @table.create!({
195
- :cf => {
196
- :blockcache => true,
197
- :blocksize => 128 * 1024,
198
- :bloomfilter => :row, # as Symbol
199
- :compression => cmp, # as String, Symbol, java.lang.Enum
200
- :compression_compact => cmp, # as String, Symbol, java.lang.Enum
201
- # TODO
202
- # :data_block_encoding => :diff,
203
- # :encode_on_disk => true,
204
- # :keep_deleted_cells => true,
205
- :in_memory => true,
206
- :min_versions => 5,
207
- :replication_scope => 0,
208
- :ttl => 100,
209
- :versions => 10,
210
- 'whatever' => 'works',
211
- }
212
- }, table_props)
213
-
214
- # Initial region count
215
- regions = @table.regions
216
- assert_equal 5, regions.count
217
-
218
- # Table properties
219
- props = @table.properties
220
- assert props[:deferred_log_flush] || props[:durability] == 'ASYNC_WAL'
221
- assert_equal false, props[:readonly]
222
- assert_equal 64 * 1024 ** 2, props[:memstore_flushsize]
223
- assert_equal 512 * 1024 ** 2, props[:max_filesize]
224
- assert_equal 'world', props['hello']
225
- assert_equal 'org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy',
226
- props[:split_policy]
227
-
228
- rprops = @table.raw_properties
229
- assert rprops['DEFERRED_LOG_FLUSH'] == 'true' || rprops['DURABILITY'] == 'ASYNC_WAL'
230
-
231
- assert_equal false.to_s, rprops['READONLY']
232
- assert_equal((64 * 1024 ** 2).to_s, rprops['MEMSTORE_FLUSHSIZE'])
233
- assert_equal((512 * 1024 ** 2).to_s, rprops['MAX_FILESIZE'])
234
- assert_equal 'world', rprops['hello']
235
- assert_equal 'org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy',
236
- rprops['SPLIT_POLICY']
237
-
238
- # Column family properties
239
- cf = @table.families['cf']
240
- assert_equal 'ROW', cf[:bloomfilter]
241
- assert_equal 0, cf[:replication_scope]
242
- assert_equal 10, cf[:versions]
243
- assert_equal 'GZ', cf[:compression]
244
- assert_equal 5, cf[:min_versions]
245
- assert_equal 100, cf[:ttl]
246
- assert_equal 131072, cf[:blocksize]
247
- assert_equal true, cf[:in_memory]
248
- assert_equal true, cf[:blockcache]
249
- assert_equal 'works', cf['whatever']
250
-
251
- rcf = @table.raw_families['cf']
252
- assert_equal 'ROW', rcf['BLOOMFILTER']
253
- assert_equal 0.to_s, rcf['REPLICATION_SCOPE']
254
- assert_equal 10.to_s, rcf['VERSIONS']
255
- assert_equal 'GZ', rcf['COMPRESSION']
256
- assert_equal 5.to_s, rcf['MIN_VERSIONS']
257
- assert_equal 100.to_s, rcf['TTL']
258
- assert_equal 131072.to_s, rcf['BLOCKSIZE']
259
- assert_equal true.to_s, rcf['IN_MEMORY']
260
- assert_equal true.to_s, rcf['BLOCKCACHE']
261
- assert_equal 'works', rcf['whatever']
262
-
263
- @table.put 31, 'cf:a' => 100
264
- @table.put 37, 'cf:a' => 100
265
- @table.split!(35)
266
- wait_for_regions 6
267
-
268
- @table.put 39, 'cf:a' => 100
269
- @table.split!(38)
270
- wait_for_regions 7
271
-
272
- regions = @table.regions
273
- assert_equal [10, 20, 30, 35, 38, 40], regions.map { |r| HBase::Util.from_bytes :fixnum, r[:start_key] }.compact.sort
274
- assert_equal [10, 20, 30, 35, 38, 40], regions.map { |r| HBase::Util.from_bytes :fixnum, r[:end_key] }.compact.sort
275
-
276
- @table.drop!
277
- end
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 @table.regions.count == rnum && @table.regions.all? { |r| r[:online] }
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::Unit::TestCase
7
+ class TestUtil < Minitest::Test
8
8
  Util = HBase::Util
9
9
 
10
10
  def test_bytea_conversion
11
- assert_raise(ArgumentError) { Util.to_bytes(10 ** 30) }
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
- assert_raise(ArgumentError) { Util.to_bytes(:short => "Hello") }
22
- assert_raise(ArgumentError) { Util.to_bytes(:xxx => 100) }
23
- assert_raise(ArgumentError) { Util.to_bytes(:short => 100, :int => 200) }
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 3.14, Util.from_bytes( type, Util.to_bytes(3.14) )
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
- assert_raise(ArgumentError) { Util.from_bytes(:xxx, [].to_java(Java::byte)) }
57
- assert_raise(ArgumentError) { Util.to_bytes({}) }
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
- assert_raise(ArgumentError) { Util.parse_column_name(nil) }
78
- assert_raise(ArgumentError) { Util.parse_column_name('') }
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
- assert_false Util.java_bytes?(v)
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.6.4
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: 2014-12-09 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: test-unit
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.1.9
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: