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.
This commit is contained in:
Avi Kivity
2015-04-30 18:37:53 +03:00
parent 8028fb441a
commit aa94cd62dc
2 changed files with 12 additions and 0 deletions

View File

@@ -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<std::remove_reference_t<decltype(x)>>(x); };
_rows.clone_from(x._rows, cloner, std::default_delete<rows_entry>());
_row_tombstones.clone_from(x._row_tombstones, cloner, std::default_delete<row_tombstones_entry>());
}
mutation_partition::~mutation_partition() {
_rows.clear_and_dispose(std::default_delete<rows_entry>());

View File

@@ -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<rows_entry, boost::intrusive::compare<rows_entry::compare>>;
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_entry, boost::intrusive::compare<row_tombstones_entry::compare>> _row_tombstones;
template<typename T>
@@ -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); }