Skip to content

Commit 659d634

Browse files
authored
[BUG] fix some extra memory in bitmap operate (#5857)
1 parent 591d391 commit 659d634

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

be/src/util/bitmap_value.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Roaring64Map {
316316
}
317317
return std::accumulate(
318318
roarings.cbegin(), roarings.cend(), (uint64_t)0,
319-
[](uint64_t previous, const std::pair<uint32_t, Roaring>& map_entry) {
319+
[](uint64_t previous, const std::pair<const uint32_t, Roaring>& map_entry) {
320320
return previous + map_entry.second.cardinality();
321321
});
322322
}
@@ -326,7 +326,7 @@ class Roaring64Map {
326326
*/
327327
bool isEmpty() const {
328328
return std::all_of(roarings.cbegin(), roarings.cend(),
329-
[](const std::pair<uint32_t, Roaring>& map_entry) {
329+
[](const std::pair<const uint32_t, Roaring>& map_entry) {
330330
return map_entry.second.isEmpty();
331331
});
332332
}
@@ -341,7 +341,7 @@ class Roaring64Map {
341341
// to avoid a clash with the Windows.h header under Windows
342342
return roarings.size() == ((size_t)(std::numeric_limits<uint32_t>::max)()) + 1
343343
? std::all_of(roarings.cbegin(), roarings.cend(),
344-
[](const std::pair<uint32_t, Roaring>& roaring_map_entry) {
344+
[](const std::pair<const uint32_t, Roaring>& roaring_map_entry) {
345345
// roarings within map are saturated if cardinality
346346
// is uint32_t max + 1
347347
return roaring_map_entry.second.cardinality() ==
@@ -384,7 +384,7 @@ class Roaring64Map {
384384
// Annoyingly, VS 2017 marks std::accumulate() as [[nodiscard]]
385385
(void)std::accumulate(
386386
roarings.cbegin(), roarings.cend(), ans,
387-
[](uint64_t* previous, const std::pair<uint32_t, Roaring>& map_entry) {
387+
[](uint64_t* previous, const std::pair<const uint32_t, Roaring>& map_entry) {
388388
for (uint32_t low_bits : map_entry.second)
389389
*previous++ = uniteBytes(map_entry.first, low_bits);
390390
return previous;
@@ -527,7 +527,7 @@ class Roaring64Map {
527527
*/
528528
void iterate(roaring_iterator64 iterator, void* ptr) const {
529529
std::for_each(roarings.begin(), roarings.cend(),
530-
[=](const std::pair<uint32_t, Roaring>& map_entry) {
530+
[=](const std::pair<const uint32_t, Roaring>& map_entry) {
531531
roaring_iterate64(&map_entry.second.roaring, iterator,
532532
uint64_t(map_entry.first) << 32, ptr);
533533
});
@@ -595,7 +595,7 @@ class Roaring64Map {
595595
// push map size
596596
buf = (char*)encode_varint64((uint8_t*)buf, roarings.size());
597597
std::for_each(roarings.cbegin(), roarings.cend(),
598-
[&buf](const std::pair<uint32_t, Roaring>& map_entry) {
598+
[&buf](const std::pair<const uint32_t, Roaring>& map_entry) {
599599
// push map key
600600
encode_fixed32_le((uint8_t*)buf, map_entry.first);
601601
buf += sizeof(uint32_t);
@@ -657,7 +657,7 @@ class Roaring64Map {
657657
// start with type code, map size and size of keys for each map entry
658658
size_t init = 1 + varint_length(roarings.size()) + roarings.size() * sizeof(uint32_t);
659659
return std::accumulate(roarings.cbegin(), roarings.cend(), init,
660-
[=](size_t previous, const std::pair<uint32_t, Roaring>& map_entry) {
660+
[=](size_t previous, const std::pair<const uint32_t, Roaring>& map_entry) {
661661
// add in bytes used by each Roaring
662662
return previous + map_entry.second.getSizeInBytes();
663663
});
@@ -731,7 +731,7 @@ class Roaring64Map {
731731
},
732732
(void*)&outer_iter_data);
733733
std::for_each(
734-
++map_iter, roarings.cend(), [](const std::pair<uint32_t, Roaring>& map_entry) {
734+
++map_iter, roarings.cend(), [](const std::pair<const uint32_t, Roaring>& map_entry) {
735735
map_entry.second.iterate(
736736
[](uint32_t low_bits, void* high_bits) -> bool {
737737
std::printf(",%llu", (long long unsigned)uniteBytes(
@@ -770,7 +770,7 @@ class Roaring64Map {
770770
(void*)&outer_iter_data);
771771
std::for_each(
772772
++map_iter, roarings.cend(),
773-
[&outer_iter_data](const std::pair<uint32_t, Roaring>& map_entry) {
773+
[&outer_iter_data](const std::pair<const uint32_t, Roaring>& map_entry) {
774774
outer_iter_data.high_bits = map_entry.first;
775775
map_entry.second.iterate(
776776
[](uint32_t low_bits, void* inner_iter_data) -> bool {

contrib/udf/src/udaf_orthogonal_bitmap/bitmap_value.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class Roaring64Map {
390390
}
391391
return std::accumulate(
392392
roarings.cbegin(), roarings.cend(), (uint64_t)0,
393-
[](uint64_t previous, const std::pair<uint32_t, Roaring>& map_entry) {
393+
[](uint64_t previous, const std::pair<const uint32_t, Roaring>& map_entry) {
394394
return previous + map_entry.second.cardinality();
395395
});
396396
}
@@ -400,7 +400,7 @@ class Roaring64Map {
400400
*/
401401
bool isEmpty() const {
402402
return std::all_of(roarings.cbegin(), roarings.cend(),
403-
[](const std::pair<uint32_t, Roaring>& map_entry) {
403+
[](const std::pair<const uint32_t, Roaring>& map_entry) {
404404
return map_entry.second.isEmpty();
405405
});
406406
}
@@ -415,7 +415,7 @@ class Roaring64Map {
415415
// to avoid a clash with the Windows.h header under Windows
416416
return roarings.size() == ((size_t)(std::numeric_limits<uint32_t>::max)()) + 1
417417
? std::all_of(roarings.cbegin(), roarings.cend(),
418-
[](const std::pair<uint32_t, Roaring>& roaring_map_entry) {
418+
[](const std::pair<const uint32_t, Roaring>& roaring_map_entry) {
419419
// roarings within map are saturated if cardinality
420420
// is uint32_t max + 1
421421
return roaring_map_entry.second.cardinality() ==
@@ -458,7 +458,7 @@ class Roaring64Map {
458458
// Annoyingly, VS 2017 marks std::accumulate() as [[nodiscard]]
459459
(void)std::accumulate(
460460
roarings.cbegin(), roarings.cend(), ans,
461-
[](uint64_t* previous, const std::pair<uint32_t, Roaring>& map_entry) {
461+
[](uint64_t* previous, const std::pair<const uint32_t, Roaring>& map_entry) {
462462
for (uint32_t low_bits : map_entry.second)
463463
*previous++ = uniteBytes(map_entry.first, low_bits);
464464
return previous;
@@ -601,7 +601,7 @@ class Roaring64Map {
601601
*/
602602
void iterate(roaring_iterator64 iterator, void* ptr) const {
603603
std::for_each(roarings.begin(), roarings.cend(),
604-
[=](const std::pair<uint32_t, Roaring>& map_entry) {
604+
[=](const std::pair<const uint32_t, Roaring>& map_entry) {
605605
roaring_iterate64(&map_entry.second.roaring, iterator,
606606
uint64_t(map_entry.first) << 32, ptr);
607607
});
@@ -669,7 +669,7 @@ class Roaring64Map {
669669
// push map size
670670
buf = (char*)encode_varint64((uint8_t*)buf, roarings.size());
671671
std::for_each(roarings.cbegin(), roarings.cend(),
672-
[&buf](const std::pair<uint32_t, Roaring>& map_entry) {
672+
[&buf](const std::pair<const uint32_t, Roaring>& map_entry) {
673673
// push map key
674674
encode_fixed32_le((uint8_t*)buf, map_entry.first);
675675
buf += sizeof(uint32_t);
@@ -731,7 +731,7 @@ class Roaring64Map {
731731
// start with type code, map size and size of keys for each map entry
732732
size_t init = 1 + varint_length(roarings.size()) + roarings.size() * sizeof(uint32_t);
733733
return std::accumulate(roarings.cbegin(), roarings.cend(), init,
734-
[=](size_t previous, const std::pair<uint32_t, Roaring>& map_entry) {
734+
[=](size_t previous, const std::pair<const uint32_t, Roaring>& map_entry) {
735735
// add in bytes used by each Roaring
736736
return previous + map_entry.second.getSizeInBytes();
737737
});
@@ -805,7 +805,7 @@ class Roaring64Map {
805805
},
806806
(void*)&outer_iter_data);
807807
std::for_each(
808-
++map_iter, roarings.cend(), [](const std::pair<uint32_t, Roaring>& map_entry) {
808+
++map_iter, roarings.cend(), [](const std::pair<const uint32_t, Roaring>& map_entry) {
809809
map_entry.second.iterate(
810810
[](uint32_t low_bits, void* high_bits) -> bool {
811811
std::printf(",%llu", (long long unsigned)uniteBytes(
@@ -844,7 +844,7 @@ class Roaring64Map {
844844
(void*)&outer_iter_data);
845845
std::for_each(
846846
++map_iter, roarings.cend(),
847-
[&outer_iter_data](const std::pair<uint32_t, Roaring>& map_entry) {
847+
[&outer_iter_data](const std::pair<const uint32_t, Roaring>& map_entry) {
848848
outer_iter_data.high_bits = map_entry.first;
849849
map_entry.second.iterate(
850850
[](uint32_t low_bits, void* inner_iter_data) -> bool {

0 commit comments

Comments
 (0)