Class: HBase::ColumnKey

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

Overview

Boxed class for column keys

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



18
19
20
21
# File 'lib/hbase-jruby/column_key.rb', line 18

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.



12
13
14
# File 'lib/hbase-jruby/column_key.rb', line 12

def cf
  @cf
end

Instance Method Details

#<=>(other) ⇒ Object

Parameters:

  • other (Object)


37
38
39
40
41
# File 'lib/hbase-jruby/column_key.rb', line 37

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

Parameters:

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


24
25
26
# File 'lib/hbase-jruby/column_key.rb', line 24

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

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

Parameters:

  • other (Object)

Returns:

  • (Boolean)


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

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

#hashObject



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

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

#to_sObject



47
48
49
# File 'lib/hbase-jruby/column_key.rb', line 47

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