Skip to content

Commit

Permalink
Merged !74, made prefix-dot for joins optional, fixed some small issu…
Browse files Browse the repository at this point in the history
…es with the HashJoin

Squashed commit of the following:

commit b9e0e91d2be35da438835bf51896bc1cfdd8abff
Author: Markus Dreseler <[email protected]>
Date:   Fri Mar 31 19:58:34 2017 +0200

    Merged develop and adapted to introduction of second NLJ

    commit 8ca66b5
    Author: Markus Dreseler <[email protected]>
    Date:   Fri Mar 31 19:42:31 2017 +0200

        Harmonized Join Setup

    commit d26e070
    Author: Markus Dreseler <[email protected]>
    Date:   Fri Mar 31 18:39:04 2017 +0200

        Merged !52  NestedLoopJoin from NonHashJoin group

    commit 1d65334
    Author: Moritz Eyssen <[email protected]>
    Date:   Fri Mar 31 08:58:17 2017 +0200

        Doc this_thread_worker and only lock the processing unit one in Worker::operator()()

    commit 42a2d8b
    Author: Jan Kossmann <[email protected]>
    Date:   Thu Mar 30 18:06:21 2017 +0200

        Move index files into separate directory

    commit c1fc107
    Author: Axel Kroschk <[email protected]>
    Date:   Thu Mar 30 10:24:47 2017 +0200

        Merge Adaptive Radix Tree Index (!66)

commit d8127bd9fee14e1ba71557b8c943ca94b3b415e1
Author: Timo Djürken <[email protected]>
Date:   Fri Mar 31 09:45:40 2017 +0200

    Join prefixes no longer include the dot automatically

commit c84b32af72ea06d04fa132cc0456eafa164fad64
Author: Timo Djürken <[email protected]>
Date:   Thu Mar 30 14:44:44 2017 +0200

    Join: correctly handle non-optional column names

commit b122a2e81d7d345dde4f93cf582350c98b89ec93
Author: Timo Djürken <[email protected]>
Date:   Thu Mar 30 14:28:35 2017 +0200

    HashJoin: remove unused property

commit 1a39f8be2687de2cab70992f30800fbcb47e81f3
Author: Timo Djürken <[email protected]>
Date:   Thu Mar 30 14:21:45 2017 +0200

    HashJoin: correctly apply prefixes
  • Loading branch information
mrks committed Mar 31, 2017
1 parent 8ca66b5 commit 15dbd5f
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 103 deletions.
2 changes: 0 additions & 2 deletions src/lib/operators/abstract_join_operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class AbstractJoinOperator : public AbstractReadOnlyOperator {
const std::string _prefix_right;
optional<std::pair<std::string, std::string>> _column_names;

std::shared_ptr<Table> _output_table;

// Some operators need an internal implementation class, mostly in cases where
// their execute method depends on a template parameter. An example for this is
// found in join_nested_loop_a.hpp.
Expand Down
10 changes: 9 additions & 1 deletion src/lib/operators/join_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ JoinHash::JoinHash(const std::shared_ptr<const AbstractOperator> left,
throw std::runtime_error(
"JoinHash: this operator does not support Cross Joins, the optimizer should use Product operator.");
}

if (_mode == Natural) {
throw std::runtime_error("JoinHash: this operator currently does not support Natural Joins.");
}

if (!column_names) {
throw std::runtime_error("JoinHash: optional column names are only supported for Cross and Natural Joins.");
}
}

const std::string JoinHash::name() const { return "JoinHash"; }
Expand Down Expand Up @@ -66,7 +74,7 @@ std::shared_ptr<const Table> JoinHash::on_execute() {
_impl = make_unique_by_column_types<AbstractReadOnlyOperatorImpl, JoinHashImpl>(
build_input->column_type(build_input->column_id_by_name(build_column_name)),
probe_input->column_type(probe_input->column_id_by_name(probe_column_name)), build_operator, probe_operator,
adjusted_column_names, _op, _mode, inputs_swapped);
adjusted_column_names, _op, _mode, _prefix_left, _prefix_right, inputs_swapped);
return _impl->on_execute();
}

