Class: Cassandra::Statements::Batch
- Inherits:
-
Object
- Object
- Cassandra::Statements::Batch
- Includes:
- Cassandra::Statement
- Defined in:
- lib/cassandra/statements/batch.rb
Overview
Batch statement groups several Cassandra::Statement. There are several types of Batch statements available:
Instance Method Summary collapse
-
#add(statement, options = nil) ⇒ self
Adds a statement to this batch.
-
#cql ⇒ nil
A batch statement doesn't really have any cql of its own as it is composed of multiple different statements.
-
#idempotent? ⇒ Boolean
Determines whether or not the statement is safe to retry on timeout Batches are idempotent only when all statements in a batch are.
-
#inspect ⇒ String
A CLI-friendly batch statement representation.
-
#type ⇒ Symbol
One of
:logged
,:unlogged
or:counter
.
Instance Method Details
#add(statement, options = nil) ⇒ self
Positional arguments for simple statements are only supported starting with Apache Cassandra 2.0 and above.
Named arguments for simple statements are only supported starting with Apache Cassandra 2.1 and above.
Adds a statement to this batch.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cassandra/statements/batch.rb', line 90 def add(statement, = nil) = if .is_a?(::Hash) .override() else end case statement when String @statements << Simple.new(statement, .arguments, .type_hints, .idempotent?) when Prepared @statements << statement.bind(.arguments) when Bound, Simple @statements << statement else raise ::ArgumentError, 'a batch can only consist of simple or prepared statements, ' \ "#{statement.inspect} given" end self end |
#cql ⇒ nil
A batch statement doesn't really have any cql of its own as it is composed of multiple different statements
132 133 134 |
# File 'lib/cassandra/statements/batch.rb', line 132 def cql nil end |
#idempotent? ⇒ Boolean
Determines whether or not the statement is safe to retry on timeout Batches are idempotent only when all statements in a batch are.
125 126 127 |
# File 'lib/cassandra/statements/batch.rb', line 125 def idempotent? @statements.all?(&:idempotent?) end |
#inspect ⇒ String
141 142 143 |
# File 'lib/cassandra/statements/batch.rb', line 141 def inspect "#<#{self.class.name}:0x#{object_id.to_s(16)} @type=#{type.inspect}>" end |
#type ⇒ Symbol
137 138 |
# File 'lib/cassandra/statements/batch.rb', line 137 def type end |