From 138ca9d2cd2e39d6afbe54cfa6fc099613d75162 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Tue, 26 May 2015 09:58:45 +0200 Subject: [PATCH] Add index_info + use in column_definition --- schema.cc | 15 +++++++++------ schema.hh | 24 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/schema.cc b/schema.cc index 5a08fb2005..f5656fbd53 100644 --- a/schema.cc +++ b/schema.cc @@ -101,12 +101,15 @@ schema::has_collections() const { }); } -column_definition::column_definition(bytes name, data_type type, column_id id, column_kind kind) - : _name(std::move(name)) - , type(std::move(type)) - , id(id) - , kind(kind) -{ } +index_info::index_info(::index_type idx_type, + std::experimental::optional idx_name, + std::experimental::optional idx_options) + : index_type(idx_type), index_name(idx_name), index_options(idx_options) +{} + +column_definition::column_definition(bytes name, data_type type, column_id id, column_kind kind, index_info idx) + : _name(std::move(name)), type(std::move(type)), id(id), kind(kind), idx_info(std::move(idx)) +{} const column_definition* schema::get_column_definition(const bytes& name) const { diff --git a/schema.hh b/schema.hh index c9caeed57c..89e7126aa3 100644 --- a/schema.hh +++ b/schema.hh @@ -21,6 +21,26 @@ using column_id = uint32_t; enum class column_kind { partition_key, clustering_key, regular_column, static_column, }; +// CMH this is also manually defined in thrift gen file. +enum class index_type { + keys, + custom, + composites, + none, // cwi: added none to avoid "optional" bs. +}; + +typedef std::unordered_map index_options_map; + +struct index_info { + index_info(::index_type = ::index_type::none + , std::experimental::optional index_name = std::experimental::optional() + , std::experimental::optional = std::experimental::optional()); + + enum index_type index_type = ::index_type::none; + std::experimental::optional index_name; + std::experimental::optional index_options; +}; + class column_definition final { public: template @@ -32,7 +52,7 @@ public: private: bytes _name; public: - column_definition(bytes name, data_type type, column_id id, column_kind kind); + column_definition(bytes name, data_type type, column_id id, column_kind kind, index_info = index_info()); data_type type; @@ -43,6 +63,7 @@ public: column_kind kind; ::shared_ptr column_specification; + index_info idx_info; bool is_static() const { return kind == column_kind::static_column; } bool is_regular() const { return kind == column_kind::regular_column; } @@ -95,6 +116,7 @@ public: struct column { bytes name; data_type type; + index_info idx_info; struct name_compare { data_type type; name_compare(data_type type) : type(type) {}