Sha256: 74b9625484a855925e7f352e30360425a9f38da26362a64a15a8cd47840d6c34

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

class HBase
class Table
# Class used to register actions to perform in batch
class BatchAction
  attr_reader :actions
  attr_reader :types

  class BatchGetScoped
    # @see HBase::Scoped#get
    def get rowkey
      @callback.call @scoped.send(:getify, rowkey)
    end

    [:range, :project, :filter, :versions, :time_range, :at].each do |method|
      define_method(method) do |*args|
        BatchGetScoped.send(:new, @scoped.send(method, *args), @callback)
      end
    end

  private
    def initialize scoped, callback
      @scoped   = scoped
      @callback = callback
    end
  end

  # @see HBase::Table#put
  def put *args
    @actions << { :type => :put, :action => @mutation.put(*args) }
  end

  # @see HBase::Table#delete
  def delete *args
    @actions << { :type => :delete, :action => @mutation.delete(*args) }
  end

  # @see HBase::Table#append
  def append *args
    @actions << { :type => :append, :action => @mutation.append(*args) }
  end

  # @see HBase::Table#increment
  def increment *args
    @actions << { :type => :increment, :action => @mutation.increment(*args) }
  end

  [:get, :range, :project, :filter, :versions, :time_range, :at].each do |method|
    define_method(method) do |*args|
      BatchGetScoped.send(:new, @table.scoped, proc { |get|
        @actions << { :type => :get, :action => get }
      }).send(method, *args)
    end
  end

private
  def initialize table, mutation
    @table    = table
    @mutation = mutation
    @actions  = []
  end
end#BatchAction
end#Table
end#HBase

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hbase-jruby-0.7.1-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.7.0-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.6.4-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.6.3-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.6.2-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.6.1-java lib/hbase-jruby/table/batch_action.rb
hbase-jruby-0.6.0-java lib/hbase-jruby/table/batch_action.rb