@@ -35,19 +35,19 @@ void write_output_rows(RowWriter &group, RowWriter &w) {
35
35
36
36
/* *
37
37
* Sort merge equi join algorithm
38
- * Input: the rows are unioned from both the left (primary ) table and the right (foreign ) table
38
+ * Input: the rows are unioned from both the primary (or left ) table and the non-primary (or right ) table
39
39
*
40
40
* Outer loop: iterate over all input rows
41
41
*
42
42
* If it's a row from the left table
43
43
* - Add it to the current group
44
44
* - Otherwise start a new group
45
- * - If it's a left semi/anti join, output the left_matched_rows/left_unmatched_rows
45
+ * - If it's a left semi/anti join, output the primary_matched_rows/primary_unmatched_rows
46
46
*
47
47
* If it's a row from the right table
48
- * - Inner join: iterate over current primary group, output the joined row only if the condition is satisfied
49
- * - Left semi/anti join: iterate over `left_unmatched_rows `, add a matched row to `left_matched_rows `
50
- * and remove from `left_unmatched_rows `
48
+ * - Inner join: iterate over current left group, output the joined row only if the condition is satisfied
49
+ * - Left semi/anti join: iterate over `primary_unmatched_rows `, add a matched row to `primary_matched_rows `
50
+ * and remove from `primary_unmatched_rows `
51
51
*
52
52
* After loop: output the last group left semi/anti join
53
53
*/
@@ -64,7 +64,7 @@ void non_oblivious_sort_merge_join(
64
64
65
65
RowWriter primary_group;
66
66
FlatbuffersTemporaryRow last_primary_of_group;
67
- RowWriter left_matched_rows, left_unmatched_rows ; // This is only used for left semi/anti join
67
+ RowWriter primary_matched_rows, primary_unmatched_rows ; // This is only used for left semi/anti join
68
68
69
69
while (r.has_next ()) {
70
70
const tuix::Row *current = r.next ();
@@ -74,27 +74,27 @@ void non_oblivious_sort_merge_join(
74
74
&& join_expr_eval.is_same_group (last_primary_of_group.get (), current)) {
75
75
76
76
// Add this primary row to the current group
77
- // If this is a left semi/anti join, also add the rows to the left group
77
+ // If this is a left semi/anti join, also add the rows to primary_unmatched_rows
78
78
primary_group.append (current);
79
79
if (join_type == tuix::JoinType_LeftSemi || join_type == tuix::JoinType_LeftAnti) {
80
- left_unmatched_rows .append (current);
80
+ primary_unmatched_rows .append (current);
81
81
}
82
82
last_primary_of_group.set (current);
83
83
84
84
} else {
85
85
// If a new primary group is encountered
86
86
if (join_type == tuix::JoinType_LeftSemi) {
87
- write_output_rows (left_matched_rows , w);
87
+ write_output_rows (primary_matched_rows , w);
88
88
} else if (join_type == tuix::JoinType_LeftAnti) {
89
- write_output_rows (left_unmatched_rows , w);
89
+ write_output_rows (primary_unmatched_rows , w);
90
90
}
91
91
92
92
primary_group.clear ();
93
- left_unmatched_rows .clear ();
94
- left_matched_rows .clear ();
93
+ primary_unmatched_rows .clear ();
94
+ primary_matched_rows .clear ();
95
95
96
96
primary_group.append (current);
97
- left_unmatched_rows .append (current);
97
+ primary_unmatched_rows .append (current);
98
98
last_primary_of_group.set (current);
99
99
}
100
100
} else {
@@ -112,36 +112,36 @@ void non_oblivious_sort_merge_join(
112
112
}
113
113
}
114
114
} else if (join_type == tuix::JoinType_LeftSemi || join_type == tuix::JoinType_LeftAnti) {
115
- auto left_unmatched_rows_buffer = left_unmatched_rows .output_buffer ();
116
- RowReader left_unmatched_rows_reader (left_unmatched_rows_buffer .view ());
117
- RowWriter new_left_unmatched_rows ;
115
+ auto primary_unmatched_rows_buffer = primary_unmatched_rows .output_buffer ();
116
+ RowReader primary_unmatched_rows_reader (primary_unmatched_rows_buffer .view ());
117
+ RowWriter new_primary_unmatched_rows ;
118
118
119
- while (left_unmatched_rows_reader .has_next ()) {
120
- const tuix::Row *primary = left_unmatched_rows_reader .next ();
119
+ while (primary_unmatched_rows_reader .has_next ()) {
120
+ const tuix::Row *primary = primary_unmatched_rows_reader .next ();
121
121
test_rows_same_group (join_expr_eval, primary, current);
122
122
if (join_expr_eval.eval_condition (primary, current)) {
123
- left_matched_rows .append (primary);
123
+ primary_matched_rows .append (primary);
124
124
} else {
125
- new_left_unmatched_rows .append (primary);
125
+ new_primary_unmatched_rows .append (primary);
126
126
}
127
127
}
128
128
129
- // Reset left_unmatched_rows
130
- left_unmatched_rows .clear ();
131
- auto new_left_unmatched_rows_buffer = new_left_unmatched_rows .output_buffer ();
132
- RowReader new_left_unmatched_rows_reader (new_left_unmatched_rows_buffer .view ());
133
- while (new_left_unmatched_rows_reader .has_next ()) {
134
- left_unmatched_rows .append (new_left_unmatched_rows_reader .next ());
129
+ // Reset primary_unmatched_rows
130
+ primary_unmatched_rows .clear ();
131
+ auto new_primary_unmatched_rows_buffer = new_primary_unmatched_rows .output_buffer ();
132
+ RowReader new_primary_unmatched_rows_reader (new_primary_unmatched_rows_buffer .view ());
133
+ while (new_primary_unmatched_rows_reader .has_next ()) {
134
+ primary_unmatched_rows .append (new_primary_unmatched_rows_reader .next ());
135
135
}
136
136
}
137
137
}
138
138
}
139
139
}
140
140
141
141
if (join_type == tuix::JoinType_LeftSemi) {
142
- write_output_rows (left_matched_rows , w);
142
+ write_output_rows (primary_matched_rows , w);
143
143
} else if (join_type == tuix::JoinType_LeftAnti) {
144
- write_output_rows (left_unmatched_rows , w);
144
+ write_output_rows (primary_unmatched_rows , w);
145
145
}
146
146
147
147
w.output_buffer (output_rows, output_rows_length);
0 commit comments