Class: HBase::ColumnKey

Inherits:
Object
  • Object
show all
Defined in:
lib/hbase-jruby/column_key.rb

Overview

@return [String] The column family

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cf, cq) ⇒ ColumnKey

Creates a ColumnKey object

Parameters:

  • cf (Object)

    Column family

  • cq (Object)

    Column qualifier



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

def initialize cf, cq
  @cf = String.from_java_bytes Util.to_bytes(cf)
  @cq = Util.to_bytes(cq)
end

Instance Attribute Details

#cfObject (readonly) Also known as: family

Returns the value of attribute cf.



14
15
16
# File 'lib/hbase-jruby/column_key.rb', line 14

def cf
  @cf
end

Instance Method Details

#<=>(other) ⇒ Object

Compares two ColumnKeys

Parameters:

  • other (Object)


42
43
44
45
46
# File 'lib/hbase-jruby/column_key.rb', line 42

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

#cq(type = :string) ⇒ Object Also known as: qualifier

Returns the column qualifer decoded as the given type

Parameters:

  • type (Symbol) (defaults to: :string)


27
28
29
# File 'lib/hbase-jruby/column_key.rb', line 27

def cq type = :string
  Util.from_bytes type, @cq
end

#eql?(other) ⇒ Boolean Also known as: ==

Checks whether if the two ColumnKeys are equal

Parameters:

  • other (Object)

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/hbase-jruby/column_key.rb', line 34

def eql? other
  other = other_as_ck(other)
  @cf == other.cf && Arrays.equals(@cq, other.cq(:raw))
end

#hashFixnum

Returns a hash number for this ColumnKey

Returns:

  • (Fixnum)


50
51
52
# File 'lib/hbase-jruby/column_key.rb', line 50

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

#to_sString

Returns String representation of the column key (Qualifier decoded as a String)

Returns:

  • (String)


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

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