class Cassandra::Aggregate

Represents a cassandra user defined aggregate @see Cassandra::Keyspace#each_aggregate @see Cassandra::Keyspace#aggregate @see Cassandra::Keyspace#has_aggregate?

Attributes

argument_types[R]

@return [Array<Cassandra::Type>] aggregate argument types

final_function[R]

@return [Cassandra::Function] the final function used by this aggregate

initial_state[R]

@return [Object, nil] the initial value of the aggregate state or nil

keyspace[R]

@private

name[R]

@return [String] aggregate name

state_function[R]

@return [Cassandra::Function] the state function used by this aggregate

state_type[R]

@return [Cassandra::Type] aggregate state type

type[R]

@return [Cassandra::Type] aggregate return type

Public Class Methods

new(keyspace, name, type, argument_types, state_type, initial_state, state_function, final_function) click to toggle source

@private

   # File lib/cassandra/aggregate.rb
43 def initialize(keyspace,
44                name,
45                type,
46                argument_types,
47                state_type,
48                initial_state,
49                state_function,
50                final_function)
51   @keyspace       = keyspace
52   @name           = name
53   @type           = type
54   @argument_types = argument_types
55   @state_type     = state_type
56   @initial_state  = initial_state
57   @state_function = state_function
58   @final_function = final_function
59 end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source

@private

   # File lib/cassandra/aggregate.rb
62 def eql?(other)
63   other.is_a?(Aggregate) && \
64     @keyspace == other.keyspace && \
65     @name == other.name && \
66     @type == other.type && \
67     @argument_types == other.argument_types && \
68     @state_type == other.state_type && \
69     @initial_state == other.initial_state && \
70     @state_function == other.state_function && \
71     @final_function == other.final_function
72 end
Also aliased as: ==
hash() click to toggle source

@private

   # File lib/cassandra/aggregate.rb
76 def hash
77   @hash ||= begin
78     h = 17
79     h = 31 * h + @keyspace.hash
80     h = 31 * h + @name.hash
81     h = 31 * h + @type.hash
82     h = 31 * h + @argument_types.hash
83     h = 31 * h + @state_type.hash
84     h = 31 * h + @initial_state.hash
85     h = 31 * h + @state_function.hash
86     h = 31 * h + @final_function.hash
87     h
88   end
89 end
inspect() click to toggle source

@private

    # File lib/cassandra/aggregate.rb
 92 def inspect
 93   "#<Cassandra::Aggregate:0x#{object_id.to_s(16)} " \
 94       "@keyspace=#{@keyspace.inspect}, " \
 95       "@name=#{@name.inspect}, " \
 96       "@type=#{@type.inspect}, " \
 97       "@argument_types=#{@argument_types.inspect}, " \
 98       "@initial_state=#{@initial_state.inspect}, " \
 99       "@state_function=#{@state_function.inspect}, " \
100       "@final_function=#{@final_function.inspect}>"
101 end
to_cql() click to toggle source

@return [String] a cql representation of this aggregate

    # File lib/cassandra/aggregate.rb
104 def to_cql
105   cql = 'CREATE AGGREGATE simplex.average('
106   first = true
107   @argument_types.each do |type|
108     if first
109       first = false
110     else
111       cql << ', '
112     end
113     cql << type.to_s
114   end
115   cql << ')'
116   cql << "\n  SFUNC #{@state_function.name}"
117   cql << "\n  STYPE #{@state_type}"
118   cql << "\n  FINALFUNC #{@final_function.name}" if @final_function
119   cql << "\n  INITCOND #{@initial_state}"
120   cql << ';'
121 end