Class: Google::Cloud::Bigtable::MutationEntry
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::MutationEntry
- Defined in:
- lib/google/cloud/bigtable/mutation_entry.rb
Overview
MutationEntry
MutationEntry is a chainable structure that holds data for different type of mutations. MutationEntry is used in following data operations:
- Mutate row. See Table#mutate_row
- Mutate rows. See Table#mutate_rows
- Check and mutate row using a predicate. See Table#check_and_mutate_row
Instance Attribute Summary collapse
-
#row_key ⇒ Object
Returns the value of attribute row_key.
Instance Method Summary collapse
-
#delete_cells(family, qualifier, timestamp_from: nil, timestamp_to: nil) ⇒ MutationEntry
Adds a DeleteFromColumn to the list of mutations.
-
#delete_from_family(family) ⇒ MutationEntry
Adds a DeleteFromFamily to the list of mutations.
-
#delete_from_row ⇒ MutationEntry
Adds a DeleteFromRow to the list of mutations.
-
#initialize(row_key = nil) ⇒ MutationEntry
constructor
Creates a mutation entry instance.
-
#length ⇒ Integer
The number of mutations.
-
#retryable? ⇒ Boolean
If the mutation entry is retryable or not based on set_cell value.
-
#set_cell(family, qualifier, value, timestamp: nil) ⇒ MutationEntry
Adds a SetCell to the list of mutations.
Constructor Details
#initialize(row_key = nil) ⇒ MutationEntry
Creates a mutation entry instance.
72 73 74 75 76 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 72 def initialize row_key = nil @row_key = row_key @mutations = [] @retryable = true end |
Instance Attribute Details
#row_key ⇒ Object
Returns the value of attribute row_key.
60 61 62 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 60 def row_key @row_key end |
Instance Method Details
#delete_cells(family, qualifier, timestamp_from: nil, timestamp_to: nil) ⇒ MutationEntry
Adds a DeleteFromColumn to the list of mutations.
A DeleteFromColumn is a mutation that deletes cells from the specified column, optionally restricting the deletions to a given timestamp range.
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 182 def delete_cells family, qualifier, timestamp_from: nil, timestamp_to: nil grpc = Google::Cloud::Bigtable::V2::Mutation::DeleteFromColumn.new \ family_name: family, column_qualifier: qualifier if || time_range = Google::Cloud::Bigtable::V2::TimestampRange.new time_range. = if time_range. = if grpc.time_range = time_range end @mutations << Google::Cloud::Bigtable::V2::Mutation.new(delete_from_column: grpc) self end |
#delete_from_family(family) ⇒ MutationEntry
Adds a DeleteFromFamily to the list of mutations.
A DeleteFromFamily is a mutation that deletes all cells from the specified column family.
209 210 211 212 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 209 def delete_from_family family @mutations << Google::Cloud::Bigtable::V2::Mutation.new(delete_from_family: { family_name: family }) self end |
#delete_from_row ⇒ MutationEntry
Adds a DeleteFromRow to the list of mutations.
A DeleteFromRow is a mutation which deletes all cells from the containing row.
225 226 227 228 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 225 def delete_from_row @mutations << Google::Cloud::Bigtable::V2::Mutation.new(delete_from_row: {}) self end |
#length ⇒ Integer
The number of mutations.
244 245 246 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 244 def length @mutations.length end |
#retryable? ⇒ Boolean
If the mutation entry is retryable or not based on set_cell value.
235 236 237 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 235 def retryable? @retryable end |
#set_cell(family, qualifier, value, timestamp: nil) ⇒ MutationEntry
Adds a SetCell to the list of mutations.
A SetCell is a mutation that sets the value of the specified cell.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 116 def set_cell family, qualifier, value, timestamp: nil # If value is integer, covert it to a 64-bit signed big-endian integer. value = Convert.integer_to_signed_be_64 value = { family_name: family, column_qualifier: qualifier, value: value } if [:timestamp_micros] = @retryable = != -1 end @mutations << Google::Cloud::Bigtable::V2::Mutation.new(set_cell: ) self end |