Class: Cequel::Metal::Batch Private
- Inherits:
-
Object
- Object
- Cequel::Metal::Batch
- Defined in:
- lib/cequel/metal/batch.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Encapsulates a batch operation
Instance Method Summary collapse
-
#apply ⇒ Object
private
Send the batch to Cassandra.
-
#execute(cql, *bind_vars) ⇒ Object
private
Add a statement to the batch.
-
#initialize(keyspace, options = {}) ⇒ Batch
constructor
private
A new instance of Batch.
-
#logged? ⇒ Boolean
private
Is this a logged batch?.
-
#unlogged? ⇒ Boolean
private
Is this an unlogged batch?.
Constructor Details
#initialize(keyspace, options = {}) ⇒ Batch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Batch.
26 27 28 29 30 31 |
# File 'lib/cequel/metal/batch.rb', line 26 def initialize(keyspace, = {}) @keyspace = keyspace @auto_apply = [:auto_apply] @unlogged = .fetch(:unlogged, false) reset end |
Instance Method Details
#apply ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Send the batch to Cassandra
50 51 52 53 54 55 56 57 |
# File 'lib/cequel/metal/batch.rb', line 50 def apply return if @statement_count.zero? if @statement_count > 1 @statement.prepend(begin_statement) @statement.append("APPLY BATCH\n") end @keyspace.execute(*@statement.args) end |
#execute(cql, *bind_vars) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add a statement to the batch.
38 39 40 41 42 43 44 45 |
# File 'lib/cequel/metal/batch.rb', line 38 def execute(cql, *bind_vars) @statement.append("#{cql}\n", *bind_vars) @statement_count += 1 if @auto_apply && @statement_count >= @auto_apply apply reset end end |
#logged? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Is this a logged batch?
72 73 74 |
# File 'lib/cequel/metal/batch.rb', line 72 def logged? !unlogged? end |
#unlogged? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Is this an unlogged batch?
63 64 65 |
# File 'lib/cequel/metal/batch.rb', line 63 def unlogged? @unlogged end |