module Cassie::Statements::Execution
Execution
support for Cassandra Statements
Requires the following methods be provided:
-
statement
-
CQL
String
orCassandra::Statements:Statement
executable by aCassandra::Session
-
-
session
-
A
Cassandra::Session
scoped to an appropriate keyspace
-
Public Class Methods
@!visibility private @!parse include Consistency
@!parse include Callbacks
@!parse include PartitionLinking
@!parse include Instrumentation
# File lib/cassie/statements/execution.rb, line 22 def self.included(base) base.instance_eval do # The result from execution. # Includes all attributes and methods available from # a +Cassandra::Result+ # @return [Cassie::Statements::Results::Result] A decorated +Cassandra::Result+ object attr_reader :result include Consistency include Callbacks include PartitionLinking include Instrumentation end base.extend ClassMethods end
Public Instance Methods
Executes the statment and populates result @param [Hash{Symbol => Object}] cassandra_driver execution options @return [Boolean] indicating a successful execution or not
# File lib/cassie/statements/execution.rb, line 59 def execute(opts={}) @result = result_class.new(session.execute(statement, execution_options.merge(opts)), result_opts) result.success? end
Same as {#execute}. Raises if not succesfull. @param [Hash{Symbol => Object}] cassandra_driver execution options @return [Boolean] true if sucessful @raise [Cassie::Statements::ExecutionError] if the result was not sucessful, see {Cassie::Statements::Results::Core#success?}
# File lib/cassie/statements/execution.rb, line 68 def execute!(opts={}) execute || (raise Cassie::Statements::ExecutionError.new(result)) end
The session exection options configured for statement execution @return [Hash{Symbol => Object}]
# File lib/cassie/statements/execution.rb, line 74 def execution_options {}.tap do |opts| # @todo rework consistency module to be more # abstract implementation for all execution options opts[:consistency] = consistency if consistency opts[:paging_state] = paging_state if respond_to?(:paging_state) && paging_state opts[:page_size] = stateless_page_size if respond_to?(:stateless_page_size) && stateless_page_size end end
Protected Instance Methods
# File lib/cassie/statements/execution.rb, line 86 def result_class self.class.result_class end
# File lib/cassie/statements/execution.rb, line 90 def result_opts {} end
Private Instance Methods
Ensures that clone
and dup
drops the reference to the result object. The cloned object should be able to mutate the statement and execute without affecting the original objecthe resulting object or its results.
# File lib/cassie/statements/execution.rb, line 100 def initialize_copy(other) super @result = nil end