Skip to content

Commit 08f5064

Browse files
data accessor has to own portion info (#11060)
1 parent 7c45196 commit 08f5064

File tree

44 files changed

+226
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+226
-166
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
@@ -34,7 +34,7 @@ bool TTxBlobsWritingFinished::DoExecute(TTransactionContext& txc, const TActorCo
3434
if (operation->GetBehaviour() == EOperationBehaviour::NoTxWrite) {
3535
granule.CommitImmediateOnExecute(txc, *CommitSnapshot, portion.GetPortionInfo());
3636
} else {
37-
granule.InsertPortionOnExecute(txc, NOlap::TPortionDataAccessor(*portion.GetPortionInfo()));
37+
granule.InsertPortionOnExecute(txc, NOlap::TPortionDataAccessor(portion.GetPortionInfo()));
3838
}
3939
}
4040
}

ydb/core/tx/columnshard/data_locks/locks/list.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class TListPortionsLock: public ILock {
3636
}
3737
}
3838

39+
TListPortionsLock(const TString& lockName, const std::vector<TPortionInfo::TConstPtr>& portions, const bool readOnly = false)
40+
: TBase(lockName, readOnly) {
41+
for (auto&& p : portions) {
42+
Portions.emplace(p->GetAddress());
43+
Granules.emplace(p->GetPathId());
44+
}
45+
}
46+
3947
TListPortionsLock(const TString& lockName, const std::vector<TPortionInfo>& portions, const bool readOnly = false)
4048
: TBase(lockName, readOnly) {
4149
for (auto&& p : portions) {

ydb/core/tx/columnshard/data_sharing/destination/events/transfer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ THashMap<NKikimr::NOlap::TTabletId, NKikimr::NOlap::NDataSharing::TTaskForTablet
1212
const TVersionedIndex& index) {
1313
THashMap<TString, THashSet<TUnifiedBlobId>> blobIds;
1414
for (auto&& i : Portions) {
15-
auto schema = i.GetSchema(index);
15+
auto schema = i->GetSchema(index);
1616
TPortionDataAccessor(i).FillBlobIdsByStorage(blobIds, schema->GetIndexInfo());
1717
}
1818

ydb/core/tx/columnshard/data_sharing/destination/events/transfer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace NKikimr::NOlap::NDataSharing::NEvents {
2121
class TPathIdData {
2222
private:
2323
YDB_READONLY(ui64, PathId, 0);
24-
YDB_ACCESSOR_DEF(std::vector<TPortionInfo>, Portions);
24+
YDB_ACCESSOR_DEF(std::vector<TPortionInfo::TPtr>, Portions);
2525

2626
TPathIdData() = default;
2727

@@ -31,7 +31,7 @@ class TPathIdData {
3131
}
3232
PathId = proto.GetPathId();
3333
for (auto&& portionProto : proto.GetPortions()) {
34-
TConclusion<TPortionInfo> portion = TPortionInfo::BuildFromProto(portionProto, indexInfo);
34+
TConclusion<TPortionInfo::TPtr> portion = TPortionInfo::BuildFromProto(portionProto, indexInfo);
3535
if (!portion) {
3636
return portion.GetError();
3737
}
@@ -41,12 +41,12 @@ class TPathIdData {
4141
}
4242

4343
public:
44-
TPathIdData(const ui64 pathId, const std::vector<TPortionInfo>& portions)
44+
TPathIdData(const ui64 pathId, const std::vector<TPortionInfo::TPtr>& portions)
4545
: PathId(pathId)
4646
, Portions(portions) {
4747
}
4848

49-
std::vector<TPortionInfo> DetachPortions() {
49+
std::vector<TPortionInfo::TPtr> DetachPortions() {
5050
return std::move(Portions);
5151
}
5252
THashMap<TTabletId, TTaskForTablet> BuildLinkTabletTasks(const std::shared_ptr<IStoragesManager>& storages, const TTabletId selfTabletId,
@@ -55,9 +55,9 @@ class TPathIdData {
5555
void InitPortionIds(ui64* lastPortionId, const std::optional<ui64> pathId = {}) {
5656
AFL_VERIFY(lastPortionId);
5757
for (auto&& i : Portions) {
58-
i.SetPortionId(++*lastPortionId);
58+
i->SetPortionId(++*lastPortionId);
5959
if (pathId) {
60-
i.SetPathId(*pathId);
60+
i->SetPathId(*pathId);
6161
}
6262
}
6363
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ NKikimr::TConclusionStatus TDestinationSession::DataReceived(
1919
auto it = PathIds.find(i.first);
2020
AFL_VERIFY(it != PathIds.end())("path_id_undefined", i.first);
2121
for (auto&& portion : i.second.DetachPortions()) {
22-
portion.SetPathId(it->second);
23-
index.AppendPortion(std::move(portion));
22+
portion->SetPathId(it->second);
23+
index.AppendPortion(*portion);
2424
}
2525
}
2626
return TConclusionStatus::Success();
@@ -167,15 +167,15 @@ bool TDestinationSession::DoStart(
167167
THashMap<TString, THashSet<TUnifiedBlobId>> local;
168168
for (auto&& i : portions) {
169169
for (auto&& p : i.second) {
170-
TPortionDataAccessor(*p).FillBlobIdsByStorage(local, shard.GetIndexAs<TColumnEngineForLogs>().GetVersionedIndex());
170+
TPortionDataAccessor(p).FillBlobIdsByStorage(local, shard.GetIndexAs<TColumnEngineForLogs>().GetVersionedIndex());
171171
}
172172
}
173173
std::swap(CurrentBlobIds, local);
174174
SendCurrentCursorAck(shard, {});
175175
return true;
176176
}
177177

178-
bool TDestinationSession::TryTakePortionBlobs(const TVersionedIndex& vIndex, const TPortionInfo& portion) {
178+
bool TDestinationSession::TryTakePortionBlobs(const TVersionedIndex& vIndex, const TPortionInfo::TConstPtr& portion) {
179179
THashMap<TString, THashSet<TUnifiedBlobId>> blobIds;
180180
TPortionDataAccessor(portion).FillBlobIdsByStorage(blobIds, vIndex);
181181
ui32 containsCounter = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TDestinationSession: public TCommonSession {
8888
}
8989

9090
public:
91-
bool TryTakePortionBlobs(const TVersionedIndex& vIndex, const TPortionInfo& portion);
91+
bool TryTakePortionBlobs(const TVersionedIndex& vIndex, const std::shared_ptr<const TPortionInfo>& portion);
9292

9393
TSourceCursorForDestination& GetCursorVerified(const TTabletId& tabletId) {
9494
auto it = Cursors.find(tabletId);

ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_data_from_source.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TTxDataFromSource::TTxDataFromSource(NColumnShard::TColumnShard* self, const std
4747
++p;
4848
} else {
4949
i.second.MutablePortions()[p] = std::move(i.second.MutablePortions().back());
50-
i.second.MutablePortions()[p].ResetShardingVersion();
50+
i.second.MutablePortions()[p]->ResetShardingVersion();
5151
i.second.MutablePortions().pop_back();
5252
}
5353
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ void TSourceCursor::BuildSelection(const std::shared_ptr<IStoragesManager>& stor
1818
ui32 chunksCount = 0;
1919
bool selectMore = true;
2020
for (; itCurrentPath != PortionsForSend.end() && selectMore; ++itCurrentPath) {
21-
std::vector<TPortionInfo> portions;
21+
std::vector<TPortionInfo::TPtr> portions;
2222
for (; itPortion != itCurrentPath->second.end(); ++itPortion) {
2323
selectMore = (count < 10000 && chunksCount < 1000000);
2424
if (!selectMore) {
2525
NextPathId = itCurrentPath->first;
2626
NextPortionId = itPortion->first;
2727
} else {
28-
portions.emplace_back(*itPortion->second);
28+
portions.emplace_back(itPortion->second);
2929
chunksCount += TPortionDataAccessor(portions.back()).GetRecords().size();
3030
chunksCount += TPortionDataAccessor(portions.back()).GetIndexes().size();
3131
++count;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TSharedBlobsManager;
1818

1919
class TSourceCursor {
2020
private:
21-
std::map<ui64, std::map<ui32, std::shared_ptr<TPortionInfo>>> PortionsForSend;
21+
std::map<ui64, std::map<ui32, TPortionInfo::TPtr>> PortionsForSend;
2222
THashMap<ui64, NEvents::TPathIdData> PreviousSelected;
2323
THashMap<ui64, NEvents::TPathIdData> Selected;
2424
THashMap<TTabletId, TTaskForTablet> Links;

ydb/core/tx/columnshard/engines/changes/abstract/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class TColumnEngineChanges {
232232
public:
233233
class IMemoryPredictor {
234234
public:
235-
virtual ui64 AddPortion(const TPortionInfo& portionInfo) = 0;
235+
virtual ui64 AddPortion(const TPortionInfo::TConstPtr& portionInfo) = 0;
236236
virtual ~IMemoryPredictor() = default;
237237
};
238238

0 commit comments

Comments
 (0)