Skip to content

Commit fc03836

Browse files
committed
Count Rounds from 1 again to prevent N+1 rounds instead of requested N (#19154)
1 parent fe88806 commit fc03836

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class TLocalKMeansScan: public TActor<TLocalKMeansScan>, public NTable::IScan {
379379
}
380380
bool ok = Clusters->SetClusters(std::move(rows));
381381
Y_ENSURE(ok);
382+
Clusters->SetRound(1);
382383
return false; // do KMEANS
383384
}
384385

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class TPrefixKMeansScan: public TActor<TPrefixKMeansScan>, public NTable::IScan
425425
}
426426
bool ok = Clusters->SetClusters(std::move(rows));
427427
Y_ENSURE(ok);
428+
Clusters->SetRound(1);
428429
return false; // do KMEANS
429430
}
430431

ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,12 +1090,12 @@ struct TSchemeShard::TIndexBuilder::TTxProgress: public TSchemeShard::TIndexBuil
10901090
if (buildInfo.KMeans.Rounds > 1) {
10911091
LOG_D("FillVectorIndex Recompute " << buildInfo.DebugString());
10921092
buildInfo.KMeans.State = TIndexBuildInfo::TKMeans::Recompute;
1093-
buildInfo.KMeans.Round = 0;
1093+
buildInfo.KMeans.Round = 1;
10941094
// Initialize Clusters
10951095
NIceDb::TNiceDb db(txc.DB);
10961096
buildInfo.Sample.MakeStrictTop(buildInfo.KMeans.K);
10971097
Self->PersistBuildIndexSampleToClusters(db, buildInfo);
1098-
buildInfo.Clusters->SetRound(0);
1098+
buildInfo.Clusters->SetRound(1);
10991099
PersistKMeansState(txc, buildInfo);
11001100
Progress(BuildId);
11011101
} else {

ydb/core/tx/schemeshard/ut_index_build/ut_vector_index_build.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ Y_UNIT_TEST_SUITE (VectorIndexBuildTest) {
551551
UNIT_ASSERT_VALUES_EQUAL(readRows, expectedReadRows);
552552
UNIT_ASSERT_VALUES_EQUAL(readBytes, expectedReadBytes);
553553

554-
// every RECOMPUTE round reads table once, no writes; there are 4 recompute rounds:
555-
for (ui32 round = 0; round < 4; round++) {
554+
// every RECOMPUTE round reads table once, no writes; there are 3 recompute rounds:
555+
for (ui32 round = 0; round < 3; round++) {
556556
for (ui32 shard = 0; shard < 3; shard++) {
557557
runtime.WaitFor("recomputeK", [&]{ return recomputeKBlocker.size(); });
558558
recomputeKBlocker.Unblock();
@@ -623,9 +623,9 @@ Y_UNIT_TEST_SUITE (VectorIndexBuildTest) {
623623
expectedUploadRows += level2clusters;
624624
expectedUploadBytes += level2clusters * levelRowBytes;
625625
if (smallScanBuffer) {
626-
// KMEANS reads build table 6 times (SAMPLE + KMEANS * 4 + UPLOAD):
627-
expectedReadRows += tableRows * 6;
628-
expectedReadBytes += buildBytes * 6;
626+
// KMEANS reads build table 5 times (SAMPLE + KMEANS * 3 + UPLOAD):
627+
expectedReadRows += tableRows * 5;
628+
expectedReadBytes += buildBytes * 5;
629629
} else {
630630
// KMEANS reads build table once:
631631
expectedReadRows += tableRows;

0 commit comments

Comments
 (0)