Coverage Report

Created: 2024-09-08 07:17

/src/rocksdb/db/wide/wide_columns_helper.cc
Line
Count
Source (jump to first uncovered line)
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/wide/wide_columns_helper.h"
7
8
#include <algorithm>
9
#include <ios>
10
11
#include "db/wide/wide_column_serialization.h"
12
13
namespace ROCKSDB_NAMESPACE {
14
void WideColumnsHelper::DumpWideColumns(const WideColumns& columns,
15
0
                                        std::ostream& os, bool hex) {
16
0
  if (columns.empty()) {
17
0
    return;
18
0
  }
19
20
0
  const std::ios_base::fmtflags orig_flags = os.flags();
21
22
0
  if (hex) {
23
0
    os << std::hex;
24
0
  }
25
0
  auto it = columns.begin();
26
0
  os << *it;
27
0
  for (++it; it != columns.end(); ++it) {
28
0
    os << ' ' << *it;
29
0
  }
30
31
0
  os.flags(orig_flags);
32
0
}
33
34
Status WideColumnsHelper::DumpSliceAsWideColumns(const Slice& value,
35
0
                                                 std::ostream& os, bool hex) {
36
0
  WideColumns columns;
37
0
  Slice value_copy = value;
38
0
  const Status s = WideColumnSerialization::Deserialize(value_copy, columns);
39
0
  if (s.ok()) {
40
0
    DumpWideColumns(columns, os, hex);
41
0
  }
42
0
  return s;
43
0
}
44
45
0
void WideColumnsHelper::SortColumns(WideColumns& columns) {
46
0
  std::sort(columns.begin(), columns.end(),
47
0
            [](const WideColumn& lhs, const WideColumn& rhs) {
48
0
              return lhs.name().compare(rhs.name()) < 0;
49
0
            });
50
0
}
51
52
}  // namespace ROCKSDB_NAMESPACE