do not use template for index

This commit is contained in:
2021-12-18 11:10:18 +01:00
parent 7e8d750f63
commit 7a6a9e209a
4 changed files with 28 additions and 26 deletions

View File

@@ -263,13 +263,13 @@ void Table::validate_row(Row &row) {
row.set_visible();
}
void Table::create_index(const Index<IndexValue>& index) {
void Table::create_index(const Index& index) {
m_indexes.push_back(index);
}
bool Table::drop_index(const std::string &index_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&index_name](const Index<IndexValue> &idx) {
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
@@ -281,7 +281,7 @@ bool Table::drop_index(const std::string &index_name) {
}
void Table::index_row(Index<IndexValue> &index, const ColDefNode &col_def, const Row &row, const size_t rowid) {
void Table::index_row(Index &index, const ColDefNode &col_def, const Row &row, const size_t rowid) {
if (col_def.type==ColumnType::integer_type) {
index.insert(row[col_def.order].getIntValue(), rowid);
} else if (col_def.type==ColumnType::varchar_type) {
@@ -291,7 +291,7 @@ void Table::index_row(Index<IndexValue> &index, const ColDefNode &col_def, const
}
}
void Table::unindex_row(Index<IndexValue> &index, const ColDefNode &col_def, const Row &row, const size_t rowid) {
void Table::unindex_row(Index &index, const ColDefNode &col_def, const Row &row, const size_t rowid) {
if (col_def.type==ColumnType::integer_type) {
index.remove(row[col_def.order].getIntValue(), rowid);
} else if (col_def.type==ColumnType::varchar_type) {
@@ -301,7 +301,7 @@ void Table::unindex_row(Index<IndexValue> &index, const ColDefNode &col_def, con
}
}
void Table::reindex_row(Index<IndexValue> &index, const ColDefNode &col_def, const Row &old_row, const Row &new_row, size_t rowid) {
void Table::reindex_row(Index &index, const ColDefNode &col_def, const Row &old_row, const Row &new_row, size_t rowid) {
unindex_row(index, col_def, old_row, rowid);
index_row(index, col_def, new_row, rowid);
}
@@ -350,18 +350,18 @@ void Table::index_rows(const std::string &index_name) {
}
Index<IndexValue> * Table::get_index(const std::string &index_name) {
Index * Table::get_index(const std::string &index_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&index_name](const Index<IndexValue> &idx) {
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
return (it != m_indexes.end()) ? &(*it) : nullptr;
}
Index<IndexValue> * Table::get_index_for_column(const std::string &col_name) {
Index * Table::get_index_for_column(const std::string &col_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&col_name](const Index<IndexValue> &idx) {
[&col_name](const Index &idx) {
return idx.get_column_name() == col_name;
});