forked from hyrise/hyrise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,047 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,7 @@ Contact: [email protected] | |
- Timo Djürken | ||
- Moritz Eyssen | ||
- Martin Fischer | ||
- Pedro Flemming | ||
- Michael Janke | ||
- Max Jendruk | ||
- Marvin Keller | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
|
||
#include "benchmark/benchmark.h" | ||
|
||
#include "../../lib/sql/sql_query_translator.hpp" | ||
#include "../base_fixture.cpp" | ||
#include "SQLParser.h" | ||
|
||
namespace opossum { | ||
|
||
class SQLBenchmark : public BenchmarkBasicFixture { | ||
public: | ||
virtual void SetUp(const ::benchmark::State& state) {} | ||
|
||
virtual void TearDown(const ::benchmark::State& state) {} | ||
}; | ||
|
||
BENCHMARK_F(SQLBenchmark, BM_SQLTranslationTotal)(benchmark::State& state) { | ||
clear_cache(); | ||
const std::string query = "SELECT * FROM benchmark_table_one WHERE a >= 7;"; | ||
|
||
while (state.KeepRunning()) { | ||
SQLQueryTranslator translator; | ||
translator.translate_query(query); | ||
} | ||
} | ||
|
||
BENCHMARK_F(SQLBenchmark, BM_SQLTranslationOnlyParsing)(benchmark::State& state) { | ||
clear_cache(); | ||
const std::string query = "SELECT * FROM benchmark_table_one WHERE a >= 7;"; | ||
|
||
while (state.KeepRunning()) { | ||
hsql::SQLParserResult result; | ||
hsql::SQLParser::parseSQLString(query, &result); | ||
} | ||
} | ||
|
||
BENCHMARK_F(SQLBenchmark, BM_SQLTranslationOnlyTransation)(benchmark::State& state) { | ||
clear_cache(); | ||
const std::string query = "SELECT * FROM benchmark_table_one WHERE a >= 7;"; | ||
hsql::SQLParserResult result; | ||
hsql::SQLParser::parseSQLString(query, &result); | ||
|
||
while (state.KeepRunning()) { | ||
SQLQueryTranslator translator; | ||
translator.translate_statement(*result.getStatement(0)); | ||
} | ||
} | ||
|
||
} // namespace opossum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "sql_query_operator.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "sql_query_translator.hpp" | ||
|
||
#include "SQLParser.h" | ||
|
||
namespace opossum { | ||
|
||
SQLQueryOperator::SQLQueryOperator(const std::string& query) : _query(query) { | ||
_result_op = std::make_shared<SQLResultOperator>(); | ||
_result_task = std::make_shared<OperatorTask>(_result_op); | ||
} | ||
|
||
const std::string SQLQueryOperator::name() const { return "SQLQueryOperator"; } | ||
|
||
uint8_t SQLQueryOperator::num_in_tables() const { return 0; } | ||
|
||
uint8_t SQLQueryOperator::num_out_tables() const { return 0; } | ||
|
||
const std::shared_ptr<OperatorTask>& SQLQueryOperator::get_result_task() const { return _result_task; } | ||
|
||
std::shared_ptr<const Table> SQLQueryOperator::on_execute(std::shared_ptr<TransactionContext> context) { | ||
// TODO(torpedro): Check query cache for execution plan. | ||
|
||
// TODO(torpedro): Check query cache for syntax tree. | ||
|
||
SQLQueryTranslator translator; | ||
|
||
hsql::SQLParserResult result; | ||
|
||
if (!translator.parse_query(_query, &result)) { | ||
throw translator.get_error_msg(); | ||
} | ||
|
||
// Translate the query. | ||
if (!translator.translate_parse_result(result)) { | ||
throw translator.get_error_msg(); | ||
} | ||
|
||
// Schedule all tasks. | ||
auto tasks = translator.get_tasks(); | ||
|
||
tasks.back()->set_as_predecessor_of(_result_task); | ||
_result_op->set_input_operator(tasks.back()->get_operator()); | ||
|
||
for (const auto& task : tasks) { | ||
task->schedule(); | ||
} | ||
_result_task->schedule(); | ||
|
||
return nullptr; | ||
} | ||
|
||
} // namespace opossum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "operators/abstract_operator.hpp" | ||
#include "operators/abstract_read_only_operator.hpp" | ||
#include "scheduler/operator_task.hpp" | ||
#include "sql/sql_result_operator.hpp" | ||
|
||
namespace opossum { | ||
|
||
// The SQLQueryOperator takes a SQL query, parses and transforms it. | ||
// The it schedules the resulting execution plan. To get the result | ||
// of the execution plan, it exposes an SQLResultOperator task, which | ||
// will upon completion contain the result table of the query. | ||
class SQLQueryOperator : public AbstractOperator { | ||
public: | ||
explicit SQLQueryOperator(const std::string& query); | ||
|
||
const std::string name() const override; | ||
|
||
uint8_t num_in_tables() const override; | ||
|
||
uint8_t num_out_tables() const override; | ||
|
||
const std::shared_ptr<OperatorTask>& get_result_task() const; | ||
|
||
protected: | ||
std::shared_ptr<const Table> on_execute(std::shared_ptr<TransactionContext> context) override; | ||
|
||
// Raw SQL query string. | ||
const std::string _query; | ||
|
||
// Result operator, which will be dependent on the full execution of the exec plan. | ||
std::shared_ptr<SQLResultOperator> _result_op; | ||
|
||
std::shared_ptr<OperatorTask> _result_task; | ||
}; | ||
|
||
} // namespace opossum |
Oops, something went wrong.