Skip to content

Commit 456c93b

Browse files
authored
Tidy up in heap iterator a little (#6510)
1 parent 483e9ee commit 456c93b

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

ydb/core/blobstorage/vdisk/hulldb/base/hullds_heap_it.h

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#pragma once
2+
23
#include "defs.h"
3-
#include <algorithm>
4-
#include "hullds_ut.h"
5-
#include "hullds_generic_it.h"
6-
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h>
7-
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_idxsnap_it.h>
8-
#include <ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment_impl.h>
9-
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_idxsnap_it.h>
4+
#include <ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment.h>
105
#include <ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_appendix.h>
116
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it.h>
127
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec_it.h>
8+
#include <algorithm>
139

1410
namespace NKikimr {
1511

@@ -146,19 +142,17 @@ namespace NKikimr {
146142
}
147143
}
148144

149-
template<typename TMerger>
150-
void Walk(TKey key, TMerger merger, std::function<bool(const TKey&, TMerger)> callback) {
151-
for (int idx = 0; idx < HeapItems; idx++) {
152-
auto *iter = Heap[idx];
153-
iter->Seek(key);
154-
while (iter->Valid()) {
155-
iter->PutToMerger(&merger);
156-
if (!callback(iter->GetCurKey(), merger)) {
157-
break;
158-
}
159-
merger.Clear();
160-
Move(nullptr);
145+
template<typename TMerger, typename TCallback>
146+
void Walk(TKey key, TMerger merger, TCallback&& callback) {
147+
Seek(key);
148+
while (Valid()) {
149+
const TKey key = GetCurKey();
150+
PutToMergerAndAdvance(merger);
151+
merger->Finish();
152+
if (!callback(key, merger)) {
153+
break;
161154
}
155+
merger->Clear();
162156
}
163157
}
164158

@@ -168,4 +162,4 @@ namespace NKikimr {
168162
}
169163
};
170164

171-
} // NKikimr
165+
} // NKikimr

ydb/core/blobstorage/vdisk/hulldb/base/hullds_heap_it_ut.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include "hullds_heap_it.h"
44
#include "hullds_ut.h"
55
#include <library/cpp/testing/unittest/registar.h>
6+
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_idxsnap_it.h>
67
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it_all_ut.h>
8+
#include <ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h>
79

810
#include <util/stream/null.h>
911

0 commit comments

Comments
 (0)