Class: HBase::Result
- Inherits:
-
Object
- Object
- HBase::Result
- Includes:
- Enumerable
- Defined in:
- lib/hbase-jruby/result.rb
Overview
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compares two Result instances on their row keys.
-
#bigdecimal(cols) ⇒ Object
Returns column values as Bigdecimals.
-
#bigdecimals(cols) ⇒ Object
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps.
-
#boolean(cols) ⇒ Object
(also: #bool)
Returns column values as Booleans.
-
#booleans(cols) ⇒ Object
(also: #bools)
Returns all versions of column values as Booleans in a Hash indexed by their timestamps.
-
#byte(cols) ⇒ Object
Returns 1-byte column values as Fixnums.
-
#bytes(cols) ⇒ Object
Returns all versions of 1-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#each ⇒ Object
Enumerates through cells.
-
#fixnum(cols) ⇒ Object
(also: #long)
Returns 8-byte column values as Fixnums.
-
#fixnums(cols) ⇒ Object
(also: #longs)
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#float(cols) ⇒ Object
(also: #double)
Returns column values as Floats.
-
#floats(cols) ⇒ Object
(also: #doubles)
Returns all versions of column values as Floats in a Hash indexed by their timestamps.
-
#int(cols) ⇒ Object
Returns 4-byte column values as Fixnums.
-
#ints(cols) ⇒ Object
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#raw(cols) ⇒ Object
Returns column values as byte arrays.
-
#raws(cols) ⇒ Object
Returns all versions of column values as byte arrays in a Hash indexed by their timestamps.
-
#rowkey(type = :string) ⇒ String, byte[]
Returns the rowkey of the row.
-
#short(cols) ⇒ Object
Returns 2-byte column values as Fixnums.
-
#shorts(cols) ⇒ Object
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps.
-
#string(cols) ⇒ Object
(also: #str)
Returns column values as Strings.
-
#strings(cols) ⇒ Object
(also: #strs)
Returns all versions of column values as Strings in a Hash indexed by their timestamps.
-
#symbol(cols) ⇒ Object
(also: #sym)
Returns column values as Symbols.
-
#symbols(cols) ⇒ Object
(also: #syms)
Returns all versions of column values as Symbols in a Hash indexed by their timestamps.
-
#to_hash(schema = {}) ⇒ Hash
Returns Hash representation of the row.
-
#to_hash_with_versions(schema = {}) ⇒ Hash<Hash>
Returns Hash representation of the row.
Instance Method Details
#<=>(other) ⇒ Object
Compares two Result instances on their row keys
374 375 376 |
# File 'lib/hbase-jruby/result.rb', line 374 def <=> other Bytes.compareTo(rowkey(:raw), other.rowkey(:raw)) end |
#bigdecimal(column) ⇒ BigDecimal #bigdecimal(columns) ⇒ Array<BigDecimal>
Returns column values as Bigdecimals
295 296 297 |
# File 'lib/hbase-jruby/result.rb', line 295 def bigdecimal cols decode_values :bigdecimal, cols end |
#bigdecimals(column) ⇒ Hash<Fixnum, BigDecimal> #bigdecimals(columns) ⇒ Array<Hash<Fixnum, BigDecimal>>
Returns all versions of column values as BigDecimals in a Hash indexed by their timestamps
309 310 311 |
# File 'lib/hbase-jruby/result.rb', line 309 def bigdecimals cols decode_values :bigdecimal, cols, true end |
#boolean(column) ⇒ true, false #boolean(columns) ⇒ Array<true|false> Also known as: bool
Returns column values as Booleans
353 354 355 |
# File 'lib/hbase-jruby/result.rb', line 353 def boolean cols decode_values :boolean, cols end |
#booleans(column) ⇒ Hash<Fixnum, true|false> #booleans(columns) ⇒ Array<Hash<Fixnum, true|false>> Also known as: bools
Returns all versions of column values as Booleans in a Hash indexed by their timestamps
368 369 370 |
# File 'lib/hbase-jruby/result.rb', line 368 def booleans cols decode_values :boolean, cols, true end |
#byte(column) ⇒ Fixnum #byte(columns) ⇒ Array<Fixnum>
Returns 1-byte column values as Fixnums
181 182 183 |
# File 'lib/hbase-jruby/result.rb', line 181 def byte cols decode_values :byte, cols end |
#bytes(column) ⇒ Hash<Fixnum, Fixnum> #bytes(columns) ⇒ Array<Hash<Fixnum, Fixnum>>
Returns all versions of 1-byte column values as Fixnums in a Hash indexed by their timestamps
195 196 197 |
# File 'lib/hbase-jruby/result.rb', line 195 def bytes cols decode_values :byte, cols, true end |
#each ⇒ Object
Enumerates through cells
18 19 20 21 22 23 24 25 26 |
# File 'lib/hbase-jruby/result.rb', line 18 def each if block_given? @result.raw.each do |kv| yield Cell.new(kv) end else self end end |
#fixnum(column) ⇒ Fixnum #fixnum(columns) ⇒ Array<Fixnum> Also known as: long
Returns 8-byte column values as Fixnums
265 266 267 |
# File 'lib/hbase-jruby/result.rb', line 265 def fixnum cols decode_values :fixnum, cols end |
#fixnums(column) ⇒ Hash<Fixnum, Fixnum> #fixnums(columns) ⇒ Array<Hash<Fixnum, Fixnum>> Also known as: longs
Returns all versions of 8-byte column values as Fixnums in a Hash indexed by their timestamps
280 281 282 |
# File 'lib/hbase-jruby/result.rb', line 280 def fixnums cols decode_values :fixnum, cols, true end |
#float(column) ⇒ Float #float(columns) ⇒ Array<Float> Also known as: double
Returns column values as Floats
323 324 325 |
# File 'lib/hbase-jruby/result.rb', line 323 def float cols decode_values :float, cols end |
#floats(column) ⇒ Hash<Fixnum, Float> #floats(columns) ⇒ Array<Hash<Fixnum, Float>> Also known as: doubles
Returns all versions of column values as Floats in a Hash indexed by their timestamps
338 339 340 |
# File 'lib/hbase-jruby/result.rb', line 338 def floats cols decode_values :float, cols, true end |
#int(column) ⇒ Fixnum #int(columns) ⇒ Array<Fixnum>
Returns 4-byte column values as Fixnums
237 238 239 |
# File 'lib/hbase-jruby/result.rb', line 237 def int cols decode_values :int, cols end |
#ints(column) ⇒ Hash<Fixnum, Fixnum> #ints(columns) ⇒ Array<Hash<Fixnum, Fixnum>>
Returns all versions of 4-byte column values as Fixnums in a Hash indexed by their timestamps
251 252 253 |
# File 'lib/hbase-jruby/result.rb', line 251 def ints cols decode_values :int, cols, true end |
#raw(column) ⇒ byte[] #raw(columns) ⇒ Array<byte[]>
Returns column values as byte arrays
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/hbase-jruby/result.rb', line 79 def raw cols ret = get_values [*cols] case cols when Array ret else ret.first end end |
#raws(column) ⇒ Hash<Fixnum, byte[]> #raws(columns) ⇒ Array<Hash<Fixnum, byte[]>>
Returns all versions of column values as byte arrays in a Hash indexed by their timestamps
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/hbase-jruby/result.rb', line 100 def raws cols ret = get_values [*cols], true case cols when Array ret else ret.first end end |
#rowkey(type = :string) ⇒ String, byte[]
Returns the rowkey of the row
13 14 15 |
# File 'lib/hbase-jruby/result.rb', line 13 def rowkey type = :string Util.from_bytes type, @result.getRow end |
#short(column) ⇒ Fixnum #short(columns) ⇒ Array<Fixnum>
Returns 2-byte column values as Fixnums
209 210 211 |
# File 'lib/hbase-jruby/result.rb', line 209 def short cols decode_values :short, cols end |
#shorts(column) ⇒ Hash<Fixnum, Fixnum> #shorts(columns) ⇒ Array<Hash<Fixnum, Fixnum>>
Returns all versions of 2-byte column values as Fixnums in a Hash indexed by their timestamps
223 224 225 |
# File 'lib/hbase-jruby/result.rb', line 223 def shorts cols decode_values :short, cols, true end |
#string(column) ⇒ String #string(columns) ⇒ Array<String> Also known as: str
Returns column values as Strings
121 122 123 |
# File 'lib/hbase-jruby/result.rb', line 121 def string cols decode_values :string, cols end |
#strings(column) ⇒ Hash<Fixnum, String> #strings(columns) ⇒ Array<Hash<Fixnum, String>> Also known as: strs
Returns all versions of column values as Strings in a Hash indexed by their timestamps
136 137 138 |
# File 'lib/hbase-jruby/result.rb', line 136 def strings cols decode_values :string, cols, true end |
#symbol(column) ⇒ Symbol #symbol(columns) ⇒ Array<Symbol> Also known as: sym
Returns column values as Symbols
151 152 153 |
# File 'lib/hbase-jruby/result.rb', line 151 def symbol cols decode_values :symbol, cols end |
#symbols(column) ⇒ Hash<Fixnum, Symbol> #symbols(columns) ⇒ Array<Hash<Fixnum, Symbol>> Also known as: syms
Returns all versions of column values as Symbols in a Hash indexed by their timestamps
166 167 168 |
# File 'lib/hbase-jruby/result.rb', line 166 def symbols cols decode_values :symbol, cols, true end |
#to_hash(schema = {}) ⇒ Hash
Returns Hash representation of the row.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hbase-jruby/result.rb', line 31 def to_hash schema = {} schema = parse_schema schema HASH_TEMPLATE.clone.tap { |ret| @result.getNoVersionMap.each do |cf, cqmap| cqmap.each do |cq, val| name = ColumnKey.new(cf, cq) type = schema[name] ret[name] = type ? Util.from_bytes(type, val) : val end end } end |
#to_hash_with_versions(schema = {}) ⇒ Hash<Hash>
Returns Hash representation of the row. Each column value again is represented as a Hash indexed by timestamp of each version.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hbase-jruby/result.rb', line 49 def to_hash_with_versions schema = {} schema = parse_schema schema HASH_TEMPLATE.clone.tap { |ret| @result.getMap.each do |cf, cqmap| cqmap.each do |cq, tsmap| name = ColumnKey.new(cf, cq) type = schema[name] ret[name] = Hash[ tsmap.map { |ts, val| [ ts, type ? Util.from_bytes(type, val) : val ] } ] end end } end |