jruby_hive 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e03b4c4f4068162e247238323658376026fe0de
4
+ data.tar.gz: 7a121073ed0e1cc8b403fb15ce249729b5d58814
5
+ SHA512:
6
+ metadata.gz: fcae0ab5e312f4740ef88d9c072b14d35b4b5945deab938d72d260fe19e3c820f83c6e5bd5f0ce1f1992de4759340284df73d37b92be8b12363a4e85dd3ce9a0
7
+ data.tar.gz: 407c0dba07eabfcdcca67018ab46d4744175e56f7375cadcbce3685c1c079d2ae50aed2a2ffb0fc57440224a760cefac93dd9132c516788627631b77f91ea74a
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jruby_hive.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Shinji Ikeda
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # JrubyHive
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ gem 'jruby_hive'
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install jruby_hive
16
+
17
+ ## Usage
18
+
19
+
20
+ #!/usr/bin/env jruby
21
+ # encoding utf-8
22
+
23
+ require 'jruby_hive'
24
+
25
+ hive = Hive.new
26
+ p hive.run("show tables")
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/[my-github-username]/jruby_hive/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jruby_hive"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Shinji Ikeda"]
9
+ spec.email = ["gm.ikeda@gmail.com"]
10
+ spec.summary = %q{jruby hive api}
11
+ spec.description = %q{}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ end
data/lib/jruby_hive.rb ADDED
@@ -0,0 +1,70 @@
1
+ # encoding utf-8
2
+
3
+ class Hive
4
+
5
+ def bootstrap
6
+ require 'java'
7
+
8
+ @JAR_PATTERN_0_20="hadoop-core-*.jar"
9
+
10
+ if ENV["HADOOP_HOME"]
11
+ hadoop_home=ENV["HADOOP_HOME"]
12
+ else
13
+ raise "hadoop_home is not set!"
14
+ end
15
+
16
+ if ENV['HIVE_HOME']
17
+ hive_home=ENV['HIVE_HOME']
18
+ else
19
+ raise "HIVE_HOME is not set!"
20
+ end
21
+
22
+ Dir[
23
+ "#{hadoop_home}/#{@JAR_PATTERN_0_20}",
24
+ "#{hadoop_home}/lib/*.jar",
25
+ "#{hadoop_home}/share/hadoop/common/*.jar",
26
+ "#{hadoop_home}/share/hadoop/common/lib/*.jar",
27
+ "#{hadoop_home}/share/hadoop/hdfs/*.jar",
28
+ "#{hadoop_home}/share/hadoop/hdfs/lib/*.jar",
29
+ "#{hadoop_home}/share/hadoop/mapreduce/*.jar",
30
+ "#{hadoop_home}/share/hadoop/mapreduce/lib/*.jar",
31
+ "#{hive_home}/lib/*.jar"
32
+ ].each do |jar|
33
+ require jar
34
+ end
35
+
36
+ $CLASSPATH << "#{hadoop_home}/conf"
37
+ $CLASSPATH << "#{hive_home}/conf"
38
+
39
+ java_import 'java.util.ArrayList'
40
+ java_import 'org.apache.hadoop.hive.conf.HiveConf'
41
+ #java_import 'org.apache.hadoop.hive.conf.HiveConf.ConfVars'
42
+ java_import 'org.apache.hadoop.hive.ql.Driver'
43
+ java_import 'org.apache.hadoop.hive.ql.processors.CommandProcessorResponse'
44
+ java_import 'org.apache.hadoop.hive.cli.CliSessionState'
45
+ java_import 'org.apache.hadoop.hive.ql.session.SessionState'
46
+ end
47
+
48
+ def initialize
49
+ self.bootstrap
50
+
51
+ @hconf = HiveConf.new
52
+
53
+ @driver = Driver.new(@hconf)
54
+ SessionState.start(CliSessionState.new(@hconf))
55
+ end
56
+
57
+ def run(cmd)
58
+ r = @driver.run(cmd)
59
+ if r.getResponseCode != 0
60
+ raise "hive error: " << r.getErrorMessage
61
+ end
62
+
63
+ list = ArrayList.new
64
+ if @driver.getResults(list)
65
+ return list.to_ary
66
+ end
67
+ return nil
68
+ end
69
+
70
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_hive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shinji Ikeda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '1.6'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ prerelease: false
40
+ type: :development
41
+ description: ''
42
+ email:
43
+ - gm.ikeda@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - LICENSE.txt
50
+ - README.md
51
+ - Rakefile
52
+ - jruby_hive.gemspec
53
+ - lib/jruby_hive.rb
54
+ homepage: ''
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.2
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: jruby hive api
78
+ test_files: []