Module: Cassie::Statements::Execution

Extended by:
ClassMethods
Includes:
Callbacks, Consistency, Instrumentation, PartitionLinking
Included in:
Core
Defined in:
lib/cassie/statements/execution.rb,
lib/cassie/statements/execution/peeking.rb,
lib/cassie/statements/execution/fetching.rb,
lib/cassie/statements/execution/callbacks.rb,
lib/cassie/statements/execution/deserialization.rb,
lib/cassie/statements/execution/instrumentation.rb,
lib/cassie/statements/execution/batched_fetching.rb,
lib/cassie/statements/execution/partition_linking.rb

Overview

Execution support for Cassandra Statements

Requires the following methods be provided:

  • statement

    • CQL String or Cassandra::Statements:Statement executable by a Cassandra::Session

  • session

    • A Cassandra::Session scoped to an appropriate keyspace

Defined Under Namespace

Modules: BatchedFetching, Callbacks, ClassMethods, Consistency, Deserialization, Fetching, Instrumentation, PartitionLinking, Peeking

Instance Method Summary collapse

Methods included from ClassMethods

inherited

Methods included from PartitionLinking

#build_partition_linker, #partition_linker?

Methods included from Consistency

#consistency

Instance Method Details

#execute(opts = {}) ⇒ Boolean

Executes the statment and populates result

Parameters:

  • cassandra_driver (Hash{Symbol => Object})

    execution options

Returns:

  • (Boolean)

    indicating a successful execution or not



59
60
61
62
# 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

#execute!(opts = {}) ⇒ Boolean

Same as #execute. Raises if not succesfull.

Parameters:

  • cassandra_driver (Hash{Symbol => Object})

    execution options

Returns:

  • (Boolean)

    true if sucessful

Raises:



68
69
70
# File 'lib/cassie/statements/execution.rb', line 68

def execute!(opts={})
  execute || (raise Cassie::Statements::ExecutionError.new(result))
end

#execution_optionsHash{Symbol => Object}

The session exection options configured for statement execution

Returns:



74
75
76
77
78
79
80
81
82
# 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