From 9717b99622d827d6ac3de4a54836242b6cc7e68d Mon Sep 17 00:00:00 2001 From: Viktor Leis Date: Wed, 20 Dec 2023 15:40:15 +0100 Subject: [PATCH 1/2] Downgrade to C++20 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index af9ec38..c39617c 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ src:=parser/ASTBase.cpp parser/SaneQLLexer.cpp infra/Schema.cpp semana/Functions gensrc:=$(PREFIX)parser/saneql_parser.cpp obj:=$(addprefix $(PREFIX),$(src:.cpp=.o)) $(gensrc:.cpp=.o) -CXXFLAGS:=-std=c++23 -I$(PREFIX) -I. -g -Wall -Wextra +CXXFLAGS:=-std=c++20 -I$(PREFIX) -I. -g -Wall -Wextra -include $(addprefix $(PREFIX),$(src:.cpp=.d)) $(gensrc:.cpp=.d) From 2c839bf6ab70231a42a2d310e56178635a0883ae Mon Sep 17 00:00:00 2001 From: Viktor Leis Date: Wed, 20 Dec 2023 15:40:51 +0100 Subject: [PATCH 2/2] Change join, map, and window operators such that they add new attributes at the front --- semana/SemanticAnalysis.cpp | 20 +++++++++++++------- semana/SemanticAnalysis.hpp | 4 +++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/semana/SemanticAnalysis.cpp b/semana/SemanticAnalysis.cpp index 695f8c2..89a8d24 100644 --- a/semana/SemanticAnalysis.cpp +++ b/semana/SemanticAnalysis.cpp @@ -183,7 +183,7 @@ SemanticAnalysis::BindingInfo::Scope* SemanticAnalysis::BindingInfo::addScope(co return &(scopes[name]); } //--------------------------------------------------------------------------- -void SemanticAnalysis::BindingInfo::addBinding(Scope* scope, const string& column, const algebra::IU* iu) +void SemanticAnalysis::BindingInfo::addBinding(Scope* scope, const string& column, const algebra::IU* iu, bool toEnd) // Add a binding { if (scope) { @@ -198,7 +198,13 @@ void SemanticAnalysis::BindingInfo::addBinding(Scope* scope, const string& colum e = ambiguousIU; else e = iu; - columns.push_back({column, iu}); + columns.insert((toEnd ? columns.end() : columns.begin()), 1, {column, iu}); +} +//--------------------------------------------------------------------------- +void SemanticAnalysis::BindingInfo::addBindingAtFront(Scope* scope, const string& column, const algebra::IU* iu) +// Add a binding +{ + addBinding(scope, column, iu, false); } //--------------------------------------------------------------------------- const algebra::IU* SemanticAnalysis::BindingInfo::lookup(const string& name) const @@ -246,7 +252,7 @@ SemanticAnalysis::BindingInfo::ArgumentInformation SemanticAnalysis::BindingInfo void SemanticAnalysis::BindingInfo::join(const BindingInfo& other) // Merge after a join { - columns.insert(columns.end(), other.columns.begin(), other.columns.end()); + columns.insert(columns.begin(), other.columns.begin(), other.columns.end()); for (auto& c : other.columnLookup) { if (!columnLookup.count(c.first)) { columnLookup.insert(c); @@ -768,10 +774,10 @@ SemanticAnalysis::ExpressionResult SemanticAnalysis::analyzeMap(ExpressionResult name = to_string(scope->columns.size() + 1); } if (auto iuref = dynamic_cast(results[slot].value.get())) { - resultBinding.addBinding(scope, name, iuref->getIU()); + resultBinding.addBindingAtFront(scope, name, iuref->getIU()); results[slot].iu.reset(); } else { - resultBinding.addBinding(scope, name, results[slot].iu.get()); + resultBinding.addBindingAtFront(scope, name, results[slot].iu.get()); } ++slot; } @@ -869,10 +875,10 @@ SemanticAnalysis::ExpressionResult SemanticAnalysis::analyzeWindow(ExpressionRes name = to_string(scope->columns.size() + 1); } if (auto iuref = dynamic_cast(results[slot].value.get())) { - resultBinding.addBinding(scope, name, iuref->getIU()); + resultBinding.addBindingAtFront(scope, name, iuref->getIU()); results[slot].iu.reset(); } else { - resultBinding.addBinding(scope, name, results[slot].iu.get()); + resultBinding.addBindingAtFront(scope, name, results[slot].iu.get()); } ++slot; } diff --git a/semana/SemanticAnalysis.hpp b/semana/SemanticAnalysis.hpp index 53e4ede..a0fc3e4 100644 --- a/semana/SemanticAnalysis.hpp +++ b/semana/SemanticAnalysis.hpp @@ -147,7 +147,9 @@ class SemanticAnalysis { /// Add a new scope, mark it as ambiguous if it already exists Scope* addScope(const std::string& name); /// Add a binding - void addBinding(Scope* scope, const std::string& column, const algebra::IU* iu); + void addBinding(Scope* scope, const std::string& column, const algebra::IU* iu, bool toEnd=true); + /// Add a binding at the front of the columns list + void addBindingAtFront(Scope* scope, const std::string& column, const algebra::IU* iu); /// Lookup a column const algebra::IU* lookup(const std::string& name) const;