-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broadcast Nested Loop Join - Left Anti and Left Semi (#159)
This PR is the first of two parts towards making TPC-H 16 work: the other will be implementing `is_distinct` for aggregate operations. `BroadcastNestedLoopJoin` is Spark's "catch all" for non-equi joins. It works by first picking a side to broadcast, then iterating through every possible row combination and checking the non-equi condition against the pair.
- Loading branch information
1 parent
3c28b5f
commit a4a6ff9
Showing
16 changed files
with
418 additions
and
63 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
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,54 @@ | ||
#include "BroadcastNestedLoopJoin.h" | ||
|
||
#include "ExpressionEvaluation.h" | ||
#include "FlatbuffersReaders.h" | ||
#include "FlatbuffersWriters.h" | ||
#include "common.h" | ||
|
||
/** C++ implementation of a broadcast nested loop join. | ||
* Assumes outer_rows is streamed and inner_rows is broadcast. | ||
* DOES NOT rely on rows to be tagged primary or secondary, and that | ||
* assumption will break the implementation. | ||
*/ | ||
void broadcast_nested_loop_join( | ||
uint8_t *join_expr, size_t join_expr_length, | ||
uint8_t *outer_rows, size_t outer_rows_length, | ||
uint8_t *inner_rows, size_t inner_rows_length, | ||
uint8_t **output_rows, size_t *output_rows_length) { | ||
|
||
FlatbuffersJoinExprEvaluator join_expr_eval(join_expr, join_expr_length); | ||
const tuix::JoinType join_type = join_expr_eval.get_join_type(); | ||
|
||
RowReader outer_r(BufferRefView<tuix::EncryptedBlocks>(outer_rows, outer_rows_length)); | ||
RowWriter w; | ||
|
||
while (outer_r.has_next()) { | ||
const tuix::Row *outer = outer_r.next(); | ||
bool o_i_match = false; | ||
|
||
RowReader inner_r(BufferRefView<tuix::EncryptedBlocks>(inner_rows, inner_rows_length)); | ||
const tuix::Row *inner; | ||
while (inner_r.has_next()) { | ||
inner = inner_r.next(); | ||
o_i_match |= join_expr_eval.eval_condition(outer, inner); | ||
} | ||
|
||
switch(join_type) { | ||
case tuix::JoinType_LeftAnti: | ||
if (!o_i_match) { | ||
w.append(outer); | ||
} | ||
break; | ||
case tuix::JoinType_LeftSemi: | ||
if (o_i_match) { | ||
w.append(outer); | ||
} | ||
break; | ||
default: | ||
throw std::runtime_error( | ||
std::string("Join type not supported: ") | ||
+ std::string(to_string(join_type))); | ||
} | ||
} | ||
w.output_buffer(output_rows, output_rows_length); | ||
} |
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,8 @@ | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
void broadcast_nested_loop_join( | ||
uint8_t *join_expr, size_t join_expr_length, | ||
uint8_t *outer_rows, size_t outer_rows_length, | ||
uint8_t *inner_rows, size_t inner_rows_length, | ||
uint8_t **output_rows, size_t *output_rows_length); |
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
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
5 changes: 0 additions & 5 deletions
5
src/enclave/Enclave/Join.h → ...clave/Enclave/NonObliviousSortMergeJoin.h
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 |
---|---|---|
@@ -1,12 +1,7 @@ | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
#ifndef JOIN_H | ||
#define JOIN_H | ||
|
||
void non_oblivious_sort_merge_join( | ||
uint8_t *join_expr, size_t join_expr_length, | ||
uint8_t *input_rows, size_t input_rows_length, | ||
uint8_t **output_rows, size_t *output_rows_length); | ||
|
||
#endif |
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
Oops, something went wrong.