diff --git a/cql3/query_options.cc b/cql3/query_options.cc index 582ec64be1..3a439dd30b 100644 --- a/cql3/query_options.cc +++ b/cql3/query_options.cc @@ -107,6 +107,16 @@ size_t query_options::get_values_count() const return _value_views.size(); } +bytes_view_opt query_options::make_temporary(bytes_opt value) const +{ + if (value) { + _temporaries.emplace_back(value->begin(), value->end()); + auto& temporary = _temporaries.back(); + return bytes_view{temporary.data(), temporary.size()}; + } + return std::experimental::nullopt; +} + bool query_options::skip_metadata() const { return _skip_metadata; diff --git a/cql3/query_options.hh b/cql3/query_options.hh index 0f3b53f9cc..6353fbb615 100644 --- a/cql3/query_options.hh +++ b/cql3/query_options.hh @@ -54,6 +54,7 @@ private: const std::experimental::optional> _names; std::vector _values; std::vector _value_views; + mutable std::vector> _temporaries; const bool _skip_metadata; const specific_options _options; const int32_t _protocol_version; // transient @@ -84,6 +85,7 @@ public: db::consistency_level get_consistency() const; bytes_view_opt get_value_at(size_t idx) const; + bytes_view_opt make_temporary(bytes_opt value) const; size_t get_values_count() const; bool skip_metadata() const; /** The pageSize for this query. Will be <= 0 if not relevant for the query. */