Class: Cassandra::Statements::Batch

Inherits:
Object
  • Object
show all
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

Instance Method Details

#add(statement, args = nil) ⇒ self

Note:

Positional arguments for simple statements are only supported starting with Apache Cassandra 2.0 and above.

Note:

Named arguments for simple statements are only supported starting with Apache Cassandra 2.1 and above.

Adds a statement to this batch.

Parameters:

Returns:

  • (self)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cassandra/statements/batch.rb', line 74

def add(statement, args = nil)
  args ||= EMPTY_LIST

  case statement
  when String
    @statements << Simple.new(statement, args)
  when Prepared
    @statements << statement.bind(args)
  when Bound, Simple
    @statements << statement
  else
    raise ::ArgumentError, "a batch can only consist of simple or prepared statements, #{statement.inspect} given"
  end

  self
end

#cqlnil

A batch statement doesn't really have any cql of its own as it is composed of multiple different statements

Returns:

  • (nil)

    nothing



93
94
95
# File 'lib/cassandra/statements/batch.rb', line 93

def cql
  nil
end

#inspectString

Returns a CLI-friendly batch statement representation.

Returns:

  • (String)

    a CLI-friendly batch statement representation



102
103
104
# File 'lib/cassandra/statements/batch.rb', line 102

def inspect
  "#<#{self.class.name}:0x#{self.object_id.to_s(16)} @type=#{type.inspect}>"
end

#typeSymbol

Returns one of :logged, :unlogged or :counter.

Returns:

  • (Symbol)

    one of :logged, :unlogged or :counter



98
99
# File 'lib/cassandra/statements/batch.rb', line 98

def type
end