Class: Cequel::Schema::TableReader
- Inherits:
-
Object
- Object
- Cequel::Schema::TableReader
- Defined in:
- lib/cequel/schema/table_reader.rb
Overview
A TableReader interprets table data from the cassandra driver into a table descriptor (read: ‘Table`).
Constant Summary collapse
- COMPOSITE_TYPE_PATTERN =
/^org\.apache\.cassandra\.db\.marshal\.CompositeType\((.+)\)$/
- REVERSED_TYPE_PATTERN =
/^org\.apache\.cassandra\.db\.marshal\.ReversedType\((.+)\)$/
- COLLECTION_TYPE_PATTERN =
/^org\.apache\.cassandra\.db\.marshal\.(List|Set|Map)Type\((.+)\)$/
Class Method Summary collapse
-
.read(keyspace, table_name) ⇒ Object
Read the schema defined in the database for a given table and return a Table instance.
Instance Method Summary collapse
-
#call ⇒ Table
private
Read table schema from the database.
-
#initialize(table_data) ⇒ TableReader
constructor
A new instance of TableReader.
Constructor Details
#initialize(table_data) ⇒ TableReader
Returns a new instance of TableReader.
53 54 55 56 57 |
# File 'lib/cequel/schema/table_reader.rb', line 53 def initialize(table_data) @table_data = table_data @table = Table.new(table_data.name, Cassandra::MaterializedView === table_data) end |
Class Method Details
.read(keyspace, table_name) ⇒ Object
Read the schema defined in the database for a given table and return a Cequel::Schema::Table instance
28 29 30 31 32 33 |
# File 'lib/cequel/schema/table_reader.rb', line 28 def read(keyspace, table_name) table_data = fetch_raw_keyspace(keyspace).table(table_name.to_s) (fail NoSuchTableError) if table_data.blank? new(table_data).call end |
Instance Method Details
#call ⇒ Table
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Read table schema from the database
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cequel/schema/table_reader.rb', line 67 def call return nil if table_data.blank? read_partition_keys read_clustering_columns read_indexes read_data_columns read_properties read_table_settings table end |