Class: HBase::Table

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Admin, Scoped::Aggregation::Admin, Util
Defined in:
lib/hbase-jruby/table.rb,
lib/hbase-jruby/table/admin.rb,
lib/hbase-jruby/table/mutation.rb,
lib/hbase-jruby/table/inspection.rb,
lib/hbase-jruby/table/batch_action.rb,
lib/hbase-jruby/table/checked_operation.rb

Overview

@return [org.apache.hadoop.conf.Configuration]

Defined Under Namespace

Modules: ThreadLocalCache Classes: BatchAction, CheckedOperation, Mutation

Constant Summary

Constants included from Util

Util::JAVA_BYTE_ARRAY_CLASS, Util::JAVA_BYTE_ARRAY_EMPTY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

append_0, from_bytes, java_bytes?, parse_column_name, to_bytes, to_typed_bytes

Methods included from Scoped::Aggregation::Admin

#disable_aggregation, #disable_aggregation!, #enable_aggregation, #enable_aggregation!

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/hbase-jruby/table.rb', line 11

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/hbase-jruby/table.rb', line 10

def name
  @name
end

Instance Method Details

#add_coprocessor(class_name, props = {}) ⇒ Object

Adds the table coprocessor to the table (asynchronous)



178
179
180
# File 'lib/hbase-jruby/table/admin.rb', line 178

def add_coprocessor class_name, props = {}
  _add_coprocessor class_name, props, false
end

#add_coprocessor!(class_name, props = {}) {|progress, total| ... } ⇒ Object

Adds the table coprocessor to the table

Parameters:

  • class_name (String)

    Full class name of the coprocessor

  • props (Hash) (defaults to: {})

    Coprocessor properties

