Skip to content

Commit d558ff8

Browse files
committed
Extract methods to format records with rows (#19141)
1 parent b698447 commit d558ff8

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

ydb/core/base/table_index.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "table_index.h"
22

33
#include <ydb/core/base/table_vector_index.h>
4+
#include <ydb/core/protos/tx_datashard.pb.h>
45

56
namespace NKikimr::NTableIndex {
67
namespace {
@@ -201,4 +202,24 @@ TClusterId SetPostingParentFlag(TClusterId parent) {
201202
return (parent | PostingParentFlag);
202203
}
203204

205+
TString ToShortDebugString(const NKikimrTxDataShard::TEvReshuffleKMeansRequest& record) {
206+
auto copy = record;
207+
TStringBuilder result;
208+
// clusters are not human readable and can be large like 100Kb+
209+
copy.ClearClusters();
210+
result << copy.ShortDebugString();
211+
result << " Clusters: " << record.ClustersSize();
212+
return result;
213+
}
214+
215+
TString ToShortDebugString(const NKikimrTxDataShard::TEvSampleKResponse& record) {
216+
auto copy = record;
217+
TStringBuilder result;
218+
// rows are not human readable and can be large like 100Kb+
219+
copy.ClearRows();
220+
result << copy.ShortDebugString();
221+
result << " Rows: " << record.RowsSize();
222+
return result;
223+
}
224+
204225
}

ydb/core/base/table_index.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <span>
1313
#include <string_view>
1414

15+
namespace NKikimrTxDataShard {
16+
class TEvReshuffleKMeansRequest;
17+
class TEvSampleKResponse;
18+
}
19+
1520
namespace NKikimr {
1621

1722
inline constexpr const char* SYSTEM_COLUMN_PREFIX = "__ydb_";
@@ -45,5 +50,8 @@ void EnsureNoPostingParentFlag(TClusterId parent);
4550

4651
TClusterId SetPostingParentFlag(TClusterId parent);
4752

53+
TString ToShortDebugString(const NKikimrTxDataShard::TEvReshuffleKMeansRequest& record);
54+
TString ToShortDebugString(const NKikimrTxDataShard::TEvSampleKResponse& record);
55+
4856
}
4957
}

ydb/core/tx/datashard/build_index/reshuffle_kmeans.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvReshuffleKMeansRequest::TPtr& ev, c
363363
response->Record.SetRequestSeqNoRound(seqNo.Round);
364364

365365
LOG_N("Starting TReshuffleKMeansScan TabletId: " << TabletID()
366-
<< " " << request.ShortDebugString()
366+
<< " " << ToShortDebugString(request)
367367
<< " row version " << rowVersion);
368368

369369
// Note: it's very unlikely that we have volatile txs before this snapshot
@@ -381,7 +381,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvReshuffleKMeansRequest::TPtr& ev, c
381381
auto trySendBadRequest = [&] {
382382
if (response->Record.GetStatus() == NKikimrIndexBuilder::EBuildStatus::BAD_REQUEST) {
383383
LOG_E("Rejecting TReshuffleKMeansScan bad request TabletId: " << TabletID()
384-
<< " " << request.ShortDebugString()
384+
<< " " << ToShortDebugString(request)
385385
<< " with response " << response->Record.ShortDebugString());
386386
ctx.Send(ev->Sender, std::move(response));
387387
return true;

ydb/core/tx/datashard/build_index/sample_k.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ class TSampleKScan final: public TActor<TSampleKScan>, public NTable::IScan {
163163
NYql::IssuesToMessage(Issues, record.MutableIssues());
164164

165165
if (Response->Record.GetStatus() == NKikimrIndexBuilder::DONE) {
166-
LOG_N("Done " << Debug() << " " << Response->Record.ShortDebugString());
166+
LOG_N("Done " << Debug() << " " << ToShortDebugString(Response->Record));
167167
} else {
168-
LOG_E("Failed " << Debug() << " " << Response->Record.ShortDebugString());
168+
LOG_E("Failed " << Debug() << " " << ToShortDebugString(Response->Record));
169169
}
170170
Send(ResponseActorId, Response.Release());
171171

@@ -265,7 +265,7 @@ void TDataShard::HandleSafe(TEvDataShard::TEvSampleKRequest::TPtr& ev, const TAc
265265
if (response->Record.GetStatus() == NKikimrIndexBuilder::EBuildStatus::BAD_REQUEST) {
266266
LOG_E("Rejecting TSampleKScan bad request TabletId: " << TabletID()
267267
<< " " << request.ShortDebugString()
268-
<< " with response " << response->Record.ShortDebugString());
268+
<< " with response " << ToShortDebugString(response->Record));
269269
ctx.Send(ev->Sender, std::move(response));
270270
return true;
271271
} else {

ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,7 @@ struct TSchemeShard::TIndexBuilder::TTxProgress: public TSchemeShard::TIndexBuil
605605
};
606606

607607
auto shardId = CommonFillRecord(ev->Record, shardIdx, buildInfo);
608-
[[maybe_unused]] auto toDebugStr = [&](const NKikimrTxDataShard::TEvReshuffleKMeansRequest& record) {
609-
auto r = record;
610-
// clusters are not human readable and can be large like 100Kb+
611-
r.ClearClusters();
612-
return r.ShortDebugString();
613-
};
614-
LOG_N("TTxBuildProgress: TEvReshuffleKMeansRequest: " << toDebugStr(ev->Record));
608+
LOG_N("TTxBuildProgress: TEvReshuffleKMeansRequest: " << ToShortDebugString(ev->Record));
615609

616610
ToTabletSend.emplace(shardId, std::move(ev));
617611
}
@@ -1566,15 +1560,9 @@ struct TSchemeShard::TIndexBuilder::TTxReplySampleK: public TSchemeShard::TIndex
15661560
return true;
15671561
}
15681562
auto& buildInfo = *buildInfoPtr->Get();
1569-
[[maybe_unused]] auto toDebugStr = [&](const NKikimrTxDataShard::TEvSampleKResponse& record) {
1570-
auto r = record;
1571-
// rows are not human readable and can be large like 100Kb+
1572-
r.ClearRows();
1573-
return r.ShortDebugString();
1574-
};
15751563
LOG_D("TTxReply : TEvSampleKResponse"
15761564
<< ", TIndexBuildInfo: " << buildInfo
1577-
<< ", record: " << toDebugStr(record));
1565+
<< ", record: " << ToShortDebugString(record));
15781566

15791567
TTabletId shardId = TTabletId(record.GetTabletId());
15801568
if (!Self->TabletIdToShardIdx.contains(shardId)) {

0 commit comments

Comments
 (0)