Skip to content

Commit ba9f646

Browse files
committed
Tidy fixes
1 parent 395bb7c commit ba9f646

File tree

9 files changed

+55
-13
lines changed

9 files changed

+55
-13
lines changed

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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-narrowing-conversions,-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,readability-container-size-empty'
1+
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-narrowing-conversions,-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'
22
WarningsAsErrors: '*'
33
HeaderFilterRegex: '.*^(re2.h)'
44
AnalyzeTemporaryDtors: false

src/common/types/value.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,36 @@ Value::Value(string val) : type_(LogicalType::VARCHAR), is_null(false), str_valu
7272
Value::~Value() {
7373
}
7474

75+
Value::Value(const Value &other)
76+
: type_(other.type_), is_null(other.is_null), value_(other.value_), str_value(other.str_value),
77+
struct_value(other.struct_value), list_value(other.list_value) {
78+
}
79+
80+
Value::Value(Value &&other) noexcept
81+
: type_(move(other.type_)), is_null(other.is_null), value_(other.value_), str_value(move(other.str_value)),
82+
struct_value(move(other.struct_value)), list_value(move(other.list_value)) {
83+
}
84+
85+
Value &Value::operator=(const Value &other) {
86+
type_ = other.type_;
87+
is_null = other.is_null;
88+
value_ = other.value_;
89+
str_value = other.str_value;
90+
struct_value = other.struct_value;
91+
list_value = other.list_value;
92+
return *this;
93+
}
94+
95+
Value &Value::operator=(Value &&other) noexcept {
96+
type_ = move(other.type_);
97+
is_null = other.is_null;
98+
value_ = other.value_;
99+
str_value = move(other.str_value);
100+
struct_value = move(other.struct_value);
101+
list_value = move(other.list_value);
102+
return *this;
103+
}
104+
75105
Value Value::MinimumValue(const LogicalType &type) {
76106
switch (type.id()) {
77107
case LogicalTypeId::BOOLEAN:

src/common/types/vector.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@ vector<idx_t> ListVector::Search(Vector &list, const Value &key, idx_t row) {
14591459
Value ListVector::GetValuesFromOffsets(Vector &list, vector<idx_t> &offsets) {
14601460
auto &child_vec = ListVector::GetEntry(list);
14611461
vector<Value> list_values;
1462+
list_values.reserve(offsets.size());
14621463
for (auto &offset : offsets) {
14631464
list_values.push_back(child_vec.GetValue(offset));
14641465
}

src/function/table/arrow.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,12 @@ unique_ptr<FunctionData> ArrowTableFunction::ArrowScanBind(ClientContext &contex
165165
vector<LogicalType> &input_table_types,
166166
vector<string> &input_table_names,
167167
vector<LogicalType> &return_types, vector<string> &names) {
168-
auto stream_factory_ptr = inputs[0].GetPointer();
169-
unique_ptr<ArrowArrayStreamWrapper> (*stream_factory_produce)(
168+
typedef unique_ptr<ArrowArrayStreamWrapper> (*stream_factory_produce_t)(
170169
uintptr_t stream_factory_ptr,
171170
std::pair<std::unordered_map<idx_t, string>, std::vector<string>> & project_columns,
172-
TableFilterCollection * filters) =
173-
(unique_ptr<ArrowArrayStreamWrapper>(*)(uintptr_t stream_factory_ptr,
174-
std::pair<std::unordered_map<idx_t, string>, std::vector<string>> &
175-
project_columns,
176-
TableFilterCollection * filters)) inputs[1]
177-
.GetPointer();
171+
TableFilterCollection * filters);
172+
auto stream_factory_ptr = inputs[0].GetPointer();
173+
auto stream_factory_produce = (stream_factory_produce_t)inputs[1].GetPointer();
178174
auto rows_per_thread = inputs[2].GetValue<uint64_t>();
179175
std::pair<std::unordered_map<idx_t, string>, std::vector<string>> project_columns;
180176
#ifndef DUCKDB_NO_THREADS

src/include/duckdb/common/types.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ struct LogicalType {
398398
return *this;
399399
}
400400
// move assignment
401-
inline LogicalType& operator=(LogicalType&& other) {
401+
inline LogicalType& operator=(LogicalType&& other) noexcept {
402402
id_ = other.id_;
403403
physical_type_ = other.physical_type_;
404404
type_info_ = move(other.type_info_);

src/include/duckdb/common/types/value.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ class Value {
4444
DUCKDB_API Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
4545
//! Create a VARCHAR value
4646
DUCKDB_API Value(string val); // NOLINT: Allow implicit conversion from `string`
47+
//! Copy constructor
48+
DUCKDB_API Value(const Value &other);
49+
//! Move constructor
50+
DUCKDB_API Value(Value &&other) noexcept;
4751
//! Destructor
4852
DUCKDB_API ~Value();
4953

54+
// copy assignment
55+
DUCKDB_API Value &operator=(const Value &other);
56+
// move assignment
57+
DUCKDB_API Value &operator=(Value &&other) noexcept;
58+
5059
inline const LogicalType &type() const {
5160
return type_;
5261
}

src/storage/meta_block_writer.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ MetaBlockWriter::MetaBlockWriter(DatabaseInstance &db, block_id_t initial_block_
1515
}
1616

1717
MetaBlockWriter::~MetaBlockWriter() {
18-
Flush();
18+
if (Exception::UncaughtException()) {
19+
return;
20+
}
21+
try {
22+
Flush();
23+
} catch (...) {
24+
}
1925
}
2026

2127
block_id_t MetaBlockWriter::GetNextBlockId() {

tools/pythonpkg/src/include/duckdb_python/pyresult.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct DuckDBPyResult {
5050

5151
void Close();
5252

53-
static py::object GetValueToPython(Value &val, const LogicalType &type);
53+
static py::object GetValueToPython(const Value &val, const LogicalType &type);
5454

5555
private:
5656
void FillNumpy(py::dict &res, idx_t col_idx, NumpyResultConversion &conversion, const char *name);

tools/pythonpkg/src/pyresult.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void DuckDBPyResult::Initialize(py::handle &m) {
3333
PyDateTime_IMPORT;
3434
}
3535

36-
py::object DuckDBPyResult::GetValueToPython(Value &val, const LogicalType &type) {
36+
py::object DuckDBPyResult::GetValueToPython(const Value &val, const LogicalType &type) {
3737
if (val.IsNull()) {
3838
return py::none();
3939
}

0 commit comments

Comments
 (0)