Skip to content

Commit 485cde2

Browse files
committed
Add stealQueryOutputVector
1 parent 3f1e5f5 commit 485cde2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Client/ClientBase.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <Common/QueryFuzzer.h>
1717
#include <Common/ShellCommand.h>
1818
#include <Common/Stopwatch.h>
19+
#include "IO/WriteBufferFromVector.h"
1920

2021
#include <Storages/MergeTree/MergeTreeSettings.h>
2122
#include <Storages/SelectQueryInfo.h>
@@ -24,6 +25,7 @@
2425
#include <boost/program_options.hpp>
2526

2627
#include <atomic>
28+
#include <memory>
2729
#include <optional>
2830
#include <string>
2931
#include <string_view>
@@ -105,12 +107,14 @@ class ClientBase
105107
return query_result_memory;
106108
}
107109

108-
std::span<char> getQueryOutputSpan()
110+
/// Steals and returns the query output vector, replacing it with a new one
111+
std::vector<char> * stealQueryOutputVector()
109112
{
110-
if (!query_result_memory || !query_result_buf)
111-
return {};
112-
auto size = query_result_buf->count();
113-
return std::span<char>(query_result_memory->begin(), size);
113+
auto * result = query_result_memory;
114+
query_result_memory = new std::vector<char>(4096);
115+
// WriteBufferFromVector takes a reference to the vector but doesn't own it
116+
query_result_buf = std::make_shared<WriteBufferFromVector<std::vector<char>>>(*query_result_memory);
117+
return result;
114118
}
115119

116120
size_t getProcessedRows() const { return processed_rows; }

0 commit comments

Comments
 (0)