Coverage Report

Created: 2026-09-28 07:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/db/compaction/compaction_state.cc
Line
Count
Source
1
//  Copyright (c) Meta Platforms, Inc. and affiliates.
2
//
3
//  This source code is licensed under both the GPLv2 (found in the
4
//  COPYING file in the root directory) and Apache 2.0 License
5
//  (found in the LICENSE.Apache file in the root directory).
6
//
7
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
8
// Use of this source code is governed by a BSD-style license that can be
9
// found in the LICENSE file. See the AUTHORS file for names of contributors.
10
11
#include "db/compaction/compaction_state.h"
12
13
namespace ROCKSDB_NAMESPACE {
14
15
1.71k
Slice CompactionState::SmallestUserKey() {
16
1.71k
  for (const auto& sub_compact_state : sub_compact_states) {
17
1.71k
    Slice smallest = sub_compact_state.SmallestUserKey();
18
1.71k
    if (!smallest.empty()) {
19
435
      return smallest;
20
435
    }
21
1.71k
  }
22
  // If there is no finished output, return an empty slice.
23
1.28k
  return Slice{nullptr, 0};
24
1.71k
}
25
26
1.71k
Slice CompactionState::LargestUserKey() {
27
2.72k
  for (auto it = sub_compact_states.rbegin(); it < sub_compact_states.rend();
28
1.71k
       ++it) {
29
1.71k
    Slice largest = it->LargestUserKey();
30
1.71k
    if (!largest.empty()) {
31
713
      return largest;
32
713
    }
33
1.71k
  }
34
  // If there is no finished output, return an empty slice.
35
1.00k
  return Slice{nullptr, 0};
36
1.71k
}
37
38
void CompactionState::AggregateCompactionStats(
39
    InternalStats::CompactionStatsFull& internal_stats,
40
5.12k
    CompactionJobStats& job_stats) {
41
5.12k
  for (const auto& sc : sub_compact_states) {
42
5.12k
    sc.AggregateCompactionOutputStats(internal_stats);
43
5.12k
    job_stats.Add(sc.compaction_job_stats);
44
5.12k
  }
45
5.12k
}
46
}  // namespace ROCKSDB_NAMESPACE