Options Hash (props):

  • path (String)

    The path of the JAR file

  • priority (Fixnum)

    Coprocessor priority

  • params (Hash<#to_s, #to_s>)

    Arbitrary key-value parameter pairs passed into the coprocessor

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions



173
174
175
# File 'lib/hbase-jruby/table/admin.rb', line 173

def add_coprocessor! class_name, props = {}, &block
  _add_coprocessor class_name, props, true, &block
end

#add_family(name, opts) ⇒ Object

Adds the column family (asynchronous)

See Also:



127
128
129
# File 'lib/hbase-jruby/table/admin.rb', line 127

def add_family name, opts
  _add_family name, opts, false
end

#add_family!(name, opts) {|progress, total| ... } ⇒ nil

Adds the column family (synchronous)

Parameters:

  • name (#to_s)

    The name of the column family

  • opts (Hash)

    Column family properties

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions

Returns:

  • (nil)


121
122
123
# File 'lib/hbase-jruby/table/admin.rb', line 121

def add_family! name, opts, &block
  _add_family name, opts, true, &block
end

#alter(props) ⇒ Object

Alters the table (asynchronous)

See Also:



110
111
112
# File 'lib/hbase-jruby/table/admin.rb', line 110

def alter props
  _alter props, false
end

#alter!(props) {|progress, total| ... } ⇒ nil

Alters the table (synchronous)

Examples:

table.alter!(
  :max_filesize       => 512 * 1024 ** 2,
  :memstore_flushsize =>  64 * 1024 ** 2,
  :readonly           => false,
  :durability         => :async_wal
)

Parameters:

  • props (Hash)

    Table properties

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions

Returns:

  • (nil)


104
105
106
# File 'lib/hbase-jruby/table/admin.rb', line 104

def alter! props, &block
  _alter props, true, &block
end

#alter_family(name, opts) ⇒ Object

Alters the column family (asynchronous)

See Also:



144
145
146
# File 'lib/hbase-jruby/table/admin.rb', line 144

def alter_family name, opts
  _alter_family name, opts, false
end

#alter_family!(name, opts) {|progress, total| ... } ⇒ nil

Alters the column family

Parameters:

  • name (#to_s)

    The name of the column family

  • opts (Hash)

    Column family properties

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions

Returns:

  • (nil)


138
139
140
# File 'lib/hbase-jruby/table/admin.rb', line 138

def alter_family! name, opts, &block
  _alter_family name, opts, true, &block
end

#append(rowkey, spec) ⇒ Hash

Appends values to one or more columns within a single row.

Examples:

table.put :rowkey, col1: 'hello', col2: 'foo'
table.append :rowkey, col1: ' world', col2: 'bar'
  # { col1: 'hello world', col2: 'foobar' }

Parameters:

  • rowkey (Object)

    Rowkey

  • spec (Hash)

    Hash (column to value)

Returns:

  • (Hash)

    Updated values



194
195
196
197
# File 'lib/hbase-jruby/table.rb', line 194

def append rowkey, spec
  result = htable.append @mutation.append(rowkey, spec)
  Row.send(:new, self, result).to_h if result # (maybe null)
end

#batch(arg = nil) {|HBase::Table::BatchAction| ... } ⇒ Array<Hash>

Method that does a batch call on Deletes, Gets, Puts, Increments, Appends and RowMutations. The ordering of execution of the actions is not defined. An Array of Hashes are returned as the results of each operation. For Delete, Put, and RowMutation, :result entry of the returned Hash is Boolean. For Increment and Append, it will be plain Hashes, and for Get, HBase::Rows will be returned. When an error has occurred, you can still access the partial results using ‘results` method of the thrown BatchException instance.

Yields:

Returns:

  • (Array<Hash>)

Raises:



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/hbase-jruby/table.rb', line 257

def batch arg = nil
  if arg
    # Backward compatibility
    return scoped.batch(arg)
  else
    raise ArgumentError, "Block not given" unless block_given?
  end
  b = BatchAction.send(:new, self, @mutation)
  yield b
  results = Array.new(b.actions.length).to_java
  process = lambda do
    results.each_with_index do |r, idx|
      action = b.actions[idx]
      type = action[:type]
      case type
      when :get
        action[:result] = (r.nil? || r.empty?) ? nil : Row.send(:new, self, r)
      when :append
        action[:result] = r && Row.send(:new, self, r).to_h
      when :increment
        action[:result] = r &&
          Row.send(:new, self, r).to_h.tap { |h|
            h.each do |k, v|
              h[k] = Util.from_bytes :fixnum, v unless v.is_a?(Fixnum)
            end
          }
      else
        case r
        when java.lang.Exception
          action[:result] = false
          action[:exception] = r
        when nil
          action[:result] = false
        else
          action[:result] = true
        end
      end
    end
    b.actions
  end

  begin
    htable.batch b.actions.map { |a| a[:action] }, results
    process.call
  rescue Exception => e
    raise HBase::BatchException.new(e, process.call)
  end
end

#check(rowkey, cond) ⇒ HBase::Table::CheckedOperation

Returns CheckedOperation instance for check-and-put and check-and-delete

Parameters:

  • rowkey (Object)
  • cond (Hash)

Returns:

Raises:

  • (ArgumentError)


234
235
236
237
238
239
240
241
242
243
244
# File 'lib/hbase-jruby/table.rb', line 234

def check rowkey, cond
  raise ArgumentError, 'invalid check condition' unless cond.length == 1
  col, val = cond.first

  cf, cq, type = lookup_and_parse(col, true)

  # If the passed value is null, the check is for the lack of column
  CheckedOperation.new self, @mutation, Util.to_bytes(rowkey),
    cf, cq,
    (val.nil? ? nil : Util.to_typed_bytes(type, val))
end

#closenil

Clean up thread-locals Generally this is not required unless you use unlimited number of threads

Returns:

  • (nil)


30
31
32
33
34
# File 'lib/hbase-jruby/table.rb', line 30

def close
  hash = thread_local(@hbase).delete(@name_sym)
  hash[:htable].close if hash && hash[:htable]
  nil
end

#closed?Boolean

Returns whether if the connection is closed

Returns:

  • (Boolean)


38
39
40
# File 'lib/hbase-jruby/table.rb', line 38

def closed?
  @hbase.closed?
end

#create!(column_family_name, props = {}) ⇒ nil #create!(column_family_hash, props = {}) ⇒ nil #create!(table_descriptor) ⇒ nil

Creates the table

Overloads:

  • #create!(column_family_name, props = {}) ⇒ nil

    Create the table with one column family of the given name

    Parameters:

    • The (#to_s)

      name of the column family

    • props (Hash) (defaults to: {})

      Table properties

    Returns:

    • (nil)
  • #create!(column_family_hash, props = {}) ⇒ nil

    Create the table with the specified column families

    Examples:

    table.create!(
      # Column family with default options
      :cf1 => {},
      # Another column family with custom properties
      :cf2 => {
        :blockcache         => true,
        :blocksize          => 128 * 1024,
        :bloomfilter        => :row,
        :compression        => :snappy,
        :in_memory          => true,
        :keep_deleted_cells => true,
        :min_versions       => 2,
        :replication_scope  => 0,
        :ttl                => 100,
        :versions           => 5,
    
        # XML config can be specified in :config Hash
        :config             => {
          'hbase.hstore.compaction.max.size' => 1 << 30,
        }
      }
    )

    Parameters:

    • Column (Hash)

      family properties

    • props (Hash) (defaults to: {})

      Table properties

    Returns:

    • (nil)
  • #create!(table_descriptor) ⇒ nil

    Create the table with the given HTableDescriptor

    Parameters:

    • Table (org.apache.hadoop.hbase.HTableDescriptor)

      descriptor

    Returns:

    • (nil)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/hbase-jruby/table/admin.rb', line 59

def create! desc, props = {}
  splits =
    if props[:splits]
      raise ArgumentError, ":splits property must be an Array" if !props[:splits].is_a?(Array)
      props[:splits].map { |e| Util.to_bytes(e).to_a }.to_java(Java::byte[])
    end

  todo = nil
  with_admin do |admin|
    raise RuntimeError, 'Table already exists' if admin.tableExists(@name)

    case desc
    when HTableDescriptor
      patch_table_descriptor! desc, props
      admin.createTable(*[desc, splits].compact)
    when Symbol, String
      todo = lambda { create!({desc => {}}, props) }
    when Hash
      htd = HTableDescriptor.new(@name.to_java_bytes)
      patch_table_descriptor! htd, props
      desc.each do |name, opts|
        htd.addFamily hcd(name, opts)
      end

      admin.createTable(*[htd, splits].compact)
    else
      raise ArgumentError, 'Invalid table description'
    end
  end
  todo.call if todo # Avoids mutex relocking
end

#delete(rowkey) ⇒ nil #delete(rowkey, *extra) ⇒ nil #delete(*delete_specs) ⇒ nil

Deletes data

Overloads:

  • #delete(rowkey) ⇒ nil

    Deletes a row with the given rowkey

    Examples:

    table.delete('a000')

    Parameters:

    • rowkey (Object)

    Returns:

    • (nil)
  • #delete(rowkey, *extra) ⇒ nil

    Deletes columns in the row.

    Examples:

    # A column (with schema)
    table.delete('a000', :title)
    # Two columns (with schema)
    table.delete('a000', :title, :author)
    # A column (without schema)
    table.delete('a000', 'cf1:col1')
    # Columns in cf1 family
    table.delete('a000', 'cf1')
    # A version
    table.delete('a000', :author, 1352978648642)
    # Two versions
    table.delete('a000', :author, 1352978648642, 1352978647642)
    # Combination of columns and versions
    table.delete('a000', :author, 1352978648642, 1352978647642,
                         :title,
                         :image, 1352978648642)

    Parameters:

    • rowkey (Object)
    • extra (*Object)
      Family|Qualifier [Timestamp …]

    Returns:

    • (nil)
  • #delete(*delete_specs) ⇒ nil

    Batch deletion

    Examples:

    table.delete(
      ['a000', 'cf1:col1', 1352978648642],
      ['a001', 'cf1:col1'],
      ['a002', 'cf1'],
      ['a003'])

    Parameters:

    • delete_specs (*Array)

    Returns:

    • (nil)


123
124
125
126
127
128
129
130
131
132
# File 'lib/hbase-jruby/table.rb', line 123

def delete *args
  specs = args.first.is_a?(Array) ? args : [args]

  list = specs.map { |spec| spec.empty? ? nil : @mutation.delete(*spec) }.compact
  if list.length == 1
    htable.delete list.first
  else
    htable.delete list
  end
end

#delete_family(name) ⇒ Object

Removes the column family (asynchronous)

See Also:



160
161
162
# File 'lib/hbase-jruby/table/admin.rb', line 160

def delete_family name
  _delete_family name, false
end

#delete_family!(name) {|progress, total| ... } ⇒ nil

Removes the column family

Parameters:

  • name (#to_s)

    The name of the column family

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions

Returns:

  • (nil)


154
155
156
# File 'lib/hbase-jruby/table/admin.rb', line 154

def delete_family! name, &block
  _delete_family name, true, &block
end

#delete_row(*rowkeys) ⇒ nil

Delete rows.

Parameters:

  • rowkeys (*Object)

    List of rowkeys of rows to delete

Returns:

  • (nil)


137
138
139
140
141
142
143
144
# File 'lib/hbase-jruby/table.rb', line 137

def delete_row *rowkeys
  list = rowkeys.map { |rk| Delete.new(Util.to_bytes rk) }
  if list.length == 1
    htable.delete list.first
  else
    htable.delete list
  end
end

#descriptororg.apache.hadoop.hbase.client.UnmodifyableHTableDescriptor

Returns a read-only org.apache.hadoop.hbase.HTableDescriptor object

Returns:

  • (org.apache.hadoop.hbase.client.UnmodifyableHTableDescriptor)


5
6
7
# File 'lib/hbase-jruby/table/inspection.rb', line 5

def descriptor
  htable.get_table_descriptor
end

#disable!nil

Disables the table

Returns:

  • (nil)


222
223
224
225
226
# File 'lib/hbase-jruby/table/admin.rb', line 222

def disable!
  with_admin do |admin|
    admin.disableTable @name if admin.isTableEnabled(@name)
  end
end

#disabled?true, false

Checks if the table is disabled

Returns:

  • (true, false)

    Whether table is disabled



17
18
19
# File 'lib/hbase-jruby/table/admin.rb', line 17

def disabled?
  !enabled?
end

#drop!nil

Drops the table

Returns:

  • (nil)


238
239
240
241
242
243
244
245
246
# File 'lib/hbase-jruby/table/admin.rb', line 238

def drop!
  with_admin do |admin|
    raise RuntimeError, 'Table does not exist' unless admin.tableExists @name

    admin.disableTable @name if admin.isTableEnabled(@name)
    admin.deleteTable  @name
    close
  end
end

#each {|row| ... } ⇒ Enumerator

Scan through the table

Yields:

  • (row)

    Yields each row in the scope

Yield Parameters:

Returns:

  • (Enumerator)


220
221
222
# File 'lib/hbase-jruby/table.rb', line 220

def each &block
  scoped.each(&block)
end

#enable!nil

Enables the table

Returns:

  • (nil)


214
215
216
217
218
# File 'lib/hbase-jruby/table/admin.rb', line 214

def enable!
  with_admin do |admin|
    admin.enableTable @name unless admin.isTableEnabled(@name)
  end
end

#enabled?true, false

Checks if the table is enabled

Returns:

  • (true, false)

    Whether table is enabled



11
12
13
# File 'lib/hbase-jruby/table/admin.rb', line 11

def enabled?
  with_admin { |admin| admin.isTableEnabled(@name) }
end

#exists?true, false

Checks if the table of the name exists

Returns:

  • (true, false)

    Whether table exists



5
6
7
# File 'lib/hbase-jruby/table/admin.rb', line 5

def exists?
  with_admin { |admin| admin.tableExists @name }
end

#familiesHash

Returns properties of column families indexed by family name

Returns:

  • (Hash)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/hbase-jruby/table/inspection.rb', line 37

def families
  {}.tap { |ret|
    descriptor.families.each do |family|
      name = family.name_as_string
      ret[name] =
        parse_raw_map(family.values).tap { |props|
          COLUMN_PROPERTIES.each do |prop, gs|
            get = gs[:get]
            if get && family.respond_to?(get)
              props.delete(prop.to_s.upcase)
              props[prop] = parse_property family.send get
            end
          end
        }
    end
  }
end

#has_coprocessor?(class_name) ⇒ true, false

Return if the table has the coprocessor of the given class name

Parameters:

  • class_name (String)

    Full class name of the coprocessor

Returns:

  • (true, false)


201
202
203
# File 'lib/hbase-jruby/table/admin.rb', line 201

def has_coprocessor? class_name
  descriptor.hasCoprocessor(class_name)
end

#htableorg.apache.hadoop.hbase.client.PooledHTable

(INTERNAL) Returns the underlying org.apache.hadoop.hbase.client.HTable object (local to current thread)

Returns:

  • (org.apache.hadoop.hbase.client.PooledHTable)


20
21
22
23
24
25
# File 'lib/hbase-jruby/table.rb', line 20

def htable
  check_closed

  # [:hbase_jruby][HBase connection][Table name]
  thread_local(@hbase, @name_sym)[:htable] ||= @hbase.send(:get_htable, @name)
end

#increment(rowkey, column, by) ⇒ Hash #increment(rowkey, column_by_hash) ⇒ Hash #increment(inc_spec) ⇒ Hash

Atomically increase numeric values

Overloads:

  • #increment(rowkey, column, by) ⇒ Hash

    Atomically increase column value by the specified amount

    Examples:

    table.increment('a000', 'cf1:col1', 1)

    Parameters:

    • rowkey (Object)

      Rowkey

    • column (String, Array)

      Column expression in String “FAMILY:QUALIFIER”, or in Array [FAMILY, QUALIFIER]

    • by (Fixnum)

      Increment amount

    Returns:

    • (Hash)
  • #increment(rowkey, column_by_hash) ⇒ Hash

    Atomically increase values of multiple columns

    Examples:

    table.increment('a000', 'cf1:col1' => 1, 'cf1:col2' => 2)

    Parameters:

    • rowkey (Object)

      Rowkey

    • column_by_hash (Hash)

      Column expression to increment amount pairs

    Returns:

    • (Hash)
  • #increment(inc_spec) ⇒ Hash

    Increase values of multiple columns from multiple rows.

    Examples:

    table.increment 'a000' => { 'cf1:col1' => 1, 'cf1:col2' => 2 },
                    'a001' => { 'cf1:col1' => 3, 'cf1:col2' => 4 }

    Parameters:

    • inc_spec (Hash)

      { rowkey => { col => by } }

    Returns:

    • (Hash)


169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/hbase-jruby/table.rb', line 169

def increment rowkey, *args
  if args.empty? && rowkey.is_a?(Hash)
    INSENSITIVE_ROW_HASH.clone.tap { |result|
      rowkey.each do |key, spec|
        result[Util.java_bytes?(key) ? ByteArray[key] : key] = increment(key, spec)
      end
    }
  else
    incr = @mutation.increment(rowkey, *args)
    Row.send(:new, self, htable.increment(incr)).to_h.tap { |h|
      h.each do |k, v|
        h[k] = Util.from_bytes :fixnum, v unless v.is_a?(Fixnum)
      end
    }
  end
end

#inspectString

Returns a printable version of the table description

Returns:

  • (String)

    Table description



76
77
78
79
80
81
82
83
# File 'lib/hbase-jruby/table/inspection.rb', line 76

def inspect
  if exists?
    descriptor.toStringCustomizedValues
  else
    # FIXME
    "{NAME => '#{@name}'}"
  end
end

#lookup_and_parse(col, expect_cq) ⇒ Object

Schema lookup without column-key caching



313
314
315
# File 'lib/hbase-jruby/table.rb', line 313

def lookup_and_parse col, expect_cq
  @hbase.schema.lookup_and_parse @name_sym, col, expect_cq
end

#lookup_schema(col) ⇒ Object



307
308
309
# File 'lib/hbase-jruby/table.rb', line 307

def lookup_schema col
  @hbase.schema.lookup @name_sym, col
end

#mutate(rowkey) {|HBase::Table::Mutation::Mutator| ... } ⇒ nil

Performs multiple mutations atomically on a single row. Currently Put and Delete are supported. The mutations are performed in the order in which they were specified.

Examples:

table.mutate do |m|
  m.put a: 100, b: 'hello'
  m.delete :c, :d
  m.put e: 3.14
end

Parameters:

  • rowkey (Object)

    Rowkey

Yields:

Returns:

  • (nil)


211
212
213
214
# File 'lib/hbase-jruby/table.rb', line 211

def mutate(rowkey, &block)
  ms = @mutation.mutate(rowkey, &block)
  htable.mutateRow ms if ms
end

#propertiesHash

Returns table properties

Returns:

  • (Hash)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hbase-jruby/table/inspection.rb', line 11

def properties
  desc = descriptor
  parse_raw_map(descriptor.values).tap { |props|
    TABLE_PROPERTIES.each do |prop, gs|
      get = gs[:get]
      if get && desc.respond_to?(get)
        props.delete(prop.to_s.upcase)
        props[prop] = parse_property desc.send get
      end
    end

    # deferred_log_flush is deprecated in 0.96
    if props.has_key?(:durability) && props.has_key?(:deferred_log_flush)
      props.delete :deferred_log_flush
    end
  }
end

#put(rowkey, data) ⇒ Fixnum #put(data) ⇒ Fixnum

Performs PUT operations

Overloads:

  • #put(rowkey, data) ⇒ Fixnum

    Put operation on a rowkey

    Parameters:

    • rowkey (Object)

      Rowkey

    • data (Hash)

      Data to put

    Returns:

    • (Fixnum)

      Number of puts succeeded

  • #put(data) ⇒ Fixnum

    Put operation on multiple rowkeys

    Parameters:

    • data (Hash<Hash>)

      Data to put indexed by rowkeys

    Returns:

    • (Fixnum)

      Number of puts succeeded



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/hbase-jruby/table.rb', line 70

def put *args
  case args.length
  when 1
    puts = args.first.map { |rowkey, props| @mutation.put rowkey, props }
    htable.put puts
    puts.length
  when 2, 3
    htable.put @mutation.put(*args)
    1
  else
    raise ArgumentError, 'invalid number of arguments'
  end
end

#raw_familiesHash

Returns raw String-to-String map of column family properties indexed by name

Returns:

  • (Hash)


57
58
59
60
61
62
63
64
# File 'lib/hbase-jruby/table/inspection.rb', line 57

def raw_families
  {}.tap { |ret|
    descriptor.families.each do |family|
      name = family.name_as_string
      ret[name] = parse_raw_map family.values
    end
  }
end

#raw_propertiesHash

Returns raw String-to-String map of table properties

Returns:

  • (Hash)


31
32
33
# File 'lib/hbase-jruby/table/inspection.rb', line 31

def raw_properties
  parse_raw_map descriptor.values
end

#regionsHash

Returns region information

Returns:

  • (Hash)


68
69
70
71
72
# File 'lib/hbase-jruby/table/inspection.rb', line 68

def regions
  with_admin do |admin|
    _regions admin
  end
end

#remove_coprocessor(class_name) ⇒ Object

Removes the coprocessor from the table (asynchronous)



194
195
196
# File 'lib/hbase-jruby/table/admin.rb', line 194

def remove_coprocessor class_name
  _remove_coprocessor class_name, false
end

#remove_coprocessor!(class_name) {|progress, total| ... } ⇒ nil

Removes the coprocessor from the table.

Parameters:

  • class_name (String)

    Full class name of the coprocessor

Yields:

  • (progress, total)

Yield Parameters:

  • progress (Fixnum)

    Number of regions updated

  • total (Fixnum)

    Total number of regions

Returns:

  • (nil)


188
189
190
# File 'lib/hbase-jruby/table/admin.rb', line 188

def remove_coprocessor! class_name, &block
  _remove_coprocessor class_name, true, &block
end

#scopedHBase::Scoped

Returns HBase::Scoped object for this table

Returns:



226
227
228
# File 'lib/hbase-jruby/table.rb', line 226

def scoped
  Scoped.send(:new, self, @hbase.config.get('hbase.client.scanner.caching').to_i)
end

#snapshot!(snapshot_name) ⇒ nil

Creates a snapshot of the table

Parameters:

  • snapshot_name (String)

    Snapshot name

Returns:

  • (nil)


251
252
253
254
255
# File 'lib/hbase-jruby/table/admin.rb', line 251

def snapshot! snapshot_name
  with_admin do |admin|
    admin.snapshot snapshot_name, @name
  end
end

#snapshotsArray<Hash>

Returns an Array of snapshot information for this table

Returns:

  • (Array<Hash>)


259
260
261
# File 'lib/hbase-jruby/table/admin.rb', line 259

def snapshots
  @hbase.snapshots.select { |h| h[:table] == @name }
end

#split!(*split_keys) ⇒ nil

Splits the table region on the given split point (asynchronous)

Parameters:

  • split_keys (*Object)

Returns:

  • (nil)


208
209
210
# File 'lib/hbase-jruby/table/admin.rb', line 208

def split! *split_keys
  _split split_keys, false
end

#truncate!nil

Truncates the table by dropping it and recreating it.

Returns:

  • (nil)


230
231
232
233
234
# File 'lib/hbase-jruby/table/admin.rb', line 230

def truncate!
  htd = htable.get_table_descriptor
  drop!
  create! htd
end

#with_java_get(&block) ⇒ Object



56
57
58
# File 'lib/hbase-jruby/table.rb', line 56

def with_java_get &block
  self.scoped.with_java_get(&block)
end

#with_java_scan(&block) ⇒ Object



52
53
54
# File 'lib/hbase-jruby/table.rb', line 52

def with_java_scan &block
  self.scoped.with_java_scan(&block)
end