Class: Google::Cloud::Bigtable::Row::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/bigtable/row.rb

Overview

Cell

Row cell built from data chunks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family, qualifier, timestamp, value, labels = []) ⇒ Cell

Creates a row cell instance.

Parameters:

  • family (String)

    Column family name.

  • qualifier (String)

    Column cell qualifier name.

  • timestamp (Integer)

    Timestamp in microseconds.

  • value (String)

    Cell value.

  • labels (Array<String>) (defaults to: [])

    List of label array.



44
45
46
47
48
49
50
# File 'lib/google/cloud/bigtable/row.rb', line 44

def initialize family, qualifier, timestamp, value, labels = []
  @family = family
  @qualifier = qualifier
  @timestamp = timestamp
  @value = value
  @labels = labels
end

Instance Attribute Details

#familyObject (readonly)

Returns the value of attribute family.



33
34
35
# File 'lib/google/cloud/bigtable/row.rb', line 33

def family
  @family
end

#labelsObject (readonly)

Returns the value of attribute labels.



33
34
35
# File 'lib/google/cloud/bigtable/row.rb', line 33

def labels
  @labels
end

#qualifierObject (readonly)

Returns the value of attribute qualifier.



33
34
35
# File 'lib/google/cloud/bigtable/row.rb', line 33

def qualifier
  @qualifier
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



33
34
35
# File 'lib/google/cloud/bigtable/row.rb', line 33

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value.



33
34
35
# File 'lib/google/cloud/bigtable/row.rb', line 33

def value
  @value
end

Instance Method Details

#to_iInteger

Converts a value to an integer.

Returns:

  • (Integer)


71
72
73
# File 'lib/google/cloud/bigtable/row.rb', line 71

def to_i
  @value.unpack1 "q>"
end

#to_time(granularity = nil) ⇒ Time | nil

Converts timestamp to Time instance.

Parameters:

  • granularity (Symbol) (defaults to: nil)

    Optional. Valid granularity types are :micros, :millis. Default is :millis.

Returns:

  • (Time | nil)


60
61
62
63
64
# File 'lib/google/cloud/bigtable/row.rb', line 60

def to_time granularity = nil
  return nil if @timestamp.zero?
  return Time.at @timestamp / 1_000_000.0 if granularity == :micros
  Time.at @timestamp / 1000.0
end