class Embulk::InputHBase
Public Class Methods
new(task, schema, index, page_builder)
click to toggle source
Calls superclass method
# File lib/embulk/input_hbase.rb, line 20 def initialize(task, schema, index, page_builder) super end
transaction(config) { |task, columns, threads| ... }
click to toggle source
# File lib/embulk/input_hbase.rb, line 7 def self.transaction(config, &control) task = { 'host' => config.param('host', :string, default: 'localhost'), 'table' => config.param('table', :string) } threads = 1 columns = config.param('columns', :array).map.with_index { |column, i| Column.new(i, column['name'], column['type'].to_sym) } commit_reports = yield(task, columns, threads) return {} end
Public Instance Methods
run()
click to toggle source
# File lib/embulk/input_hbase.rb, line 24 def run HBase.resolve_dependency! '0.98' hbase = HBase.new('hbase.zookeeper.quorum' => @task['host']) table = hbase.table(@task['table']) table.each { |row| @page_builder.add(@schema.map { |column| value = row[column.name] case column.type when :long if value HBase::Util::from_bytes(:long, value) else 0 end when :string if value HBase::Util::from_bytes(:string, value) else '' end else value end }) } @page_builder.finish commit_report = { } return commit_report end