Skip to content

Commit f2c7443

Browse files
k-morozovkst-morozov
and
kst-morozov
authored
Fixes clang-format usage (#929)
* up formatting --------- Co-authored-by: kst-morozov <[email protected]>
1 parent ea9fe63 commit f2c7443

File tree

5 files changed

+69
-58
lines changed

5 files changed

+69
-58
lines changed

ydb/core/kqp/ut/olap/kqp_olap_stats_ut.cpp

+36-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
21
#include <ydb/core/kqp/ut/common/columnshard.h>
3-
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
2+
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
43
#include <ydb/core/testlib/common_helper.h>
4+
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
55

66
namespace NKikimr {
77
namespace NKqp {
@@ -15,12 +15,11 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
1515
constexpr size_t size_single_table = 13152;
1616

1717
const TVector<TTestHelper::TColumnSchema> schema = {
18-
TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
19-
TTestHelper::TColumnSchema().SetName("resource_id").SetType(NScheme::NTypeIds::Utf8),
20-
TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32)
21-
};
18+
TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
19+
TTestHelper::TColumnSchema().SetName("resource_id").SetType(NScheme::NTypeIds::Utf8),
20+
TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32)};
2221

23-
class TOlapStatsController: public NYDBTest::NColumnShard::TController {
22+
class TOlapStatsController : public NYDBTest::NColumnShard::TController {
2423
public:
2524
TDuration GetPeriodicWakeupActivationPeriod(const TDuration /*defaultValue*/) const override {
2625
return TDuration::MilliSeconds(10);
@@ -32,7 +31,7 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
3231

3332
Y_UNIT_TEST(AddRowsTableStandalone) {
3433
auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<TOlapStatsController>();
35-
34+
3635
TKikimrSettings runnerSettings;
3736
runnerSettings.WithSampleTables = false;
3837

@@ -44,8 +43,8 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
4443
testHelper.CreateTable(testTable);
4544
{
4645
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
47-
48-
for(size_t i=0; i<inserted_rows; i++) {
46+
47+
for (size_t i = 0; i < inserted_rows; i++) {
4948
tableInserter.AddRow().Add(i).Add("test_res_" + std::to_string(i)).AddNull();
5049
}
5150

@@ -78,21 +77,25 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
7877
testTableStore.SetName("/Root/TableStoreTest").SetPrimaryKey({"id"}).SetSchema(schema);
7978
testHelper.CreateTable(testTableStore);
8079
TTestHelper::TColumnTable testTable;
81-
testTable.SetName("/Root/TableStoreTest/ColumnTableTest").SetPrimaryKey({"id"}).SetSharding({"id"}).SetSchema(schema);
80+
testTable.SetName("/Root/TableStoreTest/ColumnTableTest")
81+
.SetPrimaryKey({"id"})
82+
.SetSharding({"id"})
83+
.SetSchema(schema);
8284
testHelper.CreateTable(testTable);
8385

8486
{
8587
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
86-
for(size_t i=0; i<inserted_rows; i++) {
88+
for (size_t i = 0; i < inserted_rows; i++) {
8789
tableInserter.AddRow().Add(i).Add("test_res_" + std::to_string(i)).AddNull();
8890
}
8991
testHelper.InsertData(testTable, tableInserter);
9092
}
91-
93+
9294
Sleep(TDuration::Seconds(1));
9395

9496
auto settings = TDescribeTableSettings().WithTableStatistics(true);
95-
auto describeResult = testHelper.GetSession().DescribeTable("/Root/TableStoreTest/ColumnTableTest", settings).GetValueSync();
97+
auto describeResult =
98+
testHelper.GetSession().DescribeTable("/Root/TableStoreTest/ColumnTableTest", settings).GetValueSync();
9699

97100
UNIT_ASSERT_C(describeResult.IsSuccess(), describeResult.GetIssues().ToString());
98101

@@ -117,23 +120,32 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
117120

118121
Tests::NCommon::TLoggerInit(testHelper.GetKikimr()).SetPriority(NActors::NLog::PRI_DEBUG).Initialize();
119122

120-
for(size_t t=0; t<tables_in_store; t++) {
123+
for (size_t t = 0; t < tables_in_store; t++) {
121124
TTestHelper::TColumnTable testTable;
122-
testTable.SetName("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t)).SetPrimaryKey({"id"}).SetSharding({"id"}).SetSchema(schema);
125+
testTable.SetName("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t))
126+
.SetPrimaryKey({"id"})
127+
.SetSharding({"id"})
128+
.SetSchema(schema);
123129
testHelper.CreateTable(testTable);
124130

125131
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
126-
for(size_t i=0; i < t+ inserted_rows; i++) {
127-
tableInserter.AddRow().Add(i + t * tables_in_store).Add("test_res_" + std::to_string(i + t * tables_in_store)).AddNull();
132+
for (size_t i = 0; i < t + inserted_rows; i++) {
133+
tableInserter.AddRow()
134+
.Add(i + t * tables_in_store)
135+
.Add("test_res_" + std::to_string(i + t * tables_in_store))
136+
.AddNull();
128137
}
129-
testHelper.InsertData(testTable, tableInserter);;
138+
testHelper.InsertData(testTable, tableInserter);
130139
}
131-
140+
132141
Sleep(TDuration::Seconds(20));
133142

134143
auto settings = TDescribeTableSettings().WithTableStatistics(true);
135-
for(size_t t=0; t<tables_in_store; t++) {
136-
auto describeResult = testHelper.GetSession().DescribeTable("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t), settings).GetValueSync();
144+
for (size_t t = 0; t < tables_in_store; t++) {
145+
auto describeResult =
146+
testHelper.GetSession()
147+
.DescribeTable("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t), settings)
148+
.GetValueSync();
137149
UNIT_ASSERT_C(describeResult.IsSuccess(), describeResult.GetIssues().ToString());
138150
const auto& description = describeResult.GetTableDescription();
139151

@@ -142,5 +154,5 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
142154
}
143155
}
144156

145-
} // namespace NKqp
146-
} // namespace NKikimr
157+
} // namespace NKqp
158+
} // namespace NKikimr

ydb/core/tx/columnshard/columnshard.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,14 @@ void TColumnShard::UpdateResourceMetrics(const TActorContext& ctx, const TUsage&
293293
metrics->TryUpdate(ctx);
294294
}
295295

296-
void TColumnShard::ConfigureStats(const NOlap::TColumnEngineStats& indexStats, ::NKikimrTableStats::TTableStats * tabletStats) {
296+
void TColumnShard::ConfigureStats(const NOlap::TColumnEngineStats& indexStats,
297+
::NKikimrTableStats::TTableStats* tabletStats) {
297298
NOlap::TSnapshot lastIndexUpdate = TablesManager.GetPrimaryIndexSafe().LastUpdate();
298-
auto activeIndexStats = indexStats.Active(); // data stats excluding inactive and evicted
299+
auto activeIndexStats = indexStats.Active(); // data stats excluding inactive and evicted
299300

300301
if (activeIndexStats.Rows < 0 || activeIndexStats.Bytes < 0) {
301-
LOG_S_WARN("Negative stats counter. Rows: " << activeIndexStats.Rows
302-
<< " Bytes: " << activeIndexStats.Bytes << TabletID());
302+
LOG_S_WARN("Negative stats counter. Rows: " << activeIndexStats.Rows << " Bytes: " << activeIndexStats.Bytes
303+
<< TabletID());
303304

304305
activeIndexStats.Rows = (activeIndexStats.Rows < 0) ? 0 : activeIndexStats.Rows;
305306
activeIndexStats.Bytes = (activeIndexStats.Bytes < 0) ? 0 : activeIndexStats.Bytes;
@@ -309,7 +310,7 @@ void TColumnShard::ConfigureStats(const NOlap::TColumnEngineStats& indexStats, :
309310
tabletStats->SetDataSize(activeIndexStats.Bytes + TabletCounters->Simple()[COUNTER_COMMITTED_BYTES].Get());
310311

311312
// TODO: we need row/dataSize counters for evicted data (managed by tablet but stored outside)
312-
//tabletStats->SetIndexSize(); // TODO: calc size of internal tables
313+
// tabletStats->SetIndexSize(); // TODO: calc size of internal tables
313314

314315
tabletStats->SetLastAccessTime(LastAccessTime.MilliSeconds());
315316
tabletStats->SetLastUpdateTime(lastIndexUpdate.GetPlanStep());
@@ -330,7 +331,7 @@ void TColumnShard::FillTxTableStats(::NKikimrTableStats::TTableStats* tableStats
330331
}
331332

332333
void TColumnShard::FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
333-
ev->Record.SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
334+
ev->Record.SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
334335
ev->Record.SetGeneration(Executor()->Generation());
335336
ev->Record.SetRound(StatsReportRound++);
336337
ev->Record.SetNodeId(ctx.ExecutorThread.ActorSystem->NodeId);
@@ -346,13 +347,14 @@ void TColumnShard::FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDa
346347
}
347348
}
348349

349-
void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
350+
void TColumnShard::FillColumnTableStats(const TActorContext& ctx,
351+
std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
350352
if (!TablesManager.HasPrimaryIndex()) {
351353
return;
352354
}
353355
const auto& tablesIndexStats = TablesManager.MutablePrimaryIndex().GetStats();
354356
LOG_S_DEBUG("There are stats for " << tablesIndexStats.size() << " tables");
355-
for(const auto& [tableLocalID, columnStats] : tablesIndexStats) {
357+
for (const auto& [tableLocalID, columnStats] : tablesIndexStats) {
356358
if (!columnStats) {
357359
LOG_S_ERROR("SendPeriodicStats: empty stats");
358360
continue;
@@ -362,7 +364,7 @@ void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_pt
362364
periodicTableStats->SetDatashardId(TabletID());
363365
periodicTableStats->SetTableLocalId(tableLocalID);
364366

365-
periodicTableStats->SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
367+
periodicTableStats->SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
366368
periodicTableStats->SetGeneration(Executor()->Generation());
367369
periodicTableStats->SetRound(StatsReportRound++);
368370
periodicTableStats->SetNodeId(ctx.ExecutorThread.ActorSystem->NodeId);
@@ -411,4 +413,4 @@ void TColumnShard::SendPeriodicStats() {
411413
NTabletPipe::SendData(ctx, StatsReportPipe, ev.release());
412414
}
413415

414-
}
416+
} // namespace NKikimr::NColumnShard

ydb/core/tx/columnshard/columnshard_impl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,12 @@ class TColumnShard
488488
void SendPeriodicStats();
489489
void FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev);
490490
void FillColumnTableStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev);
491-
void ConfigureStats(const NOlap::TColumnEngineStats& indexStats, ::NKikimrTableStats::TTableStats * tabletStats);
491+
void ConfigureStats(const NOlap::TColumnEngineStats& indexStats, ::NKikimrTableStats::TTableStats* tabletStats);
492492
void FillTxTableStats(::NKikimrTableStats::TTableStats* tableStats) const;
493493

494494
static TDuration GetControllerPeriodicWakeupActivationPeriod();
495495
static TDuration GetControllerStatsReportInterval();
496+
496497
public:
497498
const std::shared_ptr<NOlap::IStoragesManager>& GetStoragesManager() const {
498499
return StoragesManager;

ydb/core/tx/schemeshard/schemeshard__table_stats.cpp

+18-22
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TTxStoreTableStats: public TTxStoreStats<TEvDataShard::TEvPeriodicTableSta
9292
bool PersistSingleStats(const TPathId& pathId, const TStatsQueue<TEvDataShard::TEvPeriodicTableStats>::TItem& item, TTransactionContext& txc, const TActorContext& ctx) override;
9393
void ScheduleNextBatch(const TActorContext& ctx) override;
9494

95-
template<typename T>
95+
template <typename T>
9696
TPartitionStats PrepareStats(const TActorContext& ctx, const T& rec) const;
9797
};
9898

@@ -124,10 +124,8 @@ THolder<TProposeRequest> MergeRequest(
124124
return std::move(request);
125125
}
126126

127-
template<typename T>
128-
TPartitionStats TTxStoreTableStats::PrepareStats(
129-
const TActorContext& ctx, const T& rec) const {
130-
127+
template <typename T>
128+
TPartitionStats TTxStoreTableStats::PrepareStats(const TActorContext& ctx, const T& rec) const {
131129
const auto& tableStats = rec.GetTableStats();
132130
const auto& tabletMetrics = rec.GetTabletMetrics();
133131

@@ -183,7 +181,8 @@ TPartitionStats TTxStoreTableStats::PrepareStats(
183181
}
184182

185183
bool TTxStoreTableStats::PersistSingleStats(const TPathId& pathId,
186-
const TStatsQueueItem<TEvDataShard::TEvPeriodicTableStats>& item, NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) {
184+
const TStatsQueueItem<TEvDataShard::TEvPeriodicTableStats>& item,
185+
NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) {
187186
const auto& rec = item.Ev->Get()->Record;
188187
const auto datashardId = TTabletId(rec.GetDatashardId());
189188

@@ -208,19 +207,17 @@ bool TTxStoreTableStats::PersistSingleStats(const TPathId& pathId,
208207
TShardIdx shardIdx = Self->TabletIdToShardIdx[datashardId];
209208

210209
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
211-
"TTxStoreTableStats.PersistSingleStats: main stats from"
212-
<< " datashardId(TabletID)=" << datashardId
213-
<< " maps to shardIdx: " << shardIdx
214-
<< ", pathId: " << pathId
215-
<< ", pathId map=" << Self->PathsById[pathId]->Name
216-
<< ", is column=" << isColumnTable
217-
<< ", is olap=" << isOlapStore);
210+
"TTxStoreTableStats.PersistSingleStats: main stats from"
211+
<< " datashardId(TabletID)=" << datashardId << " maps to shardIdx: " << shardIdx
212+
<< ", pathId: " << pathId << ", pathId map=" << Self->PathsById[pathId]->Name
213+
<< ", is column=" << isColumnTable << ", is olap=" << isOlapStore);
218214

219215
const TPartitionStats newStats = PrepareStats(ctx, rec);
220216

221217
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
222-
"Add stats from shard with datashardId(TabletID)=" << datashardId << ", pathId " << pathId.LocalPathId
223-
<< ": RowCount " << newStats.RowCount << ", DataSize " << newStats.DataSize);
218+
"Add stats from shard with datashardId(TabletID)=" << datashardId << ", pathId " << pathId.LocalPathId
219+
<< ": RowCount " << newStats.RowCount << ", DataSize "
220+
<< newStats.DataSize);
224221

225222
NIceDb::TNiceDb db(txc.DB);
226223

@@ -261,29 +258,28 @@ bool TTxStoreTableStats::PersistSingleStats(const TPathId& pathId,
261258
updateSubdomainInfo = true;
262259

263260
const auto tables = rec.GetTables();
264-
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
265-
"OLAP store contains " << tables.size() << " tables.");
261+
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "OLAP store contains " << tables.size() << " tables.");
266262

267-
for(const auto& table : tables) {
263+
for (const auto& table : tables) {
268264
const TPartitionStats newTableStats = PrepareStats(ctx, table);
269265

270266
const TPathId tablePathId = TPathId(TOwnerId(pathId.OwnerId), TLocalPathId(table.GetTableLocalId()));
271267

272268
if (Self->ColumnTables.contains(tablePathId)) {
273269
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
274-
"add stats for exists table with pathId=" << tablePathId);
270+
"add stats for exists table with pathId=" << tablePathId);
275271

276272
auto columnTable = Self->ColumnTables.TakeVerified(tablePathId);
277273
columnTable->UpdateTableStats(tablePathId, newTableStats);
278274
} else {
279275
LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
280-
"failed add stats for table with pathId=" << tablePathId);
276+
"failed add stats for table with pathId=" << tablePathId);
281277
}
282278
}
283279

284280
} else if (isColumnTable) {
285-
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "PersistSingleStats: ColumnTable rec.GetColumnTables() size="
286-
<< rec.GetTables().size());
281+
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
282+
"PersistSingleStats: ColumnTable rec.GetColumnTables() size=" << rec.GetTables().size());
287283

288284
auto columnTable = Self->ColumnTables.TakeVerified(pathId);
289285
oldAggrStats = columnTable->GetStats().Aggregated;

ydb/core/tx/schemeshard/schemeshard_path_describer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void TPathDescriber::DescribeOlapStore(TPathId pathId, TPathElement::TPtr pathEl
393393
}
394394

395395
void TPathDescriber::DescribeColumnTable(TPathId pathId, TPathElement::TPtr pathEl) {
396-
const auto tableInfo = Self->ColumnTables.GetVerified(pathId);
396+
const auto tableInfo = Self->ColumnTables.GetVerified(pathId);
397397
Y_UNUSED(pathEl);
398398

399399
auto* pathDescription = Result->Record.MutablePathDescription();

0 commit comments

Comments
 (0)