Class: HBase::Cell
- Inherits:
-
Object
- Object
- HBase::Cell
- Defined in:
- lib/hbase-jruby/cell.rb
Overview
Boxed Ruby class for org.apache.hadoop.hbase.KeyValue
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#<=>(other) ⇒ Fixnum
Implements column key order.
-
#bigdecimal ⇒ BigDecimal
Returns the column value as a BigDecimal.
-
#boolean ⇒ true, false
(also: #bool)
Returns the column value as a boolean value.
-
#byte ⇒ Fixnum
Returns the 1-byte column value as a Fixnum.
-
#eql?(other) ⇒ Boolean
(also: #==)
Checks if the cells are the same.
-
#family ⇒ String
(also: #cf)
Returns the name of the column family of the cell.
-
#fixnum ⇒ Fixnum
(also: #long)
Returns the 8-byte column value as a Fixnum.
-
#float ⇒ Float
(also: #double)
Returns the column value as a Float.
- #hash ⇒ Object
-
#initialize(table, key_value) ⇒ Cell
constructor
Creates a boxed object for a KeyValue object.
-
#inspect ⇒ String
Returns a printable version of this cell.
-
#int ⇒ Fixnum
Returns the 4-byte column value as a Fixnum.
-
#qualifier(type = :string) ⇒ Object
(also: #cq)
Returns the column qualifier of the cell.
-
#raw ⇒ byte[]
Returns the value of the cell as a Java byte array.
-
#rowkey(type = :raw) ⇒ String, byte[]
Returns the rowkey of the cell decoded as the given type.
-
#short ⇒ Fixnum
Returns the 2-byte column value as a Fixnum.
-
#string ⇒ String
(also: #str)
Returns the column value as a String.
-
#symbol ⇒ Symbol
(also: #sym)
Returns the column value as a Symbol.
-
#timestamp ⇒ Fixnum
(also: #ts)
Returns the timestamp of the cell.
-
#value ⇒ Object
Returns the value of the cell.
Constructor Details
#initialize(table, key_value) ⇒ Cell
Creates a boxed object for a KeyValue object
10 11 12 13 14 |
# File 'lib/hbase-jruby/cell.rb', line 10 def initialize table, key_value @table = table @java = key_value @ck = nil end |
Instance Attribute Details
#java ⇒ org.apache.hadoop.hbase.KeyValue (readonly)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/hbase-jruby/cell.rb', line 5 class Cell attr_reader :java # Creates a boxed object for a KeyValue object # @param [org.apache.hadoop.hbase.KeyValue] key_value def initialize table, key_value @table = table @java = key_value @ck = nil end # Returns the rowkey of the cell decoded as the given type # @param [Symbol] type The type of the rowkey. # Can be one of :string, :symbol, :fixnum, :float, :short, :int, :bigdecimal, :boolean and :raw. # @return [String, byte[]] def rowkey type = :raw Util.from_bytes type, @java.getRow end # Returns the name of the column family of the cell # @return [String] def family String.from_java_bytes @java.getFamily end alias cf family # Returns the column qualifier of the cell # @param [Symbol] type The type of the qualifier. # 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 end alias cq qualifier # Returns the timestamp of the cell # @return [Fixnum] def @java.getTimestamp end alias ts # Returns the value of the cell. If the column in not defined in the schema, returns Java byte array. def value _, _, type = @table.lookup_schema(cq) Util.from_bytes(type, raw) end # Returns the value of the cell as a Java byte array # @return [byte[]] def raw @java.getValue end # Returns the column value as a String # @return [String] def string Util.from_bytes :string, value end alias str string # Returns the column value as a Symbol # @return [Symbol] def symbol Util.from_bytes :symbol, value end alias sym symbol # Returns the 8-byte column value as a Fixnum # @return [Fixnum] def fixnum Util.from_bytes :fixnum, value end alias long fixnum # Returns the 4-byte column value as a Fixnum # @return [Fixnum] def int Util.from_bytes :int, value end # Returns the 2-byte column value as a Fixnum # @return [Fixnum] def short Util.from_bytes :short, value end # Returns the 1-byte column value as a Fixnum # @return [Fixnum] def byte Util.from_bytes :byte, value end # Returns the column value as a BigDecimal # @return [BigDecimal] def bigdecimal Util.from_bytes :bigdecimal, value end # Returns the column value as a Float # @return [Float] def float Util.from_bytes :float, value end alias double float # Returns the column value as a boolean value # @return [true, false] def boolean Util.from_bytes :boolean, value end alias bool boolean # Implements column key order # @param [Cell] other # @return [Fixnum] -1, 0, or 1 def <=> other KeyValue.COMPARATOR.compare(@java, other.java) end # Checks if the cells are the same # @param [HBase::Cell] other def eql? other (self <=> other) == 0 end alias == eql? def hash @java.hasCode end # Returns a printable version of this cell # @return [String] def inspect %[#{cf}:#{cq} = "#{string}"@#{ts}] end end |
Instance Method Details
#<=>(other) ⇒ Fixnum
Implements column key order
121 122 123 |
# File 'lib/hbase-jruby/cell.rb', line 121 def <=> other KeyValue.COMPARATOR.compare(@java, other.java) end |
#bigdecimal ⇒ BigDecimal
Returns the column value as a BigDecimal
100 101 102 |
# File 'lib/hbase-jruby/cell.rb', line 100 def bigdecimal Util.from_bytes :bigdecimal, value end |
#boolean ⇒ true, false Also known as: bool
Returns the column value as a boolean value
113 114 115 |
# File 'lib/hbase-jruby/cell.rb', line 113 def boolean Util.from_bytes :boolean, value end |
#byte ⇒ Fixnum
Returns the 1-byte column value as a Fixnum
94 95 96 |
# File 'lib/hbase-jruby/cell.rb', line 94 def byte Util.from_bytes :byte, value end |
#eql?(other) ⇒ Boolean Also known as: ==
Checks if the cells are the same
127 128 129 |
# File 'lib/hbase-jruby/cell.rb', line 127 def eql? other (self <=> other) == 0 end |
#family ⇒ String Also known as: cf
Returns the name of the column family of the cell
26 27 28 |
# File 'lib/hbase-jruby/cell.rb', line 26 def family String.from_java_bytes @java.getFamily end |
#fixnum ⇒ Fixnum Also known as: long
Returns the 8-byte column value as a Fixnum
75 76 77 |
# File 'lib/hbase-jruby/cell.rb', line 75 def fixnum Util.from_bytes :fixnum, value end |
#float ⇒ Float Also known as: double
Returns the column value as a Float
106 107 108 |
# File 'lib/hbase-jruby/cell.rb', line 106 def float Util.from_bytes :float, value end |
#hash ⇒ Object
132 133 134 |
# File 'lib/hbase-jruby/cell.rb', line 132 def hash @java.hasCode end |
#inspect ⇒ String
Returns a printable version of this cell
138 139 140 |
# File 'lib/hbase-jruby/cell.rb', line 138 def inspect %[#{cf}:#{cq} = "#{string}"@#{ts}] end |
#int ⇒ Fixnum
Returns the 4-byte column value as a Fixnum
82 83 84 |
# File 'lib/hbase-jruby/cell.rb', line 82 def int Util.from_bytes :int, value end |
#qualifier(type = :string) ⇒ Object Also known as: cq
Returns the column qualifier of the cell
35 36 37 |
# File 'lib/hbase-jruby/cell.rb', line 35 def qualifier type = :string Util.from_bytes type, @java.getQualifier end |
#raw ⇒ byte[]
Returns the value of the cell as a Java byte array
55 56 57 |
# File 'lib/hbase-jruby/cell.rb', line 55 def raw @java.getValue end |
#rowkey(type = :raw) ⇒ String, byte[]
Returns the rowkey of the cell decoded as the given type
20 21 22 |
# File 'lib/hbase-jruby/cell.rb', line 20 def rowkey type = :raw Util.from_bytes type, @java.getRow end |
#short ⇒ Fixnum
Returns the 2-byte column value as a Fixnum
88 89 90 |
# File 'lib/hbase-jruby/cell.rb', line 88 def short Util.from_bytes :short, value end |
#string ⇒ String Also known as: str
Returns the column value as a String
61 62 63 |
# File 'lib/hbase-jruby/cell.rb', line 61 def string Util.from_bytes :string, value end |
#symbol ⇒ Symbol Also known as: sym
Returns the column value as a Symbol
68 69 70 |
# File 'lib/hbase-jruby/cell.rb', line 68 def symbol Util.from_bytes :symbol, value end |
#timestamp ⇒ Fixnum Also known as: ts
Returns the timestamp of the cell
42 43 44 |
# File 'lib/hbase-jruby/cell.rb', line 42 def @java.getTimestamp end |
#value ⇒ Object
Returns the value of the cell. If the column in not defined in the schema, returns Java byte array.
48 49 50 51 |
# File 'lib/hbase-jruby/cell.rb', line 48 def value _, _, type = @table.lookup_schema(cq) Util.from_bytes(type, raw) end |