From 0b2a67027b8a8c424c8721944236ccae92f579de Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Wed, 16 Oct 2024 10:41:23 +0200 Subject: [PATCH] refactor: rename lineage_index config to generate_lineage_index --- include/silo/config/database_config.h | 2 +- src/silo/config/database_config.cpp | 10 ++++----- src/silo/config/database_config.test.cpp | 8 +++---- src/silo/config/util/config_repository.cpp | 21 ++++++++++--------- .../config/util/config_repository.test.cpp | 19 +++++++++-------- src/silo/database.cpp | 2 +- src/silo/test/lineage_filter.test.cpp | 2 +- .../diverseSequenceNames/database_config.yaml | 2 +- .../database_config.yaml | 2 +- .../emptyInputNdjson/database_config.yaml | 2 +- .../database_config.yaml | 2 +- .../emptyInputTsv/database_config.yaml | 2 +- .../exampleDataset/database_config.yaml | 2 +- .../database_config.yaml | 2 +- .../exampleDatasetAsTsv/database_config.yaml | 2 +- testBaseData/test_database_config.yaml | 2 +- ..._database_config_without_partition_by.yaml | 2 +- .../database_config.yaml | 2 +- .../unitTestDummyDataset/database_config.yaml | 2 +- 19 files changed, 45 insertions(+), 43 deletions(-) diff --git a/include/silo/config/database_config.h b/include/silo/config/database_config.h index 4c906f70..2e9b1658 100644 --- a/include/silo/config/database_config.h +++ b/include/silo/config/database_config.h @@ -21,7 +21,7 @@ class DatabaseMetadata { std::string name; ValueType type; bool generate_index; - bool lineage_index; + bool generate_lineage_index; [[nodiscard]] ColumnType getColumnType() const; }; diff --git a/src/silo/config/database_config.cpp b/src/silo/config/database_config.cpp index 112592e6..d7701f03 100644 --- a/src/silo/config/database_config.cpp +++ b/src/silo/config/database_config.cpp @@ -141,10 +141,10 @@ struct convert { } else { metadata.generate_index = false; } - if (node["lineageIndex"].IsDefined()) { - metadata.lineage_index = node["lineageIndex"].as(); + if (node["generateLineageIndex"].IsDefined()) { + metadata.generate_lineage_index = node["generateLineageIndex"].as(); } else { - metadata.lineage_index = false; + metadata.generate_lineage_index = false; } return true; } @@ -153,8 +153,8 @@ struct convert { node["name"] = metadata.name; node["type"] = toString(metadata.type); node["generateIndex"] = metadata.generate_index; - if (metadata.lineage_index) { - node["lineageIndex"] = true; + if (metadata.generate_lineage_index) { + node["generateLineageIndex"] = true; } return node; } diff --git a/src/silo/config/database_config.test.cpp b/src/silo/config/database_config.test.cpp index 7cae15dd..fcea7bb1 100644 --- a/src/silo/config/database_config.test.cpp +++ b/src/silo/config/database_config.test.cpp @@ -45,7 +45,7 @@ namespace { struct TestParameter { ValueType value_type; bool generate_index; - bool lineage_index; + bool generate_lineage_index; ColumnType expected_column_type; }; @@ -85,7 +85,7 @@ INSTANTIATE_TEST_SUITE_P( TestParameter{ .value_type = ValueType::STRING, .generate_index = true, - .lineage_index = true, + .generate_lineage_index = true, .expected_column_type = ColumnType::INDEXED_STRING }, TestParameter{ @@ -130,11 +130,11 @@ TEST(DatabaseConfigReader, shouldReadConfigWithCorrectParameters) { ASSERT_EQ(config.schema.metadata[5].name, "pango_lineage"); ASSERT_EQ(config.schema.metadata[5].type, ValueType::STRING); ASSERT_EQ(config.schema.metadata[5].generate_index, true); - ASSERT_EQ(config.schema.metadata[5].lineage_index, true); + ASSERT_EQ(config.schema.metadata[5].generate_lineage_index, true); ASSERT_EQ(config.schema.metadata[6].name, "division"); ASSERT_EQ(config.schema.metadata[6].type, ValueType::STRING); ASSERT_EQ(config.schema.metadata[6].generate_index, true); - ASSERT_EQ(config.schema.metadata[6].lineage_index, false); + ASSERT_EQ(config.schema.metadata[6].generate_lineage_index, false); ASSERT_EQ(config.schema.metadata[7].name, "age"); ASSERT_EQ(config.schema.metadata[7].type, ValueType::INT); ASSERT_EQ(config.schema.metadata[7].generate_index, false); diff --git a/src/silo/config/util/config_repository.cpp b/src/silo/config/util/config_repository.cpp index b187fa52..997e9c8d 100644 --- a/src/silo/config/util/config_repository.cpp +++ b/src/silo/config/util/config_repository.cpp @@ -26,11 +26,11 @@ std::map validateMetadataDefinitions(const DatabaseConfi throw ConfigException("Metadata " + metadata.name + " is defined twice in the config"); } - const auto must_be_string = metadata.lineage_index; + const auto must_be_string = metadata.generate_lineage_index; if (metadata.type != ValueType::STRING && must_be_string) { throw ConfigException( "Metadata '" + metadata.name + - "' lineage_index is set, but the column is not of type STRING." + "' generateLineageIndex is set, but the column is not of type STRING." ); } @@ -38,15 +38,15 @@ std::map validateMetadataDefinitions(const DatabaseConfi if (metadata.generate_index && must_not_generate_index_on_type) { throw ConfigException( "Metadata '" + metadata.name + - "' generate_index is set, but generating an index is only allowed for types STRING" + "' generateIndex is set, but generating an index is only allowed for types STRING" ); } - const auto must_generate_index = metadata.lineage_index; + const auto must_generate_index = metadata.generate_lineage_index; if (!metadata.generate_index && must_generate_index) { throw ConfigException( "Metadata '" + metadata.name + - "' lineage_index is set, generate_index must also be set." + "' generateLineageIndex is set, generateIndex must also be set." ); } @@ -65,11 +65,11 @@ void validateDateToSortBy( const std::string date_to_sort_by = config.schema.date_to_sort_by.value(); if (metadata_map.find(date_to_sort_by) == metadata_map.end()) { - throw ConfigException("date_to_sort_by '" + date_to_sort_by + "' is not in metadata"); + throw ConfigException("dateToSortBy '" + date_to_sort_by + "' is not in metadata"); } if (metadata_map[date_to_sort_by] != ValueType::DATE) { - throw ConfigException("date_to_sort_by '" + date_to_sort_by + "' must be of type DATE"); + throw ConfigException("dateToSortBy '" + date_to_sort_by + "' must be of type DATE"); } } @@ -86,12 +86,13 @@ void validatePartitionBy(const DatabaseConfig& config) { [&](const DatabaseMetadata& metadata) { return metadata.name == partition_by; } ); if (partition_by_metadata == config.schema.metadata.end()) { - throw ConfigException("partition_by '" + partition_by + "' is not in metadata"); + throw ConfigException("partitionBy '" + partition_by + "' is not in metadata"); } - if (partition_by_metadata->type != ValueType::STRING || !partition_by_metadata->lineage_index) { + if (partition_by_metadata->type != ValueType::STRING || !partition_by_metadata->generate_lineage_index) { throw ConfigException( - "partition_by '" + partition_by + "' must be of type STRING and needs 'lineageIndex' set" + "partitionBy '" + partition_by + + "' must be of type STRING and needs 'generateLineageIndex' set" ); } } diff --git a/src/silo/config/util/config_repository.test.cpp b/src/silo/config/util/config_repository.test.cpp index 5b64b94b..adbab206 100644 --- a/src/silo/config/util/config_repository.test.cpp +++ b/src/silo/config/util/config_repository.test.cpp @@ -44,7 +44,7 @@ TEST(ConfigRepository, shouldReadConfigWithoutErrors) { {.name = "metadata1", .type = ValueType::STRING, .generate_index = true, - .lineage_index = true}, + .generate_lineage_index = true}, {.name = "metadata2", .type = ValueType::DATE}, }, .primary_key = "testPrimaryKey", @@ -114,7 +114,7 @@ TEST(ConfigRepository, givenConfigWithDateToSortByThatIsNotConfiguredThenThrows) ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage( - ::testing::HasSubstr("date_to_sort_by 'notConfiguredDateToSortBy' is not in metadata") + ::testing::HasSubstr("dateToSortBy 'notConfiguredDateToSortBy' is not in metadata") ) ); } @@ -138,7 +138,7 @@ TEST(ConfigRepository, givenDateToSortByThatIsNotADateThenThrows) { ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage( - ::testing::HasSubstr("date_to_sort_by 'not a date' must be of type DATE") + ::testing::HasSubstr("dateToSortBy 'not a date' must be of type DATE") ) ); } @@ -163,7 +163,7 @@ TEST(ConfigRepository, givenConfigPartitionByThatIsNotConfiguredThenThrows) { ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage( - ::testing::HasSubstr("partition_by 'notConfiguredPartitionBy' is not in metadata") + ::testing::HasSubstr("partitionBy 'notConfiguredPartitionBy' is not in metadata") ) ); } @@ -188,7 +188,7 @@ TEST(ConfigRepository, givenConfigPartitionByThatIsNotALineageThrows) { ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage(::testing::HasSubstr( - "partition_by 'not a lineage' must be of type STRING and needs 'lineageIndex' set" + "partitionBy 'not a lineage' must be of type STRING and needs 'generateLineageIndex' set" )) ); } @@ -213,7 +213,7 @@ TEST(ConfigRepository, givenMetadataToGenerateIndexForThatIsNotStringThenThrows) ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage( - ::testing::HasSubstr("Metadata 'indexed date' generate_index is set, but generating an " + ::testing::HasSubstr("Metadata 'indexed date' generateIndex is set, but generating an " "index is only allowed for types STRING") ) ); @@ -227,7 +227,8 @@ TEST(ConfigRepository, givenLineageIndexAndNotGenerateThenThrows) { .metadata = { {.name = "testPrimaryKey", .type = ValueType::STRING}, - {.name = "some lineage", .type = ValueType::STRING, .lineage_index = true}, + {.name = "some lineage", .type = ValueType::STRING, .generate_lineage_index = true + }, }, .primary_key = "testPrimaryKey", .date_to_sort_by = std::nullopt, @@ -239,8 +240,8 @@ TEST(ConfigRepository, givenLineageIndexAndNotGenerateThenThrows) { ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml"); }, ThrowsMessage( - ::testing::HasSubstr("Metadata 'some lineage' lineage_index is set, " - "generate_index must also be set") + ::testing::HasSubstr("Metadata 'some lineage' generateLineageIndex is set, " + "generateIndex must also be set") ) ); } diff --git a/src/silo/database.cpp b/src/silo/database.cpp index ff07d14a..de31420a 100644 --- a/src/silo/database.cpp +++ b/src/silo/database.cpp @@ -603,7 +603,7 @@ void Database::initializeColumn(const config::DatabaseMetadata& metadata) { } return; case config::ColumnType::INDEXED_STRING: { - if (metadata.lineage_index) { + if (metadata.generate_lineage_index) { auto column = storage::column::IndexedStringColumn(lineage_tree); columns.indexed_string_columns.emplace(name, std::move(column)); } else { diff --git a/src/silo/test/lineage_filter.test.cpp b/src/silo/test/lineage_filter.test.cpp index 0c335bd9..d7288188 100644 --- a/src/silo/test/lineage_filter.test.cpp +++ b/src/silo/test/lineage_filter.test.cpp @@ -54,7 +54,7 @@ const auto DATABASE_CONFIG = DatabaseConfig{ {.name = "pango_lineage", .type = ValueType::STRING, .generate_index = true, - .lineage_index = true}}, + .generate_lineage_index = true}}, .primary_key = "primaryKey"} }; diff --git a/testBaseData/diverseSequenceNames/database_config.yaml b/testBaseData/diverseSequenceNames/database_config.yaml index cf7bfdf4..bb8719b3 100644 --- a/testBaseData/diverseSequenceNames/database_config.yaml +++ b/testBaseData/diverseSequenceNames/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/diverseSequenceNamesAsNdjson/database_config.yaml b/testBaseData/diverseSequenceNamesAsNdjson/database_config.yaml index cf7bfdf4..bb8719b3 100644 --- a/testBaseData/diverseSequenceNamesAsNdjson/database_config.yaml +++ b/testBaseData/diverseSequenceNamesAsNdjson/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/emptyInputNdjson/database_config.yaml b/testBaseData/emptyInputNdjson/database_config.yaml index 6426f078..fa8abea9 100644 --- a/testBaseData/emptyInputNdjson/database_config.yaml +++ b/testBaseData/emptyInputNdjson/database_config.yaml @@ -11,7 +11,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/emptyInputNdjsonUnpartitioned/database_config.yaml b/testBaseData/emptyInputNdjsonUnpartitioned/database_config.yaml index c7f1aa2e..e727745f 100644 --- a/testBaseData/emptyInputNdjsonUnpartitioned/database_config.yaml +++ b/testBaseData/emptyInputNdjsonUnpartitioned/database_config.yaml @@ -11,7 +11,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/emptyInputTsv/database_config.yaml b/testBaseData/emptyInputTsv/database_config.yaml index 4ccdb6fe..f69d5e7c 100644 --- a/testBaseData/emptyInputTsv/database_config.yaml +++ b/testBaseData/emptyInputTsv/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/exampleDataset/database_config.yaml b/testBaseData/exampleDataset/database_config.yaml index faae3dc4..3fe50baa 100644 --- a/testBaseData/exampleDataset/database_config.yaml +++ b/testBaseData/exampleDataset/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/exampleDataset1000Sequences/database_config.yaml b/testBaseData/exampleDataset1000Sequences/database_config.yaml index 98c976d7..fd76d224 100644 --- a/testBaseData/exampleDataset1000Sequences/database_config.yaml +++ b/testBaseData/exampleDataset1000Sequences/database_config.yaml @@ -14,7 +14,7 @@ schema: - name: pangoLineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/exampleDatasetAsTsv/database_config.yaml b/testBaseData/exampleDatasetAsTsv/database_config.yaml index faae3dc4..3fe50baa 100644 --- a/testBaseData/exampleDatasetAsTsv/database_config.yaml +++ b/testBaseData/exampleDatasetAsTsv/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/test_database_config.yaml b/testBaseData/test_database_config.yaml index ef9d11d6..fb0691e2 100644 --- a/testBaseData/test_database_config.yaml +++ b/testBaseData/test_database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/test_database_config_without_partition_by.yaml b/testBaseData/test_database_config_without_partition_by.yaml index 04331621..50a0e049 100644 --- a/testBaseData/test_database_config_without_partition_by.yaml +++ b/testBaseData/test_database_config_without_partition_by.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/tsvWithQuoteInPartitionBy/database_config.yaml b/testBaseData/tsvWithQuoteInPartitionBy/database_config.yaml index cf96faa5..cf4893e0 100644 --- a/testBaseData/tsvWithQuoteInPartitionBy/database_config.yaml +++ b/testBaseData/tsvWithQuoteInPartitionBy/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: 'pango_"lineage' type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true diff --git a/testBaseData/unitTestDummyDataset/database_config.yaml b/testBaseData/unitTestDummyDataset/database_config.yaml index 13db7130..30881154 100644 --- a/testBaseData/unitTestDummyDataset/database_config.yaml +++ b/testBaseData/unitTestDummyDataset/database_config.yaml @@ -16,7 +16,7 @@ schema: - name: pango_lineage type: string generateIndex: true - lineageIndex: true + generateLineageIndex: true - name: division type: string generateIndex: true