Class: HBase::Row
Overview
Represents a set of key-values returned by HBase
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compares two Result instances on their row keys.
- #[](*col) ⇒ Object
-
#bigdecimal(column) ⇒ BigDecimal
Returns column values as Bigdecimals.
-
#bigdecimals(column) ⇒ Hash<Fixnum, BigDecimal>
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps.
-
#boolean(column) ⇒ true, false
(also: #bool)
Returns column values as Booleans.
-
#booleans(column) ⇒ Hash<Fixnum, true|false>
(also: #bools)
Returns all versions of column values as Booleans in a Hash indexed by their timestamps.
-
#byte(column) ⇒ Fixnum
Returns 1-byte column values as Fixnums.
-
#bytes(column) ⇒ 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(column) ⇒ Fixnum
(also: #long)
Returns 8-byte column values as Fixnums.
-
#fixnums(column) ⇒ Hash<Fixnum, Fixnum>
(also: #longs)
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#float(column) ⇒ Float
(also: #double)
Returns column values as Floats.
-
#floats(column) ⇒ Hash<Fixnum, Float>
(also: #doubles)
Returns all versions of column values as Floats in a Hash indexed by their timestamps.
-
#int(column) ⇒ Fixnum
Returns 4-byte column values as Fixnums.
-
#ints(column) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#raw(column) ⇒ byte[]
Returns column values as byte arrays.
-
#raws(column) ⇒ Hash<Fixnum, byte[]>
Returns all versions of column values as byte arrays in a Hash indexed by their timestamps.
-
#rowkey(type = :raw) ⇒ String, byte[]
Returns the rowkey of the row.
-
#short(column) ⇒ Fixnum
Returns 2-byte column values as Fixnums.
-
#shorts(column) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#string(column) ⇒ String
(also: #str)
Returns column values as Strings.
-
#strings(column) ⇒ Hash<Fixnum, String>
(also: #strs)
Returns all versions of column values as Strings in a Hash indexed by their timestamps.
-
#symbol(column) ⇒ Symbol
(also: #sym)
Returns column values as Symbols.
-
#symbols(column) ⇒ 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
274 275 276 |
# File 'lib/hbase-jruby/row.rb', line 274 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(column) ⇒ BigDecimal
Returns column values as Bigdecimals
220 221 222 |
# File 'lib/hbase-jruby/row.rb', line 220 def bigdecimal col decode_value :bigdecimal, col end |
#bigdecimals(column) ⇒ Hash<Fixnum, BigDecimal>
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps
229 230 231 |
# File 'lib/hbase-jruby/row.rb', line 229 def bigdecimals col decode_value :bigdecimal, col, true end |
#boolean(column) ⇒ true, false Also known as: bool
Returns column values as Booleans
258 259 260 |
# File 'lib/hbase-jruby/row.rb', line 258 def boolean col decode_value :boolean, col end |
#booleans(column) ⇒ Hash<Fixnum, true|false> Also known as: bools
Returns all versions of column values as Booleans in a Hash indexed by their timestamps
268 269 270 |
# File 'lib/hbase-jruby/row.rb', line 268 def booleans col decode_value :boolean, col, true end |
#byte(column) ⇒ Fixnum
Returns 1-byte column values as Fixnums
146 147 148 |
# File 'lib/hbase-jruby/row.rb', line 146 def byte col decode_value :byte, col end |
#bytes(column) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 1-byte column values as Fixnums in a Hash indexed by their timestamps
155 156 157 |
# File 'lib/hbase-jruby/row.rb', line 155 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(column) ⇒ Fixnum Also known as: long
Returns 8-byte column values as Fixnums
200 201 202 |
# File 'lib/hbase-jruby/row.rb', line 200 def fixnum col decode_value :fixnum, col end |
#fixnums(column) ⇒ Hash<Fixnum, Fixnum> Also known as: longs
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps
210 211 212 |
# File 'lib/hbase-jruby/row.rb', line 210 def fixnums col decode_value :fixnum, col, true end |
#float(column) ⇒ Float Also known as: double
Returns column values as Floats
238 239 240 |
# File 'lib/hbase-jruby/row.rb', line 238 def float col decode_value :float, col end |
#floats(column) ⇒ Hash<Fixnum, Float> Also known as: doubles
Returns all versions of column values as Floats in a Hash indexed by their timestamps
248 249 250 |
# File 'lib/hbase-jruby/row.rb', line 248 def floats col decode_value :float, col, true end |
#int(column) ⇒ Fixnum
Returns 4-byte column values as Fixnums
182 183 184 |
# File 'lib/hbase-jruby/row.rb', line 182 def int col decode_value :int, col end |
#ints(column) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps
191 192 193 |
# File 'lib/hbase-jruby/row.rb', line 191 def ints col decode_value :int, col, true end |
#raw(column) ⇒ byte[]
Returns column values as byte arrays
88 89 90 |
# File 'lib/hbase-jruby/row.rb', line 88 def raw col get_value col end |
#raws(column) ⇒ Hash<Fixnum, byte[]>
Returns all versions of column values as byte arrays in a Hash indexed by their timestamps
97 98 99 |
# File 'lib/hbase-jruby/row.rb', line 97 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(column) ⇒ Fixnum
Returns 2-byte column values as Fixnums
164 165 166 |
# File 'lib/hbase-jruby/row.rb', line 164 def short col decode_value :short, col end |
#shorts(column) ⇒ Hash<Fixnum, Fixnum>
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps
173 174 175 |
# File 'lib/hbase-jruby/row.rb', line 173 def shorts col decode_value :short, col, true end |
#string(column) ⇒ String Also known as: str
Returns column values as Strings
106 107 108 |
# File 'lib/hbase-jruby/row.rb', line 106 def string col decode_value :string, col end |
#strings(column) ⇒ Hash<Fixnum, String> Also known as: strs
Returns all versions of column values as Strings in a Hash indexed by their timestamps
116 117 118 |
# File 'lib/hbase-jruby/row.rb', line 116 def strings col decode_value :string, col, true end |
#symbol(column) ⇒ Symbol Also known as: sym
Returns column values as Symbols
126 127 128 |
# File 'lib/hbase-jruby/row.rb', line 126 def symbol col decode_value :symbol, col end |
#symbols(column) ⇒ Hash<Fixnum, Symbol> Also known as: syms
Returns all versions of column values as Symbols in a Hash indexed by their timestamps
136 137 138 |
# File 'lib/hbase-jruby/row.rb', line 136 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 |