Sha256: 5e989ecf0cfd0099bd4302d11a560922f8a663f700059a092a53e63e3e4e0769

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

class HBase
class << self
  # Shortcut method to HBase::ColumnKey.new
  # @param [Object] cf Column family
  # @param [Object] cq Column qualifier
  def ColumnKey cf, cq
    ColumnKey.new cf, cq
  end
end
# Boxed class for column keys
class ColumnKey
  attr_reader :cf
  alias family cf

  # Creates a ColumnKey object
  # @param [Object] cf Column family
  # @param [Object] cq Column qualifier
  def initialize cf, cq
    @cf = String.from_java_bytes Util.to_bytes(cf)
    @cq = Util.to_bytes(cq)
  end

  # @param [Symbol] type
  def cq type = :string
    Util.from_bytes type, @cq
  end
  alias qualifier cq

  # @param [Object] other
  def eql? other
    other = other_as_ck(other)
    @cf == other.cf && Arrays.equals(@cq, other.cq(:raw))
  end
  alias == eql?

  # @param [Object] other
  def <=> other
    other = other_as_ck(other)
    d = @cf <=> other.cf
    d != 0 ? d : Bytes.compareTo(@cq, other.cq(:raw))
  end

  def hash
    [@cf, Arrays.java_send(:hashCode, [Util::JAVA_BYTE_ARRAY_CLASS], @cq)].hash
  end

  def to_s
    [@cf, @cq.empty? ? nil : cq].compact.join(':')
  end

private
  def other_as_ck other
    case other
    when ColumnKey
      other
    else
      cf, cq = Util.parse_column_name(other)
      ColumnKey.new(cf, cq)
    end
  end
end#ColumnKey
end#HBase

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hbase-jruby-0.1.3-java lib/hbase-jruby/column_key.rb
hbase-jruby-0.1.2-java lib/hbase-jruby/column_key.rb
hbase-jruby-0.1.1-java lib/hbase-jruby/column_key.rb