hbase-jruby 0.6.4-java → 0.7.0-java
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.
- 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/lib/hbase-jruby/version.rb
CHANGED
data/lib/hbase-jruby.rb
CHANGED
@@ -7,7 +7,6 @@ class HBase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
require 'hbase-jruby/version'
|
10
|
-
require 'hbase-jruby/dependency'
|
11
10
|
require 'hbase-jruby/util'
|
12
11
|
require 'hbase-jruby/byte_array'
|
13
12
|
require 'hbase-jruby/cell'
|
@@ -24,4 +23,5 @@ require 'hbase-jruby/table/inspection'
|
|
24
23
|
require 'hbase-jruby/table/checked_operation'
|
25
24
|
require 'hbase-jruby/row'
|
26
25
|
require 'hbase-jruby/hbase'
|
26
|
+
require 'hbase-jruby/dependency'
|
27
27
|
|
data/test/helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
$VERBOSE = true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require "test-unit"
|
3
|
+
require 'minitest/autorun'
|
5
4
|
require 'simplecov'
|
6
5
|
SimpleCov.start
|
7
6
|
|
@@ -16,13 +15,11 @@ $rowkey = Time.now.to_i
|
|
16
15
|
|
17
16
|
require "hbase-jruby"
|
18
17
|
if jar = ENV['HBASE_JRUBY_TEST_JAR']
|
19
|
-
|
20
|
-
elsif dist = ENV['HBASE_JRUBY_TEST_DIST']
|
21
|
-
HBase.resolve_dependency!(dist, :verbose => true)
|
18
|
+
$CLASSPATH << jar
|
22
19
|
end
|
23
20
|
HBase.log4j = { 'log4j.threshold' => 'ERROR' }
|
24
21
|
|
25
|
-
class TestHBaseJRubyBase < Test
|
22
|
+
class TestHBaseJRubyBase < Minitest::Test
|
26
23
|
TABLE = 'test_hbase_jruby'
|
27
24
|
ZK = ENV.fetch 'HBASE_JRUBY_TEST_ZK'
|
28
25
|
|
data/test/test_aggregation.rb
CHANGED
@@ -7,37 +7,37 @@ class TestAggregation < TestHBaseJRubyBase
|
|
7
7
|
def test_aggregation
|
8
8
|
omit 'AggregationClient is not found' unless @aggregation
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
range = 1..100
|
11
|
+
@table.put range.map { |idx|
|
12
|
+
{ idx => { 'cf1:a' => idx, 'cf1:b' => idx * 2 } }
|
13
|
+
}.reduce(&:merge)
|
13
14
|
|
14
15
|
assert_nil @table.enable_aggregation!
|
15
16
|
assert_nil @table.enable_aggregation! # no prob!
|
16
17
|
|
17
18
|
lci = org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter.new
|
19
|
+
scope = @table.range(range)
|
18
20
|
[nil, :fixnum, :long, lci].each do |ci|
|
19
|
-
assert_equal 100,
|
20
|
-
assert_equal 5050,
|
21
|
-
assert_equal 1,
|
22
|
-
assert_equal 100,
|
23
|
-
assert_equal 50.5,
|
24
|
-
assert_equal 28,
|
21
|
+
assert_equal 100, scope.project('cf1:a').aggregate(:row_count, *[*ci].compact)
|
22
|
+
assert_equal 5050, scope.project('cf1:a').aggregate(:sum, *[*ci].compact)
|
23
|
+
assert_equal 1, scope.project('cf1:a').aggregate(:min, *[*ci].compact)
|
24
|
+
assert_equal 100, scope.project('cf1:a').aggregate(:max, *[*ci].compact)
|
25
|
+
assert_equal 50.5, scope.project('cf1:a').aggregate(:avg, *[*ci].compact)
|
26
|
+
assert_equal 28, scope.project('cf1:a').aggregate(:std, *[*ci].compact).to_i # FIXME: 28 or 29?
|
25
27
|
end
|
26
28
|
|
27
29
|
[%w[cf1:a cf1:b], %w[cf1]].each do |prj|
|
28
|
-
assert_equal 5050 * 3,
|
29
|
-
assert_equal 1,
|
30
|
-
assert_equal 200,
|
30
|
+
assert_equal 5050 * 3, scope.project(*prj).aggregate(:sum)
|
31
|
+
assert_equal 1, scope.project(*prj).aggregate(:min)
|
32
|
+
assert_equal 200, scope.project(*prj).aggregate(:max)
|
31
33
|
end
|
32
34
|
|
33
35
|
# No projection
|
34
|
-
|
35
|
-
|
36
|
+
assert_raises(ArgumentError) { @table.aggregate(:sum) }
|
37
|
+
assert_raises(ArgumentError) { scope.aggregate(:sum) }
|
36
38
|
|
37
39
|
# Invalid type
|
38
|
-
|
39
|
-
|
40
|
-
@table.drop!
|
40
|
+
assert_raises(ArgumentError) { scope.project('cf1:a').aggregate(:sum, :double) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/test/test_byte_array.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
4
4
|
require 'helper'
|
5
5
|
|
6
|
-
class TestByteArray < Test
|
6
|
+
class TestByteArray < Minitest::Test
|
7
7
|
def test_order
|
8
8
|
[
|
9
9
|
[(1..100).to_a, :fixnum],
|
@@ -66,7 +66,7 @@ class TestByteArray < Test::Unit::TestCase
|
|
66
66
|
assert_equal 100, ba[0, 8].decode(:fixnum)
|
67
67
|
assert_equal 200, ba[8...16].as(:fixnum)
|
68
68
|
assert_equal "Hello", ba[16, 5].decode(:string)
|
69
|
-
assert_equal 3.14, ba[21..-1].decode(:
|
69
|
+
assert_equal 3.14, ba[21..-1].decode(:double)
|
70
70
|
assert_equal "H", ba[16].chr
|
71
71
|
end
|
72
72
|
|
@@ -78,29 +78,29 @@ class TestByteArray < Test::Unit::TestCase
|
|
78
78
|
assert_equal 22, ba.length
|
79
79
|
assert_equal 200, ba.shift(:fixnum)
|
80
80
|
assert_equal 14, ba.length
|
81
|
-
|
81
|
+
assert_raises(ArgumentError) { ba.shift(:string) }
|
82
82
|
assert_equal "Hello", ba.shift(:string, 5)
|
83
83
|
assert_equal 9, ba.length
|
84
84
|
assert_equal false, ba.shift(:boolean)
|
85
85
|
assert_equal 8, ba.length
|
86
|
-
assert_equal 3.14, ba.shift(:
|
86
|
+
assert_equal 3.14, ba.shift(:double)
|
87
87
|
assert_equal 0, ba.length
|
88
88
|
|
89
|
-
|
89
|
+
assert_raises(ArgumentError) { ba.shift(:fixnum) }
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_short_int
|
93
93
|
assert_equal 1, HBase::ByteArray(:byte => 12).length
|
94
94
|
assert_equal 12, HBase::ByteArray(:byte => 12).decode(:byte)
|
95
|
-
|
95
|
+
assert_raises(RangeError) { HBase::ByteArray(:byte => 128) }
|
96
96
|
|
97
97
|
assert_equal 2, HBase::ByteArray(:short => 12345).length
|
98
98
|
assert_equal 12345, HBase::ByteArray(:short => 12345).as(:short)
|
99
|
-
|
99
|
+
assert_raises(RangeError) { HBase::ByteArray( :short => 1 << 16 ) }
|
100
100
|
|
101
101
|
assert_equal 4, HBase::ByteArray(:int => 12345).length
|
102
102
|
assert_equal 12345, HBase::ByteArray(:int => 12345).decode(:int)
|
103
|
-
|
103
|
+
assert_raises(RangeError) { HBase::ByteArray.new( :int => 1 << 32 ) }
|
104
104
|
|
105
105
|
ba = HBase::ByteArray( {:int => 10000}, 20000, {:short => 30000}, "Hello" )
|
106
106
|
assert_equal 10000, ba[0, 4].as(:int)
|
@@ -140,7 +140,7 @@ class TestByteArray < Test::Unit::TestCase
|
|
140
140
|
assert_equal 200, ba.shift(:long)
|
141
141
|
assert_equal 300, ba.shift(:int)
|
142
142
|
assert_equal "Hello", ba.shift(:string, 5)
|
143
|
-
assert_equal 3.14, ba.shift(:
|
143
|
+
assert_equal 3.14, ba.shift(:double)
|
144
144
|
end
|
145
145
|
|
146
146
|
def test_to_s
|
data/test/test_cell.rb
CHANGED
@@ -14,13 +14,14 @@ class TestCell < TestHBaseJRubyBase
|
|
14
14
|
'value' => :string,
|
15
15
|
:value => :symbol,
|
16
16
|
123 => :fixnum,
|
17
|
-
123.456 => :
|
17
|
+
123.456 => :double,
|
18
18
|
true => :boolean,
|
19
19
|
false => :boolean,
|
20
20
|
BigDecimal.new("123.456") => :bigdecimal,
|
21
21
|
{ :int => 10240 } => :int,
|
22
22
|
{ :short => 1024 } => :short,
|
23
|
-
{ :byte => 100 } => :byte
|
23
|
+
{ :byte => 100 } => :byte,
|
24
|
+
{ :float => 123.0 } => :float
|
24
25
|
}.each do |value, type|
|
25
26
|
kv = KeyValue.new("rowkey".to_java_bytes, "hello".to_java_bytes, "world".to_java_bytes, ts, Util.to_bytes(value))
|
26
27
|
cell = HBase::Cell.new(@table, kv) # FIXME
|
data/test/test_hbase.rb
CHANGED
@@ -34,19 +34,19 @@ class TestHBase < TestHBaseJRubyBase
|
|
34
34
|
assert @hbase.closed?
|
35
35
|
assert table.closed?
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
assert_raises(RuntimeError) { @hbase.list }
|
38
|
+
assert_raises(RuntimeError) { table.exists? }
|
39
|
+
assert_raises(RuntimeError) { table.drop! }
|
40
40
|
# ...
|
41
41
|
|
42
42
|
# get, delete, put, delete_row, increment, each
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
assert_raises(RuntimeError) { table.first }
|
44
|
+
assert_raises(RuntimeError) { table.get :key }
|
45
|
+
assert_raises(RuntimeError) { table.put :key => {'cf1:a' => 100} }
|
46
|
+
assert_raises(RuntimeError) { table.delete :key }
|
47
|
+
assert_raises(RuntimeError) { table.delete_row :key }
|
48
|
+
assert_raises(RuntimeError) { table.increment :key, 'cf1:a' => 1 }
|
49
|
+
assert_raises(RuntimeError) { table.project('cf1:a').aggregate(:row_count) }
|
50
50
|
|
51
51
|
# Reconnect and check
|
52
52
|
@hbase = connect
|
@@ -109,13 +109,13 @@ class TestHBase < TestHBaseJRubyBase
|
|
109
109
|
hbase2.close
|
110
110
|
|
111
111
|
# Connection is already closed
|
112
|
-
|
113
|
-
|
112
|
+
assert_raises(RuntimeError) { hbase2[TABLE] }
|
113
|
+
assert_raises(RuntimeError) { table.htable }
|
114
114
|
end
|
115
115
|
|
116
116
|
def test_reset_pool
|
117
117
|
hbase2 = HBase.new @hbase.config
|
118
|
-
|
118
|
+
if hbase2.use_table_pool?
|
119
119
|
table = hbase2[TABLE]
|
120
120
|
|
121
121
|
htable = table.htable
|
data/test/test_schema.rb
CHANGED
@@ -16,7 +16,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
16
16
|
def test_invalid_schema_type
|
17
17
|
@hbase.schema = { @table.name => { :cf1 => { :a => 'string' } } }
|
18
18
|
|
19
|
-
|
19
|
+
assert_raises(ArgumentError) do
|
20
20
|
@hbase.schema = { @table.name => { :cf1 => { :a => :xxx } } }
|
21
21
|
end
|
22
22
|
end
|
@@ -28,7 +28,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
28
28
|
:a => :fixnum,
|
29
29
|
:b => :symbol,
|
30
30
|
:c => :int,
|
31
|
-
/^d/i => :
|
31
|
+
/^d/i => :double,
|
32
32
|
'd2' => :short,
|
33
33
|
},
|
34
34
|
# Every column from cf2 is :string
|
@@ -36,7 +36,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
36
36
|
|
37
37
|
# cf3:f is a 8-byte integer
|
38
38
|
:cf3 => { :f => :fixnum },
|
39
|
-
'cf3:g' => :
|
39
|
+
'cf3:g' => :double
|
40
40
|
}
|
41
41
|
}
|
42
42
|
|
@@ -135,8 +135,8 @@ class TestSchema < TestHBaseJRubyBase
|
|
135
135
|
:name => :string,
|
136
136
|
:age => :fixnum,
|
137
137
|
:sex => :symbol,
|
138
|
-
:height => :
|
139
|
-
:weight => :
|
138
|
+
:height => :double,
|
139
|
+
:weight => :double,
|
140
140
|
:alive => :boolean
|
141
141
|
},
|
142
142
|
:cf2 => {
|
@@ -188,7 +188,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
188
188
|
:year => :short,
|
189
189
|
:pages => :int,
|
190
190
|
:price => :bigdecimal,
|
191
|
-
:weight => :
|
191
|
+
:weight => :double,
|
192
192
|
:in_print => :boolean,
|
193
193
|
:image => :raw
|
194
194
|
},
|
@@ -331,7 +331,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
331
331
|
table.mutate(rk) do |m|
|
332
332
|
m.delete :comment1, :comment2
|
333
333
|
m.put :comment3 => 'nice', :comment4 => 'great'
|
334
|
-
|
334
|
+
assert_raises(ArgumentError) {
|
335
335
|
m.put :some_unknown_column => 'perfect'
|
336
336
|
}
|
337
337
|
end
|
@@ -397,7 +397,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
397
397
|
}
|
398
398
|
|
399
399
|
rk = next_rowkey
|
400
|
-
|
400
|
+
assert_raises(ArgumentError) {
|
401
401
|
@table.put rk, :a => nil, :b => nil, :c => nil, 'cf1:z' => nil
|
402
402
|
}
|
403
403
|
@table.put rk, :a => nil, :b => nil, :c => nil, :d => 'yo', 'cf1:z' => 1000
|
@@ -425,7 +425,7 @@ class TestSchema < TestHBaseJRubyBase
|
|
425
425
|
assert_equal 100, @table.get(rk)['cf1:a']
|
426
426
|
|
427
427
|
@hbase.schema.delete @table.name
|
428
|
-
|
428
|
+
assert_raises(ArgumentError) { @table.get(rk)[:a] }
|
429
429
|
assert_equal true, HBase::Util.java_bytes?(@table.get(rk)['cf1:a'])
|
430
430
|
assert_equal 100, HBase::Util.from_bytes(:fixnum, @table.get(rk)['cf1:a'])
|
431
431
|
end
|
data/test/test_scoped.rb
CHANGED
@@ -5,57 +5,57 @@ require 'helper'
|
|
5
5
|
|
6
6
|
class TestScoped < TestHBaseJRubyBase
|
7
7
|
def test_invalid_limit
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
assert_raises(ArgumentError) { @table.limit }
|
9
|
+
assert_raises(ArgumentError) { @table.limit(-1) }
|
10
|
+
assert_raises(ArgumentError) { @table.limit("hello") }
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_invalid_versions
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
assert_raises(ArgumentError) { @table.versions }
|
15
|
+
assert_raises(ArgumentError) { @table.versions(0) }
|
16
|
+
assert_raises(ArgumentError) { @table.versions("hello") }
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_invalid_batch
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
assert_raises(ArgumentError) { @table.batch }
|
21
|
+
assert_raises(ArgumentError) { @table.batch(0) }
|
22
|
+
assert_raises(ArgumentError) { @table.batch("hello") }
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_invalid_range
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
assert_raises(ArgumentError) { @table.range }
|
27
|
+
assert_raises(ArgumentError) { @table.range(:xxx => 'row1') }
|
28
|
+
assert_raises(ArgumentError) { @table.range({}) }
|
29
|
+
assert_raises(ArgumentError) { @table.range(1, 2, 3) }
|
30
|
+
assert_raises(ArgumentError) { @table.range(nil, nil) }
|
31
|
+
assert_raises(ArgumentError) { @table.range(1..3, 4..5) }
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_invalid_project
|
35
|
-
|
36
|
-
|
35
|
+
assert_raises(ArgumentError) { @table.project(:offset => 'a', :limit => 10).to_a }
|
36
|
+
assert_raises(ArgumentError) { @table.project(:offset => 10, :limit => 'a').to_a }
|
37
37
|
|
38
38
|
@table.project(:offset => 100) # Fine yet
|
39
39
|
@table.project(:limit => 10)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
assert_raises(ArgumentError) { @table.project(:offset => 100).to_a }
|
41
|
+
assert_raises(ArgumentError) { @table.project(:limit => 10).to_a }
|
42
|
+
assert_raises(ArgumentError) { @table.project(:offset => -1) }
|
43
|
+
assert_raises(ArgumentError) { @table.project(:limit => -1) }
|
44
|
+
assert_raises(ArgumentError) { @table.project(:offset => :a) }
|
45
|
+
assert_raises(ArgumentError) { @table.project(:limit => :a) }
|
46
|
+
assert_raises(ArgumentError) { @table.project(:xxx => 1) }
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_invalid_filter
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
assert_raises(ArgumentError) { @table.filter(3.14) }
|
51
|
+
assert_raises(ArgumentError) { @table.filter('cf1:a' => { :xxx => 50 }) }
|
52
|
+
assert_raises(ArgumentError) { @table.filter('cf1:a' => { :eq => { 1 => 2 } }) }
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_each_and_count
|
56
|
-
(101..150).
|
57
|
-
|
58
|
-
|
56
|
+
@table.put (101..150).map { |i|
|
57
|
+
{ i => { 'cf1:a' => i, 'cf2:b' => i, 'cf3:c' => i * 3 } }
|
58
|
+
}.reduce(&:merge)
|
59
59
|
|
60
60
|
assert_instance_of HBase::Scoped, @table.scoped
|
61
61
|
assert_instance_of Enumerator, @table.each
|
@@ -154,16 +154,24 @@ class TestScoped < TestHBaseJRubyBase
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def test_filter_operator_and_short_int
|
157
|
-
|
157
|
+
assert_raises(ArgumentError) {
|
158
158
|
@table.filter('cf1:a' => { :long => 100, :gt => 10 })
|
159
159
|
}
|
160
160
|
end
|
161
161
|
|
162
162
|
def test_scan
|
163
163
|
insert = lambda do
|
164
|
-
(40..70).
|
165
|
-
|
166
|
-
|
164
|
+
@table.put (40..70).map { |i|
|
165
|
+
{
|
166
|
+
i => {
|
167
|
+
'cf1:a' => i,
|
168
|
+
'cf2:b' => i * 2,
|
169
|
+
'cf3:c' => i * 3,
|
170
|
+
'cf3:d' => 'dummy',
|
171
|
+
'cf3:e' => 3.14
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}.reduce(&:merge)
|
167
175
|
end
|
168
176
|
insert.call
|
169
177
|
|
@@ -246,29 +254,20 @@ class TestScoped < TestHBaseJRubyBase
|
|
246
254
|
end
|
247
255
|
|
248
256
|
def test_scan_on_non_string_rowkey
|
249
|
-
(1..20).
|
250
|
-
@table.put rk, 'cf1:a' => rk
|
251
|
-
end
|
257
|
+
@table.put (1..20).map { |rk| { rk => { 'cf1:a' => rk } } }.reduce(:merge)
|
252
258
|
assert_equal 9, @table.range(1..9).count
|
253
259
|
assert_equal [1, 2, 3, 4, 5, 6, 7, 8, 9], @table.range(1..9).map { |row| row.rowkey :fixnum }
|
254
260
|
assert_equal 8, @table.range(1...9).count
|
255
261
|
|
256
|
-
@table.
|
257
|
-
|
258
|
-
(1..20).each do |rk|
|
259
|
-
@table.put rk.to_s, 'cf1:a' => rk
|
260
|
-
end
|
262
|
+
@table.put (1..20).map { |rk| { rk.to_s => { 'cf1:a' => rk } } }.reduce(:merge)
|
261
263
|
assert_equal 20, @table.range('1'..'9').count
|
262
264
|
assert_equal %w[1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9], @table.range('1'..'9').map { |e| e.rowkey :string }
|
263
|
-
|
264
265
|
assert_equal 19, @table.range('1'...'9').count
|
265
266
|
|
266
|
-
@table.
|
267
|
+
@table.delete_row *(1..20).map { |i| [i, i.to_s] }.flatten
|
268
|
+
|
267
269
|
data = { 'cf1:1' => 1 } # doesn't matter
|
268
|
-
(1..15).
|
269
|
-
@table.put i, data
|
270
|
-
@table.put i.to_s, data
|
271
|
-
end
|
270
|
+
@table.put (1..15).map { |i| { i => data, i.to_s => data } }.reduce(:merge)
|
272
271
|
|
273
272
|
assert_equal [1, 2, 3], @table.range(1..3).map { |r| r.rowkey :fixnum }
|
274
273
|
assert_equal %w[1 10 11 12 13 14 15 2 3], @table.range('1'..'3').map { |r| r.rowkey :string }
|
@@ -293,7 +292,7 @@ class TestScoped < TestHBaseJRubyBase
|
|
293
292
|
assert_instance_of org.apache.hadoop.hbase.client.UnmodifyableHTableDescriptor, @table.descriptor
|
294
293
|
|
295
294
|
# Should be read-only
|
296
|
-
|
295
|
+
assert_raises(java.lang.UnsupportedOperationException) {
|
297
296
|
@table.descriptor.setMaxFileSize 100 * 1024 ** 2
|
298
297
|
}
|
299
298
|
end
|
@@ -307,16 +306,17 @@ class TestScoped < TestHBaseJRubyBase
|
|
307
306
|
end
|
308
307
|
|
309
308
|
def test_null_filter
|
310
|
-
10.times
|
309
|
+
@table.put 10.times.map { |i|
|
311
310
|
if i % 2 == 0
|
312
|
-
|
311
|
+
{ i => { 'cf1:col1' => true } }
|
313
312
|
else
|
314
|
-
|
313
|
+
{ i => { 'cf1:col2' => true } }
|
315
314
|
end
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
315
|
+
}.reduce(&:merge)
|
316
|
+
|
317
|
+
@table.put 20.times.map { |i|
|
318
|
+
{ i + 10 => { 'cf1:col1' => 100, 'cf1:col2' => 100 } }
|
319
|
+
}.reduce(&:merge)
|
320
320
|
|
321
321
|
assert_equal 30, @table.count
|
322
322
|
assert_equal 30, @table.filter('cf1:what' => nil).count
|
@@ -365,9 +365,9 @@ class TestScoped < TestHBaseJRubyBase
|
|
365
365
|
end
|
366
366
|
|
367
367
|
def test_prefix_filter
|
368
|
-
('aa'..'zz').
|
369
|
-
|
370
|
-
|
368
|
+
@table.put ('aa'..'zz').map { |rk|
|
369
|
+
{ rk => { 'cf1:a' => 1 } }
|
370
|
+
}.reduce(&:merge)
|
371
371
|
|
372
372
|
assert_equal 26, @table.range(:prefix => 'c').count
|
373
373
|
assert_equal 1, @table.range(:prefix => 'cc').count
|
@@ -412,9 +412,9 @@ class TestScoped < TestHBaseJRubyBase
|
|
412
412
|
end
|
413
413
|
|
414
414
|
def test_while
|
415
|
-
(0...100).
|
416
|
-
|
417
|
-
|
415
|
+
@table.put (0...100).map { |idx|
|
416
|
+
{ idx => { 'cf1:a' => idx % 10, 'cf2:b' => 'Hello' } }
|
417
|
+
}.reduce(&:merge)
|
418
418
|
|
419
419
|
assert_equal 20, @table.filter('cf1:a' => { :lte => 1 }, 'cf2:b' => 'Hello').count
|
420
420
|
assert_equal 2, @table.while( 'cf1:a' => { :lte => 1 }, 'cf2:b' => 'Hello').count
|
@@ -425,17 +425,18 @@ class TestScoped < TestHBaseJRubyBase
|
|
425
425
|
end
|
426
426
|
|
427
427
|
def test_min_max
|
428
|
-
(0...
|
428
|
+
(0...20).each do |idx|
|
429
429
|
@table.put idx, 'cf1:a' => 1
|
430
|
-
|
431
|
-
assert_equal
|
430
|
+
rows = @table.to_a
|
431
|
+
assert_equal 0, rows.reverse.min.rowkey(:fixnum)
|
432
|
+
assert_equal idx, rows.reverse.max.rowkey(:fixnum)
|
432
433
|
end
|
433
434
|
end
|
434
435
|
|
435
436
|
def test_regex
|
436
|
-
('aa'..'zz').
|
437
|
-
|
438
|
-
|
437
|
+
@table.put ('aa'..'zz').map { |rowkey|
|
438
|
+
{ rowkey => { 'cf1:a' => rowkey } }
|
439
|
+
}.reduce(&:merge)
|
439
440
|
|
440
441
|
assert_equal 1, @table.filter('cf1:a' => /gg/).count
|
441
442
|
assert_equal 1, @table.filter('cf1:a' => /GG/i).count
|
@@ -451,11 +452,13 @@ class TestScoped < TestHBaseJRubyBase
|
|
451
452
|
end
|
452
453
|
|
453
454
|
def test_java_bytes_prefix
|
454
|
-
(
|
455
|
-
(1..100).
|
456
|
-
|
457
|
-
|
458
|
-
|
455
|
+
@table.put(
|
456
|
+
(1..100).map { |i|
|
457
|
+
(1..100).map { |j|
|
458
|
+
{ (HBase::ByteArray(i) + HBase::ByteArray(j)).to_java_bytes => { 'cf1:a' => i * j } }
|
459
|
+
}
|
460
|
+
}.flatten.reduce(&:merge)
|
461
|
+
)
|
459
462
|
|
460
463
|
assert_equal 100, @table.range(:prefix => HBase::ByteArray(50)).count
|
461
464
|
assert_equal 100, @table.range(:prefix => HBase::ByteArray(50).to_java_bytes).count
|
@@ -508,9 +511,9 @@ class TestScoped < TestHBaseJRubyBase
|
|
508
511
|
end
|
509
512
|
|
510
513
|
def test_with_java_scan
|
511
|
-
('a'..'z').
|
512
|
-
|
513
|
-
|
514
|
+
@table.put ('a'..'z').map { |rk|
|
515
|
+
{ rk => { 'cf1:a' => 1 } }
|
516
|
+
}.reduce(&:merge)
|
514
517
|
|
515
518
|
assert_equal 2, @table.with_java_scan { |scan|
|
516
519
|
scan.setStartRow HBase::Util.to_bytes 'a'
|
@@ -548,9 +551,9 @@ class TestScoped < TestHBaseJRubyBase
|
|
548
551
|
def test_count_options
|
549
552
|
# TODO how to confirm?
|
550
553
|
|
551
|
-
(101..150).
|
552
|
-
|
553
|
-
|
554
|
+
@table.put (101..150).map { |i|
|
555
|
+
{ i => { 'cf1:a' => i, 'cf2:b' => i, 'cf3:c' => i * 3 } }
|
556
|
+
}.reduce(&:merge)
|
554
557
|
|
555
558
|
assert_equal 50, @table.count(:cache_blocks => false)
|
556
559
|
assert_equal 50, @table.count(:cache_blocks => true)
|