From aa50138b9562c8140935ce0c36ba9b3392bda71c Mon Sep 17 00:00:00 2001 From: Christian Jaeger Date: Thu, 7 Nov 2024 14:17:35 +0100 Subject: [PATCH] refactor: panic: prefix all macros with `SILO_` To avoid clashing with gtest's `ASSERT_EQ` and potentially more. Prefix all macros at once. --- CMakeLists.txt | 8 +- include/silo/common/panic.h | 84 +++++++++---------- src/silo/common/aa_symbols.cpp | 2 +- src/silo/common/lineage_tree.cpp | 14 ++-- src/silo/common/nucleotide_symbols.cpp | 2 +- src/silo/common/optional_bool.cpp | 4 +- src/silo/common/panic.test.cpp | 38 ++++----- src/silo/common/string_utils.cpp | 2 +- src/silo/common/table_reader.cpp | 2 +- src/silo/database.cpp | 6 +- src/silo/preprocessing/metadata_info.cpp | 2 +- src/silo/preprocessing/preprocessor.cpp | 2 +- src/silo/query_engine/actions/fasta.cpp | 6 +- .../query_engine/actions/fasta_aligned.cpp | 2 +- src/silo/query_engine/actions/tuple.cpp | 10 +-- .../filter_expressions/string_equals.cpp | 2 +- .../filter_expressions/string_search.cpp | 2 +- src/silo/query_engine/operators/operator.cpp | 2 +- src/silo/query_engine/operators/selection.cpp | 6 +- src/silo/query_engine/query_result.cpp | 4 +- src/silo/storage/column_group.cpp | 8 +- src/silo/zstd/zstd_decompressor.cpp | 2 +- 22 files changed, 103 insertions(+), 107 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb2542d8..963255ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,13 @@ endif () message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") set(CMAKE_CXX_FLAGS "-Wall") -set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -D DEBUG_ASSERTIONS=1") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D DEBUG_ASSERTIONS=0") +set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -D SILO_DEBUG_ASSERTIONS=1") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D SILO_DEBUG_ASSERTIONS=0") # Work-around only for MacOS if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_CXX_FLAGS_DEBUG "-g -D DEBUG_ASSERTIONS=1") - set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D DEBUG_ASSERTIONS=0") + set(CMAKE_CXX_FLAGS_DEBUG "-g -D SILO_DEBUG_ASSERTIONS=1") + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D SILO_DEBUG_ASSERTIONS=0") endif () set(CMAKE_CXX_STANDARD 20) diff --git a/include/silo/common/panic.h b/include/silo/common/panic.h index 33bf0b70..13514038 100644 --- a/include/silo/common/panic.h +++ b/include/silo/common/panic.h @@ -29,31 +29,31 @@ namespace silo::common { /// Passes arguments to `fmt::format` (at least a format string /// argument is required) and adds file and line information, then /// calls `panic`. -#define PANIC(...) silo::common::panic(fmt::format(__VA_ARGS__), __FILE__, __LINE__) +#define SILO_PANIC(...) silo::common::panic(fmt::format(__VA_ARGS__), __FILE__, __LINE__) /// Denotes a place that isn't implemented *yet*, during /// development. Follows the same path as `PANIC` when reached. -#define TODO() silo::common::todo(__FILE__, __LINE__) +#define SILO_TODO() silo::common::todo(__FILE__, __LINE__) [[noreturn]] void todo(const char* file, int line); /// Denotes a place that theoretically can't be reached. Follows the /// same path as `PANIC` when reached. -#define UNREACHABLE() silo::common::unreachable(__FILE__, __LINE__) +#define SILO_UNREACHABLE() silo::common::unreachable(__FILE__, __LINE__) [[noreturn]] void unreachable(const char* file, int line); /// Denotes a missing implementation. Follows the same path as `PANIC` /// when reached. -#define UNIMPLEMENTED() silo::common::unimplemented(__FILE__, __LINE__) +#define SILO_UNIMPLEMENTED() silo::common::unimplemented(__FILE__, __LINE__) [[noreturn]] void unimplemented(const char* file, int line); /// Asserts that the expression `e` evaluates to true. On failure /// calls `panic` with the stringification of the code `e` and -/// file/line information. `ASSERT` is always compiled in; if -/// performance overrides safety, use `DEBUG_ASSERT` instead. -#define ASSERT(e) \ +/// file/line information. `SILO_ASSERT` is always compiled in; if +/// performance overrides safety, use `SILO_DEBUG_ASSERT` instead. +#define SILO_ASSERT(e) \ do { \ if (!(e)) { \ silo::common::assertFailure(#e, __FILE__, __LINE__); \ @@ -62,7 +62,7 @@ namespace silo::common { [[noreturn]] void assertFailure(const char* msg, const char* file, int line); -#define INTERNAL_ASSERT_OP_(prefix_str, e1, op, e2) \ +#define SILO_INTERNAL_ASSERT_OP_(prefix_str, e1, op, e2) \ do { \ auto internal_assert_op__v1 = (e1); \ auto internal_assert_op__v2 = (e2); \ @@ -79,8 +79,8 @@ namespace silo::common { } \ } while (0) -#define ASSERT_OP_(partial_prefix, e1, op, e2) \ - INTERNAL_ASSERT_OP_("ASSERT_" #partial_prefix, e1, op, e2) +#define SILO_ASSERT_OP_(partial_prefix, e1, op, e2) \ + SILO_INTERNAL_ASSERT_OP_("ASSERT_" #partial_prefix, e1, op, e2) [[noreturn]] void assertOpFailure( const char* prefix, @@ -96,49 +96,49 @@ namespace silo::common { /// value, compared via `==`. On failure calls `panic` with the stringification of the code and the /// two values passed through fmt::format, plus file/line information. Always compiled in, if /// performance overrides safety, use `DEBUG_ASSERT_EQ` instead. -#define ASSERT_EQ(e1, e2) ASSERT_OP_(EQ, e1, ==, e2) +#define SILO_ASSERT_EQ(e1, e2) SILO_ASSERT_OP_(EQ, e1, ==, e2) /// Like ASSERT_EQ but asserts that `e1 <= e2`. -#define ASSERT_LE(e1, e2) ASSERT_OP_(LE, e1, <=, e2) +#define SILO_ASSERT_LE(e1, e2) SILO_ASSERT_OP_(LE, e1, <=, e2) /// Like ASSERT_EQ but asserts that `e1 < e2`. -#define ASSERT_LT(e1, e2) ASSERT_OP_(LT, e1, <, e2) +#define SILO_ASSERT_LT(e1, e2) SILO_ASSERT_OP_(LT, e1, <, e2) /// Like ASSERT_EQ but asserts that `e1 >= e2`. -#define ASSERT_GE(e1, e2) ASSERT_OP_(GE, e1, >=, e2) +#define SILO_ASSERT_GE(e1, e2) SILO_ASSERT_OP_(GE, e1, >=, e2) /// Like ASSERT_EQ but asserts that `e1 > e2`. -#define ASSERT_GT(e1, e2) ASSERT_OP_(GT, e1, >, e2) +#define SILO_ASSERT_GT(e1, e2) SILO_ASSERT_OP_(GT, e1, >, e2) -/// Like ASSERT_EQ but asserts that `e1 != e2`. -#define ASSERT_NE(e1, e2) ASSERT_OP_(NE, e1, !=, e2) +/// Like SILO_ASSERT_EQ but asserts that `e1 != e2`. +#define SILO_ASSERT_NE(e1, e2) SILO_ASSERT_OP_(NE, e1, !=, e2) -/// `DEBUG_ASSERT` is like `ASSERT`, but for cases where performance +/// `SILO_DEBUG_ASSERT` is like `SILO_ASSERT`, but for cases where performance /// is more important than verification in production: instantiations /// are only active when compiling SILO in debug (via /// `CMakeLists.txt`; concretely, they are compiled to be active when -/// the preprocessor variable `DEBUG_ASSERTIONS` is set to 1, and +/// the preprocessor variable `SILO_DEBUG_ASSERTIONS` is set to 1, and /// ignored if that variable is set to 0; if the variable is missing, -/// a compilation warning is printed and `DEBUG_ASSERT` is ignored, if +/// a compilation warning is printed and `SILO_DEBUG_ASSERT` is ignored, if /// present with another value, a compilation error results. Note that -/// `DEBUG_ASSERTIONS` must be set to 1 for debug builds or -/// `DEBUG_ASSERT` won't even check the assertion in debug builds. The +/// `SILO_DEBUG_ASSERTIONS` must be set to 1 for debug builds or +/// `SILO_DEBUG_ASSERT` won't even check the assertion in debug builds. The /// SILO `CMakeLists.txt` does set it up that way.) -#ifndef DEBUG_ASSERTIONS +#ifndef SILO_DEBUG_ASSERTIONS #warning \ - "DEBUG_ASSERTIONS is not set, should be 0 to ignore DEBUG_ASSERT, 1 to compile it in, assuming 0" -#define DEBUG_ASSERTIONS 0 + "SILO_DEBUG_ASSERTIONS is not set, should be 0 to ignore SILO_DEBUG_ASSERT, 1 to compile it in, assuming 0" +#define SILO_DEBUG_ASSERTIONS 0 #else -#if DEBUG_ASSERTIONS == 0 /* never */ -#elif DEBUG_ASSERTIONS == 1 /* always */ +#if SILO_DEBUG_ASSERTIONS == 0 /* never */ +#elif SILO_DEBUG_ASSERTIONS == 1 /* always */ #else -#error "DEBUG_ASSERTIONS should be 0 to ignore DEBUG_ASSERT, 1 to compile it in" +#error "SILO_DEBUG_ASSERTIONS should be 0 to ignore SILO_DEBUG_ASSERT, 1 to compile it in" #endif #endif -#define DEBUG_ASSERT(e) \ +#define SILO_DEBUG_ASSERT(e) \ do { \ - if (DEBUG_ASSERTIONS) { \ + if (SILO_DEBUG_ASSERTIONS) { \ if (!(e)) { \ silo::common::debugAssertFailure(#e, __FILE__, __LINE__); \ } \ @@ -147,30 +147,30 @@ namespace silo::common { [[noreturn]] void debugAssertFailure(const char* msg, const char* file, int line); -#define DEBUG_ASSERT_OP_(partial_prefix, e1, op, e2) \ - do { \ - if (DEBUG_ASSERTIONS) { \ - INTERNAL_ASSERT_OP_("DEBUG_ASSERT_" #partial_prefix, e1, op, e2); \ - } \ +#define SILO_DEBUG_ASSERT_OP_(partial_prefix, e1, op, e2) \ + do { \ + if (SILO_DEBUG_ASSERTIONS) { \ + SILO_INTERNAL_ASSERT_OP_("DEBUG_ASSERT_" #partial_prefix, e1, op, e2); \ + } \ } while (0) -/// Like `ASSERT_EQ`, but like `DEBUG_ASSERT`, for cases where +/// Like `SILO_ASSERT_EQ`, but like `SILO_DEBUG_ASSERT`, for cases where /// performance is more important than verification in production. -#define DEBUG_ASSERT_EQ(e1, e2) DEBUG_ASSERT_OP_(EQ, e1, ==, e2) +#define SILO_DEBUG_ASSERT_EQ(e1, e2) SILO_DEBUG_ASSERT_OP_(EQ, e1, ==, e2) /// Like DEBUG_ASSERT_EQ but asserts that `e1 <= e2`. -#define DEBUG_ASSERT_LE(e1, e2) DEBUG_ASSERT_OP_(LE, e1, <=, e2) +#define SILO_DEBUG_ASSERT_LE(e1, e2) SILO_DEBUG_ASSERT_OP_(LE, e1, <=, e2) /// Like DEBUG_ASSERT_EQ but asserts that `e1 < e2`. -#define DEBUG_ASSERT_LT(e1, e2) DEBUG_ASSERT_OP_(LT, e1, <, e2) +#define SILO_DEBUG_ASSERT_LT(e1, e2) SILO_DEBUG_ASSERT_OP_(LT, e1, <, e2) /// Like DEBUG_ASSERT_EQ but asserts that `e1 >= e2`. -#define DEBUG_ASSERT_GE(e1, e2) DEBUG_ASSERT_OP_(GE, e1, >=, e2) +#define SILO_DEBUG_ASSERT_GE(e1, e2) SILO_DEBUG_ASSERT_OP_(GE, e1, >=, e2) /// Like DEBUG_ASSERT_EQ but asserts that `e1 > e2`. -#define DEBUG_ASSERT_GT(e1, e2) DEBUG_ASSERT_OP_(GT, e1, >, e2) +#define SILO_DEBUG_ASSERT_GT(e1, e2) SILO_DEBUG_ASSERT_OP_(GT, e1, >, e2) /// Like DEBUG_ASSERT_EQ but asserts that `e1 != e2`. -#define DEBUG_ASSERT_NE(e1, e2) DEBUG_ASSERT_OP_(NE, e1, !=, e2) +#define SILO_DEBUG_ASSERT_NE(e1, e2) SILO_DEBUG_ASSERT_OP_(NE, e1, !=, e2) } // namespace silo::common diff --git a/src/silo/common/aa_symbols.cpp b/src/silo/common/aa_symbols.cpp index 7deb2555..b33721e4 100644 --- a/src/silo/common/aa_symbols.cpp +++ b/src/silo/common/aa_symbols.cpp @@ -61,7 +61,7 @@ char AminoAcid::symbolToChar(AminoAcid::Symbol symbol) { case AminoAcid::Symbol::STOP: return '*'; } - UNREACHABLE(); + SILO_UNREACHABLE(); } std::optional AminoAcid::charToSymbol(char character) { diff --git a/src/silo/common/lineage_tree.cpp b/src/silo/common/lineage_tree.cpp index b3a5b5ad..bed214f7 100644 --- a/src/silo/common/lineage_tree.cpp +++ b/src/silo/common/lineage_tree.cpp @@ -46,8 +46,8 @@ Graph::Graph(size_t number_of_vertices) adjacency_list(number_of_vertices) {} void Graph::addEdge(Idx vertex_from, Idx vertex_to) { - ASSERT_LT(vertex_from, number_of_vertices); - ASSERT_LT(vertex_to, number_of_vertices); + SILO_ASSERT_LT(vertex_from, number_of_vertices); + SILO_ASSERT_LT(vertex_to, number_of_vertices); adjacency_list.at(vertex_from).emplace_back(vertex_to); } @@ -100,11 +100,11 @@ std::optional> Graph::getCycle() const { if (witness_lasso.has_value()) { // We found a witness lasso of the form 1 -> 2 -> 3 -> 4 -> 5 -> 3 // We need to remove leading vertices up until the cycle - ASSERT_GE(witness_lasso.value().size(), 2); + SILO_ASSERT_GE(witness_lasso.value().size(), 2); const Idx cycle_node = witness_lasso.value().back(); auto cycle_node_first_occurrence = std::find(witness_lasso.value().begin(), witness_lasso.value().end(), cycle_node); - ASSERT(cycle_node_first_occurrence < witness_lasso.value().end()); + SILO_ASSERT(cycle_node_first_occurrence < witness_lasso.value().end()); witness_lasso.value().erase(witness_lasso.value().begin(), cycle_node_first_occurrence); return witness_lasso; } @@ -201,7 +201,7 @@ std::unordered_map assignAliasIdsAndGetAliasMapping( std::unordered_map alias_mapping; for (const auto& lineage : file.lineages) { const auto lineage_id = lookup.getId(lineage.lineage_name.string); - ASSERT(lineage_id.has_value()); + SILO_ASSERT(lineage_id.has_value()); for (const auto& alias : lineage.aliases) { if (lookup.getId(alias.string).has_value()) { throw silo::preprocessing::PreprocessingException(fmt::format( @@ -225,7 +225,7 @@ std::vector> getParentChildEdges( std::vector> edge_list; for (const auto& lineage : file.lineages) { const auto child_id = lookup.getId(lineage.lineage_name.string); - ASSERT(child_id.has_value()); + SILO_ASSERT(child_id.has_value()); for (const auto& parent_lineage : lineage.parents) { auto parent_id = lookup.getId(parent_lineage.string); @@ -270,4 +270,4 @@ LineageTreeAndIdMap LineageTreeAndIdMap::fromLineageDefinitionFilePath( return fromLineageDefinitionFile(definition_file); } -} // namespace silo::common \ No newline at end of file +} // namespace silo::common diff --git a/src/silo/common/nucleotide_symbols.cpp b/src/silo/common/nucleotide_symbols.cpp index dab1b967..ff375f80 100644 --- a/src/silo/common/nucleotide_symbols.cpp +++ b/src/silo/common/nucleotide_symbols.cpp @@ -38,7 +38,7 @@ char Nucleotide::symbolToChar(Nucleotide::Symbol symbol) { case Symbol::N: return 'N'; } - UNREACHABLE(); + SILO_UNREACHABLE(); } std::optional Nucleotide::charToSymbol(char character) { diff --git a/src/silo/common/optional_bool.cpp b/src/silo/common/optional_bool.cpp index c25b953a..6e09a3ba 100644 --- a/src/silo/common/optional_bool.cpp +++ b/src/silo/common/optional_bool.cpp @@ -45,7 +45,7 @@ std::optional OptionalBool::value() const noexcept { case Representation::TRUE: return true; } - UNREACHABLE(); + SILO_UNREACHABLE(); } std::string_view OptionalBool::asStr() const noexcept { @@ -57,7 +57,7 @@ std::string_view OptionalBool::asStr() const noexcept { case Representation::TRUE: return "true"; } - UNREACHABLE(); + SILO_UNREACHABLE(); } } // namespace silo::common diff --git a/src/silo/common/panic.test.cpp b/src/silo/common/panic.test.cpp index c6e7bb47..b4a53f12 100644 --- a/src/silo/common/panic.test.cpp +++ b/src/silo/common/panic.test.cpp @@ -3,14 +3,10 @@ #include #include -/* get rid of gtest's definition, we're going to test our own */ -#undef ASSERT_EQ - #include "silo/common/panic.h" namespace { -// Since we can't use ASSERT_EQ from gtest, make a simple -// replacement. `expected` should be without the file:line +// Fuzzy comparison: `expected` should be without the file:line // information, whereas `got` should contain it. void assertMsg(std::string got, std::string expected) { auto start = got.substr(0, expected.size()); @@ -47,18 +43,18 @@ void nullCapableSetenv(const char* name, const char* value, int overwrite) { // NOLINTNEXTLINE(readability-identifier-naming,readability-function-cognitive-complexity) TEST(panic, assertEqPanicModes) { - ASSERT_EQ(1 + 1, 2); + SILO_ASSERT_EQ(1 + 1, 2); const char* old_env = getenv("SILO_PANIC"); setenv("SILO_PANIC", "", 1); try { - ASSERT_EQ(1 + 1, 3); + SILO_ASSERT_EQ(1 + 1, 3); } catch (const std::exception& ex) { assertMsg(ex.what(), "ASSERT_EQ failure: 1 + 1 == 3: 2 == 3"); }; setenv("SILO_PANIC", "abort", 1); - ASSERT_DEATH(ASSERT_EQ(1 + 1, 3), "ASSERT_EQ failure: 1 \\+ 1 == 3: 2 == 3"); + ASSERT_DEATH(SILO_ASSERT_EQ(1 + 1, 3), "ASSERT_EQ failure: 1 \\+ 1 == 3: 2 == 3"); // revert it back nullCapableSetenv("SILO_PANIC", old_env, 1); @@ -67,49 +63,49 @@ TEST(panic, assertEqPanicModes) { // NOLINTNEXTLINE(readability-identifier-naming,readability-function-cognitive-complexity) TEST(panic, debugAssertBehavesAsPerCompilationMode) { // should never complain - DEBUG_ASSERT(1 + 1 == 2); + SILO_DEBUG_ASSERT(1 + 1 == 2); - // Check that DEBUG_ASSERT is active if DEBUG_ASSERTIONS==1, off + // Check that SILO_DEBUG_ASSERT is active if SILO_DEBUG_ASSERTIONS==1, off // otherwise; each of those branches is only tested when compiling // the unit tests in debug or release mode, respectively. -#if DEBUG_ASSERTIONS +#if SILO_DEBUG_ASSERTIONS const char* old_env = getenv("SILO_PANIC"); setenv("SILO_PANIC", "", 1); try { - DEBUG_ASSERT(1 + 1 == 3); + SILO_DEBUG_ASSERT(1 + 1 == 3); } catch (const std::exception& ex) { assertMsg(ex.what(), "DEBUG_ASSERT failure: 1 + 1 == 3"); }; nullCapableSetenv("SILO_PANIC", old_env, 1); #else - // check that DEBUG_ASSERT is disabled - DEBUG_ASSERT(1 + 1 == 3); + // check that SILO_DEBUG_ASSERT is disabled + SILO_DEBUG_ASSERT(1 + 1 == 3); #endif } // NOLINTNEXTLINE(readability-identifier-naming,readability-function-cognitive-complexity) TEST(panic, debugAssertGeWorks) { - // stand-in for all the DEBUG_ASSERT_* variants + // stand-in for all the SILO_DEBUG_ASSERT_* variants - DEBUG_ASSERT_GE(1 + 5, 6); - DEBUG_ASSERT_GE(1 + 5, 5); + SILO_DEBUG_ASSERT_GE(1 + 5, 6); + SILO_DEBUG_ASSERT_GE(1 + 5, 5); -#if DEBUG_ASSERTIONS +#if SILO_DEBUG_ASSERTIONS const char* old_env = getenv("SILO_PANIC"); setenv("SILO_PANIC", "", 1); try { - DEBUG_ASSERT_GE(1 + 5, 7); + SILO_DEBUG_ASSERT_GE(1 + 5, 7); } catch (const std::exception& ex) { assertMsg(ex.what(), "DEBUG_ASSERT_GE failure: 1 + 5 >= 7: 6 >= 7"); }; nullCapableSetenv("SILO_PANIC", old_env, 1); #else - // check that DEBUG_ASSERT is disabled - DEBUG_ASSERT_GE(1 + 5, 7); + // check that SILO_DEBUG_ASSERT is disabled + SILO_DEBUG_ASSERT_GE(1 + 5, 7); #endif } diff --git a/src/silo/common/string_utils.cpp b/src/silo/common/string_utils.cpp index f639805c..04755844 100644 --- a/src/silo/common/string_utils.cpp +++ b/src/silo/common/string_utils.cpp @@ -64,7 +64,7 @@ std::vector tie( const std::vector& elements2, std::string_view suffix ) { - ASSERT(elements1.size() == elements2.size()); + SILO_ASSERT(elements1.size() == elements2.size()); std::vector output; output.reserve(elements1.size()); for (size_t i = 0; i < elements1.size(); ++i) { diff --git a/src/silo/common/table_reader.cpp b/src/silo/common/table_reader.cpp index f0b39c86..ddd7b2ac 100644 --- a/src/silo/common/table_reader.cpp +++ b/src/silo/common/table_reader.cpp @@ -39,7 +39,7 @@ silo::TableReader::TableReader( size_t silo::TableReader::read() { loadTable(); - ASSERT(query_result->ColumnCount() == column_functions.size() + 1); + SILO_ASSERT(query_result->ColumnCount() == column_functions.size() + 1); size_t current_start_of_chunk = 0; std::unique_ptr current_chunk = query_result->Fetch(); while (current_chunk) { diff --git a/src/silo/database.cpp b/src/silo/database.cpp index 9b2d40c9..027259e4 100644 --- a/src/silo/database.cpp +++ b/src/silo/database.cpp @@ -199,7 +199,7 @@ BitmapContainerSize& BitmapContainerSize::operator+=(const BitmapContainerSize& BitmapSizePerSymbol& BitmapSizePerSymbol::operator+=(const BitmapSizePerSymbol& other) { for (const auto& symbol : Nucleotide::SYMBOLS) { - ASSERT(size_in_bytes.contains(symbol)); + SILO_ASSERT(size_in_bytes.contains(symbol)); size_in_bytes.at(symbol) += other.size_in_bytes.at(symbol); } return *this; @@ -223,7 +223,7 @@ BitmapSizePerSymbol Database::calculateBitmapSizePerSymbol( for (const SequenceStorePartition& seq_store_partition : seq_store.partitions) { for (const auto& position : seq_store_partition.positions) { - ASSERT(bitmap_size_per_symbol.size_in_bytes.contains(symbol)); + SILO_ASSERT(bitmap_size_per_symbol.size_in_bytes.contains(symbol)); bitmap_size_per_symbol.size_in_bytes[symbol] += position.getBitmap(symbol)->getSizeInBytes(); } @@ -649,7 +649,7 @@ void Database::initializeColumn(const config::DatabaseMetadata& metadata) { } return; } - UNREACHABLE(); + SILO_UNREACHABLE(); } void Database::initializeColumns() { diff --git a/src/silo/preprocessing/metadata_info.cpp b/src/silo/preprocessing/metadata_info.cpp index 669e493a..b1f4abbc 100644 --- a/src/silo/preprocessing/metadata_info.cpp +++ b/src/silo/preprocessing/metadata_info.cpp @@ -25,7 +25,7 @@ std::string toSQLType(ValueType value_type) { case ValueType::DATE: return "DATE"; } - UNREACHABLE(); + SILO_UNREACHABLE(); } } // namespace diff --git a/src/silo/preprocessing/preprocessor.cpp b/src/silo/preprocessing/preprocessor.cpp index e980261c..0ebf453f 100644 --- a/src/silo/preprocessing/preprocessor.cpp +++ b/src/silo/preprocessing/preprocessor.cpp @@ -92,7 +92,7 @@ Database Preprocessor::preprocess() { } const auto& ndjson_input_filename = preprocessing_config.getNdjsonInputFilename(); - ASSERT(ndjson_input_filename.has_value()); + SILO_ASSERT(ndjson_input_filename.has_value()); SPDLOG_INFO("preprocessing - ndjson pipeline chosen"); auto input_file = ValidatedNdjsonFile::validateFileAgainstConfig( ndjson_input_filename.value(), database_config, reference_genomes diff --git a/src/silo/query_engine/actions/fasta.cpp b/src/silo/query_engine/actions/fasta.cpp index e593e3f0..af18981f 100644 --- a/src/silo/query_engine/actions/fasta.cpp +++ b/src/silo/query_engine/actions/fasta.cpp @@ -151,7 +151,7 @@ uint32_t addSequencesToResultsForPartition( const std::string& primary_key_column, size_t num_result_rows ) { - ASSERT(num_result_rows > 0); + SILO_ASSERT(num_result_rows > 0); duckdb::DuckDB duck_db; duckdb::Connection connection(duck_db); @@ -199,7 +199,7 @@ uint32_t addSequencesToResultsForPartition( } else if (holds_alternative(primary_key.value())) { primary_key_string = std::to_string(get(primary_key.value())); } else { - ASSERT(holds_alternative(primary_key.value())); + SILO_ASSERT(holds_alternative(primary_key.value())); primary_key_string = get(primary_key.value()); } appender.Append(duckdb::Value::BLOB(primary_key_string)); @@ -297,7 +297,7 @@ QueryResult Fasta::execute(const Database& database, std::vectorskip(result_row_indices.size()); diff --git a/src/silo/query_engine/actions/fasta_aligned.cpp b/src/silo/query_engine/actions/fasta_aligned.cpp index 205a5f05..61235227 100644 --- a/src/silo/query_engine/actions/fasta_aligned.cpp +++ b/src/silo/query_engine/actions/fasta_aligned.cpp @@ -213,7 +213,7 @@ QueryResult FastaAligned::execute( return; } } - PANIC("ran out of bitmap before finishing result_row_indices"); + SILO_PANIC("ran out of bitmap before finishing result_row_indices"); } } }); diff --git a/src/silo/query_engine/actions/tuple.cpp b/src/silo/query_engine/actions/tuple.cpp index bb34b469..8b78842b 100644 --- a/src/silo/query_engine/actions/tuple.cpp +++ b/src/silo/query_engine/actions/tuple.cpp @@ -75,7 +75,7 @@ void assignTupleField( return; } } - UNREACHABLE(); + SILO_UNREACHABLE(); } silo::common::JsonValueType tupleFieldToValueType( @@ -134,7 +134,7 @@ silo::common::JsonValueType tupleFieldToValueType( return std::move(string_value); } } - UNREACHABLE(); + SILO_UNREACHABLE(); } std::strong_ordering compareDouble(double value1, double value2) { @@ -233,7 +233,7 @@ std::strong_ordering compareTupleFields( return compareString(string_value1, string_value2); } } - UNREACHABLE(); + SILO_UNREACHABLE(); } size_t getColumnSize(const silo::storage::ColumnMetadata& metadata) { @@ -257,7 +257,7 @@ size_t getColumnSize(const silo::storage::ColumnMetadata& metadata) { return sizeof(silo::Idx); } } - UNREACHABLE(); + SILO_UNREACHABLE(); } } // namespace @@ -286,7 +286,7 @@ Tuple& Tuple::operator=(const Tuple& other) { if (this == &other) { return *this; } - ASSERT(this->data_size == other.data_size); + SILO_ASSERT(this->data_size == other.data_size); columns = other.columns; std::memcpy(this->data, other.data, data_size); return *this; diff --git a/src/silo/query_engine/filter_expressions/string_equals.cpp b/src/silo/query_engine/filter_expressions/string_equals.cpp index 55beaf21..d689f93e 100644 --- a/src/silo/query_engine/filter_expressions/string_equals.cpp +++ b/src/silo/query_engine/filter_expressions/string_equals.cpp @@ -49,7 +49,7 @@ std::unique_ptr StringEquals::compile( bitmap.value(), database_partition.sequence_count ); } - ASSERT(database_partition.columns.string_columns.contains(column_name)); + SILO_ASSERT(database_partition.columns.string_columns.contains(column_name)); const auto& string_column = database_partition.columns.string_columns.at(column_name); const auto& embedded_string = string_column.embedString(value); if (embedded_string.has_value()) { diff --git a/src/silo/query_engine/filter_expressions/string_search.cpp b/src/silo/query_engine/filter_expressions/string_search.cpp index f03cd31e..cd8618ee 100644 --- a/src/silo/query_engine/filter_expressions/string_search.cpp +++ b/src/silo/query_engine/filter_expressions/string_search.cpp @@ -67,7 +67,7 @@ std::unique_ptr StringSearch::compile( string_column, *search_expression, database_partition.sequence_count ); } - ASSERT(database_partition.columns.string_columns.contains(column_name)); + SILO_ASSERT(database_partition.columns.string_columns.contains(column_name)); const auto& string_column = database_partition.columns.string_columns.at(column_name); return createMatchingBitmap( string_column, *search_expression, database_partition.sequence_count diff --git a/src/silo/query_engine/operators/operator.cpp b/src/silo/query_engine/operators/operator.cpp index e5bea390..cd8f3ea4 100644 --- a/src/silo/query_engine/operators/operator.cpp +++ b/src/silo/query_engine/operators/operator.cpp @@ -70,7 +70,7 @@ std::unique_ptr Operator::negate(std::unique_ptr&& some_oper return BitmapProducer::negate(std::unique_ptr(bitmap_producer)); } } - UNREACHABLE(); + SILO_UNREACHABLE(); } } // namespace silo::query_engine::operators diff --git a/src/silo/query_engine/operators/selection.cpp b/src/silo/query_engine/operators/selection.cpp index 1b0c9d06..ce3f02c2 100644 --- a/src/silo/query_engine/operators/selection.cpp +++ b/src/silo/query_engine/operators/selection.cpp @@ -135,7 +135,7 @@ CompareToValueSelection::CompareToValueSelection( template bool CompareToValueSelection::match(uint32_t row_id) const { - ASSERT(column.size() > row_id); + SILO_ASSERT(column.size() > row_id); switch (comparator) { case Comparator::EQUALS: return column[row_id] == value; @@ -157,7 +157,7 @@ bool CompareToValueSelection::match(uint32_t row_id) const { template <> bool CompareToValueSelection::match(uint32_t row_id) const { - ASSERT(column.size() > row_id); + SILO_ASSERT(column.size() > row_id); switch (comparator) { case Comparator::EQUALS: if (std::isnan(value)) { @@ -186,7 +186,7 @@ bool CompareToValueSelection::match(uint32_t row_id) const { template <> bool CompareToValueSelection::match(uint32_t row_id) const { - ASSERT(column.size() > row_id); + SILO_ASSERT(column.size() > row_id); if (comparator == Comparator::EQUALS) { return column[row_id] == value; } diff --git a/src/silo/query_engine/query_result.cpp b/src/silo/query_engine/query_result.cpp index 011207f9..34433178 100644 --- a/src/silo/query_engine/query_result.cpp +++ b/src/silo/query_engine/query_result.cpp @@ -92,14 +92,14 @@ void QueryResult::materialize() { std::vector& QueryResult::entriesMut() { if (!is_materialized_) { - PANIC("can't give access to entries vector for a QueryResult that is streamed"); + SILO_PANIC("can't give access to entries vector for a QueryResult that is streamed"); } return query_result_chunk_; } const std::vector& QueryResult::entries() const { if (!is_materialized_) { - PANIC("can't give access to entries vector for a QueryResult that is streamed"); + SILO_PANIC("can't give access to entries vector for a QueryResult that is streamed"); } return query_result_chunk_; } diff --git a/src/silo/storage/column_group.cpp b/src/silo/storage/column_group.cpp index bcf41035..b9a3b5be 100644 --- a/src/silo/storage/column_group.cpp +++ b/src/silo/storage/column_group.cpp @@ -61,7 +61,7 @@ void ColumnPartitionGroup::addValueToColumn( float_columns.at(column_name).insert(value.ToString()); return; } - UNREACHABLE(); + SILO_UNREACHABLE(); } void ColumnPartitionGroup::addNullToColumn(const std::string& column_name, ColumnType column_type) { @@ -85,7 +85,7 @@ void ColumnPartitionGroup::addNullToColumn(const std::string& column_name, Colum float_columns.at(column_name).insertNull(); return; } - UNREACHABLE(); + SILO_UNREACHABLE(); } void ColumnPartitionGroup::reserveSpaceInColumn( @@ -113,7 +113,7 @@ void ColumnPartitionGroup::reserveSpaceInColumn( float_columns.at(column_name).reserve(row_count); return; } - UNREACHABLE(); + SILO_UNREACHABLE(); } ColumnPartitionGroup ColumnPartitionGroup::getSubgroup( @@ -148,7 +148,7 @@ ColumnPartitionGroup ColumnPartitionGroup::getSubgroup( result.float_columns.insert({item.name, float_columns.at(item.name)}); return; } - UNREACHABLE(); + SILO_UNREACHABLE(); })(); } return result; diff --git a/src/silo/zstd/zstd_decompressor.cpp b/src/silo/zstd/zstd_decompressor.cpp index d0457d65..df2ce8e5 100644 --- a/src/silo/zstd/zstd_decompressor.cpp +++ b/src/silo/zstd/zstd_decompressor.cpp @@ -53,7 +53,7 @@ void ZstdDecompressor::decompress( fmt::format("Error '{}' in dependency when decompressing using zstd", error_name) ); } - ASSERT(uncompressed_size == size_or_error_code); + SILO_ASSERT(uncompressed_size == size_or_error_code); } } // namespace silo