From 815cd254e275f0cdaa7c73ed87a5f8a39ce7d010 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Thu, 21 Dec 2017 22:28:28 +0100 Subject: [PATCH] streamed_mutation: Introduce peek() Will be used in assertions to merge consecutive range tombstones. --- streamed_mutation.hh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/streamed_mutation.hh b/streamed_mutation.hh index 731d3d5068..f206c2a699 100644 --- a/streamed_mutation.hh +++ b/streamed_mutation.hh @@ -670,6 +670,21 @@ public: return _impl->operator()(); } + // Resolves with a pointer to the next fragment in the stream without consuming it from the stream, + // or nullptr if there are no more fragments. + // The returned pointer is invalidated by any other call to this object. + future peek() { + if (!is_buffer_empty()) { + return make_ready_future(&_impl->_buffer.front()); + } + if (is_end_of_stream()) { + return make_ready_future(nullptr); + } + return fill_buffer().then([this] { + return peek(); + }); + } + void set_max_buffer_size(size_t size) { _impl->max_buffer_size_in_bytes = size; }