Files
scylladb/mutation.hh
Tomasz Grabiec b1e45e4401 db: Store ttl in atomic_cell
Origin does that, so should we. Both ttl and expiry time are stored in
sstables. The value of ttl seems to be used to calculate the read
digest (expiry is not used for that).

The API for creating atomic_cells changed a bit.

To create a non-expiring cell:

  atomic_cell::make_live(timestamp, value);

To create an expiring cell:

  atomic_cell::make_live(timestamp, value, expiry, ttl);

or:

  // Expiry is calculated based on current clock reading
  atomic_cell::make_live(timestamp, value, ttl_optional);
2015-05-06 19:42:38 +02:00

44 lines
2.1 KiB
C++

/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*/
#pragma once
#include <iostream>
#include "mutation_partition.hh"
#include "keys.hh"
#include "schema.hh"
#include "dht/i_partitioner.hh"
class mutation final {
private:
schema_ptr _schema;
const dht::decorated_key _dk;
mutation_partition _p;
public:
mutation(dht::decorated_key key, schema_ptr schema);
mutation(partition_key key, schema_ptr schema);
mutation(mutation&&) = default;
mutation(const mutation&) = default;
void set_static_cell(const column_definition& def, atomic_cell_or_collection value);
void set_clustered_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection value);
void set_clustered_cell(const clustering_key& key, const bytes& name, const boost::any& value, api::timestamp_type timestamp, ttl_opt ttl = {});
void set_clustered_cell(const clustering_key& key, const column_definition& def, atomic_cell_or_collection value);
void set_cell(const exploded_clustering_prefix& prefix, const bytes& name, const boost::any& value, api::timestamp_type timestamp, ttl_opt ttl = {});
void set_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection value);
std::experimental::optional<atomic_cell_or_collection> get_cell(const clustering_key& rkey, const column_definition& def) const;
const partition_key& key() const { return _dk._key; };
const dht::decorated_key& decorated_key() const { return _dk; };
const dht::token token() const { return _dk._token; }
const schema_ptr& schema() const { return _schema; }
const mutation_partition& partition() const { return _p; }
mutation_partition& partition() { return _p; }
const utils::UUID& column_family_id() const { return _schema->id(); }
bool operator==(const mutation&) const;
bool operator!=(const mutation&) const;
private:
static void update_column(row& row, const column_definition& def, atomic_cell_or_collection&& value);
friend std::ostream& operator<<(std::ostream& os, const mutation& m);
};