Skip to content

Commit

Permalink
query: Split send_timestamp_and_expiry into two separate options
Browse files Browse the repository at this point in the history
It's cleaner that way. They don't need to come together.
  • Loading branch information
tgrabiec committed Feb 15, 2016
1 parent 100b540 commit 916a91c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cql3/selection/selection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ selection::selection(schema_ptr schema,
query::partition_slice::option_set selection::get_query_options() {
query::partition_slice::option_set opts;

opts.set_if<query::partition_slice::option::send_timestamp_and_expiry>(_collect_timestamps || _collect_TTLs);
opts.set_if<query::partition_slice::option::send_timestamp>(_collect_timestamps);
opts.set_if<query::partition_slice::option::send_expiry>(_collect_TTLs);

opts.set_if<query::partition_slice::option::send_partition_key>(
std::any_of(_columns.begin(), _columns.end(),
Expand Down
3 changes: 2 additions & 1 deletion partition_slice_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ partition_slice_builder::partition_slice_builder(const schema& schema)
{
_options.set<query::partition_slice::option::send_partition_key>();
_options.set<query::partition_slice::option::send_clustering_key>();
_options.set<query::partition_slice::option::send_timestamp_and_expiry>();
_options.set<query::partition_slice::option::send_timestamp>();
_options.set<query::partition_slice::option::send_expiry>();
}

query::partition_slice
Expand Down
5 changes: 3 additions & 2 deletions query-request.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ private:
// Schema-dependent.
class partition_slice {
public:
enum class option { send_clustering_key, send_partition_key, send_timestamp_and_expiry, reversed, distinct };
enum class option { send_clustering_key, send_partition_key, send_timestamp, send_expiry, reversed, distinct };
using option_set = enum_set<super_enum<option,
option::send_clustering_key,
option::send_partition_key,
option::send_timestamp_and_expiry,
option::send_timestamp,
option::send_expiry,
option::reversed,
option::distinct>>;
clustering_row_ranges _row_ranges;
Expand Down
6 changes: 4 additions & 2 deletions query-result-reader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ public:
}
api::timestamp_type timestamp = api::missing_timestamp;
expiry_opt expiry_;
if (_slice.options.contains<partition_slice::option::send_timestamp_and_expiry>()) {
timestamp = _in.read <api::timestamp_type> ();
if (_slice.options.contains<partition_slice::option::send_timestamp>()) {
timestamp = _in.read<api::timestamp_type>();
}
if (_slice.options.contains<partition_slice::option::send_expiry>()) {
auto expiry_rep = _in.read<gc_clock::rep>();
if (expiry_rep != std::numeric_limits<gc_clock::rep>::max()) {
expiry_ = gc_clock::time_point(gc_clock::duration(expiry_rep));
Expand Down
4 changes: 3 additions & 1 deletion query-result-writer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ public:
// FIXME: store this in a bitmap
_w.write<int8_t>(true);
assert(c.is_live());
if (_slice.options.contains<partition_slice::option::send_timestamp_and_expiry>()) {
if (_slice.options.contains<partition_slice::option::send_timestamp>()) {
_w.write(c.timestamp());
}
if (_slice.options.contains<partition_slice::option::send_expiry>()) {
if (c.is_live_and_has_ttl()) {
_w.write<gc_clock::rep>(c.expiry().time_since_epoch().count());
} else {
Expand Down
2 changes: 1 addition & 1 deletion query-result.hh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public:
// <static-row> ::= <row>
// <row> ::= <row-length> <cell>+
// <cell> ::= <atomic-cell> | <collection-cell>
// <atomic-cell> ::= <present-byte> [ <timestamp> <expiry> ] <value>
// <atomic-cell> ::= <present-byte> [ <timestamp> ] [ <expiry> ] <value>
// <collection-cell> ::= <blob>
//
// <value> ::= <blob>
Expand Down

0 comments on commit 916a91c

Please sign in to comment.