Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: trueeyu <[email protected]>
  • Loading branch information
trueeyu committed Nov 17, 2023
1 parent c0f0b86 commit c0b266d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 51 deletions.
26 changes: 14 additions & 12 deletions be/src/exec/pipeline/nljoin/nljoin_probe_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,24 @@ void NLJoinProbeOperator::_next_build_chunk_index_for_other_join() {

// probe one chunk from right
void NLJoinProbeOperator::_next_probe_row_index_for_inner_join() {
// next build chunk index
_curr_build_chunk_index++;
// all build chunks iter over
if (_curr_build_chunk_index >= _num_build_chunks()) {
_curr_build_chunk_index = 0;
// get next probe row
_probe_row_current++;
// all probe row iter over
if (_probe_row_current >= _probe_chunk->num_rows()) {
// next probe row
_probe_row_current++;
// probe chunk iter over
if (_probe_row_current >= _probe_chunk->num_rows()) {
// next build chunk
_curr_build_chunk_index++;
if (_curr_build_chunk_index >= _num_build_chunks()) {
// build chunks iter over
_curr_build_chunk_index = 0;
_probe_row_current = 0;
_probe_chunk = nullptr;
} else {
// next build chunk
_probe_row_current = 0;
_curr_build_chunk = _cross_join_context->get_build_chunk(_curr_build_chunk_index);
_build_row_current = 0;
}
}
// get next build chunk
_curr_build_chunk = _cross_join_context->get_build_chunk(_curr_build_chunk_index);
_build_row_current = 0;
}

// probe one chunk from left
Expand Down
96 changes: 57 additions & 39 deletions test/sql/test_nest_loop_join/R/test_nest_loop_join
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,37 @@ insert into t2 select generate_series, generate_series from table(generate_serie
-- !result
select count(*) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
1
28
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2, t2.c2 limit 10;
-- result:
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 desc, t2.c2 desc limit 10;
-- result:
2 1
8 7
8 6
8 5
8 4
8 3
8 2
8 1
7 6
7 5
7 4
-- !result
select sum(t1.c2), sum(t2.c2) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
2 1
168 84
-- !result
truncate table t1;
-- result:
Expand All @@ -291,20 +309,20 @@ insert into t2 select generate_series, generate_series from table(generate_serie
-- !result
select count(*) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
16448760
49995000
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2, t2.c2 limit 10;
-- result:
4097 1
4097 2
4097 3
4097 4
4097 5
4097 6
4097 7
4097 8
4097 9
4097 10
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 desc, t2.c2 desc limit 10;
-- result:
Expand All @@ -321,7 +339,7 @@ select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 de
-- !result
select sum(t1.c2), sum(t2.c2) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
150098176080 75049088040
333333330000 166666665000
-- !result
truncate table t1;
-- result:
Expand All @@ -337,20 +355,20 @@ insert into t2 select generate_series, generate_series from table(generate_serie
-- !result
select count(*) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
16428763
49975003
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2, t2.c2 limit 10;
-- result:
4097 1
4097 2
4097 3
4097 4
4097 5
4097 6
4097 7
4097 8
4097 9
4097 10
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 desc, t2.c2 desc limit 10;
-- result:
Expand All @@ -367,7 +385,7 @@ select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 de
-- !result
select sum(t1.c2), sum(t2.c2) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
149898216078 74949108039
333133369998 166566684999
-- !result
truncate table t1;
-- result:
Expand All @@ -383,20 +401,20 @@ insert into t2 select generate_series, generate_series from table(generate_serie
-- !result
select count(*) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
1645815
49994999
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2, t2.c2 limit 10;
-- result:
4097 1
4097 2
4097 3
4097 4
4097 5
4097 6
4097 7
4097 8
4097 9
4097 10
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
-- !result
select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 desc, t2.c2 desc limit 10;
-- result:
Expand All @@ -413,7 +431,7 @@ select t1.c2, t2.c2 from t1 join [broadcast] t2 on t1.c1>t2.c1 order by t1.c2 de
-- !result
select sum(t1.c2), sum(t2.c2) from t1 join [broadcast] t2 on t1.c1>t2.c1;
-- result:
15435784512 14408817945
333333320000 166666655001
-- !result
truncate table t1;
-- result:
Expand Down

0 comments on commit c0b266d

Please sign in to comment.