Skip to content

Commit 8cd73c7

Browse files
author
Konstantin Morozov
committed
up formatting
1 parent 6d1c7a8 commit 8cd73c7

File tree

5 files changed

+37
-50
lines changed

5 files changed

+37
-50
lines changed

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

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
21
#include <ydb/core/kqp/ut/common/columnshard.h>
3-
4-
5-
6-
7-
8-
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
2+
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
93
#include <ydb/core/testlib/common_helper.h>
4+
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
105

116
namespace NKikimr {
127
namespace NKqp {
@@ -19,10 +14,9 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
1914
constexpr size_t tables_in_store = 1000;
2015
constexpr size_t size_single_table = 13152;
2116

22-
const TVector<TTestHelper::TColumnSchema> schema = {TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),TTestHelper::TColumnSchema().SetName("resource_id").SetType(NScheme::NTypeIds::Utf8),TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32)
23-
};
17+
const TVector<TTestHelper::TColumnSchema> schema = {TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false), TTestHelper::TColumnSchema().SetName("resource_id").SetType(NScheme::NTypeIds::Utf8), TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32)};
2418

25-
class TOlapStatsController: public NYDBTest::NColumnShard::TController {
19+
class TOlapStatsController : public NYDBTest::NColumnShard::TController {
2620
public:
2721
TDuration GetPeriodicWakeupActivationPeriod(const TDuration /*defaultValue*/) const override {
2822
return TDuration::MilliSeconds(10);
@@ -34,7 +28,7 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
3428

3529
Y_UNIT_TEST(AddRowsTableStandalone) {
3630
auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<TOlapStatsController>();
37-
31+
3832
TKikimrSettings runnerSettings;
3933
runnerSettings.WithSampleTables = false;
4034

@@ -46,8 +40,8 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
4640
testHelper.CreateTable(testTable);
4741
{
4842
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
49-
50-
for(size_t i=0; i<inserted_rows; i++) {
43+
44+
for (size_t i = 0; i < inserted_rows; i++) {
5145
tableInserter.AddRow().Add(i).Add("test_res_" + std::to_string(i)).AddNull();
5246
}
5347

@@ -85,12 +79,12 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
8579

8680
{
8781
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
88-
for(size_t i=0; i<inserted_rows; i++) {
82+
for (size_t i = 0; i < inserted_rows; i++) {
8983
tableInserter.AddRow().Add(i).Add("test_res_" + std::to_string(i)).AddNull();
9084
}
9185
testHelper.InsertData(testTable, tableInserter);
9286
}
93-
87+
9488
Sleep(TDuration::Seconds(1));
9589

9690
auto settings = TDescribeTableSettings().WithTableStatistics(true);
@@ -119,22 +113,22 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
119113

120114
Tests::NCommon::TLoggerInit(testHelper.GetKikimr()).SetPriority(NActors::NLog::PRI_DEBUG).Initialize();
121115

122-
for(size_t t=0; t<tables_in_store; t++) {
116+
for (size_t t = 0; t < tables_in_store; t++) {
123117
TTestHelper::TColumnTable testTable;
124118
testTable.SetName("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t)).SetPrimaryKey({"id"}).SetSharding({"id"}).SetSchema(schema);
125119
testHelper.CreateTable(testTable);
126120

127121
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
128-
for(size_t i=0; i < t+ inserted_rows; i++) {
122+
for (size_t i = 0; i < t + inserted_rows; i++) {
129123
tableInserter.AddRow().Add(i + t * tables_in_store).Add("test_res_" + std::to_string(i + t * tables_in_store)).AddNull();
130124
}
131-
testHelper.InsertData(testTable, tableInserter);;
125+
testHelper.InsertData(testTable, tableInserter);
132126
}
133-
127+
134128
Sleep(TDuration::Seconds(20));
135129

136130
auto settings = TDescribeTableSettings().WithTableStatistics(true);
137-
for(size_t t=0; t<tables_in_store; t++) {
131+
for (size_t t = 0; t < tables_in_store; t++) {
138132
auto describeResult = testHelper.GetSession().DescribeTable("/Root/TableStoreTest/ColumnTableTest_" + std::to_string(t), settings).GetValueSync();
139133
UNIT_ASSERT_C(describeResult.IsSuccess(), describeResult.GetIssues().ToString());
140134
const auto& description = describeResult.GetTableDescription();
@@ -144,5 +138,5 @@ Y_UNIT_TEST_SUITE(KqpOlapStats) {
144138
}
145139
}
146140

147-
} // namespace NKqp
148-
} // namespace NKikimr
141+
} // namespace NKqp
142+
} // namespace NKikimr

ydb/core/tx/columnshard/columnshard.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,12 @@ 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, ::NKikimrTableStats::TTableStats* tabletStats) {
297297
NOlap::TSnapshot lastIndexUpdate = TablesManager.GetPrimaryIndexSafe().LastUpdate();
298-
auto activeIndexStats = indexStats.Active(); // data stats excluding inactive and evicted
298+
auto activeIndexStats = indexStats.Active(); // data stats excluding inactive and evicted
299299

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

304303
activeIndexStats.Rows = (activeIndexStats.Rows < 0) ? 0 : activeIndexStats.Rows;
305304
activeIndexStats.Bytes = (activeIndexStats.Bytes < 0) ? 0 : activeIndexStats.Bytes;
@@ -309,7 +308,7 @@ void TColumnShard::ConfigureStats(const NOlap::TColumnEngineStats& indexStats, :
309308
tabletStats->SetDataSize(activeIndexStats.Bytes + TabletCounters->Simple()[COUNTER_COMMITTED_BYTES].Get());
310309

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

314313
tabletStats->SetLastAccessTime(LastAccessTime.MilliSeconds());
315314
tabletStats->SetLastUpdateTime(lastIndexUpdate.GetPlanStep());
@@ -330,7 +329,7 @@ void TColumnShard::FillTxTableStats(::NKikimrTableStats::TTableStats* tableStats
330329
}
331330

332331
void TColumnShard::FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
333-
ev->Record.SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
332+
ev->Record.SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
334333
ev->Record.SetGeneration(Executor()->Generation());
335334
ev->Record.SetRound(StatsReportRound++);
336335
ev->Record.SetNodeId(ctx.ExecutorThread.ActorSystem->NodeId);
@@ -352,7 +351,7 @@ void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_pt
352351
}
353352
const auto& tablesIndexStats = TablesManager.MutablePrimaryIndex().GetStats();
354353
LOG_S_DEBUG("There are stats for " << tablesIndexStats.size() << " tables");
355-
for(const auto& [tableLocalID, columnStats] : tablesIndexStats) {
354+
for (const auto& [tableLocalID, columnStats] : tablesIndexStats) {
356355
if (!columnStats) {
357356
LOG_S_ERROR("SendPeriodicStats: empty stats");
358357
continue;
@@ -362,7 +361,7 @@ void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_pt
362361
periodicTableStats->SetDatashardId(TabletID());
363362
periodicTableStats->SetTableLocalId(tableLocalID);
364363

365-
periodicTableStats->SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
364+
periodicTableStats->SetShardState(2); // NKikimrTxDataShard.EDatashardState.Ready
366365
periodicTableStats->SetGeneration(Executor()->Generation());
367366
periodicTableStats->SetRound(StatsReportRound++);
368367
periodicTableStats->SetNodeId(ctx.ExecutorThread.ActorSystem->NodeId);

ydb/core/tx/columnshard/columnshard_impl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -488,12 +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-
496+
497497
public:
498498
const std::shared_ptr<NOlap::IStoragesManager>& GetStoragesManager() const {
499499
return StoragesManager;

ydb/core/tx/schemeshard/schemeshard__table_stats.cpp

+11-17
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

@@ -182,8 +180,7 @@ TPartitionStats TTxStoreTableStats::PrepareStats(
182180
return newStats;
183181
}
184182

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

@@ -208,9 +205,9 @@ bool TTxStoreTableStats::PersistSingleStats(const TPathId& pathId,
208205
TShardIdx shardIdx = Self->TabletIdToShardIdx[datashardId];
209206

210207
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
211-
"TTxStoreTableStats.PersistSingleStats: main stats from"
212-
<< " datashardId(TabletID)=" << datashardId
213-
<< " maps to shardIdx: " << shardIdx
208+
"TTxStoreTableStats.PersistSingleStats: main stats from"
209+
<< " datashardId(TabletID)=" << datashardId
210+
<< " maps to shardIdx: " << shardIdx
214211
<< ", pathId: " << pathId
215212
<< ", pathId map=" << Self->PathsById[pathId]->Name
216213
<< ", is column=" << isColumnTable
@@ -261,23 +258,20 @@ 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)) {
273-
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
274-
"add stats for exists table with pathId=" << tablePathId);
269+
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "add stats for exists table with pathId=" << tablePathId);
275270

276271
auto columnTable = Self->ColumnTables.TakeVerified(tablePathId);
277272
columnTable->UpdateTableStats(tablePathId, newTableStats);
278273
} else {
279-
LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
280-
"failed add stats for table with pathId=" << tablePathId);
274+
LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "failed add stats for table with pathId=" << tablePathId);
281275
}
282276
}
283277

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)