Expand Down
14 changes: 9 additions & 5 deletions src/lib/operators/join_hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ class JoinHash::JoinHashImpl : public AbstractJoinOperatorImpl {
public:
JoinHashImpl(const std::shared_ptr<const AbstractOperator> left, const std::shared_ptr<const AbstractOperator> right,
const std::pair<std::string, std::string> &column_names, const std::string &op, const JoinMode mode,
const bool inputs_swapped)
const std::string &prefix_left, const std::string &prefix_right, const bool inputs_swapped)
: _left(left),
_right(right),
_column_names(column_names),
_op(op),
_mode(mode),
_prefix_left(prefix_left),
_prefix_right(prefix_right),
_inputs_swapped(inputs_swapped),
_output_table(std::make_shared<Table>()) {
// Setting comparator to Equal Comparison -> That is the only supported comparison type for Hash Joins
Expand All @@ -86,6 +88,8 @@ class JoinHash::JoinHashImpl : public AbstractJoinOperatorImpl {
const std::pair<std::string, std::string> _column_names;
const std::string _op;
const JoinMode _mode;
const std::string _prefix_left;
const std::string _prefix_right;

const bool _inputs_swapped;
const std::shared_ptr<Table> _output_table;
Expand Down Expand Up @@ -526,11 +530,11 @@ class JoinHash::JoinHashImpl : public AbstractJoinOperatorImpl {
auto _right_column_id = _right_in_table->column_id_by_name(_column_names.second);

if (_inputs_swapped) {
_copy_table_metadata(_right_in_table, _output_table, "left.");
_copy_table_metadata(_left_in_table, _output_table, "right.");
_copy_table_metadata(_right_in_table, _output_table, _prefix_left);
_copy_table_metadata(_left_in_table, _output_table, _prefix_right);
} else {
_copy_table_metadata(_left_in_table, _output_table, "left.");
_copy_table_metadata(_right_in_table, _output_table, "right.");
_copy_table_metadata(_left_in_table, _output_table, _prefix_left);
_copy_table_metadata(_right_in_table, _output_table, _prefix_right);
}

// Pre-partitioning
Expand Down
16 changes: 13 additions & 3 deletions src/lib/operators/join_nested_loop_a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ JoinNestedLoopA::JoinNestedLoopA(const std::shared_ptr<const AbstractOperator> l
optional<std::pair<std::string, std::string>> column_names, const std::string &op,
const JoinMode mode, const std::string &prefix_left, const std::string &prefix_right)
: AbstractJoinOperator(left, right, column_names, op, mode, prefix_left, prefix_right) {
if (mode == Cross) {
throw std::runtime_error(
"JoinNestedLoopA: this operator does not support Cross Joins, the optimizer should use Product operator.");
if (IS_DEBUG) {
if (mode == Cross) {
throw std::runtime_error(
"JoinNestedLoopA: this operator does not support Cross Joins, the optimizer should use Product operator.");
}

if (_mode == Natural) {
throw std::runtime_error("NestedLoopJoin: this operator currently does not support Natural Joins.");
}

if (!column_names) {
throw std::runtime_error("NestedLoopJoin: optional column names are only supported for Cross and Natural Joins.");
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/operators/join_nested_loop_a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JoinNestedLoopA : public AbstractJoinOperator {
JoinNestedLoopA(const std::shared_ptr<const AbstractOperator> left,
const std::shared_ptr<const AbstractOperator> right,
optional<std::pair<std::string, std::string>> column_names, const std::string &op,
const JoinMode mode, const std::string &prefix_left, const std::string &prefix_right);
const JoinMode mode, const std::string &prefix_left = "", const std::string &prefix_right = "");

std::shared_ptr<const Table> on_execute() override;

Expand Down Expand Up @@ -359,13 +359,13 @@ class JoinNestedLoopA::JoinNestedLoopAImpl : public AbstractJoinOperatorImpl {
Left.Right.Right.ColumnA
*/
for (ColumnID column_id = 0; column_id < _left_in_table->col_count(); ++column_id) {
_output_table->add_column(_prefix_left + "." + _left_in_table->column_name(column_id),
_output_table->add_column(_prefix_left + _left_in_table->column_name(column_id),
_left_in_table->column_type(column_id), false);
}

// Preparing output table by adding columns from right table
for (ColumnID column_id = 0; column_id < _right_in_table->col_count(); ++column_id) {
_output_table->add_column(_prefix_right + "." + _right_in_table->column_name(column_id),
_output_table->add_column(_prefix_right + _right_in_table->column_name(column_id),
_right_in_table->column_type(column_id), false);
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib/operators/join_nested_loop_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ void JoinNestedLoopB::_append_columns_to_output(std::shared_ptr<const Table> inp
// Append each column of the input column to the output
for (size_t column_id = 0; column_id < input_table->col_count(); column_id++) {
// Add the column meta data
_output->add_column((prefix.size() ? prefix + "." : "") + input_table->column_name(column_id),
input_table->column_type(column_id), false);
_output->add_column(prefix + input_table->column_name(column_id), input_table->column_type(column_id), false);

// Check whether the column consists of reference columns
const auto r_column = std::dynamic_pointer_cast<ReferenceColumn>(input_table->get_chunk(0).get_column(column_id));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/operators/join_nested_loop_b.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JoinNestedLoopB : public AbstractJoinOperator {
JoinNestedLoopB(const std::shared_ptr<const AbstractOperator> left,
const std::shared_ptr<const AbstractOperator> right,
optional<std::pair<std::string, std::string>> column_names, const std::string& op,
const JoinMode mode, const std::string& prefix_left, const std::string& prefix_right);
const JoinMode mode, const std::string& prefix_left = "", const std::string& prefix_right = "");

const std::string name() const override;
uint8_t num_in_tables() const override;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/operators/product.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ std::shared_ptr<const Table> Product::on_execute() {

// add columns from left table to output
for (size_t col_id = 0; col_id < input_table_left()->col_count(); ++col_id) {
output->add_column((_prefix_left.size() ? _prefix_left + "." : "") + input_table_left()->column_name(col_id),
input_table_left()->column_type(col_id), false);
output->add_column(_prefix_left + input_table_left()->column_name(col_id), input_table_left()->column_type(col_id),
false);
}

// add columns from right table to output
for (size_t col_id = 0; col_id < input_table_right()->col_count(); ++col_id) {
output->add_column((_prefix_right.size() ? _prefix_right + "." : "") + input_table_right()->column_name(col_id),
output->add_column(_prefix_right + input_table_right()->column_name(col_id),
input_table_right()->column_type(col_id), false);
}

Expand Down
Loading

0 comments on commit 15dbd5f

Please sign in to comment.