Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks: '-*,clang-diagnostic-*,bugprone-*,performance-*,google-explicit-constructor,google-build-using-namespace,google-runtime-int,misc-definitions-in-headers,modernize-use-nullptr,modernize-use-override,-bugprone-macro-parentheses,readability-braces-around-statements,-bugprone-branch-clone,readability-identifier-naming,hicpp-exception-baseclass,misc-throw-by-value-catch-by-reference,-bugprone-signed-char-misuse,-bugprone-misplaced-widening-cast,-bugprone-sizeof-expression,-bugprone-easily-swappable-parameters,google-global-names-in-headers,llvm-header-guard,misc-definitions-in-headers,modernize-use-emplace,modernize-use-bool-literals,-performance-inefficient-string-concatenation,-performance-no-int-to-ptr,readability-container-size-empty,cppcoreguidelines-pro-type-cstyle-cast,-llvm-header-guard,-performance-enum-size,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-slicing,cppcoreguidelines-rvalue-reference-param-not-moved,cppcoreguidelines-virtual-class-destructor,-readability-identifier-naming,-bugprone-exception-escape,-bugprone-unused-local-non-trivial-variable,-bugprone-empty-catch'
Checks: '-*,clang-diagnostic-*,bugprone-*,performance-*,google-explicit-constructor,google-build-using-namespace,google-runtime-int,misc-definitions-in-headers,modernize-use-nullptr,modernize-use-override,-bugprone-macro-parentheses,readability-braces-around-statements,-bugprone-branch-clone,readability-identifier-naming,hicpp-exception-baseclass,misc-throw-by-value-catch-by-reference,-bugprone-signed-char-misuse,-bugprone-misplaced-widening-cast,-bugprone-sizeof-expression,-bugprone-easily-swappable-parameters,google-global-names-in-headers,llvm-header-guard,misc-definitions-in-headers,modernize-use-emplace,modernize-use-bool-literals,-performance-inefficient-string-concatenation,-performance-no-int-to-ptr,readability-container-size-empty,cppcoreguidelines-pro-type-cstyle-cast,-llvm-header-guard,-performance-enum-size,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-slicing,cppcoreguidelines-rvalue-reference-param-not-moved,cppcoreguidelines-virtual-class-destructor,-readability-identifier-naming,-bugprone-exception-escape,-bugprone-unused-local-non-trivial-variable,-bugprone-empty-catch,-misc-use-internal-linkage,-readability-static-definition-in-anonymous-namespace'
WarningsAsErrors: '*'
HeaderFilterRegex: 'src/include/duckdb/.*'
FormatStyle: none
Expand Down Expand Up @@ -49,4 +49,7 @@ CheckOptions:
value: '::duckdb::shared_ptr;::duckdb::unique_ptr;::std::auto_ptr;::duckdb::weak_ptr'
- key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams
value: true

- key: misc-use-internal-linkage
value: true
- key: readability-static-definition-in-anonymous-namespace
value: true
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/algebraic/avg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace duckdb {

namespace {

template <class T>
struct AvgState {
uint64_t count;
Expand Down Expand Up @@ -275,6 +277,8 @@ unique_ptr<FunctionData> BindDecimalAvg(ClientContext &context, AggregateFunctio
Hugeint::Cast<double>(Hugeint::POWERS_OF_TEN[DecimalType::GetScale(decimal_type)]));
}

} // namespace

AggregateFunctionSet AvgFun::GetFunctions() {
AggregateFunctionSet avg;

Expand Down
12 changes: 8 additions & 4 deletions extension/core_functions/aggregate/distributive/approx_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace duckdb {
// Algorithms from
// "New cardinality estimation algorithms for HyperLogLog sketches"
// Otmar Ertl, arXiv:1702.01284
namespace {

struct ApproxDistinctCountState {
HyperLogLog hll;
};
Expand All @@ -36,8 +38,8 @@ struct ApproxCountDistinctFunction {
}
};

static void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count,
data_ptr_t state, idx_t count) {
void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count, data_ptr_t state,
idx_t count) {
D_ASSERT(input_count == 1);
auto &input = inputs[0];

Expand All @@ -51,8 +53,8 @@ static void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], AggregateIn
agg_state->hll.Update(input, hash_vec, count);
}

static void ApproxCountDistinctUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count,
Vector &state_vector, idx_t count) {
void ApproxCountDistinctUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector,
idx_t count) {
D_ASSERT(input_count == 1);
auto &input = inputs[0];
UnifiedVectorFormat idata;
Expand Down Expand Up @@ -92,6 +94,8 @@ AggregateFunction GetApproxCountDistinctFunction(const LogicalType &input_type)
return fun;
}

} // namespace

