Class: Apache::Hadoop::Hbase::Thrift::TCell

Inherits:
Object
  • Object
show all
Includes:
Thrift::Struct, Thrift::Struct_Union
Defined in:
lib/thrift/hbase_types.rb,
lib/hbaserb/extensions.rb

Overview

TCell - Used to transport a cell value (byte[]) and the timestamp it was stored with together as a result for get and getRow methods. This promotes the timestamp of a cell to a first-class value, making it easy to take note of temporal data. Cell is used all the way from HStore up to HTable.

Constant Summary collapse

VALUE =
1
TIMESTAMP =
2
FIELDS =
{
  VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary => true},
  TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp'}
}

Instance Method Summary collapse

Instance Method Details

#struct_fieldsObject



26
# File 'lib/thrift/hbase_types.rb', line 26

def struct_fields; FIELDS; end

#to_doubleObject



29
30
31
# File 'lib/hbaserb/extensions.rb', line 29

def to_double
  value.unpack('G').first
end

#to_i16Object



8
9
10
11
# File 'lib/hbaserb/extensions.rb', line 8

def to_i16
  val, = value.unpack('n')
  (val > 0x7fff) ? (0 - ((val - 1) ^ 0xffff)) : val
end

#to_i32Object



13
14
15
16
# File 'lib/hbaserb/extensions.rb', line 13

def to_i32
  val, = value.unpack('N')
  (val > 0x7fffffff) ? (0 - ((val - 1) ^ 0xffffffff)) : val
end

#to_i64Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/hbaserb/extensions.rb', line 18

def to_i64
  hi, lo = value.unpack('N2')
  if (hi > 0x7fffffff)
    hi ^= 0xffffffff
    lo ^= 0xffffffff
    0 - (hi << 32) - lo - 1
  else
    (hi << 32) + lo
  end
end

#validateObject



28
29
# File 'lib/thrift/hbase_types.rb', line 28

def validate
end