class Google::Cloud::Bigtable::ReadModifyWriteRule

# ReadModifyWriteRule

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

@example Append value rule

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

@example increment value rule

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

Public Class Methods

append(family, qualifier, value) click to toggle source

Creates an instance of an append-value rule.

@param family [String]

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

@param qualifier [String]

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

@param 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.

@return [Google::Cloud::Bigtable::ReadModifyWriteRule]

@example Append value rule

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.append(
  "cf", "field01", "append-xyz"
)
# 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) click to toggle source

Creates an instance of an increment-amount rule.

@param family [String]

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

@param qualifier [String]

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

@param 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.

@return [Google::Cloud::Bigtable::ReadModifyWriteRule]

@example

rule = Google::Cloud::Bigtable::ReadModifyWriteRule.increment(
  "cf", "field01", 1
)
# 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
new(family, qualifier) click to toggle source

@private Creates an instance of ReadModifyWriteRule

@param family [String]

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

@param qualifier [String]

The qualifier of the column to which the read/modify/write should be applied.
# File lib/google/cloud/bigtable/read_modify_write_rule.rb, line 46
def initialize family, qualifier
  @grpc = Google::Cloud::Bigtable::V2::ReadModifyWriteRule.new
  @grpc.family_name = family
  @grpc.column_qualifier = qualifier
end

Public Instance Methods

append(value) click to toggle source

Sets the append value.

@param value [String] @return [Google::Cloud::Bigtable::ReadModifyWriteRule]

# File lib/google/cloud/bigtable/read_modify_write_rule.rb, line 106
def append value
  @grpc.append_value = value
  self
end
increment(amount) click to toggle source

Sets the increment amount.

@param amount [Integer] @return [Google::Cloud::Bigtable::ReadModifyWriteRule]

# File lib/google/cloud/bigtable/read_modify_write_rule.rb, line 117
def increment amount
  @grpc.increment_amount = amount
  self
end
to_grpc() click to toggle source

@private

Get gRPC protobuf instance.

@return [Google::Cloud::Bigtable::V2::ReadModifyWriteRule]

# File lib/google/cloud/bigtable/read_modify_write_rule.rb, line 128
def to_grpc
  @grpc
end