Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/hbase-jruby/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def family
# Can be one of :string, :symbol, :fixnum, :float, :short, :int, :bigdecimal, :boolean and :raw.
# @return [Object]
def qualifier type = :string
Util.from_bytes type, @java.getQualifier
Util.from_bytes type, @java.getQualifierArray
end
alias cq qualifier

Expand All @@ -53,7 +53,7 @@ def value
# Returns the value of the cell as a Java byte array
# @return [byte[]]
def raw
@java.getValue
@java.getValueArray
end

# Returns the column value as a String
Expand Down
4 changes: 3 additions & 1 deletion lib/hbase-jruby/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ class HBase
# @private
@deps = {
self => %w[
org.apache.hadoop.hbase.client.ConnectionFactory
org.apache.hadoop.hbase.HBaseConfiguration
org.apache.hadoop.hbase.client.HBaseAdmin
org.apache.hadoop.hbase.client.HConnectionManager
org.apache.hadoop.hbase.client.HTablePool
org.apache.hadoop.hbase.TableName
],
Util => %w[
java.nio.ByteBuffer
Expand All @@ -27,6 +28,7 @@ class HBase
],
Cell => %w[
org.apache.hadoop.hbase.KeyValue
org.apache.hadoop.hbase.CellUtil
],
Result => %w[
org.apache.hadoop.hbase.util.Bytes
Expand Down
19 changes: 5 additions & 14 deletions lib/hbase-jruby/hbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HBase
include Admin
include HBase::Util

DEFAULT_COLUMN_CACHE_SIZE = 200
DEFAULT_COLUMN_CACHE_SIZE ||= 200

# @overload HBase.log4j=(filename)
# Configure Log4j logging with the given file
Expand All @@ -33,13 +33,13 @@ def self.log4j= arg
arg.each do |k, v|
props.setProperty k.to_s, v.to_s
end
org.apache.log4j.PropertyConfigurator.configure props
# org.apache.log4j.PropertyConfigurator.configure props
else
case File.extname(arg).downcase
when '.xml'
org.apache.log4j.xml.DOMConfigurator.configure arg
else
org.apache.log4j.PropertyConfigurator.configure arg
# org.apache.log4j.PropertyConfigurator.configure arg
end
end
end
Expand Down Expand Up @@ -74,7 +74,7 @@ def initialize config = {}
end
end
end
@connection = HConnectionManager.createConnection @config
@connection = ConnectionFactory.createConnection @config
@htable_pool =
if @connection.respond_to?(:getTable)
nil
Expand Down Expand Up @@ -112,16 +112,7 @@ def close
@mutex.synchronize do
unless @closed
@closed = true
@htable_pool.close if use_table_pool?
@connection.close

# To be deprecated
begin
HConnectionManager.deleteConnection(@config)
rescue ArgumentError
# HBase 0.92 or below
HConnectionManager.deleteConnection(@config, true)
end if use_table_pool?
end
end

Expand Down Expand Up @@ -214,7 +205,7 @@ def reset_table_pool

private
def get_htable name
(@htable_pool || @connection).get_table name
(@htable_pool || @connection).get_table TableName.valueOf name
end

def check_closed
Expand Down
4 changes: 2 additions & 2 deletions lib/hbase-jruby/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def rowkey type = :raw
# Enumerates through cells
def each
return enum_for(:each) unless block_given?
@result.raw.each do |kv|
@result.rawCells.each do |kv|
yield Cell.new(@table, kv)
end
end
Expand Down Expand Up @@ -317,5 +317,5 @@ def allmap
end#HBase

# For backward compatibility
HBase::Result = HBase::Row
HBase::Result ||= HBase::Row

2 changes: 1 addition & 1 deletion lib/hbase-jruby/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def empty_lookup_table
}
end

KNOWN_TYPES = Set[
KNOWN_TYPES ||= Set[
:string, :str, :symbol, :sym,
:byte,
:boolean, :bool,
Expand Down
6 changes: 3 additions & 3 deletions lib/hbase-jruby/scoped.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def getify rowkey
case @trange
when Array
get.setTimeRange(*@trange)
when Time, Fixnum
when Time, Integer
get.setTimeStamp @trange
end

Expand Down Expand Up @@ -495,7 +495,7 @@ def filter_for cf, cq, type, val

def set_max_versions obj
case @versions
when Fixnum
when Integer
obj.setMaxVersions @versions
when :all
obj.setMaxVersions
Expand Down Expand Up @@ -547,7 +547,7 @@ def filtered_scan
case @trange
when Array
scan.setTimeRange(*@trange)
when Time, Fixnum
when Time, Integer
scan.setTimeStamp @trange
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hbase-jruby/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def check_closed
raise RuntimeError, "HBase connection is already closed" if @hbase.closed?
end

INSENSITIVE_ROW_HASH = {}.tap { |h|
INSENSITIVE_ROW_HASH ||= {}.tap { |h|
h.instance_eval do
def [] key
if Util.java_bytes?(key)
Expand Down
6 changes: 3 additions & 3 deletions lib/hbase-jruby/table/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def snapshots
end

private
COLUMN_PROPERTIES = {
COLUMN_PROPERTIES ||= {
:blockcache => { :set => :setBlockCacheEnabled, :get => :isBlockCacheEnabled },
:blocksize => { :set => :setBlocksize, :get => :getBlocksize },
:bloomfilter => { :set => :setBloomFilterType, :get => :getBloomFilterType },
Expand All @@ -281,7 +281,7 @@ def snapshots
:versions => { :set => :setMaxVersions, :get => :getMaxVersions },
}

TABLE_PROPERTIES = {
TABLE_PROPERTIES ||= {
:max_filesize => { :get => :getMaxFileSize, :set => :setMaxFileSize },
:readonly => { :get => :isReadOnly, :set => :setReadOnly },
:memstore_flushsize => { :get => :getMemStoreFlushSize, :set => :setMemStoreFlushSize },
Expand Down Expand Up @@ -311,7 +311,7 @@ def snapshots
}
}

MAX_SPLIT_WAIT = 30
MAX_SPLIT_WAIT ||= 30

def hcd obj, opts
hcd =
Expand Down
16 changes: 8 additions & 8 deletions lib/hbase-jruby/table/mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ def put rowkey, props, timestamp = nil
val.each do |t, v|
case t
# Timestamp / Ruby Time
when Time, Fixnum
put.add cf, cq, time_to_long(t), Util.to_typed_bytes(type, v)
when Time, Integer
put.addColumn cf, cq, time_to_long(t), Util.to_typed_bytes(type, v)
# Types: :byte, :short, :int, ...
else
put.add cf, cq, Util.to_typed_bytes(t, v)
put.addColumn cf, cq, Util.to_typed_bytes(t, v)
end unless v.nil?
end
when String
if timestamp
put.add cf, cq, time_to_long(timestamp), val.to_java_bytes
put.addColumn cf, cq, time_to_long(timestamp), val.to_java_bytes
else
put.add cf, cq, val.to_java_bytes
put.addColumn cf, cq, val.to_java_bytes
end
else
if timestamp
put.add cf, cq, time_to_long(timestamp), Util.to_typed_bytes(type, val)
put.addColumn cf, cq, time_to_long(timestamp), Util.to_typed_bytes(type, val)
else
put.add cf, cq, Util.to_typed_bytes(type, val)
put.addColumn cf, cq, Util.to_typed_bytes(type, val)
end
end
end
Expand All @@ -63,7 +63,7 @@ def delete rowkey, *extra

extra.each do |x|
case x
when Fixnum, Time
when Integer, Time
if cq
del.deleteColumn cf, cq, time_to_long(x)
prcd = true
Expand Down
12 changes: 6 additions & 6 deletions lib/hbase-jruby/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class HBase
module Util
JAVA_BYTE_ARRAY_EMPTY = [].to_java(Java::byte)
JAVA_BYTE_ARRAY_CLASS = JAVA_BYTE_ARRAY_EMPTY.java_class
JAVA_BYTE_ARRAY_EMPTY ||= [].to_java(Java::byte)
JAVA_BYTE_ARRAY_CLASS ||= JAVA_BYTE_ARRAY_EMPTY.java_class

class << self
def java_bytes? v
Expand All @@ -21,7 +21,7 @@ def to_bytes v
v.to_java(Java::byte)
when String, ByteArray
v.to_java_bytes
when Fixnum
when Integer
Bytes.java_send :toBytes, [Java::long], v
when Symbol
v.to_s.to_java_bytes
Expand Down Expand Up @@ -167,10 +167,10 @@ def parse_column_name col
raise ArgumentError, "Column family not specified"
else
col = col.to_s
cfcq = KeyValue.parseColumn(col.to_java_bytes)
cf = cfcq[0]
cfcq = col.split(':')
cf = cfcq[0].to_java_bytes
cq = if cfcq.length == 2
cfcq[1]
cfcq[1].to_java_bytes
elsif col[-1, 1] == ':'
JAVA_BYTE_ARRAY_EMPTY
end
Expand Down
2 changes: 1 addition & 1 deletion lib/hbase-jruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class HBase
module JRuby
VERSION = '0.7.1'
VERSION ||= '0.7.1'
end
end