embulk-plugin-input-hbase 0.0.1
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 +7 -0
- data/README.md +42 -0
- data/lib/embulk/input_hbase.rb +55 -0
- metadata +87 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 86fec11c1456942d02ab71d1af28eb9485ca9d0f
         | 
| 4 | 
            +
              data.tar.gz: cdfb3faa20b8196951c482f73073655218d1df22
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 2d768b08a793abedcc55b4feea1c3d6e9a6a4f900c394612429277e2eff079d116c7622c08e625903210f3ac6408701b6094c7e30589b1fbf6f6e5d035312c0e
         | 
| 7 | 
            +
              data.tar.gz: 4376a62c510a62d4fba1166759059692b153e4aa9c6bf13d1071f56f37b7dbdc2bf0a1f4563f3066a5ecf28a06ddecab3ef262457e6ac294d27671be81d863ac
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            # embulk-plugin-input-hbase
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ## Example
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            HBase table:
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ```ruby
         | 
| 8 | 
            +
            hbase(main):029:0> scan 'example:test'
         | 
| 9 | 
            +
            ROW                                  COLUMN+CELL                                                                                               
         | 
| 10 | 
            +
             r1                                  column=foo:dig, timestamp=1422458241976, value=\x00\x00\x00\x00\x00\x00\x00\x01                           
         | 
| 11 | 
            +
             r2                                  column=foo:dig, timestamp=1422458257028, value=\x00\x00\x00\x00\x00\x00\x00\x02                           
         | 
| 12 | 
            +
             r2                                  column=foo:str, timestamp=1422458830978, value=hello                                                      
         | 
| 13 | 
            +
             r3                                  column=foo:str, timestamp=1422458270762, value=hey                                                        
         | 
| 14 | 
            +
            3 row(s) in 0.0860 seconds
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Embulk config:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ```yaml
         | 
| 20 | 
            +
            in:
         | 
| 21 | 
            +
              type: hbase
         | 
| 22 | 
            +
              host: localhost
         | 
| 23 | 
            +
              table: 'example:test'
         | 
| 24 | 
            +
              columns:
         | 
| 25 | 
            +
                - {name: 'foo:dig', type: long}
         | 
| 26 | 
            +
                - {name: 'foo:str', type: string}
         | 
| 27 | 
            +
            out:
         | 
| 28 | 
            +
              type: stdout
         | 
| 29 | 
            +
            ```
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            Embulk preview:
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ```bash
         | 
| 34 | 
            +
            $ java -jar embulk.jar preview example.yml
         | 
| 35 | 
            +
            +--------------+----------------+
         | 
| 36 | 
            +
            | foo:dig:long | foo:str:string |
         | 
| 37 | 
            +
            +--------------+----------------+
         | 
| 38 | 
            +
            |            1 |                |
         | 
| 39 | 
            +
            |            2 |          hello |
         | 
| 40 | 
            +
            |            0 |            hey |
         | 
| 41 | 
            +
            +--------------+----------------+
         | 
