Skip to content
Snippets Groups Projects
Commit d4d621e6 authored by Thomas Blum's avatar Thomas Blum
Browse files

refactor

parent 310abffa
No related branches found
No related tags found
No related merge requests found
Pipeline #38732 failed
......@@ -358,6 +358,9 @@ branch_id_t Database::createBranch(const std::string & name, branch_id_t parent)
void Database::constructBranchLineage(branch_id_t branch, ExecutionContext & dstCtx) {
assert(branch != invalid_branch_id);
if (dstCtx.branch_lineages.find(branch) == dstCtx.branch_lineages.end()) {
dstCtx.branch_lineages[branch] = std::unordered_map<branch_id_t, branch_id_t>();
}
dstCtx.branch_lineage.clear();
dstCtx.branch_lineage_bitset.clear();
dstCtx.branch_lineage_bitset.resize(_next_branch_id);
......@@ -369,6 +372,7 @@ void Database::constructBranchLineage(branch_id_t branch, ExecutionContext & dst
if (branch_obj->parent_id == invalid_branch_id) {
break;
}
dstCtx.branch_lineages[branch].insert({branch_obj->parent_id, current});
dstCtx.branch_lineage.insert({branch_obj->parent_id, current});
current = branch_obj->parent_id;
}
......
......@@ -264,9 +264,9 @@ std::unique_ptr<Native::Sql::SqlTuple> get_latest_tuple(tid_t tid, Table & table
const void *get_latest_entry(tid_t tid, Table & table, branch_id_t branchId, QueryContext & ctx) {
ctx.executionContext.branchId = branchId;
ctx.analyzingContext.db.constructBranchLineage(ctx.executionContext.branchId, ctx.executionContext);
ctx.executionContext.branch_lineage = ctx.executionContext.branch_lineages[branchId];
if (ctx.executionContext.branchId == master_branch_id) {
if (branchId == master_branch_id) {
return nullptr;
}
......
#ifndef PROTODB_QUERYCONTEXT_HPP
#define PROTODB_QUERYCONTEXT_HPP
#include "queryExecutor/ExecutionContext.hpp"
#if USE_HYRISE
#include "SQLParser.h"
#else
......@@ -18,6 +19,8 @@ struct QueryContext {
CodeGen & codeGen;
static void constructBranchLineages(std::set<branch_id_t> &branches, QueryContext &context);
ExecutionContext executionContext;
semanticalAnalysis::AnalyzingContext analyzingContext;
#if USE_HYRISE
......
......@@ -21,6 +21,7 @@ struct ExecutionContext {
bool overflowFlag = false;
branch_id_t branchId = 0;
std::unordered_map<branch_id_t, branch_id_t> branch_lineage; // mapping: parent -> offspring
std::unordered_map<branch_id_t,std::unordered_map<branch_id_t, branch_id_t>> branch_lineages;
boost::dynamic_bitset<> branch_lineage_bitset;
};
......
......@@ -21,6 +21,7 @@ namespace semanticalAnalysis {
std::unordered_map<std::string, iu_p_t> scope;
JoinGraph graph;
std::set<branch_id_t> branchIds;
std::unordered_map<std::string,std::unordered_map<std::string, iu_p_t>> ius;
std::unordered_map<std::string, std::unique_ptr<Operator>> dangling_productions;
......
......@@ -5,6 +5,12 @@ void ExecutionContext::acquireResource(std::unique_ptr<ExecutionResource> && res
resources.push_back(std::move(resource));
}
void QueryContext::constructBranchLineages(std::set<branch_id_t> &branches, QueryContext &context) {
for (auto &branch : branches) {
context.analyzingContext.db.constructBranchLineage(branch,context.executionContext);
}
}
#if USE_HYRISE
std::tuple<std::string,int,int> QueryContext::convertDataType(hsql::ColumnType type) {
......
......@@ -78,6 +78,8 @@ namespace QueryCompiler {
auto queryFunc = compileQuery(query, queryTree,queryContext);
if (queryFunc == nullptr) return;
QueryContext::constructBranchLineages(queryContext.analyzingContext.branchIds,queryContext);
std::vector<llvm::GenericValue> args(2);
args[0].IntVal = llvm::APInt(64, 5);
args[1].PointerVal = (void *) &queryContext;
......@@ -113,6 +115,8 @@ namespace QueryCompiler {
const auto translationDuration = std::chrono::high_resolution_clock::now() - translationStart;
if (queryFunc == nullptr) unreachable();
QueryContext::constructBranchLineages(queryContext.analyzingContext.branchIds,queryContext);
std::vector<llvm::GenericValue> args(2);
args[0].IntVal = llvm::APInt(64, 5);
args[1].PointerVal = (void *) &queryContext;
......
......@@ -26,6 +26,7 @@ namespace semanticalAnalysis {
} else {
branchId = master_branch_id;
}
context.branchIds.insert(branchId);
//Construct the logical TableScan operator
Table* table = context.db.getTable(relation.name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment