Skip to content

Commit ec9c55d

Browse files
committed
fix tests
1 parent 6a9ca4b commit ec9c55d

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

src/query/service/src/pipelines/processors/transforms/hash_join/desc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
use std::collections::HashMap;
16-
use std::collections::HashSet;
1716

1817
use common_exception::Result;
1918
use common_functions::scalars::FunctionFactory;
@@ -29,15 +28,15 @@ use crate::sql::plans::JoinType;
2928

3029
pub struct RightJoinDesc {
3130
/// Record rows in build side that are matched with rows in probe side.
32-
pub(crate) build_indexes: RwLock<HashSet<RowPtr>>,
31+
pub(crate) build_indexes: RwLock<Vec<RowPtr>>,
3332
/// Record row in build side that is matched how many rows in probe side.
3433
pub(crate) row_state: RwLock<HashMap<RowPtr, usize>>,
3534
}
3635

3736
impl RightJoinDesc {
3837
pub fn create() -> Self {
3938
RightJoinDesc {
40-
build_indexes: RwLock::new(HashSet::new()),
39+
build_indexes: RwLock::new(Vec::new()),
4140
row_state: RwLock::new(HashMap::new()),
4241
}
4342
}

src/query/service/src/pipelines/processors/transforms/hash_join/join_hash_table.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use std::borrow::BorrowMut;
16+
use std::collections::HashSet;
1617
use std::fmt::Debug;
1718
use std::sync::Arc;
1819
use std::sync::Mutex;
@@ -437,30 +438,24 @@ impl JoinHashTable {
437438
// For right join, build side will appear at lease once in the joined table
438439
// Find the unmatched rows in build side
439440
let mut unmatched_build_indexes = vec![];
440-
{
441-
let chunks = self.row_space.chunks.read().unwrap();
442-
for (chunk_index, chunk) in chunks.iter().enumerate() {
443-
for row_index in 0..chunk.num_rows() {
444-
let row_ptr = RowPtr {
445-
chunk_index: chunk_index as u32,
446-
row_index: row_index as u32,
447-
marker: None,
448-
};
449-
if !self
450-
.hash_join_desc
451-
.right_join_desc
452-
.build_indexes
453-
.read()
454-
.contains(&row_ptr)
455-
{
456-
let mut row_state = self.hash_join_desc.right_join_desc.row_state.write();
457-
row_state.entry(row_ptr).or_insert(0_usize);
458-
unmatched_build_indexes.push(row_ptr);
459-
}
441+
let build_indexes = self.hash_join_desc.right_join_desc.build_indexes.read();
442+
let build_indexes_set: HashSet<&RowPtr> = build_indexes.iter().collect();
443+
let chunks = self.row_space.chunks.read().unwrap();
444+
for (chunk_index, chunk) in chunks.iter().enumerate() {
445+
for row_index in 0..chunk.num_rows() {
446+
let row_ptr = RowPtr {
447+
chunk_index: chunk_index as u32,
448+
row_index: row_index as u32,
449+
marker: None,
450+
};
451+
if !build_indexes_set.contains(&row_ptr) {
452+
let mut row_state = self.hash_join_desc.right_join_desc.row_state.write();
453+
row_state.entry(row_ptr).or_insert(0_usize);
454+
unmatched_build_indexes.push(row_ptr);
460455
}
461456
}
462-
drop(chunks);
463457
}
458+
drop(chunks);
464459
Ok(unmatched_build_indexes)
465460
}
466461
}

src/query/service/src/pipelines/processors/transforms/hash_join/result_blocks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::collections::HashSet;
1615
use std::iter::TrustedLen;
1716

1817
use common_arrow::arrow::bitmap::Bitmap;
@@ -656,7 +655,7 @@ impl JoinHashTable {
656655

657656
pub(crate) fn filter_rows_for_right_join(
658657
bm: &mut MutableBitmap,
659-
build_indexes: &HashSet<RowPtr>,
658+
build_indexes: &Vec<RowPtr>,
660659
row_state: &mut std::collections::HashMap<RowPtr, usize>,
661660
) {
662661
for (index, row) in build_indexes.iter().enumerate() {

0 commit comments

Comments
 (0)