Skip to content

Commit 7c5a2c4

Browse files
split chunks from portion to optional usage method
1 parent 6c24540 commit 7c5a2c4

File tree

32 files changed

+299
-233
lines changed

32 files changed

+299
-233
lines changed

ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void TTxBlobsWritingFinished::DoComplete(const TActorContext& ctx) {
9999
Self->GetOperationsManager().AddEventForLock(*Self, op->GetLockId(), evWrite);
100100
}
101101
}
102-
granule.InsertPortionOnComplete(portion.GetPortionInfo().MutablePortionInfoPtr());
102+
granule.InsertPortionOnComplete(portion.GetPortionInfo(), index);
103103
}
104104
if (op->GetBehaviour() == EOperationBehaviour::NoTxWrite) {
105105
AFL_VERIFY(CommitSnapshot);

ydb/core/tx/columnshard/columnshard__statistics.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ void TColumnShard::Handle(NStat::TEvStatistics::TEvStatisticsRequest::TPtr& ev,
7474
}
7575
AFL_VERIFY(indexMeta->GetColumnIds().size() == 1);
7676

77-
const std::vector<TString> data = portionInfo->GetIndexInplaceDataVerified(indexMeta->GetIndexId());
77+
const std::vector<TString> data
78+
//= portionInfo->GetIndexInplaceDataVerified(indexMeta->GetIndexId())
79+
;
7880

7981
for (const auto& sketchAsString : data) {
8082
auto sketch = std::unique_ptr<TCountMinSketch>(TCountMinSketch::FromString(sketchAsString.data(), sketchAsString.size()));

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,15 +1238,15 @@ class TTxAskPortionChunks: public TTransactionBase<TColumnShard> {
12381238
for (auto&& i : PortionsByPath) {
12391239
while (i.second.size()) {
12401240
auto p = i.second.back();
1241-
auto rowset = db.Table<NColumnShard::Schema::IndexColumnsV1>().Prefix(p->GetPathId(), p->GetPortionId()).Select();
1242-
NOlap::TPortionInfoConstructor constructor(*p, false, true, true);
1241+
std::vector<NOlap::TColumnChunkLoadContextV1> records;
1242+
std::vector<NOlap::TIndexChunkLoadContext> indexes;
12431243
{
1244+
auto rowset = db.Table<NColumnShard::Schema::IndexColumnsV1>().Prefix(p->GetPathId(), p->GetPortionId()).Select();
12441245
if (!rowset.IsReady()) {
12451246
return false;
12461247
}
12471248
while (!rowset.EndOfSet()) {
1248-
NOlap::TColumnChunkLoadContextV1 chunkLoadContext(rowset);
1249-
constructor.LoadRecord(chunkLoadContext);
1249+
records.emplace_back(NOlap::TColumnChunkLoadContextV1(rowset));
12501250
if (!rowset.Next()) {
12511251
return false;
12521252
}
@@ -1258,13 +1258,13 @@ class TTxAskPortionChunks: public TTransactionBase<TColumnShard> {
12581258
return false;
12591259
}
12601260
while (!rowset.EndOfSet()) {
1261-
NOlap::TIndexChunkLoadContext chunkLoadContext(rowset, &selector);
1262-
constructor.LoadIndex(chunkLoadContext);
1261+
indexes.emplace_back(NOlap::TIndexChunkLoadContext(rowset, &selector));
12631262
if (!rowset.Next()) {
12641263
return false;
12651264
}
12661265
}
12671266
}
1267+
NOlap::TPortionInfoConstructor constructor = NOlap::TPortionInfoConstructor::BuildForLoading(p, std::move(records), std::move(indexes));
12681268
Accessors[i.first].emplace_back(constructor.Build(true));
12691269
i.second.pop_back();
12701270
}

ydb/core/tx/columnshard/counters/portions.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void TSimplePortionsGroupInfo::AddPortion(const TPortionInfo& p) {
3030
RawBytes += p.GetTotalRawBytes();
3131
Count += 1;
3232
RecordsCount += p.GetRecordsCount();
33-
ChunksCount += p.GetChunksCount();
3433
}
3534

3635
void TSimplePortionsGroupInfo::RemovePortion(const std::shared_ptr<const NOlap::TPortionInfo>& p) {
@@ -42,12 +41,10 @@ void TSimplePortionsGroupInfo::RemovePortion(const TPortionInfo& p) {
4241
RawBytes -= p.GetTotalRawBytes();
4342
Count -= 1;
4443
RecordsCount -= p.GetRecordsCount();
45-
ChunksCount -= p.GetChunksCount();
4644
AFL_VERIFY(RawBytes >= 0);
4745
AFL_VERIFY(BlobBytes >= 0);
4846
AFL_VERIFY(Count >= 0);
4947
AFL_VERIFY(RecordsCount >= 0);
50-
AFL_VERIFY(ChunksCount >= 0);
5148
}
5249

5350
} // namespace NKikimr::NOlap

ydb/core/tx/columnshard/counters/portions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class TSimplePortionsGroupInfo {
1515
YDB_READONLY(i64, RawBytes, 0);
1616
YDB_READONLY(i64, Count, 0);
1717
YDB_READONLY(i64, RecordsCount, 0);
18-
YDB_READONLY(i64, ChunksCount, 0);
1918

2019
public:
2120
NJson::TJsonValue SerializeToJson() const {
@@ -24,7 +23,6 @@ class TSimplePortionsGroupInfo {
2423
result.InsertValue("raw_bytes", RawBytes);
2524
result.InsertValue("count", Count);
2625
result.InsertValue("records_count", RecordsCount);
27-
result.InsertValue("chunks_count", ChunksCount);
2826
return result;
2927
}
3028

@@ -47,7 +45,6 @@ class TSimplePortionsGroupInfo {
4745
result.RawBytes = RawBytes + item.RawBytes;
4846
result.Count = Count + item.Count;
4947
result.RecordsCount = RecordsCount + item.RecordsCount;
50-
result.ChunksCount = ChunksCount + item.ChunksCount;
5148
return result;
5249
}
5350

ydb/core/tx/columnshard/data_accessor/controller.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,27 @@ class IGranuleDataAccessor {
3434
class TMemDataAccessor: public IGranuleDataAccessor {
3535
private:
3636
using TBase = IGranuleDataAccessor;
37+
THashMap<ui64, TPortionDataAccessor> Accessors;
3738
virtual void DoAskData(const std::shared_ptr<TDataAccessorsRequest>& request) override {
3839
std::vector<TPortionDataAccessor> accessors;
3940
auto& portions = request->StartFetching(GetPathId());
4041
for (auto&& i : portions) {
41-
accessors.emplace_back(TPortionDataAccessor(i));
42+
auto it = Accessors.find(i->GetPortionId());
43+
AFL_VERIFY(it != Accessors.end());
44+
accessors.emplace_back(it->second);
4245
}
4346
request->AddData(GetPathId(), std::move(accessors));
4447
}
45-
virtual void DoModifyPortions(const std::vector<TPortionDataAccessor>& /*add*/, const std::vector<ui64>& /*remove*/) override {
48+
virtual void DoModifyPortions(const std::vector<TPortionDataAccessor>& add, const std::vector<ui64>& remove) override {
49+
for (auto&& i : remove) {
50+
AFL_VERIFY(Accessors.erase(i));
51+
}
52+
for (auto&& i : add) {
53+
AFL_VERIFY(Accessors.emplace(i.GetPortionInfo().GetPortionId(), i).second);
54+
}
4655
}
4756

4857
public:
49-
TPortionDataAccessor BuildAccessor(const TPortionInfo::TConstPtr& portion) const {
50-
return TPortionDataAccessor(portion);
51-
}
52-
5358
TMemDataAccessor(const ui64 pathId)
5459
: TBase(pathId) {
5560
}
@@ -64,10 +69,6 @@ class TTabletDataAccessor: public IGranuleDataAccessor {
6469
}
6570

6671
public:
67-
TPortionDataAccessor BuildAccessor(const TPortionInfo::TConstPtr& portion) const {
68-
return TPortionDataAccessor(portion);
69-
}
70-
7172
TTabletDataAccessor(const ui64 pathId)
7273
: TBase(pathId) {
7374
}

ydb/core/tx/columnshard/data_sharing/common/session/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TConclusionStatus TCommonSession::TryStart(NColumnShard::TColumnShard& shard) {
2727
if (shard.GetDataLocksManager()->IsLocked(*p.second, { "sharing_session:" + GetSessionId() })) {
2828
return TConclusionStatus::Fail("failed to start cursor: portion is locked");
2929
}
30-
portionsByPath[i].emplace_back(p.second);
30+
// portionsByPath[i].emplace_back(p.second);
3131
}
3232
}
3333

ydb/core/tx/columnshard/data_sharing/destination/session/destination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ NKikimr::TConclusionStatus TDestinationSession::DataReceived(
2020
AFL_VERIFY(it != PathIds.end())("path_id_undefined", i.first);
2121
for (auto&& portion : i.second.DetachPortions()) {
2222
portion.MutablePortionInfo().SetPathId(it->second);
23-
index.AppendPortion(portion.MutablePortionInfoPtr());
23+
index.AppendPortion(portion);
2424
}
2525
}
2626
return TConclusionStatus::Success();

ydb/core/tx/columnshard/data_sharing/source/session/cursor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void TSourceCursor::BuildSelection(const std::shared_ptr<IStoragesManager>& stor
2626
NextPortionId = itPortion->first;
2727
} else {
2828
portions.emplace_back(itPortion->second);
29-
chunksCount += portions.back().GetRecords().size();
30-
chunksCount += portions.back().GetIndexes().size();
29+
chunksCount += portions.back().GetRecordsVerified().size();
30+
chunksCount += portions.back().GetIndexesVerified().size();
3131
++count;
3232
}
3333
}

ydb/core/tx/columnshard/engines/changes/with_appended.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void TChangesWithAppend::DoWriteIndexOnComplete(NColumnShard::TColumnShard* self
113113
context.EngineLogs.AddCleanupPortion(i);
114114
}
115115
for (auto& portionBuilder : AppendedPortions) {
116-
context.EngineLogs.AppendPortion(portionBuilder.GetPortionResult().MutablePortionInfoPtr());
116+
context.EngineLogs.AppendPortion(portionBuilder.GetPortionResult());
117117
}
118118
}
119119
}

0 commit comments

Comments
 (0)