Class: Google::Cloud::Bigtable::ReadModifyWriteRule

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

Overview

ReadModifyWriteRule

Specifies an atomic read/modify/write operation on the latest value of the specified column.

Examples:

Append value rule

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.append(
  "cf", "field01", "append-xyz"
)

increment value rule

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.increment(
  "cf", "field01", 1
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append(family, qualifier, value) ⇒ Google::Cloud::Bigtable::ReadModifyWriteRule

Creates an instance of an append-value rule.

Examples:

Append value rule

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.append(
  "cf", "field01", "append-xyz"
)

Parameters:

  • family (String)

    The name of the family to which the read/modify/write should be applied.

  • qualifier (String)

    The qualifier of the column to which the read/modify/write should be applied.

  • value (String)

    Rule specifying that append_value be appended to the existing value. If the targeted cell is unset, it will be treated as if it contains an empty string.

Returns:



69
70
71
72
73
# File 'lib/google/cloud/bigtable/read_modify_write_rule.rb', line 69

def self.append family, qualifier, value
  rule = new family, qualifier
  rule.append value
  rule
end

.increment(family, qualifier, amount) ⇒ Google::Cloud::Bigtable::ReadModifyWriteRule

Creates an instance of an increment-amount rule.

Examples:

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.increment(
  "cf", "field01", 1
)

Parameters:

  • family (String)

    The name of the family to which the read/modify/write should be applied.

  • qualifier (String)

    The qualifier of the column to which the read/modify/write should be applied.

  • amount (String)

    Rule specifying that increment_amount be added to the existing value. If the targeted cell is unset, it will be treated as if it contains a zero. Otherwise, the targeted cell must contain an 8-byte value (interpreted as a 64-bit big-endian signed integer), or the entire request will fail.

Returns:



94
95
96
97
98
# File 'lib/google/cloud/bigtable/read_modify_write_rule.rb', line 94

def self.increment family, qualifier, amount
  rule = new family, qualifier
  rule.increment amount
  rule
end

Instance Method Details

#append(value) ⇒ Google::Cloud::Bigtable::ReadModifyWriteRule

Sets the append value.

Parameters:

  • value (String)

Returns:



106
107
108
109
# File 'lib/google/cloud/bigtable/read_modify_write_rule.rb', line 106

def append value
  @grpc.append_value = value
  self
end

#increment(amount) ⇒ Google::Cloud::Bigtable::ReadModifyWriteRule

Sets the increment amount.

Parameters:

  • amount (Integer)

Returns:



117
118
119
120
# File 'lib/google/cloud/bigtable/read_modify_write_rule.rb', line 117

def increment amount
  @grpc.increment_amount = amount
  self
end