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
-
#mutations ⇒ Array<Google::Bigtable::V2::Mutation>
mutations gRPC list.
-
#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
Add DeleteFromColumn entry to list of mutations.
-
#delete_from_family(family) ⇒ MutationEntry
Add DeleteFromFamily to list of mutations.
-
#delete_from_row ⇒ MutationEntry
Add DeleteFromRow entry to list of mutations.
-
#initialize(row_key = nil) ⇒ MutationEntry
constructor
Creates a mutation entry instance.
-
#length ⇒ Integer
Number of mutations.
-
#retryable? ⇒ Boolean
Mutation entry is retryable or not based on set_cell value.
-
#set_cell(family, qualifier, value, timestamp: nil) ⇒ MutationEntry
Add SetCell mutation to list of mutations.
Constructor Details
#initialize(row_key = nil) ⇒ MutationEntry
Creates a mutation entry instance.
64 65 66 67 68 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 64 def initialize row_key = nil @row_key = row_key @mutations = [] @retryable = true end |
Instance Attribute Details
#mutations ⇒ Array<Google::Bigtable::V2::Mutation>
mutations gRPC list
59 60 61 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 59 def mutations @mutations end |
#row_key ⇒ Object
Returns the value of attribute row_key.
55 56 57 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 55 def row_key @row_key end |
Instance Method Details
#delete_cells(family, qualifier, timestamp_from: nil, timestamp_to: nil) ⇒ MutationEntry
Add DeleteFromColumn entry to list of mutations.
A mutation that deletes cells from the specified column, optionally restricting the deletions to a given timestamp range.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 157 def delete_cells \ family, qualifier, timestamp_from: nil, timestamp_to: nil grpc = Google::Bigtable::V2::Mutation::DeleteFromColumn.new( family_name: family, column_qualifier: qualifier ) if || time_range = Google::Bigtable::V2::TimestampRange.new time_range. = if time_range. = if grpc.time_range = time_range end @mutations << Google::Bigtable::V2::Mutation.new( delete_from_column: grpc ) self end |
#delete_from_family(family) ⇒ MutationEntry
Add DeleteFromFamily to list of mutations.
A mutation that deletes all cells from the specified column family.
191 192 193 194 195 196 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 191 def delete_from_family family @mutations << Google::Bigtable::V2::Mutation.new( delete_from_family: { family_name: family } ) self end |
#delete_from_row ⇒ MutationEntry
Add DeleteFromRow entry to list of mutations
A Mutation which deletes all cells from the containing row.
208 209 210 211 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 208 def delete_from_row @mutations << Google::Bigtable::V2::Mutation.new(delete_from_row: {}) self end |
#length ⇒ Integer
Number of mutations
225 226 227 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 225 def length @mutations.length end |
#retryable? ⇒ Boolean
Mutation entry is retryable or not based on set_cell value.
217 218 219 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 217 def retryable? @retryable end |
#set_cell(family, qualifier, value, timestamp: nil) ⇒ MutationEntry
Add SetCell mutation to list of mutations.
A mutation that sets the value of the specified cell.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/google/cloud/bigtable/mutation_entry.rb', line 103 def set_cell family, qualifier, value, timestamp: nil # If value is integer, covert it to a 64-bit signed big-endian integer. value = [value].pack("q>") if value.is_a?(Integer) = { family_name: family, column_qualifier: qualifier, value: value } if [:timestamp_micros] = @retryable = != -1 end @mutations << Google::Bigtable::V2::Mutation.new(set_cell: ) self end |