From aa94cd62dcab6eeca16e5d4832fded0ac3d21504 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Thu, 30 Apr 2015 18:37:53 +0300 Subject: [PATCH] db: implement mutation_partition copy constructor As a temporary measure, we will return temporary mutation_partition objects in response to queries, so we need an easy way to construct them. --- mutation_partition.cc | 9 +++++++++ mutation_partition.hh | 3 +++ 2 files changed, 12 insertions(+) diff --git a/mutation_partition.cc b/mutation_partition.cc index 0bd33b7a01..bedaaad094 100644 --- a/mutation_partition.cc +++ b/mutation_partition.cc @@ -4,6 +4,15 @@ #include "mutation_partition.hh" +mutation_partition::mutation_partition(const mutation_partition& x) + : _tombstone(x._tombstone) + , _static_row(x._static_row) + , _rows(x._rows.value_comp()) + , _row_tombstones(x._row_tombstones.value_comp()) { + auto cloner = [] (const auto& x) { return new std::remove_const_t>(x); }; + _rows.clone_from(x._rows, cloner, std::default_delete()); + _row_tombstones.clone_from(x._row_tombstones, cloner, std::default_delete()); +} mutation_partition::~mutation_partition() { _rows.clear_and_dispose(std::default_delete()); diff --git a/mutation_partition.hh b/mutation_partition.hh index 088fe0c8a7..6501b8e981 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -149,6 +149,7 @@ class serializer; class mutation_partition final { + // FIXME: using boost::intrusive because gcc's std::set<> does not support heterogeneous lookup yet using rows_type = boost::intrusive::set>; private: tombstone _tombstone; @@ -156,6 +157,7 @@ private: rows_type _rows; // Contains only strict prefixes so that we don't have to lookup full keys // in both _row_tombstones and _rows. + // FIXME: using boost::intrusive because gcc's std::set<> does not support heterogeneous lookup yet boost::intrusive::set> _row_tombstones; template @@ -166,6 +168,7 @@ public: , _row_tombstones(row_tombstones_entry::compare(*s)) { } mutation_partition(mutation_partition&&) = default; + mutation_partition(const mutation_partition&); ~mutation_partition(); tombstone partition_tombstone() const { return _tombstone; } void apply(tombstone t) { _tombstone.apply(t); }