buffer_input_stream: make it possible to specify chunk size
This will allow to force input stream to return its data in chunks of a specified size. Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "buffer_input_stream.hh"
|
||||
#include "limiting_data_source.hh"
|
||||
|
||||
using namespace seastar;
|
||||
|
||||
@@ -45,6 +46,13 @@ public:
|
||||
};
|
||||
|
||||
input_stream<char> make_buffer_input_stream(temporary_buffer<char>&& buf) {
|
||||
return input_stream<char>{
|
||||
data_source{std::make_unique<buffer_data_source_impl>(std::move(buf))}};
|
||||
return input_stream < char > {
|
||||
data_source{std::make_unique<buffer_data_source_impl>(std::move(buf))}
|
||||
};
|
||||
}
|
||||
|
||||
input_stream<char> make_buffer_input_stream(temporary_buffer<char>&& buf,
|
||||
seastar::noncopyable_function<size_t()>&& limit_generator) {
|
||||
auto res = data_source{std::make_unique<buffer_data_source_impl>(std::move(buf))};
|
||||
return input_stream < char > { make_limiting_data_source(std::move(res), std::move(limit_generator)) };
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <seastar/core/iostream.hh>
|
||||
#include <seastar/core/temporary_buffer.hh>
|
||||
#include <seastar/util/noncopyable_function.hh>
|
||||
#include "seastarx.hh"
|
||||
|
||||
/// \brief Creates an input_stream to read from a supplied buffer
|
||||
@@ -30,3 +31,11 @@
|
||||
/// \param buf Buffer to return from the stream while reading
|
||||
/// \return resulting input stream
|
||||
input_stream<char> make_buffer_input_stream(temporary_buffer<char>&& buf);
|
||||
|
||||
/// \brief Creates an input_stream to read from a supplied buffer
|
||||
///
|
||||
/// \param buf Buffer to return from the stream while reading
|
||||
/// \param limit_generator Generates limits of chunk sizes
|
||||
/// \return resulting input stream
|
||||
input_stream<char> make_buffer_input_stream(temporary_buffer<char>&& buf,
|
||||
seastar::noncopyable_function<size_t()>&& limit_generator);
|
||||
|
||||
Reference in New Issue
Block a user