| 42 | 
            +
            ```
         | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            require 'hbase-jruby'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Embulk
         | 
| 4 | 
            +
              class InputHBase < InputPlugin
         | 
| 5 | 
            +
                Plugin.register_input('hbase', self)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def self.transaction(config, &control)
         | 
| 8 | 
            +
                  task = {
         | 
| 9 | 
            +
                    'host' => config.param('host', :string, default: 'localhost'),
         | 
| 10 | 
            +
                    'table' => config.param('table', :string)
         | 
| 11 | 
            +
                  }
         | 
| 12 | 
            +
                  threads = 1
         | 
| 13 | 
            +
                  columns = config.param('columns', :array).map.with_index { |column, i|
         | 
| 14 | 
            +
                    Column.new(i, column['name'], column['type'].to_sym)
         | 
| 15 | 
            +
                  }
         | 
| 16 | 
            +
                  commit_reports = yield(task, columns, threads)
         | 
| 17 | 
            +
                  return {}
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def initialize(task, schema, index, page_builder)
         | 
| 21 | 
            +
                  super
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def run
         | 
| 25 | 
            +
                  HBase.resolve_dependency! '0.98'
         | 
| 26 | 
            +
                  hbase = HBase.new('hbase.zookeeper.quorum' => @task['host'])
         | 
| 27 | 
            +
                  table = hbase.table(@task['table'])
         | 
| 28 | 
            +
                  table.each { |row|
         | 
| 29 | 
            +
                    @page_builder.add(@schema.map { |column|
         | 
| 30 | 
            +
                      value = row[column.name]
         | 
| 31 | 
            +
                      case column.type
         | 
| 32 | 
            +
                      when :long
         | 
| 33 | 
            +
                        if value
         | 
| 34 | 
            +
                          HBase::Util::from_bytes(:long, value)
         | 
| 35 | 
            +
                        else
         | 
| 36 | 
            +
                          0
         | 
| 37 | 
            +
                        end
         | 
| 38 | 
            +
                      when :string
         | 
| 39 | 
            +
                        if value
         | 
| 40 | 
            +
                          HBase::Util::from_bytes(:string, value)
         | 
| 41 | 
            +
                        else
         | 
| 42 | 
            +
                          ''
         | 
| 43 | 
            +
                        end
         | 
| 44 | 
            +
                      else
         | 
| 45 | 
            +
                        value
         | 
| 46 | 
            +
                      end
         | 
| 47 | 
            +
                    })
         | 
| 48 | 
            +
                  }
         | 
| 49 | 
            +
                  @page_builder.finish
         | 
| 50 | 
            +
                  commit_report = {
         | 
| 51 | 
            +
                  }
         | 
| 52 | 
            +
                  return commit_report
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,87 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: embulk-plugin-input-hbase
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Shun Takebayashi
         | 
| 8 | 
            +
            autorequire:
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-01-28 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: hbase-jruby
         | 
| 15 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 21 | 
            +
                requirements:
         | 
| 22 | 
            +
                - - ">="
         | 
| 23 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 24 | 
            +
                    version: '0'
         | 
| 25 | 
            +
              prerelease: false
         | 
| 26 | 
            +
              type: :runtime
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: bundler
         | 
| 29 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '1.0'
         | 
| 34 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 35 | 
            +
                requirements:
         | 
| 36 | 
            +
                - - "~>"
         | 
| 37 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 38 | 
            +
                    version: '1.0'
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              type: :development
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rake
         | 
| 43 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 0.9.2
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                requirements:
         | 
| 50 | 
            +
                - - ">="
         | 
| 51 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            +
                    version: 0.9.2
         | 
| 53 | 
            +
              prerelease: false
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
            description: Embulk plugin for HBase input
         | 
| 56 | 
            +
            email: shun@takebayashi.asia
         | 
| 57 | 
            +
            executables: []
         | 
| 58 | 
            +
            extensions: []
         | 
| 59 | 
            +
            extra_rdoc_files: []
         | 
| 60 | 
            +
            files:
         | 
| 61 | 
            +
            - README.md
         | 
| 62 | 
            +
            - lib/embulk/input_hbase.rb
         | 
| 63 | 
            +
            homepage: https://github.com/takebayashi/embulk-plugin-input-hbase
         | 
| 64 | 
            +
            licenses:
         | 
| 65 | 
            +
            - Apache 2.0
         | 
| 66 | 
            +
            metadata: {}
         | 
| 67 | 
            +
            post_install_message:
         | 
| 68 | 
            +
            rdoc_options: []
         | 
| 69 | 
            +
            require_paths:
         | 
| 70 | 
            +
            - lib
         | 
| 71 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
              requirements:
         | 
| 73 | 
            +
              - - ">="
         | 
| 74 | 
            +
                - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                  version: '0'
         | 
| 76 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 77 | 
            +
              requirements:
         | 
| 78 | 
            +
              - - ">="
         | 
| 79 | 
            +
                - !ruby/object:Gem::Version
         | 
| 80 | 
            +
                  version: '0'
         | 
| 81 | 
            +
            requirements: []
         | 
| 82 | 
            +
            rubyforge_project:
         | 
| 83 | 
            +
            rubygems_version: 2.4.5
         | 
| 84 | 
            +
            signing_key:
         | 
| 85 | 
            +
            specification_version: 4
         | 
| 86 | 
            +
            summary: Embulk plugin for HBase input
         | 
| 87 | 
            +
            test_files: []
         |