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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0714705c9427de687d1657774b34d8126ef10dbd
|
4
|
+
data.tar.gz: 768ac4c28e4709151a665290402f2a3fe573aefb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2102cbfca64c12be4addf08d0c6526549fe7f25923c079b89510d0a3404d1e64245d9feac24299c9ae10ff8533f2e8aaedf08d4859af5158fcea815a34e7ba14
|
7
|
+
data.tar.gz: dfb7325181769b6e57319c072d874f2b01dce456edaad2c7d33590eda98963b9b05a5540d7856b0df85253a900d39fe4829d047bde990ca18346b810a6d92858
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
0.7.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
- Distinguish float and double
|
8
|
+
- `Cell#float` / `Cell#double`
|
9
|
+
- `Row#float` / `Row#double`
|
10
|
+
- `Row#floats` / `Row#doubles`
|
11
|
+
- `Util.to_bytes 3.14` (double by default)
|
12
|
+
- `Util.to_bytes :float => 3.14`
|
13
|
+
- `Util.to_bytes :double => 3.14`
|
14
|
+
- `Util.from_bytes :float, bytes'`
|
15
|
+
- Removed automatic disable/enable to support online alter
|
16
|
+
- Fixed `HBase::Table#alter_family[!]` not to drop previous non-default
|
17
|
+
settings
|
18
|
+
- Performance improvement with column key interpretation cache
|
19
|
+
- Dependency resolution is now deprecated
|
20
|
+
- HBase 1.0 client compatibility
|
21
|
+
|
4
22
|
0.6.4
|
5
23
|
-----
|
6
24
|
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
*hbase-jruby* provides the followings:
|
6
6
|
- Easy, Ruby-esque interface for the fundamental HBase operations
|
7
7
|
- ActiveRecord-like method chaining for data retrieval
|
8
|
-
- Automatic Hadoop/HBase dependency resolution
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
@@ -18,14 +17,13 @@ You can use this gem in HBase shell without external JRuby installation.
|
|
18
17
|
First, clone this repository,
|
19
18
|
|
20
19
|
```sh
|
21
|
-
git clone https://github.com/junegunn/hbase-jruby.git
|
20
|
+
git clone --depth 1 https://github.com/junegunn/hbase-jruby.git
|
22
21
|
```
|
23
22
|
|
24
|
-
then start up the shell (`hbase shell`) and type in the following
|
23
|
+
then start up the shell (`hbase shell`) and type in the following line:
|
25
24
|
|
26
25
|
```ruby
|
27
|
-
$LOAD_PATH << 'hbase-jruby/lib'
|
28
|
-
require 'hbase-jruby'
|
26
|
+
$LOAD_PATH << 'hbase-jruby/lib'; require 'hbase-jruby'
|
29
27
|
```
|
30
28
|
|
31
29
|
Now, you're all set.
|
@@ -46,8 +44,48 @@ hbase[:my_table].get(100).double('f:c') # Returns 3.14
|
|
46
44
|
```ruby
|
47
45
|
require 'hbase-jruby'
|
48
46
|
|
49
|
-
#
|
50
|
-
|
47
|
+
# HBase client dependencies
|
48
|
+
$CLASSPATH << 'hbase-client-dep-1.0.jar'
|
49
|
+
|
50
|
+
# Connect to HBase
|
51
|
+
hbase = HBase.new 'localhost'
|
52
|
+
|
53
|
+
# Table object
|
54
|
+
table = hbase[:test_table]
|
55
|
+
table.drop! if table.exists?
|
56
|
+
table.create! :cf1, :cf2
|
57
|
+
|
58
|
+
# PUT
|
59
|
+
table.put 'rowkey1' => { 'cf1:a' => 100, 'cf2:b' => 'Hello' },
|
60
|
+
'rowkey2' => { 'cf1:a' => 200, 'cf2:b' => 'world' }
|
61
|
+
|
62
|
+
# GET
|
63
|
+
row = table.get('rowkey1')
|
64
|
+
number = row.fixnum('cf1:a')
|
65
|
+
string = row.string('cf1:b')
|
66
|
+
|
67
|
+
# SCAN
|
68
|
+
table.range('rowkey1'..'rowkey9')
|
69
|
+
.filter('cf1:a' => 100..200, # cf1:a between 100 and 200
|
70
|
+
'cf1:b' => 'Hello', # cf1:b = 'Hello'
|
71
|
+
'cf2:c' => /world/i, # cf2:c matches /world/i
|
72
|
+
'cf2:d' => ['foo', /^BAR/i]) # cf2:d = 'foo' OR matches /^BAR/i
|
73
|
+
.project('cf1:a', 'cf2').
|
74
|
+
.each do |row|
|
75
|
+
puts row.fixnum('cf1:a')
|
76
|
+
end
|
77
|
+
|
78
|
+
# DELETE
|
79
|
+
table.delete('rowkey9')
|
80
|
+
```
|
81
|
+
|
82
|
+
## A quick example using schema definition
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require 'hbase-jruby'
|
86
|
+
|
87
|
+
# HBase client dependencies
|
88
|
+
$CLASSPATH << 'hbase-client-dep-1.0.jar'
|
51
89
|
|
52
90
|
# Connect to HBase on localhost
|
53
91
|
hbase = HBase.new
|
@@ -64,7 +102,8 @@ hbase.schema = {
|
|
64
102
|
year: :short, # Short integer (2-byte)
|
65
103
|
pages: :int, # Integer (4-byte)
|
66
104
|
price: :bigdecimal, # BigDecimal
|
67
|
-
|
105
|
+
height: :float, # Single-precision floating-point number (4-byte)
|
106
|
+
weight: :double, # Double-precision floating-point number (8-byte)
|
68
107
|
in_print: :boolean, # Boolean (true | false)
|
69
108
|
image: :raw # Java byte array; no automatic type conversion
|
70
109
|
thumbnail: :byte_array # HBase::ByteArray
|
@@ -72,7 +111,7 @@ hbase.schema = {
|
|
72
111
|
# Columns in cf2 family
|
73
112
|
cf2: {
|
74
113
|
summary: :string,
|
75
|
-
reviews: :fixnum,
|
114
|
+
reviews: :fixnum, # Long integer (8-byte)
|
76
115
|
stars: :fixnum,
|
77
116
|
/^comment\d+/ => :string
|
78
117
|
}
|
@@ -144,73 +183,25 @@ table.delete 1
|
|
144
183
|
### Resolving Hadoop/HBase dependency
|
145
184
|
|
146
185
|
To be able to access HBase from JRuby, Hadoop/HBase dependency must be
|
147
|
-
satisfied. This can be done by
|
148
|
-
or by `require`ing relevant JAR
|
186
|
+
satisfied. This can be done either by setting up CLASSPATH beforehand (e.g.
|
187
|
+
`CLASSPATH=$(hbase classpath) jruby ...`) or by `require`ing relevant JAR
|
188
|
+
files after launching JRuby.
|
149
189
|
|
150
|
-
You might
|
151
|
-
|
152
|
-
(If you don't find one, send me a pull request.)
|
190
|
+
You might want to check out pre-built uberjars for various versions of HBase
|
191
|
+
client in [hbase-client-dep releases page][client].
|
153
192
|
|
154
193
|
```ruby
|
155
194
|
require 'hbase-jruby'
|
156
|
-
|
195
|
+
$CLASSPATH << 'hbase-client-dep-1.0.jar'
|
157
196
|
|
158
|
-
HBase.log4j = { 'log4j.threshold' => 'ERROR' }
|
159
197
|
hbase = HBase.new
|
160
198
|
```
|
161
199
|
|
162
|
-
|
163
|
-
|
164
|
-
hbase-jruby is shipped with `HBase.resolve_dependency!` helper method that can
|
165
|
-
be used to load JAR files from Maven repository.
|
166
|
-
|
167
|
-
| Argument | Dependency | Default version | Required executable |
|
168
|
-
| ---------- | ------------------------ | --------------- | ------------------- |
|
169
|
-
| cdh5.2[.*] | Cloudera CDH5.2 | cdh5.2.1 | mvn |
|
170
|
-
| cdh5.1[.*] | Cloudera CDH5.1 | cdh5.1.4 | mvn |
|
171
|
-
| cdh5.0[.*] | Cloudera CDH5.0 | cdh5.0.5 | mvn |
|
172
|
-
| cdh4.5[.*] | Cloudera CDH4.5 | cdh4.5.0 | mvn |
|
173
|
-
| cdh4.4[.*] | Cloudera CDH4.4 | cdh4.4.0 | mvn |
|
174
|
-
| cdh4.3[.*] | Cloudera CDH4.3 | cdh4.3.2 | mvn |
|
175
|
-
| cdh4.2[.*] | Cloudera CDH4.2 | cdh4.2.2 | mvn |
|
176
|
-
| cdh4.1[.*] | Cloudera CDH4.1 | cdh4.1.5 | mvn |
|
177
|
-
| cdh3[u*] | Cloudera CDH3 | cdh3u6 | mvn |
|
178
|
-
| 0.98[.*] | Apache HBase 0.98 | 0.98.0-hadoop2 | mvn |
|
179
|
-
| 0.96[.*] | Apache HBase 0.96 | 0.96.2-hadoop2 | mvn |
|
180
|
-
| 0.94[.*] | Apache HBase 0.94 | 0.94.18 | mvn |
|
181
|
-
| 0.92[.*] | Apache HBase 0.92 | 0.92.2 | mvn |
|
182
|
-
| *POM PATH* | Custom Maven POM file | - | mvn |
|
183
|
-
| `:local` | Local HBase installation | - | hbase |
|
184
|
-
|
185
|
-
(Default version is used when an argument prefix is given without specific patch version.
|
186
|
-
e.g. `cdh4.2` defaults to `cdh4.2.2`)
|
187
|
-
|
188
|
-
#### Examples
|
189
|
-
|
190
|
-
```ruby
|
191
|
-
# Load JAR files from CDH4 using Maven
|
192
|
-
HBase.resolve_dependency! 'cdh4.3.0'
|
193
|
-
HBase.resolve_dependency! 'cdh4.2'
|
194
|
-
|
195
|
-
# Load JAR files of HBase 0.94.x using Maven
|
196
|
-
HBase.resolve_dependency! '0.94.7'
|
197
|
-
HBase.resolve_dependency! '0.94.2', verbose: true
|
198
|
-
|
199
|
-
# Dependency resolution with custom POM file
|
200
|
-
HBase.resolve_dependency! '/path/to/my/pom.xml'
|
201
|
-
HBase.resolve_dependency! '/path/to/my/pom.xml', profile: 'trunk'
|
202
|
-
|
203
|
-
# Load JAR files from local HBase installation
|
204
|
-
# (equivalent to: export CLASSPATH=$CLASSPATH:`hbase classpath`)
|
205
|
-
HBase.resolve_dependency! :local
|
206
|
-
```
|
207
|
-
|
208
|
-
(If you're behind an http proxy, set up your ~/.m2/settings.xml file
|
209
|
-
as described in [this page](http://maven.apache.org/guides/mini/guide-proxies.html))
|
200
|
+
[client]: https://github.com/junegunn/hbase-client-dep/releases
|
210
201
|
|
211
202
|
### Log4j logs from HBase
|
212
203
|
|
213
|
-
You
|
204
|
+
You can suppress (or customize) log messages from HBase.
|
214
205
|
|
215
206
|
```ruby
|
216
207
|
# With an external log4j.properties or log4j.xml file
|
@@ -228,6 +219,9 @@ HBase.log4j = { 'log4j.threshold' => 'ERROR' }
|
|
228
219
|
hbase = HBase.new
|
229
220
|
|
230
221
|
# HBase on remote host
|
222
|
+
hbase = HBase.new 'remote-server.mydomain.net'
|
223
|
+
|
224
|
+
# The above is equivalent to the following:
|
231
225
|
hbase = HBase.new 'hbase.zookeeper.quorum' => 'remote-server.mydomain.net'
|
232
226
|
|
233
227
|
# Extra configuration
|
@@ -303,7 +297,7 @@ hbase.schema = {
|
|
303
297
|
year: :short, # Short integer (2-byte)
|
304
298
|
pages: :int, # Integer (4-byte)
|
305
299
|
price: :bigdecimal, # BigDecimal
|
306
|
-
weight: :
|
300
|
+
weight: :double, # Double-precision floating-point number
|
307
301
|
in_print: :boolean, # Boolean (true | false)
|
308
302
|
image: :raw # Java byte array; no automatic type conversion
|
309
303
|
},
|
@@ -958,10 +952,12 @@ hbase[:dupe_table].create!(
|
|
958
952
|
|
959
953
|
## Table administration
|
960
954
|
|
961
|
-
`HBase#Table` provides a number of *bang_methods!* for table administration
|
962
|
-
They run synchronously, except when mentioned otherwise (e.g.
|
963
|
-
Some of them take an optional block to allow progress
|
964
|
-
and come with non-bang, asynchronous counterparts.
|
955
|
+
`HBase#Table` provides a number of *bang_methods!* for table administration
|
956
|
+
tasks. They run synchronously, except when mentioned otherwise (e.g.
|
957
|
+
`HTable#split!`). Some of them take an optional block to allow progress
|
958
|
+
monitoring and come with non-bang, asynchronous counterparts. If you're
|
959
|
+
running an old version of HBase cluster, you'll have to `disable!` the table
|
960
|
+
before altering it.
|
965
961
|
|
966
962
|
### Creation and alteration
|
967
963
|
|
@@ -1218,7 +1214,7 @@ first = ba[0, 8]
|
|
1218
1214
|
second = ba[8...16]
|
1219
1215
|
|
1220
1216
|
first.decode(:fixnum) # 100
|
1221
|
-
second.decode(:
|
1217
|
+
second.decode(:double) # 3.14
|
1222
1218
|
```
|
1223
1219
|
|
1224
1220
|
append, prepend more elements to it,
|
@@ -1240,7 +1236,7 @@ or shift decoded objects from it.
|
|
1240
1236
|
ba.shift(:fixnum)
|
1241
1237
|
ba.shift(:boolean)
|
1242
1238
|
ba.shift(:fixnum)
|
1243
|
-
ba.shift(:
|
1239
|
+
ba.shift(:double)
|
1244
1240
|
ba.shift(:int)
|
1245
1241
|
ba.shift(:string, 11) # Byte length must be given as Strings are not fixed in size
|
1246
1242
|
```
|
data/hbase-jruby.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
|
22
|
-
gem.add_development_dependency '
|
22
|
+
gem.add_development_dependency 'yard'
|
23
23
|
gem.add_development_dependency 'simplecov'
|
24
24
|
end
|
data/lib/hbase-jruby/cell.rb
CHANGED
@@ -101,12 +101,17 @@ class Cell
|
|
101
101
|
Util.from_bytes :bigdecimal, value
|
102
102
|
end
|
103
103
|
|
104
|
-
# Returns the column value as a Float
|
104
|
+
# Returns the 4-byte column value as a Float
|
105
105
|
# @return [Float]
|
106
106
|
def float
|
107
107
|
Util.from_bytes :float, value
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
|
+
# Returns the 8-byte column value as a Float
|
111
|
+
# @return [Float]
|
112
|
+
def double
|
113
|
+
Util.from_bytes :double, value
|
114
|
+
end
|
110
115
|
|
111
116
|
# Returns the column value as a boolean value
|
112
117
|
# @return [true, false]
|
@@ -5,213 +5,96 @@ require 'erb'
|
|
5
5
|
|
6
6
|
# HBase connection
|
7
7
|
class HBase
|
8
|
+
# @private
|
9
|
+
@mutex = Mutex.new
|
8
10
|
|
9
11
|
# @private
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
@deps = {
|
13
|
+
self => %w[
|
14
|
+
org.apache.hadoop.hbase.HBaseConfiguration
|
15
|
+
org.apache.hadoop.hbase.client.HBaseAdmin
|
16
|
+
org.apache.hadoop.hbase.client.HConnectionManager
|
17
|
+
org.apache.hadoop.hbase.client.HTablePool
|
18
|
+
],
|
19
|
+
Util => %w[
|
20
|
+
java.nio.ByteBuffer
|
21
|
+
org.apache.hadoop.hbase.KeyValue
|
22
|
+
org.apache.hadoop.hbase.util.Bytes
|
23
|
+
],
|
24
|
+
ByteArray => %w[
|
25
|
+
java.util.Arrays
|
26
|
+
org.apache.hadoop.hbase.util.Bytes
|
27
|
+
],
|
28
|
+
Cell => %w[
|
29
|
+
org.apache.hadoop.hbase.KeyValue
|
30
|
+
],
|
31
|
+
Result => %w[
|
32
|
+
org.apache.hadoop.hbase.util.Bytes
|
33
|
+
],
|
34
|
+
Table => %w[
|
35
|
+
org.apache.hadoop.hbase.HColumnDescriptor
|
36
|
+
org.apache.hadoop.hbase.HTableDescriptor
|
37
|
+
org.apache.hadoop.hbase.client.Append
|
38
|
+
org.apache.hadoop.hbase.client.Delete
|
39
|
+
org.apache.hadoop.hbase.client.Increment
|
40
|
+
org.apache.hadoop.hbase.client.Put
|
41
|
+
org.apache.hadoop.hbase.client.RowMutations
|
42
|
+
] << %w[org.apache.hadoop.hbase.io.hfile.Compression
|
43
|
+
org.apache.hadoop.hbase.io.compress.Compression],
|
44
|
+
Scoped => %w[
|
45
|
+
org.apache.hadoop.hbase.client.Get
|
46
|
+
org.apache.hadoop.hbase.client.Scan
|
47
|
+
org.apache.hadoop.hbase.filter.BinaryComparator
|
48
|
+
org.apache.hadoop.hbase.filter.ColumnPaginationFilter
|
49
|
+
org.apache.hadoop.hbase.filter.ColumnRangeFilter
|
50
|
+
org.apache.hadoop.hbase.filter.CompareFilter
|
51
|
+
org.apache.hadoop.hbase.filter.FilterBase
|
52
|
+
org.apache.hadoop.hbase.filter.FilterList
|
53
|
+
org.apache.hadoop.hbase.filter.KeyOnlyFilter
|
54
|
+
org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter
|
55
|
+
org.apache.hadoop.hbase.filter.MultipleColumnPrefixFilter
|
56
|
+
org.apache.hadoop.hbase.filter.PrefixFilter
|
57
|
+
org.apache.hadoop.hbase.filter.RegexStringComparator
|
58
|
+
org.apache.hadoop.hbase.filter.RowFilter
|
59
|
+
org.apache.hadoop.hbase.filter.SingleColumnValueFilter
|
60
|
+
org.apache.hadoop.hbase.filter.WhileMatchFilter
|
61
|
+
org.apache.hadoop.hbase.client.coprocessor.AggregationClient
|
62
|
+
org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter
|
63
|
+
]
|
30
64
|
}
|
31
65
|
|
32
66
|
class << self
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
# @option options [Boolean] :verbose Enable verbose output
|
38
|
-
# @return [Array<String>] Loaded JAR files
|
39
|
-
# @overload resolve_dependency!(pom_path, options)
|
40
|
-
# Resolve Hadoop and HBase dependency with the given Maven POM file
|
41
|
-
# @param [String] pom_path Path to POM file
|
42
|
-
# @param [Hash] options Options
|
43
|
-
# @option options [Boolean] :verbose Enable verbose output
|
44
|
-
# @option options [String] :profile Maven profile
|
45
|
-
# @return [Array<String>] Loaded JAR files
|
46
|
-
def resolve_dependency! dist, options = {}
|
47
|
-
# Backward-compatibility
|
48
|
-
options = { :verbose => options } if [true, false].include?(options)
|
49
|
-
options = { :verbose => false }.merge(options)
|
50
|
-
|
51
|
-
dist = dist.to_s
|
52
|
-
verbose = options[:verbose]
|
53
|
-
|
54
|
-
silencer = verbose ? '' : '> /dev/null'
|
55
|
-
tempfiles = []
|
56
|
-
|
57
|
-
jars =
|
58
|
-
if %w[hbase local].include?(dist)
|
59
|
-
# Check for hbase executable
|
60
|
-
hbase = `which hbase`
|
61
|
-
raise RuntimeError, "Cannot find `hbase` executable" if hbase.empty?
|
62
|
-
`hbase classpath`.strip.split(':').map { |e| Dir[e] }.flatten
|
63
|
-
else
|
64
|
-
# Check for Maven executable
|
65
|
-
mvn = `which mvn`
|
66
|
-
raise RuntimeError, "Cannot find `mvn` executable" if mvn.empty?
|
67
|
-
|
68
|
-
# POM file path given (with optional profile)
|
69
|
-
if File.exists?(dist)
|
70
|
-
path = dist
|
71
|
-
profile = options[:profile] && "-P #{options[:profile]}"
|
72
|
-
# Predefined dependencies
|
73
|
-
else
|
74
|
-
matched_profiles = SUPPORTED_PROFILES.keys.select { |pf| dist.start_with? pf }
|
75
|
-
if matched_profiles.length != 1
|
76
|
-
raise ArgumentError, "Unknown profile: #{dist}"
|
77
|
-
end
|
78
|
-
matched_profile = matched_profiles.first
|
79
|
-
profiles = SUPPORTED_PROFILES.dup
|
80
|
-
profiles[matched_profile] = dist if dist != matched_profile
|
81
|
-
tempfiles << tf = Tempfile.new('hbase-jruby-pom')
|
82
|
-
erb = ERB.new(File.read File.expand_path("../pom/pom.xml.erb", __FILE__))
|
83
|
-
tf << erb.result(binding)
|
84
|
-
tf.close(false)
|
85
|
-
path = tf.path
|
86
|
-
profile = "-P #{matched_profile}"
|
87
|
-
end
|
88
|
-
|
89
|
-
# Download dependent JAR files and build classpath string
|
90
|
-
tempfiles << tf = Tempfile.new('hbase-jruby-classpath')
|
91
|
-
tf.close(false)
|
92
|
-
system("mvn org.apache.maven.plugins:maven-dependency-plugin:2.5.1:resolve " <<
|
93
|
-
"org.apache.maven.plugins:maven-dependency-plugin:2.5.1:build-classpath " <<
|
94
|
-
"-Dsilent=true -Dmdep.outputFile=#{tf.path} #{profile} -f #{path} #{silencer}")
|
95
|
-
|
96
|
-
unless $?.exitstatus == 0
|
97
|
-
message = "Error occurred."
|
98
|
-
message << " Set verbose option to see the log." unless verbose
|
99
|
-
raise RuntimeError.new(message)
|
100
|
-
end
|
101
|
-
|
102
|
-
if File.read(tf.path).empty?
|
103
|
-
desc =
|
104
|
-
if options[:profile]
|
105
|
-
"#{dist} (#{options[:profile]})"
|
106
|
-
else
|
107
|
-
dist
|
108
|
-
end
|
109
|
-
raise ArgumentError.new("Invalid profile: #{desc}")
|
110
|
-
end
|
111
|
-
File.read(tf.path).split(':')
|
112
|
-
end
|
113
|
-
|
114
|
-
# Load jars
|
115
|
-
jars_loaded = jars.select { |jar|
|
116
|
-
File.file?(jar) &&
|
117
|
-
File.extname(jar).downcase == '.jar' &&
|
118
|
-
require(jar)
|
119
|
-
}
|
120
|
-
|
121
|
-
# Apply pending log4j configuration
|
122
|
-
HBase.log4j = @@log4j if @@log4j
|
123
|
-
|
124
|
-
# Try importing Java classes again
|
125
|
-
not_found = HBase.import_java_classes!
|
126
|
-
if verbose && !not_found.empty?
|
127
|
-
warn "Java classes not found: #{not_found.join(', ')}"
|
128
|
-
end
|
129
|
-
|
130
|
-
return jars_loaded
|
131
|
-
ensure
|
132
|
-
tempfiles.each { |tempfile| tempfile.unlink rescue nil }
|
67
|
+
# Returns the version of the loaded client library
|
68
|
+
# @return [String]
|
69
|
+
def version
|
70
|
+
org.apache.hadoop.hbase.util.VersionInfo.getVersion
|
133
71
|
end
|
134
72
|
|
135
|
-
#
|
136
|
-
# @return [Array<String>] List of Java classes *NOT* found
|
73
|
+
# @private
|
137
74
|
def import_java_classes!
|
138
|
-
|
139
|
-
|
75
|
+
@mutex.synchronize do
|
76
|
+
@deps.each do |base, list|
|
140
77
|
base.class_eval do
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
78
|
+
list.reject! do |classes|
|
79
|
+
[*classes].find do |klass|
|
80
|
+
begin
|
81
|
+
java_import klass
|
82
|
+
true
|
83
|
+
rescue NameError
|
84
|
+
false
|
85
|
+
end
|
147
86
|
end
|
148
|
-
}.compact
|
149
|
-
end
|
150
|
-
}.flatten
|
151
|
-
}
|
152
|
-
|
153
|
-
imp.call(
|
154
|
-
HBase => %w[
|
155
|
-
org.apache.hadoop.hbase.HBaseConfiguration
|
156
|
-
org.apache.hadoop.hbase.client.HBaseAdmin
|
157
|
-
org.apache.hadoop.hbase.client.HConnectionManager
|
158
|
-
org.apache.hadoop.hbase.client.HTablePool
|
159
|
-
],
|
160
|
-
HBase::Util => %w[
|
161
|
-
java.nio.ByteBuffer
|
162
|
-
org.apache.hadoop.hbase.KeyValue
|
163
|
-
org.apache.hadoop.hbase.util.Bytes
|
164
|
-
],
|
165
|
-
HBase::ByteArray => %w[
|
166
|
-
java.util.Arrays
|
167
|
-
org.apache.hadoop.hbase.util.Bytes
|
168
|
-
],
|
169
|
-
HBase::Cell => %w[
|
170
|
-
org.apache.hadoop.hbase.KeyValue
|
171
|
-
],
|
172
|
-
HBase::Result => %w[
|
173
|
-
org.apache.hadoop.hbase.util.Bytes
|
174
|
-
],
|
175
|
-
HBase::Table => %w[
|
176
|
-
org.apache.hadoop.hbase.HColumnDescriptor
|
177
|
-
org.apache.hadoop.hbase.HTableDescriptor
|
178
|
-
org.apache.hadoop.hbase.client.Append
|
179
|
-
org.apache.hadoop.hbase.client.Delete
|
180
|
-
org.apache.hadoop.hbase.client.Increment
|
181
|
-
org.apache.hadoop.hbase.client.Put
|
182
|
-
org.apache.hadoop.hbase.client.RowMutations
|
183
|
-
org.apache.hadoop.hbase.io.hfile.Compression
|
184
|
-
org.apache.hadoop.hbase.io.compress.Compression
|
185
|
-
], # hfile.Compression <= 0.94
|
186
|
-
HBase::Scoped => %w[
|
187
|
-
org.apache.hadoop.hbase.client.Get
|
188
|
-
org.apache.hadoop.hbase.client.Scan
|
189
|
-
org.apache.hadoop.hbase.filter.BinaryComparator
|
190
|
-
org.apache.hadoop.hbase.filter.ColumnPaginationFilter
|
191
|
-
org.apache.hadoop.hbase.filter.ColumnRangeFilter
|
192
|
-
org.apache.hadoop.hbase.filter.CompareFilter
|
193
|
-
org.apache.hadoop.hbase.filter.FilterBase
|
194
|
-
org.apache.hadoop.hbase.filter.FilterList
|
195
|
-
org.apache.hadoop.hbase.filter.KeyOnlyFilter
|
196
|
-
org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter
|
197
|
-
org.apache.hadoop.hbase.filter.MultipleColumnPrefixFilter
|
198
|
-
org.apache.hadoop.hbase.filter.PrefixFilter
|
199
|
-
org.apache.hadoop.hbase.filter.RegexStringComparator
|
200
|
-
org.apache.hadoop.hbase.filter.RowFilter
|
201
|
-
org.apache.hadoop.hbase.filter.SingleColumnValueFilter
|
202
|
-
org.apache.hadoop.hbase.filter.WhileMatchFilter
|
203
|
-
org.apache.hadoop.hbase.client.coprocessor.AggregationClient
|
204
|
-
org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter
|
205
|
-
]).tap { |not_found|
|
206
|
-
|
207
|
-
if not_found.empty?
|
208
|
-
self.instance_eval do
|
209
|
-
def import_java_classes!
|
210
|
-
[]
|
211
87
|
end
|
212
88
|
end
|
213
89
|
end
|
214
|
-
|
90
|
+
@deps.reject! { |k, v| v.empty? }
|
91
|
+
|
92
|
+
self.instance_eval do
|
93
|
+
def import_java_classes!
|
94
|
+
end
|
95
|
+
end if @deps.empty?
|
96
|
+
end
|
97
|
+
nil
|
215
98
|
end
|
216
99
|
end#class << self
|
217
100
|
end
|