aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanly <stanly@yandex-team.com>2023-05-25 16:59:06 +0300
committerstanly <stanly@yandex-team.com>2023-05-25 16:59:06 +0300
commit9e6f7e52150074c7586b0c6b8e6730721c5bdebb (patch)
tree6ba26a337ec66b49717b03180a7e2961b0b014a1
parentec9da1027668e44c2271e152a062082913c3848e (diff)
downloadydb-9e6f7e52150074c7586b0c6b8e6730721c5bdebb.tar.gz
assemble batch only if needed
-rw-r--r--ydb/core/tx/columnshard/engines/index_logic_logs.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/ydb/core/tx/columnshard/engines/index_logic_logs.cpp b/ydb/core/tx/columnshard/engines/index_logic_logs.cpp
index bb845e2e747..684450d18c3 100644
--- a/ydb/core/tx/columnshard/engines/index_logic_logs.cpp
+++ b/ydb/core/tx/columnshard/engines/index_logic_logs.cpp
@@ -143,24 +143,25 @@ std::vector<TPortionInfo> TIndexLogicBase::MakeAppendedPortions(const ui64 pathI
return out;
}
-std::pair<std::vector<std::shared_ptr<arrow::RecordBatch>>, TSnapshot> TCompactionLogic::PortionsToBatches(const std::vector<TPortionInfo>& portions,
- const THashMap<TBlobRange, TString>& blobs,
- bool insertedOnly) const {
+std::pair<std::vector<std::shared_ptr<arrow::RecordBatch>>, TSnapshot>
+TCompactionLogic::PortionsToBatches(const std::vector<TPortionInfo>& portions, const THashMap<TBlobRange, TString>& blobs,
+ const bool insertedOnly) const {
std::vector<std::shared_ptr<arrow::RecordBatch>> batches;
batches.reserve(portions.size());
- auto resultSchema = SchemaVersions.GetLastSchema();
+ const auto resultSchema = SchemaVersions.GetLastSchema();
TSnapshot maxSnapshot = resultSchema->GetSnapshot();
- for (auto& portionInfo : portions) {
- auto blobSchema = SchemaVersions.GetSchema(portionInfo.GetSnapshot());
- auto batch = portionInfo.AssembleInBatch(*blobSchema, *resultSchema, blobs);
+ for (const auto& portionInfo : portions) {
if (!insertedOnly || portionInfo.IsInserted()) {
- batches.push_back(batch);
+ const auto blobSchema = SchemaVersions.GetSchema(portionInfo.GetSnapshot());
+
+ batches.push_back(portionInfo.AssembleInBatch(*blobSchema, *resultSchema, blobs));
+
if (maxSnapshot < portionInfo.GetSnapshot()) {
maxSnapshot = portionInfo.GetSnapshot();
}
}
}
- return std::make_pair(batches, maxSnapshot);
+ return std::make_pair(std::move(batches), maxSnapshot);
}
THashMap<ui64, std::shared_ptr<arrow::RecordBatch>> TIndexLogicBase::SliceIntoGranules(const std::shared_ptr<arrow::RecordBatch>& batch,
@@ -238,7 +239,7 @@ std::vector<TString> TIndexationLogic::Apply(std::shared_ptr<TColumnEngineChange
batch = it->second;
} else if (auto* blobData = changes->Blobs.FindPtr(blobRange)) {
Y_VERIFY(!blobData->empty(), "Blob data not present");
- // Prepare batch
+ // Prepare batch
batch = NArrow::DeserializeBatch(*blobData, indexInfo.ArrowSchema());
if (!batch) {
AFL_ERROR(NKikimrServices::TX_COLUMNSHARD)