class Cassandra::MaterializedView

Represents a cassandra materialized view @see Cassandra::Keyspace#each_materialized_view @see Cassandra::Keyspace#materialized_view

Attributes

include_all_columns[R]

@private

where_clause[R]

@private

Public Class Methods

new(keyspace, name, partition_key, clustering_columns, other_columns, options, include_all_columns, where_clause, base_table_name, id) click to toggle source

@private

Calls superclass method Cassandra::ColumnContainer::new
   # File lib/cassandra/materialized_view.rb
25 def initialize(keyspace,
26                name,
27                partition_key,
28                clustering_columns,
29                other_columns,
30                options,
31                include_all_columns,
32                where_clause,
33                base_table_name,
34                id)
35   super(keyspace, name, partition_key, clustering_columns, other_columns, options, id)
36   @include_all_columns = include_all_columns
37   @where_clause = where_clause
38   @base_table_name = base_table_name
39 end

Public Instance Methods

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

@return [Table] the table that this materialized view applies to.

   # File lib/cassandra/materialized_view.rb
42 def base_table
43   @keyspace.table(@base_table_name)
44 end
eql?(other) click to toggle source

@private

Calls superclass method Cassandra::ColumnContainer#eql?
   # File lib/cassandra/materialized_view.rb
74 def eql?(other)
75   other.is_a?(MaterializedView) &&
76     super.eql?(other) &&
77     @include_all_columns == other.include_all_columns &&
78     @where_clause == other.where_clause &&
79     @base_table_name == other.base_table.name
80 end
Also aliased as: ==
to_cql() click to toggle source

@return [String] a cql representation of this materialized view

   # File lib/cassandra/materialized_view.rb
47 def to_cql
48   keyspace_name = Util.escape_name(@keyspace.name)
49   cql = "CREATE MATERIALIZED VIEW #{keyspace_name}.#{Util.escape_name(@name)} AS\nSELECT "
50   cql << if @include_all_columns
51            '*'
52          else
53            @columns.map do |column|
54              Util.escape_name(column.name)
55            end.join(', ')
56          end
57   cql << "\nFROM #{keyspace_name}.#{Util.escape_name(@base_table_name)}"
58   cql << "\nWHERE #{@where_clause}" if @where_clause
59   cql << "\nPRIMARY KEY (("
60   cql << @partition_key.map do |column|
61     Util.escape_name(column.name)
62   end.join(', ')
63   cql << ')'
64   unless @clustering_columns.empty?
65     cql << ', '
66     cql << @clustering_columns.map do |column|
67       Util.escape_name(column.name)
68     end.join(', ')
69   end
70   cql << ")\nWITH #{@options.to_cql.split("\n").join("\n ")};"
71 end