Class: Cassandra::Aggregate
- Inherits:
-
Object
- Object
- Cassandra::Aggregate
- Defined in:
- lib/cassandra/aggregate.rb
Overview
Represents a cassandra user defined aggregate
Instance Attribute Summary collapse
-
#argument_types ⇒ Array<Cassandra::Type>
readonly
Aggregate argument types.
-
#final_function ⇒ Cassandra::Function
readonly
The final function used by this aggregate.
-
#initial_state ⇒ Object?
readonly
The initial value of the aggregate state or nil.
-
#name ⇒ String
readonly
Aggregate name.
-
#state_function ⇒ Cassandra::Function
readonly
The state function used by this aggregate.
-
#state_type ⇒ Cassandra::Type
readonly
Aggregate state type.
-
#type ⇒ Cassandra::Type
readonly
Aggregate return type.
Instance Method Summary collapse
-
#to_cql ⇒ String
A cql representation of this aggregate.
Instance Attribute Details
#argument_types ⇒ Array<Cassandra::Type> (readonly)
Returns aggregate argument types.
32 33 34 |
# File 'lib/cassandra/aggregate.rb', line 32 def argument_types @argument_types end |
#final_function ⇒ Cassandra::Function (readonly)
Returns the final function used by this aggregate.
40 41 42 |
# File 'lib/cassandra/aggregate.rb', line 40 def final_function @final_function end |
#initial_state ⇒ Object? (readonly)
Returns the initial value of the aggregate state or nil.
36 37 38 |
# File 'lib/cassandra/aggregate.rb', line 36 def initial_state @initial_state end |
#name ⇒ String (readonly)
Returns aggregate name.
28 29 30 |
# File 'lib/cassandra/aggregate.rb', line 28 def name @name end |
#state_function ⇒ Cassandra::Function (readonly)
Returns the state function used by this aggregate.
38 39 40 |
# File 'lib/cassandra/aggregate.rb', line 38 def state_function @state_function end |
#state_type ⇒ Cassandra::Type (readonly)
Returns aggregate state type.
34 35 36 |
# File 'lib/cassandra/aggregate.rb', line 34 def state_type @state_type end |
#type ⇒ Cassandra::Type (readonly)
Returns aggregate return type.
30 31 32 |
# File 'lib/cassandra/aggregate.rb', line 30 def type @type end |
Instance Method Details
#to_cql ⇒ String
Returns a cql representation of this aggregate.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/cassandra/aggregate.rb', line 104 def to_cql cql = 'CREATE AGGREGATE simplex.average(' first = true @argument_types.each do |type| if first first = false else cql << ', ' end cql << type.to_s end cql << ')' cql << "\n SFUNC #{@state_function.name}" cql << "\n STYPE #{@state_type}" cql << "\n FINALFUNC #{@final_function.name}" if @final_function cql << "\n INITCOND #{@initial_state}" cql << ';' end |