Coverage Report

Created: 2025-10-26 07:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/db/coalescing_iterator.cc
Line
Count
Source
1
//  Copyright (c) Meta Platforms, Inc. and affiliates.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
6
#include "db/coalescing_iterator.h"
7
8
#include "db/wide/wide_columns_helper.h"
9
10
namespace ROCKSDB_NAMESPACE {
11
12
void CoalescingIterator::Coalesce(
13
0
    const autovector<MultiCfIteratorInfo>& items) {
14
0
  assert(wide_columns_.empty());
15
0
  MinHeap heap;
16
0
  for (const auto& item : items) {
17
0
    assert(item.iterator);
18
0
    for (auto& column : item.iterator->columns()) {
19
0
      heap.push(WideColumnWithOrder{&column, item.order});
20
0
    }
21
0
  }
22
0
  if (heap.empty()) {
23
0
    return;
24
0
  }
25
0
  wide_columns_.reserve(heap.size());
26
0
  auto current = heap.top();
27
0
  heap.pop();
28
0
  while (!heap.empty()) {
29
0
    int comparison = current.column->name().compare(heap.top().column->name());
30
0
    if (comparison < 0) {
31
0
      wide_columns_.push_back(*current.column);
32
0
    } else if (comparison > 0) {
33
      // Shouldn't reach here.
34
      // Current item in the heap is greater than the top item in the min heap
35
0
      assert(false);
36
0
    }
37
0
    current = heap.top();
38
0
    heap.pop();
39
0
  }
40
0
  wide_columns_.push_back(*current.column);
41
42
0
  if (WideColumnsHelper::HasDefaultColumn(wide_columns_)) {
43
0
    value_ = WideColumnsHelper::GetDefaultColumn(wide_columns_);
44
0
  }
45
0
}
46
47
}  // namespace ROCKSDB_NAMESPACE