Class: Believer::Batch
Overview
A command which issues 0 or more other commands in batch to the Cassandra server. This is achieved using the CQL BATCH command
Instance Attribute Summary
Attributes inherited from Command
#consistency_level, #record_class
Instance Method Summary collapse
-
#<<(command) ⇒ Object
Adds a command.
-
#add(command) ⇒ Object
Adds a command.
-
#commands ⇒ Array<Command>
Yields the collection of commands.
-
#to_cql ⇒ String
Yields the CQL for this command.
Methods inherited from Command
#can_execute?, #clone, #command_name, #consistency, #execute, #execution_options, #execution_options=, #initialize, #override_execution_options, #query_attributes
Constructor Details
This class inherits a constructor from Believer::Command
Instance Method Details
#<<(command) ⇒ Object
Adds a command
15 16 17 |
# File 'lib/believer/batch.rb', line 15 def <<(command) add(command) end |
#add(command) ⇒ Object
Adds a command
21 22 23 24 |
# File 'lib/believer/batch.rb', line 21 def add(command) commands << command self end |
#commands ⇒ Array<Command>
Yields the collection of commands
9 10 11 |
# File 'lib/believer/batch.rb', line 9 def commands @commands ||= [] end |
#to_cql ⇒ String
Yields the CQL for this command
28 29 30 31 32 33 34 35 |
# File 'lib/believer/batch.rb', line 28 def to_cql cql = "BEGIN BATCH\n" commands.each do |c| cql += " #{c.to_cql}\n" end cql += "APPLY BATCH;\n" cql end |