Class: HBase::ByteArray

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ByteArray

Returns a new instance of ByteArray.



6
7
8
# File 'lib/hbase-jruby/byte_array.rb', line 6

def initialize value
  @java = Util.to_bytes value
end

Instance Attribute Details

#javaObject (readonly)

Returns the value of attribute java.



4
5
6
# File 'lib/hbase-jruby/byte_array.rb', line 4

def java
  @java
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
# File 'lib/hbase-jruby/byte_array.rb', line 15

def <=> other
  Bytes.compareTo(@java, other.java)
end

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

Returns:

  • (Boolean)


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

def eql? other
  Arrays.equals(@java, other.java)
end

#hashObject



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

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

#stopkey_bytes_for_prefixObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hbase-jruby/byte_array.rb', line 19

def stopkey_bytes_for_prefix
  arr = @java.to_a
  csr = arr.length - 1
  arr[csr] += 1
  while csr >= 0 && arr[csr] > 127
    csr -= 1
    arr[csr] += 1
  end
  if csr < 0
    nil
  else
    arr[0..csr].to_java(Java::byte)
  end
end