Class: NoSE::Backend::CassandraBackend::DeleteStatementStep
- Inherits:
-
Backend::DeleteStatementStep
- Object
- Backend::StatementStep
- Backend::DeleteStatementStep
- NoSE::Backend::CassandraBackend::DeleteStatementStep
- Defined in:
- lib/nose/backend/cassandra.rb
Overview
Delete data from an index on the backend
Instance Attribute Summary
Attributes inherited from Backend::StatementStep
Instance Method Summary collapse
-
#initialize(client, index) ⇒ DeleteStatementStep
constructor
A new instance of DeleteStatementStep.
-
#process(results) ⇒ Object
Execute the delete for a given set of keys.
Methods included from Supertype
Constructor Details
#initialize(client, index) ⇒ DeleteStatementStep
Returns a new instance of DeleteStatementStep.
234 235 236 237 238 239 240 241 242 243 |
# File 'lib/nose/backend/cassandra.rb', line 234 def initialize(client, index) super @index_keys = @index.hash_fields + @index.order_fields.to_set # Prepare the statement required to perform the deletion delete = "DELETE FROM #{index.key} WHERE " delete += @index_keys.map { |key| "\"#{key.id}\" = ?" }.join(' AND ') @prepared = client.prepare delete end |
Instance Method Details
#process(results) ⇒ Object
Execute the delete for a given set of keys
246 247 248 249 250 251 252 |
# File 'lib/nose/backend/cassandra.rb', line 246 def process(results) # Delete each row from the index results.each do |result| values = delete_values result @client.execute(@prepared, arguments: values) end end |