@@ -89,37 +89,8 @@ void TInsertionSummary::OnEraseInserted(TPathInfo& pathInfo, const ui64 dataSize
89
89
AFL_VERIFY (Counters.Inserted .GetDataSize () == (i64)StatsPrepared.Bytes );
90
90
}
91
91
92
- THashSet<TInsertWriteId> TInsertionSummary::GetInsertedByPathId (const ui64 pathId) const {
93
- THashSet<TInsertWriteId> result;
94
- for (auto & [writeId, data] : Inserted) {
95
- if (data.GetPathId () == pathId) {
96
- result.insert (writeId);
97
- }
98
- }
99
-
100
- return result;
101
- }
102
-
103
92
THashSet<TInsertWriteId> TInsertionSummary::GetExpiredInsertions (const TInstant timeBorder, const ui64 limit) const {
104
- if (timeBorder < MinInsertedTs) {
105
- return {};
106
- }
107
-
108
- THashSet<TInsertWriteId> toAbort;
109
- TInstant newMin = TInstant::Max ();
110
- for (auto & [writeId, data] : Inserted) {
111
- const TInstant dataInsertTs = data.GetMeta ().GetDirtyWriteTime ();
112
- if (data.IsNotAbortable ()) {
113
- continue ;
114
- }
115
- if (dataInsertTs < timeBorder && toAbort.size () < limit) {
116
- toAbort.insert (writeId);
117
- } else {
118
- newMin = Min (newMin, dataInsertTs);
119
- }
120
- }
121
- MinInsertedTs = (toAbort.size () == Inserted.size ()) ? TInstant::Zero () : newMin;
122
- return toAbort;
93
+ return Inserted.GetExpired (timeBorder, limit);
123
94
}
124
95
125
96
bool TInsertionSummary::EraseAborted (const TInsertWriteId writeId) {
@@ -173,33 +144,21 @@ const NKikimr::NOlap::TInsertedData* TInsertionSummary::AddAborted(TInsertedData
173
144
}
174
145
175
146
std::optional<NKikimr::NOlap::TInsertedData> TInsertionSummary::ExtractInserted (const TInsertWriteId id) {
176
- auto it = Inserted.find (id);
177
- if (it == Inserted.end ()) {
178
- return {};
179
- } else {
180
- auto pathInfo = GetPathInfoOptional (it->second .GetPathId ());
147
+ auto result = Inserted.ExtractOptional (id);
148
+ if (result) {
149
+ auto pathInfo = GetPathInfoOptional (result->GetPathId ());
181
150
if (pathInfo) {
182
- OnEraseInserted (*pathInfo, it-> second . BlobSize ());
151
+ OnEraseInserted (*pathInfo, result-> BlobSize ());
183
152
}
184
- std::optional<TInsertedData> result = std::move (it->second );
185
- Inserted.erase (it);
186
- return result;
187
153
}
154
+ return result;
188
155
}
189
156
190
157
const NKikimr::NOlap::TInsertedData* TInsertionSummary::AddInserted (TInsertedData&& data, const bool load /* = false*/ ) {
191
- const TInsertWriteId writeId = data.GetInsertWriteId ();
192
- const ui32 dataSize = data.BlobSize ();
193
- const ui64 pathId = data.GetPathId ();
194
- auto insertInfo = Inserted.emplace (writeId, std::move (data));
195
- AFL_VERIFY_DEBUG (!Aborted.contains (writeId));
196
- if (insertInfo.second ) {
197
- OnNewInserted (GetPathInfo (pathId), dataSize, load);
198
- return &insertInfo.first ->second ;
199
- } else {
200
- Counters.Inserted .SkipAdd (dataSize);
201
- return nullptr ;
202
- }
158
+ auto * insertInfo = Inserted.AddVerified (std::move (data));
159
+ AFL_VERIFY_DEBUG (!Aborted.contains (insertInfo->GetInsertWriteId ()));
160
+ OnNewInserted (GetPathInfo (insertInfo->GetPathId ()), insertInfo->BlobSize (), load);
161
+ return insertInfo;
203
162
}
204
163
205
164
}
0 commit comments