Skip to content

Commit 08f2dfb

Browse files
authored
Statistics: Expanded ForceTraversalOperations scheme, add CreatedAt (#8194)
1 parent c8af2fe commit 08f2dfb

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

ydb/core/statistics/aggregator/aggregator_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class TStatisticsAggregator : public TActor<TStatisticsAggregator>, public NTabl
379379
std::vector<TForceTraversalTable> Tables;
380380
TString Types;
381381
TActorId ReplyToActorId;
382+
TInstant CreatedAt;
382383
};
383384
std::list<TForceTraversalOperation> ForceTraversals;
384385

ydb/core/statistics/aggregator/schema.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ struct TAggregatorSchema : NIceDb::Schema {
5151
struct ForceTraversalOperations : Table<6> {
5252
struct OperationId : Column<1, NScheme::NTypeIds::String> {};
5353
struct Types : Column<2, NScheme::NTypeIds::String> {};
54+
struct CreatedAt : Column<3, NScheme::NTypeIds::Uint64> {};
5455

5556
using TKey = TableKey<OperationId>;
5657
using TColumns = TableColumns<
5758
OperationId,
58-
Types
59+
Types,
60+
CreatedAt
5961
>;
6062
};
6163

ydb/core/statistics/aggregator/tx_analyze.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct TStatisticsAggregator::TTxAnalyze : public TTxBase {
1818

1919
TTxType GetTxType() const override { return TXTYPE_ANALYZE_TABLE; }
2020

21-
bool Execute(TTransactionContext& txc, const TActorContext&) override {
21+
bool Execute(TTransactionContext& txc, const TActorContext& ctx) override {
2222
SA_LOG_D("[" << Self->TabletID() << "] TTxAnalyze::Execute. ReplyToActorId " << ReplyToActorId << " , Record " << Record);
2323

2424
if (!Self->EnableColumnStatistics) {
@@ -48,11 +48,13 @@ struct TStatisticsAggregator::TTxAnalyze : public TTxBase {
4848
const TString types = JoinVectorIntoString(TVector<ui32>(Record.GetTypes().begin(), Record.GetTypes().end()), ",");
4949

5050
// create new force trasersal
51+
auto createdAt = ctx.Now();
5152
TForceTraversalOperation operation {
5253
.OperationId = operationId,
5354
.Tables = {},
5455
.Types = types,
55-
.ReplyToActorId = ReplyToActorId
56+
.ReplyToActorId = ReplyToActorId,
57+
.CreatedAt = createdAt
5658
};
5759

5860
for (const auto& table : Record.GetTables()) {
@@ -79,11 +81,12 @@ struct TStatisticsAggregator::TTxAnalyze : public TTxBase {
7981
);
8082
}
8183

82-
Self->ForceTraversals.emplace_back(operation);
84+
Self->ForceTraversals.emplace_back(operation);
8385

8486
db.Table<Schema::ForceTraversalOperations>().Key(operationId).Update(
8587
NIceDb::TUpdate<Schema::ForceTraversalOperations::OperationId>(operationId),
86-
NIceDb::TUpdate<Schema::ForceTraversalOperations::Types>(types)
88+
NIceDb::TUpdate<Schema::ForceTraversalOperations::Types>(types),
89+
NIceDb::TUpdate<Schema::ForceTraversalOperations::CreatedAt>(createdAt.GetValue())
8790
);
8891

8992
return true;

ydb/core/statistics/aggregator/tx_init.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,14 @@ struct TStatisticsAggregator::TTxInit : public TTxBase {
194194
while (!rowset.EndOfSet()) {
195195
TString operationId = rowset.GetValue<Schema::ForceTraversalOperations::OperationId>();
196196
TString types = rowset.GetValue<Schema::ForceTraversalOperations::Types>();
197+
ui64 createdAt = rowset.GetValue<Schema::ForceTraversalOperations::CreatedAt>();
197198

198199
TForceTraversalOperation operation {
199200
.OperationId = operationId,
200201
.Tables = {},
201202
.Types = types,
202-
.ReplyToActorId = {}
203+
.ReplyToActorId = {},
204+
.CreatedAt = TInstant::FromValue(createdAt)
203205
};
204206
Self->ForceTraversals.emplace_back(operation);
205207

0 commit comments

Comments
 (0)