Class: HBase::Row
Overview
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compares two Result instances on their row keys.
- #[](*col) ⇒ Object
-
#bigdecimal(col) ⇒ BigDecimal
Returns the latest column value as a BigDecimal.
-
#bigdecimals(col) ⇒ Hash<Fixnum, BigDecimal>
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps.
-
#boolean(col) ⇒ true, false
(also: #bool)
Returns the latest column value as a boolean value.
-
#booleans(col) ⇒ Hash<Fixnum, true|false>
(also: #bools)
Returns all versions of column values as boolean values in a Hash indexed by their timestamps.
-
#byte(col) ⇒ Fixnum
Returns the latest 1-byte column value as a Fixnum.
-
#byte_array(col) ⇒ byte[]
Returns the latest column value as a HBase::ByteArray instance.
-
#byte_arrays(col) ⇒ byte[]
Returns all versions of column values as HBase::ByteArray instances in a Hash indexed by their timestamps.
-
#bytes(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 1-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#each ⇒ Object
Enumerates through cells.
-
#empty? ⇒ Boolean
Returns if the returned row is empty.
-
#fixnum(col) ⇒ Fixnum
(also: #long)
Returns the latest 8-byte column value as a Fixnum.
-
#fixnums(col) ⇒ Hash<Fixnum, Fixnum>
(also: #longs)
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#float(col) ⇒ Float
(also: #double)
Returns the latest column value as a Float.
-
#floats(col) ⇒ Hash<Fixnum, Float>
(also: #doubles)
Returns all versions of column values as Floats in a Hash indexed by their timestamps.
-
#int(col) ⇒ Fixnum
Returns the latest 4-byte column value as a Fixnum.
-
#ints(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#raw(col) ⇒ byte[]
Returns the latest column value as a Java byte array.
-
#raws(col) ⇒ Hash<Fixnum, byte[]>
Returns all versions of column values as Java byte arrays in a Hash indexed by their timestamps.
-
#rowkey(type = :raw) ⇒ String, byte[]
Returns the rowkey of the row.
-
#short(col) ⇒ Fixnum
Returns the latest 2-byte column value as a Fixnum.
-
#shorts(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#string(col) ⇒ String
(also: #str)
Returns the latest column value as a String.
-
#strings(col) ⇒ Hash<Fixnum, String>
(also: #strs)
Returns all versions of column values as Strings in a Hash indexed by their timestamps.
-
#symbol(col) ⇒ Symbol
(also: #sym)
Returns the latest column value as a Symbol.
-
#symbols(col) ⇒ Hash<Fixnum, Symbol>
(also: #syms)
Returns all versions of column values as Symbols in a Hash indexed by their timestamps.
- #to_H ⇒ Hash (also: #to_hash_with_versions)
-
#to_h ⇒ Hash
(also: #to_hash)
Only supports string column qualifiers.
Instance Method Details
#<=>(other) ⇒ Object
Compares two Result instances on their row keys
248 249 250 |
# File 'lib/hbase-jruby/row.rb', line 248 def <=> other Bytes.compareTo(rowkey(:raw), other.rowkey(:raw)) end |
#[](*col) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/hbase-jruby/row.rb', line 31 def [] *col col = col.length == 1 ? col[0] : col cf, cq, type = @table.lookup_schema(col) if cf self.send type, [cf, cq] else self.raw col end end |
#bigdecimal(col) ⇒ BigDecimal
Returns the latest column value as a BigDecimal
204 205 206 |
# File 'lib/hbase-jruby/row.rb', line 204 def bigdecimal col decode_value :bigdecimal, col end |
#bigdecimals(col) ⇒ Hash<Fixnum, BigDecimal>
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps
211 212 213 |
# File 'lib/hbase-jruby/row.rb', line 211 def bigdecimals col decode_value :bigdecimal, col, true end |
#boolean(col) ⇒ true, false Also known as: bool
Returns the latest column value as a boolean value
234 235 236 |
# File 'lib/hbase-jruby/row.rb', line 234 def boolean col decode_value :boolean, col end |
#booleans(col) ⇒ Hash<Fixnum, true|false> Also known as: bools
Returns all versions of column values as boolean values in a Hash indexed by their timestamps
242 243 244 |
# File 'lib/hbase-jruby/row.rb', line 242 def booleans col decode_value :boolean, col, true end |
#byte(col) ⇒ Fixnum
Returns the latest 1-byte column value as a Fixnum
146 147 148 |
# File 'lib/hbase-jruby/row.rb', line 146 def byte col decode_value :byte, col end |
#byte_array(col) ⇒ byte[]
Returns the latest column value as a HBase::ByteArray instance
100 101 102 |
# File 'lib/hbase-jruby/row.rb', line 100 def byte_array col decode_value :byte_array, col end |
#byte_arrays(col) ⇒ byte[]
Returns all versions of column values as HBase::ByteArray instances in a Hash indexed by their timestamps
107 108 109 |
# File 'lib/hbase-jruby/row.rb', line 107 def byte_arrays col decode_value :byte_array, col, true end |
#bytes(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 1-byte column values as Fixnums in a Hash indexed by their timestamps
153 154 155 |
# File 'lib/hbase-jruby/row.rb', line 153 def bytes col decode_value :byte, col, true end |
#each ⇒ Object
Enumerates through cells
24 25 26 27 28 29 |
# File 'lib/hbase-jruby/row.rb', line 24 def each return enum_for(:each) unless block_given? @result.raw.each do |kv| yield Cell.new(@table, kv) end end |
#empty? ⇒ Boolean
Returns if the returned row is empty
11 12 13 |
# File 'lib/hbase-jruby/row.rb', line 11 def empty? @result.empty? end |
#fixnum(col) ⇒ Fixnum Also known as: long
Returns the latest 8-byte column value as a Fixnum
188 189 190 |
# File 'lib/hbase-jruby/row.rb', line 188 def fixnum col decode_value :fixnum, col end |
#fixnums(col) ⇒ Hash<Fixnum, Fixnum> Also known as: longs
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps
196 197 198 |
# File 'lib/hbase-jruby/row.rb', line 196 def fixnums col decode_value :fixnum, col, true end |
#float(col) ⇒ Float Also known as: double
Returns the latest column value as a Float
218 219 220 |
# File 'lib/hbase-jruby/row.rb', line 218 def float col decode_value :float, col end |
#floats(col) ⇒ Hash<Fixnum, Float> Also known as: doubles
Returns all versions of column values as Floats in a Hash indexed by their timestamps
226 227 228 |
# File 'lib/hbase-jruby/row.rb', line 226 def floats col decode_value :float, col, true end |
#int(col) ⇒ Fixnum
Returns the latest 4-byte column value as a Fixnum
174 175 176 |
# File 'lib/hbase-jruby/row.rb', line 174 def int col decode_value :int, col end |
#ints(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps
181 182 183 |
# File 'lib/hbase-jruby/row.rb', line 181 def ints col decode_value :int, col, true end |
#raw(col) ⇒ byte[]
Returns the latest column value as a Java byte array
86 87 88 |
# File 'lib/hbase-jruby/row.rb', line 86 def raw col get_value col end |
#raws(col) ⇒ Hash<Fixnum, byte[]>
Returns all versions of column values as Java byte arrays in a Hash indexed by their timestamps
93 94 95 |
# File 'lib/hbase-jruby/row.rb', line 93 def raws col get_value col, true end |
#rowkey(type = :raw) ⇒ String, byte[]
Returns the rowkey of the row
19 20 21 |
# File 'lib/hbase-jruby/row.rb', line 19 def rowkey type = :raw Util.from_bytes type, @result.getRow end |
#short(col) ⇒ Fixnum
Returns the latest 2-byte column value as a Fixnum
160 161 162 |
# File 'lib/hbase-jruby/row.rb', line 160 def short col decode_value :short, col end |
#shorts(col) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps
167 168 169 |
# File 'lib/hbase-jruby/row.rb', line 167 def shorts col decode_value :short, col, true end |
#string(col) ⇒ String Also known as: str
Returns the latest column value as a String
114 115 116 |
# File 'lib/hbase-jruby/row.rb', line 114 def string col decode_value :string, col end |
#strings(col) ⇒ Hash<Fixnum, String> Also known as: strs
Returns all versions of column values as Strings in a Hash indexed by their timestamps
122 123 124 |
# File 'lib/hbase-jruby/row.rb', line 122 def strings col decode_value :string, col, true end |
#symbol(col) ⇒ Symbol Also known as: sym
Returns the latest column value as a Symbol
130 131 132 |
# File 'lib/hbase-jruby/row.rb', line 130 def symbol col decode_value :symbol, col end |
#symbols(col) ⇒ Hash<Fixnum, Symbol> Also known as: syms
Returns all versions of column values as Symbols in a Hash indexed by their timestamps
138 139 140 |
# File 'lib/hbase-jruby/row.rb', line 138 def symbols col decode_value :symbol, col, true end |
#to_H ⇒ Hash Also known as: to_hash_with_versions
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/hbase-jruby/row.rb', line 61 def to_H HASH_TEMPLATE.clone.tap do |ret| @result.getMap.each do |cf, cqmap| cf = Util.from_bytes :string, cf cqmap.each do |cq, tsmap| cqs = Util.from_bytes(:string, cq) rescue nil f, q, t = @table.lookup_schema(cqs) t = nil if f != cf name = t ? q : [cf.to_sym, ByteArray[cq]] ret[name] = Hash[ tsmap.map { |ts, val| [ ts, Util.from_bytes(t, val) ] } ] end end end end |
#to_h ⇒ Hash Also known as: to_hash
Only supports string column qualifiers
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/hbase-jruby/row.rb', line 43 def to_h HASH_TEMPLATE.clone.tap do |ret| @result.getNoVersionMap.each do |cf, cqmap| cf = Util.from_bytes :string, cf cqmap.each do |cq, val| cqs = Util.from_bytes(:string, cq) rescue nil f, q, t = @table.lookup_schema(cqs) t = nil if f != cf name = t ? q : [cf.to_sym, ByteArray[cq]] ret[name] = Util.from_bytes(t, val) end end end end |