Coverage Report

Created: 2026-03-31 07:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/duckdb/src/parser/parsed_data/sample_options.cpp
Line
Count
Source
1
#include "duckdb/parser/parsed_data/sample_options.hpp"
2
#include "duckdb/common/enum_util.hpp"
3
#include "duckdb/common/to_string.hpp"
4
5
namespace duckdb {
6
7
// **DEPRECATED**: Use EnumUtil directly instead.
8
0
string SampleMethodToString(SampleMethod method) {
9
0
  return EnumUtil::ToString(method);
10
0
}
11
12
654
SampleOptions::SampleOptions(int64_t seed_) {
13
654
  repeatable = false;
14
654
  if (seed_ >= 0) {
15
0
    seed = static_cast<idx_t>(seed_);
16
0
  }
17
654
  sample_size = 0;
18
654
  is_percentage = false;
19
654
  method = SampleMethod::INVALID;
20
654
}
21
22
468
unique_ptr<SampleOptions> SampleOptions::Copy() {
23
468
  auto result = make_uniq<SampleOptions>();
24
468
  result->sample_size = sample_size;
25
468
  result->is_percentage = is_percentage;
26
468
  result->method = method;
27
468
  result->seed = seed;
28
468
  result->repeatable = repeatable;
29
468
  return result;
30
468
}
31
32
0
void SampleOptions::SetSeed(idx_t new_seed) {
33
0
  seed = new_seed;
34
0
}
35
36
589k
bool SampleOptions::Equals(SampleOptions *a, SampleOptions *b) {
37
589k
  if (a == b) {
38
589k
    return true;
39
589k
  }
40
473
  if (!a || !b) {
41
18
    return false;
42
18
  }
43
  // if only one is valid, they are not equal
44
455
  if (a->seed.IsValid() != b->seed.IsValid()) {
45
0
    return false;
46
0
  }
47
  // if both are invalid, then they are technically the same
48
455
  if (!a->seed.IsValid() && !b->seed.IsValid()) {
49
455
    return true;
50
455
  }
51
0
  if (a->sample_size != b->sample_size || a->is_percentage != b->is_percentage || a->method != b->method ||
52
0
      a->seed.GetIndex() != b->seed.GetIndex()) {
53
0
    return false;
54
0
  }
55
0
  return true;
56
0
}
57
58
78
int64_t SampleOptions::GetSeed() const {
59
78
  if (seed.IsValid()) {
60
0
    return static_cast<int64_t>(seed.GetIndex());
61
0
  }
62
78
  return -1;
63
78
}
64
65
} // namespace duckdb