hbase-jruby 0.2.3-java → 0.2.4-java

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.2.4
5
+ -----
6
+ - Fixed NameError when HBase::ByteArray is used without first creating an HBase instance
7
+ - Updated dependency profiles: 0.95.0, 0.94.6.1, 0.92.2, cdh3u6
8
+
4
9
  0.2.3
5
10
  -----
6
11
  - Fix: [Thread.current[:htable] must be local to each connection](https://github.com/junegunn/hbase-jruby/issues/4)
data/README.md CHANGED
@@ -66,15 +66,19 @@ or by `require`ing relevant JAR files after launching JRuby.
66
66
  Well, there's an easier way.
67
67
  Call `HBase.resolve_dependency!` helper method passing one of the arguments listed below.
68
68
 
69
- | Argument | Dependency | Required executable |
70
- |------------|--------------------------|---------------------|
71
- | cdh4.2[.*] | Cloudera CDH4.2 | mvn |
72
- | cdh4.1[.*] | Cloudera CDH4.1 | mvn |
73
- | cdh3[u*] | Cloudera CDH3 | mvn |
74
- | 0.94[.*] | Apache HBase 0.94 | mvn |
75
- | 0.92[.*] | Apache HBase 0.92 | mvn |
76
- | *POM PATH* | Custom Maven POM file | mvn |
77
- | `:local` | Local HBase installation | hbase |
69
+ | Argument | Dependency | Default version | Required executable |
70
+ | ---------- | ------------------------ | --------------- | ------------------- |
71
+ | cdh4.2[.*] | Cloudera CDH4.2 | cdh4.2.0 | mvn |
72
+ | cdh4.1[.*] | Cloudera CDH4.1 | cdh4.1.3 | mvn |
73
+ | cdh3[u*] | Cloudera CDH3 | cdh3u6 | mvn |
74
+ | 0.95[.*] | Apache HBase 0.95 | 0.95.0 | mvn |
75
+ | 0.94[.*] | Apache HBase 0.94 | 0.94.6.1 | mvn |
76
+ | 0.92[.*] | Apache HBase 0.92 | 0.92.2 | mvn |
77
+ | *POM PATH* | Custom Maven POM file | - | mvn |
78
+ | `:local` | Local HBase installation | - | hbase |
79
+
80
+ (Default version is used when an argument prefix is given without specific patch version.
81
+ e.g. `cdh4.2` defaults to `cdh4.2.0`)
78
82
 
79
83
  #### Examples
80
84
 
@@ -84,7 +88,7 @@ HBase.resolve_dependency! 'cdh4.2.0'
84
88
  HBase.resolve_dependency! 'cdh4.1.3'
85
89
 
86
90
  # Load JAR files of HBase 0.94.x using Maven
87
- HBase.resolve_dependency! '0.94.1'
91
+ HBase.resolve_dependency! '0.94.6.1'
88
92
  HBase.resolve_dependency! '0.94.2', :verbose => true
89
93
 
90
94
  # Dependency resolution with custom POM file
@@ -92,6 +96,7 @@ HBase.resolve_dependency! '/path/to/my/pom.xml'
92
96
  HBase.resolve_dependency! '/path/to/my/pom.xml', :profile => 'trunk'
93
97
 
94
98
  # Load JAR files from local HBase installation
99
+ # (equivalent to: export CLASSPATH=$CLASSPATH:`hbase classpath`)
95
100
  HBase.resolve_dependency! :local
96
101
  ```
97
102
 
@@ -20,9 +20,13 @@ class ByteArray
20
20
  # each converted to its byte array representation
21
21
  # @param [*Object] values
22
22
  def initialize *values
23
- @java = values.inject(Util::JAVA_BYTE_ARRAY_EMPTY) { |sum, value|
24
- Bytes.add sum, Util.to_bytes(value)
25
- }
23
+ HBase.import_java_classes!
24
+ if defined?(Bytes) && defined?(Arrays)
25
+ ByteArray.class_eval do
26
+ alias initialize initialize_
27
+ end
28
+ end
29
+ initialize_(*values)
26
30
  end
27
31
 
28
32
  def each
@@ -111,7 +115,7 @@ class ByteArray
111
115
  length
112
116
  end
113
117
  raise ArgumentError.new("Byte length must be specified for type: #{type}") unless length
114
- raise ArgumentError.new("Not enought bytes for #{type}") if length > @java.length
118
+ raise ArgumentError.new("Not enough bytes for #{type}") if length > @java.length
115
119
 
116
120
  arr = @java.to_a
117
121
  val = arr[0, length].to_java(Java::byte)
@@ -142,6 +146,13 @@ class ByteArray
142
146
  def hash
143
147
  Arrays.java_send(:hashCode, [Util::JAVA_BYTE_ARRAY_CLASS], @java)
144
148
  end
149
+
150
+ private
151
+ def initialize_ *values
152
+ @java = values.inject(Util::JAVA_BYTE_ARRAY_EMPTY) { |sum, value|
153
+ Bytes.add sum, Util.to_bytes(value)
154
+ }
155
+ end
145
156
  end#ByteArray
146
157
  end#HBase
147
158
 
@@ -7,13 +7,17 @@ require 'erb'
7
7
  class HBase
8
8
 
9
9
  # @private
10
+ # https://github.com/apache/hbase/tags
11
+ # http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.hbase%22%20AND%20a%3A%22hbase%22
12
+ # https://ccp.cloudera.com/display/SUPPORT/CDH+Downloads
10
13
  SUPPORTED_PROFILES = {
11
- # Prefix => Latest version
14
+ # Prefix => Latest known version
12
15
  'cdh4.2' => 'cdh4.2.0',
13
16
  'cdh4.1' => 'cdh4.1.3',
14
- 'cdh3' => 'cdh3u5',
15
- '0.94' => '0.94.3',
16
- '0.92' => '0.92.1',
17
+ 'cdh3' => 'cdh3u6',
18
+ '0.95' => '0.95.0',
19
+ '0.94' => '0.94.6.1',
20
+ '0.92' => '0.92.2',
17
21
  }
18
22
 
19
23
  class << self
@@ -111,7 +115,7 @@ class HBase
111
115
  end
112
116
 
113
117
  # Import Java classes (Prerequisite for classes in hbase-jruby)
114
- # @return [Array<String>] List of Java classes not found
118
+ # @return [Array<String>] List of Java classes *NOT* found
115
119
  def import_java_classes!
116
120
  imp = lambda { |hash|
117
121
  hash.map { |base, classes|
@@ -4,7 +4,7 @@
4
4
 
5
5
  <groupId>hbase-jruby</groupId>
6
6
  <artifactId>hbase-project</artifactId>
7
- <version>0.2.3</version>
7
+ <version>0.2.4</version>
8
8
  <packaging>jar</packaging>
9
9
 
10
10
  <name>hbase-jruby</name>
@@ -115,37 +115,13 @@
115
115
  </dependencies>
116
116
  </profile>
117
117
 
118
+ <% %w[0.92 0.94 0.95].each do |version| %>
118
119
  <profile>
119
- <id>0.92</id>
120
+ <id><%= version %></id>
120
121
  <properties>
121
122
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
122
- <hadoop.version>1.1.1</hadoop.version>
123
- <hbase.version><%= profiles['0.92'] %></hbase.version>
124
- </properties>
125
-
126
- <dependencies>
127
- <dependency>
128
- <groupId>org.apache.hadoop</groupId>
129
- <artifactId>hadoop-core</artifactId>
130
- <version>${hadoop.version}</version>
131
- <scope>compile</scope>
132
- </dependency>
133
-
134
- <dependency>
135
- <groupId>org.apache.hbase</groupId>
136
- <artifactId>hbase</artifactId>
137
- <version>${hbase.version}</version>
138
- <scope>compile</scope>
139
- </dependency>
140
- </dependencies>
141
- </profile>
142
-
143
- <profile>
144
- <id>0.94</id>
145
- <properties>
146
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
147
- <hadoop.version>1.1.1</hadoop.version>
148
- <hbase.version><%= profiles['0.94'] %></hbase.version>
123
+ <hadoop.version>1.1.2</hadoop.version>
124
+ <hbase.version><%= profiles[version] %></hbase.version>
149
125
  </properties>
150
126
 
151
127
  <dependencies>
@@ -164,6 +140,7 @@
164
140
  </dependency>
165
141
  </dependencies>
166
142
  </profile>
143
+ <% end %>
167
144
  </profiles>
168
145
  </project>
169
146
 
@@ -389,7 +389,7 @@ private
389
389
  # Timerange / Timestamp
390
390
  case @trange
391
391
  when Array
392
- get.setTimeRange *@trange
392
+ get.setTimeRange(*@trange)
393
393
  when Time, Fixnum
394
394
  get.setTimeStamp @trange
395
395
  end
@@ -520,7 +520,7 @@ private
520
520
  # Timerange / Timestamp
521
521
  case @trange
522
522
  when Array
523
- scan.setTimeRange *@trange
523
+ scan.setTimeRange(*@trange)
524
524
  when Time, Fixnum
525
525
  scan.setTimeStamp @trange
526
526
  end
@@ -65,7 +65,7 @@ class Table
65
65
  case desc
66
66
  when HTableDescriptor
67
67
  patch_table_descriptor! desc, props
68
- admin.createTable *[desc, splits].compact
68
+ admin.createTable(*[desc, splits].compact)
69
69
  when Symbol, String
70
70
  todo = lambda { create!({desc => {}}, props) }
71
71
  when Hash
@@ -75,7 +75,7 @@ class Table
75
75
  htd.addFamily hcd(name, opts)
76
76
  end
77
77
 
78
- admin.createTable *[htd, splits].compact
78
+ admin.createTable(*[htd, splits].compact)
79
79
  else
80
80
  raise ArgumentError, 'Invalid table description'
81
81
  end
@@ -14,6 +14,8 @@ module Util
14
14
  # @param [byte[]] v
15
15
  # @return [byte[]]
16
16
  def to_bytes v
17
+ import_java_classes!
18
+
17
19
  case v
18
20
  when Array
19
21
  v.to_java(Java::byte)
@@ -70,6 +72,7 @@ module Util
70
72
  def from_bytes type, val
71
73
  return nil if val.nil?
72
74
 
75
+ import_java_classes!
73
76
  case type
74
77
  when :string, :str
75
78
  Bytes.to_string val
@@ -124,6 +127,17 @@ module Util
124
127
  return cf, cq
125
128
  end
126
129
  end
130
+
131
+ private
132
+ def import_java_classes!
133
+ HBase.import_java_classes!
134
+ if defined?(ByteBuffer) && defined?(KeyValue) && defined?(Bytes)
135
+ self.instance_eval do
136
+ def import_java_classes!
137
+ end
138
+ end
139
+ end
140
+ end
127
141
  end
128
142
 
129
143
  private
@@ -1,5 +1,5 @@
1
1
  class HBase
2
2
  module JRuby
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: hbase-jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: java
7
7
  authors:
8
8
  - Junegunn Choi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-05 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit