Skip to content

Commit bee43ca

Browse files
authored
Merge 2b7a4f6 into 41f47f8
2 parents 41f47f8 + 2b7a4f6 commit bee43ca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ydb/tests/tools/kqprun/src/actors.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,29 @@ class TRunScriptActorMock : public NActors::TActorBootstrapped<TRunScriptActorMo
5050
auto resultSetIndex = ev->Get()->Record.GetQueryResultIndex();
5151
if (resultSetIndex >= ResultSets_.size()) {
5252
ResultSets_.resize(resultSetIndex + 1);
53+
ResultSetSizes_.resize(resultSetIndex + 1, 0);
5354
}
5455

5556
if (!ResultSets_[resultSetIndex].truncated()) {
57+
ui64& resultSetSize = ResultSetSizes_[resultSetIndex];
5658
for (auto& row : *ev->Get()->Record.MutableResultSet()->mutable_rows()) {
5759
if (static_cast<ui64>(ResultSets_[resultSetIndex].rows_size()) >= ResultRowsLimit_) {
5860
ResultSets_[resultSetIndex].set_truncated(true);
5961
break;
6062
}
6163

62-
if (ResultSets_[resultSetIndex].ByteSizeLong() + row.ByteSizeLong() > ResultSizeLimit_) {
64+
auto rowSize = row.ByteSizeLong();
65+
if (resultSetSize + rowSize > ResultSizeLimit_) {
6366
ResultSets_[resultSetIndex].set_truncated(true);
6467
break;
6568
}
6669

70+
resultSetSize += rowSize;
6771
*ResultSets_[resultSetIndex].add_rows() = std::move(row);
6872
}
69-
*ResultSets_[resultSetIndex].mutable_columns() = ev->Get()->Record.GetResultSet().columns();
73+
if (!ResultSets_[resultSetIndex].columns_size()) {
74+
*ResultSets_[resultSetIndex].mutable_columns() = ev->Get()->Record.GetResultSet().columns();
75+
}
7076
}
7177

7278
Send(ev->Sender, response.Release());
@@ -89,6 +95,7 @@ class TRunScriptActorMock : public NActors::TActorBootstrapped<TRunScriptActorMo
8995
ui64 ResultRowsLimit_;
9096
ui64 ResultSizeLimit_;
9197
std::vector<Ydb::ResultSet>& ResultSets_;
98+
std::vector<ui64> ResultSetSizes_;
9299
TProgressCallback ProgressCallback_;
93100
};
94101

0 commit comments

Comments
 (0)