* Forward commitlog replay_position to column_family.memtable, updating highest RP if needed * When flushing memtable, signal back to commitlog that RP has been dealt with to potentially remove finished segment(s) Note: since memtable flushing right now is _not_ explicitly ordered, this does not actually work, since we need to guarantee ordering with regards to RP. I.e. if we flush N blocks, we must guarantee that: a.) We report "flushed RP" in RP order b.) For a given RP1, all RP* lower than RP1 must also have been flushed. (The latter means that it is fine to say, flush X tables at the same time, as long as we report a single RP that is the highest, and no lower RP:s exist in non-flushed tables) I am however letting someone else deal with ensuring MT->sstable flush order. Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include "database_fwd.hh"
|
|
#include "dht/i_partitioner.hh"
|
|
#include "schema.hh"
|
|
#include "db/commitlog/replay_position.hh"
|
|
|
|
class frozen_mutation;
|
|
|
|
class memtable {
|
|
public:
|
|
using partitions_type = std::map<dht::decorated_key, mutation_partition, dht::decorated_key::less_comparator>;
|
|
private:
|
|
schema_ptr _schema;
|
|
partitions_type partitions;
|
|
db::replay_position _replay_position;
|
|
|
|
void update(const db::replay_position&);
|
|
public:
|
|
using const_mutation_partition_ptr = std::unique_ptr<const mutation_partition>;
|
|
public:
|
|
explicit memtable(schema_ptr schema);
|
|
schema_ptr schema() const { return _schema; }
|
|
mutation_partition& find_or_create_partition(const dht::decorated_key& key);
|
|
mutation_partition& find_or_create_partition_slow(partition_key_view key);
|
|
row& find_or_create_row_slow(const partition_key& partition_key, const clustering_key& clustering_key);
|
|
const_mutation_partition_ptr find_partition(const dht::decorated_key& key) const;
|
|
void apply(const mutation& m, const db::replay_position& = db::replay_position());
|
|
void apply(const frozen_mutation& m, const db::replay_position& = db::replay_position());
|
|
const partitions_type& all_partitions() const;
|
|
bool empty() const { return partitions.empty(); }
|
|
const db::replay_position& replay_position() const {
|
|
return _replay_position;
|
|
}
|
|
};
|