From 0aef6f2ff79e25f69602eaa2151b2f9b20934548 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 6 May 2015 09:40:25 +0200 Subject: [PATCH] mutation_partition: Allow row lookup by clustering_key_view --- mutation_partition.cc | 10 ++++++++++ mutation_partition.hh | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/mutation_partition.cc b/mutation_partition.cc index 9553d69f2e..5e267b0c70 100644 --- a/mutation_partition.cc +++ b/mutation_partition.cc @@ -172,6 +172,16 @@ mutation_partition::clustered_row(const clustering_key& key) { return i->row(); } +deletable_row& +mutation_partition::clustered_row(const schema& s, const clustering_key_view& key) { + auto i = _rows.find(key, rows_entry::compare(s)); + if (i == _rows.end()) { + auto e = new rows_entry(key); + _rows.insert(i, *e); + return e->row(); + } + return i->row(); +} boost::iterator_range mutation_partition::range(const schema& schema, const query::range& r) const { diff --git a/mutation_partition.hh b/mutation_partition.hh index 3b4ad4ce4b..d896031f73 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -129,6 +129,12 @@ public: bool operator()(const rows_entry& e, const clustering_key& key) const { return _c(e._key, key); } + bool operator()(const clustering_key_view& key, const rows_entry& e) const { + return _c(key, e._key); + } + bool operator()(const rows_entry& e, const clustering_key_view& key) const { + return _c(e._key, key); + } }; template struct delegating_compare { @@ -192,6 +198,7 @@ public: const rows_type& clustered_rows() const { return _rows; } const row& static_row() const { return _static_row; } deletable_row& clustered_row(const clustering_key& key); + deletable_row& clustered_row(const schema& s, const clustering_key_view& key); const row* find_row(const clustering_key& key) const; const rows_entry* find_entry(schema_ptr schema, const clustering_key_prefix& key) const; tombstone range_tombstone_for_row(const schema& schema, const clustering_key& key) const;