AggregateFunction ApproxCountDistinctFun::GetFunction() {
return GetApproxCountDistinctFunction(LogicalType::ANY);
}
Expand Down
26 changes: 15 additions & 11 deletions extension/core_functions/aggregate/distributive/arg_min_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace duckdb {

namespace {

struct ArgMinMaxStateBase {
ArgMinMaxStateBase() : is_initialized(false), arg_null(false) {
}
Expand Down Expand Up @@ -346,7 +348,7 @@ AggregateFunction GetVectorArgMinMaxFunctionBy(const LogicalType &by_type, const
}
#endif

static const vector<LogicalType> ArgMaxByTypes() {
const vector<LogicalType> ArgMaxByTypes() {
vector<LogicalType> types = {LogicalType::INTEGER, LogicalType::BIGINT, LogicalType::HUGEINT,
LogicalType::DOUBLE, LogicalType::VARCHAR, LogicalType::DATE,
LogicalType::TIMESTAMP, LogicalType::TIMESTAMP_TZ, LogicalType::BLOB};
Expand Down Expand Up @@ -417,7 +419,7 @@ void AddArgMinMaxFunctionBy(AggregateFunctionSet &fun, const LogicalType &type)
}

template <class OP>
static AggregateFunction GetDecimalArgMinMaxFunction(const LogicalType &by_type, const LogicalType &type) {
AggregateFunction GetDecimalArgMinMaxFunction(const LogicalType &by_type, const LogicalType &type) {
D_ASSERT(type.id() == LogicalTypeId::DECIMAL);
#ifndef DUCKDB_SMALLER_BINARY
switch (type.InternalType()) {
Expand All @@ -436,8 +438,8 @@ static AggregateFunction GetDecimalArgMinMaxFunction(const LogicalType &by_type,
}

template <class OP>
static unique_ptr<FunctionData> BindDecimalArgMinMax(ClientContext &context, AggregateFunction &function,
vector<unique_ptr<Expression>> &arguments) {
unique_ptr<FunctionData> BindDecimalArgMinMax(ClientContext &context, AggregateFunction &function,
vector<unique_ptr<Expression>> &arguments) {
auto decimal_type = arguments[0]->return_type;
auto by_type = arguments[1]->return_type;

Expand Down Expand Up @@ -485,7 +487,7 @@ void AddGenericArgMinMaxFunction(AggregateFunctionSet &fun) {
}

template <class COMPARATOR, bool IGNORE_NULL, OrderType ORDER_TYPE>
static void AddArgMinMaxFunctions(AggregateFunctionSet &fun) {
void AddArgMinMaxFunctions(AggregateFunctionSet &fun) {
using GENERIC_VECTOR_OP = VectorArgMinMaxBase<LessThan, IGNORE_NULL, ORDER_TYPE, GenericArgMinMaxState<ORDER_TYPE>>;
#ifndef DUCKDB_SMALLER_BINARY
using OP = ArgMinMaxBase<COMPARATOR, IGNORE_NULL>;
Expand Down Expand Up @@ -543,8 +545,8 @@ class ArgMinMaxNState {
// Operation
//------------------------------------------------------------------------------
template <class STATE>
static void ArgMinMaxNUpdate(Vector inputs[], AggregateInputData &aggr_input, idx_t input_count, Vector &state_vector,
idx_t count) {
void ArgMinMaxNUpdate(Vector inputs[], AggregateInputData &aggr_input, idx_t input_count, Vector &state_vector,
idx_t count) {

auto &val_vector = inputs[0];
auto &arg_vector = inputs[1];
Expand Down Expand Up @@ -604,7 +606,7 @@ static void ArgMinMaxNUpdate(Vector inputs[], AggregateInputData &aggr_input, id
// Bind
//------------------------------------------------------------------------------
template <class VAL_TYPE, class ARG_TYPE, class COMPARATOR>
static void SpecializeArgMinMaxNFunction(AggregateFunction &function) {
void SpecializeArgMinMaxNFunction(AggregateFunction &function) {
using STATE = ArgMinMaxNState<VAL_TYPE, ARG_TYPE, COMPARATOR>;
using OP = MinMaxNOperation;

Expand All @@ -618,7 +620,7 @@ static void SpecializeArgMinMaxNFunction(AggregateFunction &function) {
}

template <class VAL_TYPE, class COMPARATOR>
static void SpecializeArgMinMaxNFunction(PhysicalType arg_type, AggregateFunction &function) {
void SpecializeArgMinMaxNFunction(PhysicalType arg_type, AggregateFunction &function) {
switch (arg_type) {
#ifndef DUCKDB_SMALLER_BINARY
case PhysicalType::VARCHAR:
Expand All @@ -644,7 +646,7 @@ static void SpecializeArgMinMaxNFunction(PhysicalType arg_type, AggregateFunctio
}

template <class COMPARATOR>
static void SpecializeArgMinMaxNFunction(PhysicalType val_type, PhysicalType arg_type, AggregateFunction &function) {
void SpecializeArgMinMaxNFunction(PhysicalType val_type, PhysicalType arg_type, AggregateFunction &function) {
switch (val_type) {
#ifndef DUCKDB_SMALLER_BINARY
case PhysicalType::VARCHAR:
Expand Down Expand Up @@ -689,14 +691,16 @@ unique_ptr<FunctionData> ArgMinMaxNBind(ClientContext &context, AggregateFunctio
}

template <class COMPARATOR>
static void AddArgMinMaxNFunction(AggregateFunctionSet &set) {
void AddArgMinMaxNFunction(AggregateFunctionSet &set) {
AggregateFunction function({LogicalTypeId::ANY, LogicalTypeId::ANY, LogicalType::BIGINT},
LogicalType::LIST(LogicalType::ANY), nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, ArgMinMaxNBind<COMPARATOR>);

return set.AddFunction(function);
}

} // namespace

//------------------------------------------------------------------------------
// Function Registration
//------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion extension/core_functions/aggregate/distributive/bitagg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace duckdb {

namespace {

template <class T>
struct BitState {
using TYPE = T;
Expand All @@ -16,7 +18,7 @@ struct BitState {
};

template <class OP>
static AggregateFunction GetBitfieldUnaryAggregate(LogicalType type) {
AggregateFunction GetBitfieldUnaryAggregate(LogicalType type) {
switch (type.id()) {
case LogicalTypeId::TINYINT:
return AggregateFunction::UnaryAggregate<BitState<uint8_t>, int8_t, int8_t, OP>(type, type);
Expand Down Expand Up @@ -194,6 +196,8 @@ struct BitStringXorOperation : public BitStringBitwiseOperation {
}
};

} // namespace

AggregateFunctionSet BitAndFun::GetFunctions() {
AggregateFunctionSet bit_and;
for (auto &type : LogicalType::Integral()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace duckdb {

namespace {

template <class INPUT_TYPE>
struct BitAggState {
bool is_set;
Expand Down Expand Up @@ -258,7 +260,7 @@ unique_ptr<FunctionData> BindBitstringAgg(ClientContext &context, AggregateFunct
}

template <class TYPE>
static void BindBitString(AggregateFunctionSet &bitstring_agg, const LogicalTypeId &type) {
void BindBitString(AggregateFunctionSet &bitstring_agg, const LogicalTypeId &type) {
auto function =
AggregateFunction::UnaryAggregateDestructor<BitAggState<TYPE>, TYPE, string_t, BitStringAggOperation>(
type, LogicalType::BIT);
Expand Down Expand Up @@ -309,6 +311,8 @@ void GetBitStringAggregate(const LogicalType &type, AggregateFunctionSet &bitstr
}
}

} // namespace

AggregateFunctionSet BitstringAggFun::GetFunctions() {
AggregateFunctionSet bitstring_agg("bitstring_agg");
for (auto &type : LogicalType::Integral()) {
Expand Down
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/distributive/bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace duckdb {

namespace {

struct BoolState {
bool empty;
bool val;
Expand Down Expand Up @@ -91,6 +93,8 @@ struct BoolOrFunFunction {
}
};

} // namespace

AggregateFunction BoolOrFun::GetFunction() {
auto fun = AggregateFunction::UnaryAggregate<BoolState, bool, bool, BoolOrFunFunction>(
LogicalType(LogicalTypeId::BOOLEAN), LogicalType::BOOLEAN);
Expand Down
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/distributive/kurtosis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace duckdb {

namespace {

struct KurtosisState {
idx_t n;
double sum;
Expand Down Expand Up @@ -98,6 +100,8 @@ struct KurtosisOperation {
}
};

} // namespace

AggregateFunction KurtosisFun::GetFunction() {
auto result =
AggregateFunction::UnaryAggregate<KurtosisState, double, double, KurtosisOperation<KurtosisFlagBiasCorrection>>(
Expand Down
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/distributive/product.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace duckdb {

namespace {

struct ProductState {
bool empty;
double val;
Expand Down Expand Up @@ -53,6 +55,8 @@ struct ProductFunction {
}
};

} // namespace

AggregateFunction ProductFun::GetFunction() {
return AggregateFunction::UnaryAggregate<ProductState, double, double, ProductFunction>(
LogicalType(LogicalTypeId::DOUBLE), LogicalType::DOUBLE);
Expand Down
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/distributive/skew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace duckdb {

namespace {

struct SkewState {
size_t n;
double sum;
Expand Down Expand Up @@ -78,6 +80,8 @@ struct SkewnessOperation {
}
};

} // namespace

AggregateFunction SkewnessFun::GetFunction() {
return AggregateFunction::UnaryAggregate<SkewState, double, double, SkewnessOperation>(LogicalType::DOUBLE,
LogicalType::DOUBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace duckdb {

namespace {

struct StringAggState {
idx_t size;
idx_t alloc_size;
Expand Down Expand Up @@ -135,8 +137,8 @@ unique_ptr<FunctionData> StringAggBind(ClientContext &context, AggregateFunction
return make_uniq<StringAggBindData>(std::move(separator_string));
}

static void StringAggSerialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
const AggregateFunction &function) {
void StringAggSerialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
const AggregateFunction &function) {
auto bind_data = bind_data_p->Cast<StringAggBindData>();
serializer.WriteProperty(100, "separator", bind_data.sep);
}
Expand All @@ -146,6 +148,8 @@ unique_ptr<FunctionData> StringAggDeserialize(Deserializer &deserializer, Aggreg
return make_uniq<StringAggBindData>(std::move(sep));
}

} // namespace

AggregateFunctionSet StringAggFun::GetFunctions() {
AggregateFunctionSet string_agg;
AggregateFunction string_agg_param(
Expand Down
4 changes: 4 additions & 0 deletions extension/core_functions/aggregate/distributive/sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace duckdb {

namespace {

struct SumSetOperation {
template <class STATE>
static void Initialize(STATE &state) {
Expand Down Expand Up @@ -209,6 +211,8 @@ unique_ptr<FunctionData> BindDecimalSum(ClientContext &context, AggregateFunctio
return nullptr;
}

} // namespace

AggregateFunctionSet SumFun::GetFunctions() {
AggregateFunctionSet sum;
// decimal
Expand Down
10 changes: 7 additions & 3 deletions extension/core_functions/aggregate/holistic/approx_top_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace duckdb {

namespace {

struct ApproxTopKString {
ApproxTopKString() : str(UINT32_C(0)), hash(0) {
}
Expand Down Expand Up @@ -313,8 +315,8 @@ struct ApproxTopKOperation {
};

template <class T = string_t, class OP = HistogramGenericFunctor>
static void ApproxTopKUpdate(Vector inputs[], AggregateInputData &aggr_input, idx_t input_count, Vector &state_vector,
idx_t count) {
void ApproxTopKUpdate(Vector inputs[], AggregateInputData &aggr_input, idx_t input_count, Vector &state_vector,
idx_t count) {
using STATE = ApproxTopKState;
auto &input = inputs[0];
UnifiedVectorFormat sdata;
Expand All @@ -339,7 +341,7 @@ static void ApproxTopKUpdate(Vector inputs[], AggregateInputData &aggr_input, id
}

template <class OP = HistogramGenericFunctor>
static void ApproxTopKFinalize(Vector &state_vector, AggregateInputData &, Vector &result, idx_t count, idx_t offset) {
void ApproxTopKFinalize(Vector &state_vector, AggregateInputData &, Vector &result, idx_t count, idx_t offset) {
UnifiedVectorFormat sdata;
state_vector.ToUnifiedFormat(count, sdata);
auto states = UnifiedVectorFormat::GetData<ApproxTopKState *>(sdata);
Expand Down Expand Up @@ -400,6 +402,8 @@ unique_ptr<FunctionData> ApproxTopKBind(ClientContext &context, AggregateFunctio
return nullptr;
}

} // namespace

AggregateFunction ApproxTopKFun::GetFunction() {
using STATE = ApproxTopKState;
using OP = ApproxTopKOperation;
Expand Down
Loading
Loading