Skip to content

Commit

Permalink
refactor: rename lineage_index config to generate_lineage_index
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Oct 16, 2024
1 parent 1d9f6f7 commit 0336600
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion include/silo/config/database_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
10 changes: 5 additions & 5 deletions src/silo/config/database_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ struct convert<silo::config::DatabaseMetadata> {
} else {
metadata.generate_index = false;
}
if (node["lineageIndex"].IsDefined()) {
metadata.lineage_index = node["lineageIndex"].as<bool>();
if (node["generateLineageIndex"].IsDefined()) {
metadata.generate_lineage_index = node["generateLineageIndex"].as<bool>();
} else {
metadata.lineage_index = false;
metadata.generate_lineage_index = false;
}
return true;
}
Expand All @@ -153,8 +153,8 @@ struct convert<silo::config::DatabaseMetadata> {
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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/silo/config/database_config.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace {
struct TestParameter {
ValueType value_type;
bool generate_index;
bool lineage_index;
bool generate_lineage_index;
ColumnType expected_column_type;
};

Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 12 additions & 10 deletions src/silo/config/util/config_repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ std::map<std::string, ValueType> 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."
);
}

const auto must_not_generate_index_on_type = metadata.type != ValueType::STRING;
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."
);
}

Expand All @@ -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");
}
}

Expand All @@ -86,12 +86,14 @@ 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"
);
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/silo/config/util/config_repository.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using silo::config::ValueType;
class ConfigReaderMock : public silo::config::DatabaseConfigReader {
public:
ConfigReaderMock() = default;
ConfigReaderMock(const ConfigReaderMock& /*other*/){};
ConfigReaderMock(const ConfigReaderMock& /*other*/) {};

MOCK_METHOD((DatabaseConfig), readConfig, (const std::filesystem::path&), (const override));
};
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -114,7 +114,7 @@ TEST(ConfigRepository, givenConfigWithDateToSortByThatIsNotConfiguredThenThrows)
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<ConfigException>(
::testing::HasSubstr("date_to_sort_by 'notConfiguredDateToSortBy' is not in metadata")
::testing::HasSubstr("dateToSortBy 'notConfiguredDateToSortBy' is not in metadata")
)
);
}
Expand All @@ -138,7 +138,7 @@ TEST(ConfigRepository, givenDateToSortByThatIsNotADateThenThrows) {
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<ConfigException>(
::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")
)
);
}
Expand All @@ -163,7 +163,7 @@ TEST(ConfigRepository, givenConfigPartitionByThatIsNotConfiguredThenThrows) {
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<ConfigException>(
::testing::HasSubstr("partition_by 'notConfiguredPartitionBy' is not in metadata")
::testing::HasSubstr("partitionBy 'notConfiguredPartitionBy' is not in metadata")
)
);
}
Expand All @@ -188,7 +188,7 @@ TEST(ConfigRepository, givenConfigPartitionByThatIsNotALineageThrows) {
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<silo::config::ConfigException>(::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"
))
);
}
Expand All @@ -213,7 +213,7 @@ TEST(ConfigRepository, givenMetadataToGenerateIndexForThatIsNotStringThenThrows)
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<ConfigException>(
::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")
)
);
Expand All @@ -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,
Expand All @@ -239,8 +240,8 @@ TEST(ConfigRepository, givenLineageIndexAndNotGenerateThenThrows) {
ConfigRepository(config_reader_mock).getValidatedConfig("test.yaml");
},
ThrowsMessage<ConfigException>(
::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")
)
);
}
2 changes: 1 addition & 1 deletion src/silo/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/silo/test/lineage_filter.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
};

Expand Down
2 changes: 1 addition & 1 deletion testBaseData/diverseSequenceNames/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/emptyInputNdjson/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/emptyInputTsv/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/exampleDataset/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ schema:
- name: pangoLineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/exampleDatasetAsTsv/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/test_database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: 'pango_"lineage'
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down
2 changes: 1 addition & 1 deletion testBaseData/unitTestDummyDataset/database_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ schema:
- name: pango_lineage
type: string
generateIndex: true
lineageIndex: true
generateLineageIndex: true
- name: division
type: string
generateIndex: true
Expand Down

0 comments on commit 0336600

Please sign in to comment.