diff --git a/src/common/assert.cpp b/src/common/assert.cpp index 799ba0e52f..6bb6a24d67 100644 --- a/src/common/assert.cpp +++ b/src/common/assert.cpp @@ -2,18 +2,16 @@ #include "common/exception/internal.h" #include "common/string_format.h" -#include "common/utils.h" namespace kuzu { namespace common { -void kuAssertInternal(bool condition, const char* condition_name, const char* file, int linenr) { - if (!condition) { - // LCOV_EXCL_START - throw InternalException(stringFormat( - "Assertion triggered in file \"{}\" on line {}: {}", file, linenr, condition_name)); - // LCOV_EXCL_END - } +[[noreturn]] void kuAssertFailureInternal( + const char* condition_name, const char* file, int linenr) { + // LCOV_EXCL_START + throw InternalException(stringFormat( + "Assertion failed in file \"{}\" on line {}: {}", file, linenr, condition_name)); + // LCOV_EXCL_END } } // namespace common diff --git a/src/common/types/types.cpp b/src/common/types/types.cpp index 0be88c2dd7..bd2b701709 100644 --- a/src/common/types/types.cpp +++ b/src/common/types/types.cpp @@ -781,6 +781,9 @@ std::vector LogicalTypeUtils::parseStructFields(const std::string& startPos = curPos + 1; } } break; + default: { + // Normal character, continue. + } } curPos++; } diff --git a/src/include/common/assert.h b/src/include/common/assert.h index 9187838d8b..f80f8fd924 100644 --- a/src/include/common/assert.h +++ b/src/include/common/assert.h @@ -2,9 +2,12 @@ namespace kuzu { namespace common { -void kuAssertInternal(bool condition, const char* condition_name, const char* file, int linenr); +[[noreturn]] void kuAssertFailureInternal(const char* condition_name, const char* file, int linenr); #define KU_ASSERT(condition) \ - kuzu::common::kuAssertInternal(bool(condition), #condition, __FILE__, __LINE__) + if (!(condition)) { \ + [[unlikely]] kuzu::common::kuAssertFailureInternal(#condition, __FILE__, __LINE__); \ + } + } // namespace common } // namespace kuzu diff --git a/src/include/processor/operator/persistent/delete_executor.h b/src/include/processor/operator/persistent/delete_executor.h index b921f83839..3f8364bc6e 100644 --- a/src/include/processor/operator/persistent/delete_executor.h +++ b/src/include/processor/operator/persistent/delete_executor.h @@ -9,7 +9,7 @@ namespace processor { class NodeDeleteExecutor { public: - NodeDeleteExecutor(const DataPos& nodeIDPos) : nodeIDPos{nodeIDPos} {} + NodeDeleteExecutor(const DataPos& nodeIDPos) : nodeIDPos{nodeIDPos}, nodeIDVector(nullptr) {} virtual ~NodeDeleteExecutor() = default; virtual void init(ResultSet* resultSet, ExecutionContext* context); @@ -67,7 +67,8 @@ class RelDeleteExecutor { public: RelDeleteExecutor( const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos) - : srcNodeIDPos{srcNodeIDPos}, dstNodeIDPos{dstNodeIDPos}, relIDPos{relIDPos} {} + : srcNodeIDPos{srcNodeIDPos}, dstNodeIDPos{dstNodeIDPos}, relIDPos{relIDPos}, + srcNodeIDVector(nullptr), dstNodeIDVector(nullptr), relIDVector(nullptr) {} virtual ~RelDeleteExecutor() = default; void init(ResultSet* resultSet, ExecutionContext* context); @@ -86,19 +87,17 @@ class RelDeleteExecutor { common::ValueVector* relIDVector; }; -class SingleLabelRelDeleteExecutor : public RelDeleteExecutor { +class SingleLabelRelDeleteExecutor final : public RelDeleteExecutor { public: SingleLabelRelDeleteExecutor(storage::RelsStoreStats* relsStatistic, storage::RelTable* table, const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos) : RelDeleteExecutor(srcNodeIDPos, dstNodeIDPos, relIDPos), relsStatistic{relsStatistic}, table{table} {} - SingleLabelRelDeleteExecutor(const SingleLabelRelDeleteExecutor& other) - : RelDeleteExecutor(other.srcNodeIDPos, other.dstNodeIDPos, other.relIDPos), - relsStatistic{other.relsStatistic}, table{other.table} {} + SingleLabelRelDeleteExecutor(const SingleLabelRelDeleteExecutor& other) = default; - void delete_() final; + void delete_(); - inline std::unique_ptr copy() const final { + inline std::unique_ptr copy() const { return std::make_unique(*this); } @@ -107,7 +106,7 @@ class SingleLabelRelDeleteExecutor : public RelDeleteExecutor { storage::RelTable* table; }; -class MultiLabelRelDeleteExecutor : public RelDeleteExecutor { +class MultiLabelRelDeleteExecutor final : public RelDeleteExecutor { using rel_table_statistic_pair = std::pair; public: @@ -116,13 +115,11 @@ class MultiLabelRelDeleteExecutor : public RelDeleteExecutor { const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos) : RelDeleteExecutor(srcNodeIDPos, dstNodeIDPos, relIDPos), tableIDToTableMap{std::move( tableIDToTableMap)} {} - MultiLabelRelDeleteExecutor(const MultiLabelRelDeleteExecutor& other) - : RelDeleteExecutor(other.srcNodeIDPos, other.dstNodeIDPos, other.relIDPos), - tableIDToTableMap{other.tableIDToTableMap} {} + MultiLabelRelDeleteExecutor(const MultiLabelRelDeleteExecutor& other) = default; - void delete_() final; + void delete_(); - inline std::unique_ptr copy() const final { + inline std::unique_ptr copy() const { return std::make_unique(*this); } diff --git a/src/parser/query/CMakeLists.txt b/src/parser/query/CMakeLists.txt index 7c18a5aa68..9f7a41b2e3 100644 --- a/src/parser/query/CMakeLists.txt +++ b/src/parser/query/CMakeLists.txt @@ -1,9 +1,5 @@ add_subdirectory(reading_clause) -add_library(kuzu_parser_query - OBJECT - single_query.cpp) - set(ALL_OBJECT_FILES - ${ALL_OBJECT_FILES} $ + ${ALL_OBJECT_FILES} PARENT_SCOPE) diff --git a/src/parser/query/single_query.cpp b/src/parser/query/single_query.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/processor/operator/persistent/reader/csv/driver.cpp b/src/processor/operator/persistent/reader/csv/driver.cpp index 3225e1946e..159c1fa823 100644 --- a/src/processor/operator/persistent/reader/csv/driver.cpp +++ b/src/processor/operator/persistent/reader/csv/driver.cpp @@ -95,8 +95,9 @@ void SniffCSVNameAndTypeDriver::addValue(uint64_t, common::column_id_t, std::str try { columnType = LogicalTypeUtils::dataTypeFromString(std::string(value.substr(it + 1))); columnName = std::string(value.substr(0, it)); - } catch (NotImplementedException) { - // Just use the whole name. + } catch (Exception) { // NOLINT(bugprone-empty-catch): This is how we check for a suitable + // datatype name. + // Didn't parse, just use the whole name. } } columns.emplace_back(columnName, columnType); diff --git a/src/processor/result/factorized_table.cpp b/src/processor/result/factorized_table.cpp index f4f79ee136..bd0d08f851 100644 --- a/src/processor/result/factorized_table.cpp +++ b/src/processor/result/factorized_table.cpp @@ -1,5 +1,6 @@ #include "processor/result/factorized_table.h" +#include "common/assert.h" #include "common/data_chunk/data_chunk_state.h" #include "common/null_buffer.h" #include "common/vector/value_vector.h" @@ -197,6 +198,7 @@ void FactorizedTable::lookup(std::vector& vectors, uint64_t startPos, uint64_t numTuplesToRead) const { assert(vectors.size() == colIdxesToScan.size()); auto tuplesToRead = std::make_unique(tupleIdxesToRead.size()); + KU_ASSERT(numTuplesToRead > 0); for (auto i = 0u; i < numTuplesToRead; i++) { tuplesToRead[i] = getTuple(tupleIdxesToRead[i + startPos]); } diff --git a/src/storage/buffer_manager/buffer_manager.cpp b/src/storage/buffer_manager/buffer_manager.cpp index 707da25ad9..e312b57a7c 100644 --- a/src/storage/buffer_manager/buffer_manager.cpp +++ b/src/storage/buffer_manager/buffer_manager.cpp @@ -107,6 +107,11 @@ uint8_t* BufferManager::pin( case PageState::LOCKED: { continue; } + default: { + // LCOV_EXCL_START + throw NotImplementedException("Invalid PageState in BufferManager::pin!"); + // LCOV_EXCL_END + } } } }