Skip to content

Commit 9529742

Browse files
committed
use shrink
1 parent 5302382 commit 9529742

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,11 @@ EFetchResult ProcessSpilledData(TComputationContext&, NUdf::TUnboxedValue*const*
895895

896896
LeftPacker->TuplesBatchPacked = 0;
897897
LeftPacker->TablePtr->ClearBucket(NextBucketToJoin); // Clear content of returned bucket
898+
LeftPacker->TablePtr->ShrinkBucket(NextBucketToJoin);
898899

899900
RightPacker->TuplesBatchPacked = 0;
900901
RightPacker->TablePtr->ClearBucket(NextBucketToJoin); // Clear content of returned bucket
902+
RightPacker->TablePtr->ShrinkBucket(NextBucketToJoin);
901903

902904
JoinedTablePtr->Clear();
903905
JoinedTablePtr->ResetIterator();

ydb/library/yql/minikql/comp_nodes/mkql_grace_join_imp.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,19 +1114,12 @@ void TTable::Clear() {
11141114

11151115
void TTable::ClearBucket(ui64 bucket) {
11161116
TTableBucket & tb = TableBuckets[bucket];
1117-
std::vector<ui64, TMKQLAllocator<ui64>>().swap(tb.KeyIntVals);
1118-
std::vector<ui64, TMKQLAllocator<ui64>>().swap(tb.DataIntVals);
1119-
std::vector<ui32, TMKQLAllocator<ui32>>().swap(tb.StringsOffsets);
1120-
std::vector<char, TMKQLAllocator<char>>().swap(tb.StringsValues);
1121-
std::vector<char, TMKQLAllocator<char>>().swap(tb.InterfaceValues);
1122-
std::vector<ui32, TMKQLAllocator<ui32>>().swap(tb.InterfaceOffsets);
1123-
1124-
/* tb.KeyIntVals.clear();
1117+
tb.KeyIntVals.clear();
11251118
tb.DataIntVals.clear();
11261119
tb.StringsOffsets.clear();
11271120
tb.StringsValues.clear();
11281121
tb.InterfaceValues.clear();
1129-
tb.InterfaceOffsets.clear();*/
1122+
tb.InterfaceOffsets.clear();
11301123
tb.JoinIds.clear();
11311124
tb.RightIds.clear();
11321125

@@ -1136,6 +1129,18 @@ void TTable::ClearBucket(ui64 bucket) {
11361129
tbs.StringValuesTotalSize = 0;
11371130
}
11381131

1132+
void TTable::ShrinkBucket(ui64 bucket) {
1133+
TTableBucket & tb = TableBuckets[bucket];
1134+
tb.KeyIntVals.shrink_to_fit();
1135+
tb.DataIntVals.shrink_to_fit();
1136+
tb.StringsOffsets.shrink_to_fit();
1137+
tb.StringsValues.shrink_to_fit();
1138+
tb.InterfaceValues.shrink_to_fit();
1139+
tb.InterfaceOffsets.shrink_to_fit();
1140+
tb.JoinIds.shrink_to_fit();
1141+
tb.RightIds.shrink_to_fit();
1142+
}
1143+
11391144
void TTable::InitializeBucketSpillers(ISpiller::TPtr spiller) {
11401145
for (size_t i = 0; i < NumberOfBuckets; ++i) {
11411146
TableBucketsSpillers.emplace_back(spiller, 5_MB);

ydb/library/yql/minikql/comp_nodes/mkql_grace_join_imp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ class TTable {
321321
// Clears all the data related to a single bucket
322322
void ClearBucket(ui64 bucket);
323323

324+
// Forces bucket to release the space used for underlying containers.
325+
void ShrinkBucket(ui64 bucket);
326+
324327
// Clears table content
325328
void Clear();
326329

0 commit comments

Comments
 (0)