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

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

Overview

Cell

Row cell build from data chunks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Create row cell instance

Parameters:

  • family (String)

    Column family name

  • qualifier (String)

    Column cell qualifier name

  • timestamp (Integer)

    Timestamp in micro seconds

  • value (String)

    Cell value

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

    List of label array



39
40
41
42
43
44
45
# File 'lib/google/cloud/bigtable/row.rb', line 39

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



29
30
31
# File 'lib/google/cloud/bigtable/row.rb', line 29

def family
  @family
end

#labelsObject (readonly)

Returns the value of attribute labels



29
30
31
# File 'lib/google/cloud/bigtable/row.rb', line 29

def labels
  @labels
end

#qualifierObject (readonly)

Returns the value of attribute qualifier



29
30
31
# File 'lib/google/cloud/bigtable/row.rb', line 29

def qualifier
  @qualifier
end

#timestampObject (readonly)

Returns the value of attribute timestamp



29
30
31
# File 'lib/google/cloud/bigtable/row.rb', line 29

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value



29
30
31
# File 'lib/google/cloud/bigtable/row.rb', line 29

def value
  @value
end

Instance Method Details

#to_iInteger

Convert value to integer

Returns:

  • (Integer)


64
65
66
# File 'lib/google/cloud/bigtable/row.rb', line 64

def to_i
  @value.unpack("q>").first
end

#to_time(granularity = nil) ⇒ Time | nil

Convert timestamp to Time instance

Parameters:

  • granularity (Symbol) (defaults to: nil)

    Optional Valid granularity types are :micros, millis DEfault granularity is a millis.

Returns:

  • (Time | nil)


54
55
56
57
58
# File 'lib/google/cloud/bigtable/row.rb', line 54

def to_time granularity = nil
  return nil if @timestamp.zero?
  return Time.at(@timestamp / 100_0000.0) if granularity == :micros
  Time.at(@timestamp / 1000.0)
end