Skip to content

Commit

Permalink
Merge 14a4376 into 481ccad
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Nov 19, 2024
2 parents 481ccad + 14a4376 commit 77d45e0
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions ydb/core/tx/columnshard/engines/portions/constructor_accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,39 @@ TPortionDataAccessor TPortionAccessorConstructor::BuildForLoading(
const TPortionInfo::TConstPtr& portion, std::vector<TColumnChunkLoadContextV1>&& records, std::vector<TIndexChunkLoadContext>&& indexes) {
AFL_VERIFY(portion);
std::vector<TColumnRecord> recordChunks;
for (auto&& i : records) {
recordChunks.emplace_back(TColumnRecord(i));
{
const auto pred = [](const TColumnRecord& l, const TColumnRecord& r) {
return l.GetAddress() < r.GetAddress();
};
bool needSort = false;
for (auto&& i : records) {
if (recordChunks.size() && !pred(recordChunks.back(), i)) {
needSort = true;
}
recordChunks.emplace_back(TColumnRecord(i));
}
if (needSort) {
std::sort(recordChunks.begin(), recordChunks.end(), pred);
}
}
std::vector<TIndexChunk> indexChunks;
for (auto&& i : indexes) {
indexChunks.emplace_back(i.BuildIndexChunk());
{

const auto pred = [](const TIndexChunk& l, const TIndexChunk& r) {
return l.GetAddress() < r.GetAddress();
};
bool needSort = false;
for (auto&& i : indexes) {
if (indexChunks.size() && !pred(indexChunks.back(), i)) {
needSort = true;
}
indexChunks.emplace_back(i.BuildIndexChunk());
}
if (needSort) {
std::sort(indexChunks.begin(), indexChunks.end(), pred);
}
}
std::sort(indexChunks.begin(), indexChunks.end(), pred);
return TPortionDataAccessor(portion, std::move(recordChunks), std::move(indexChunks), true);
}

Expand Down

0 comments on commit 77d45e0

Please sign in to comment.