indexes WIP

This commit is contained in:
2021-12-13 22:08:27 +01:00
parent 411f0fd48c
commit 7ae4ef53f9
12 changed files with 410 additions and 272 deletions

View File

@@ -66,7 +66,7 @@ bool USql::eval_relational_operator(const RelationalOperatorNode &filter, Table
return !all_null;
return false;
} else if (left_value->node_type == NodeType::int_value && right_value->node_type == NodeType::int_value) {
comparator = left_value->getIntegerValue() - right_value->getIntegerValue();
comparator = (double)(left_value->getIntegerValue() - right_value->getIntegerValue());
} else if ((left_value->node_type == NodeType::int_value && right_value->node_type == NodeType::float_value) ||
(left_value->node_type == NodeType::float_value && right_value->node_type == NodeType::int_value) ||
(left_value->node_type == NodeType::float_value && right_value->node_type == NodeType::float_value)) {
@@ -414,20 +414,27 @@ USql::min_function(const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars,
Table *USql::find_table(const std::string &name) const {
auto name_cmp = [name](const Table& t) { return t.m_name == name; };
auto table_def = std::find_if(begin(m_tables), end(m_tables), name_cmp);
if (table_def != std::end(m_tables)) {
if (table_def != std::end(m_tables))
return const_cast<Table *>(table_def.operator->());
} else {
throw Exception("table not found (" + name + ")");
}
throw Exception("table not found (" + name + ")");
}
void USql::check_table_not_exists(const std::string &name) const {
auto name_cmp = [name](const Table& t) { return t.m_name == name; };
auto table_def = std::find_if(begin(m_tables), end(m_tables), name_cmp);
if (table_def != std::end(m_tables)) {
if (table_def != std::end(m_tables))
throw Exception("table already exists");
}
}
void USql::check_index_not_exists(const std::string &index_name) {
for (auto &table : m_tables)
if (table.get_index(index_name) != nullptr)
throw Exception("index already exists");
}
} // namespace