pub struct HashJoinOperator { /* private fields */ }Expand description
Streaming hash join operator.
The join proceeds in two phases:
-
Build Phase (in
open()):- Materialize the build side (smaller side)
- Build hash table on join keys
-
Probe Phase (in
next()):- Stream through probe side one row at a time
- Lookup matches in hash table
- Return combined rows
For OUTER joins, additional tracking is used to ensure unmatched rows are returned with NULL padding.
Implementations§
Source§impl HashJoinOperator
impl HashJoinOperator
Sourcepub fn new(
left: Box<dyn Operator>,
right: Box<dyn Operator>,
join_type: JoinType,
left_key_indices: Vec<usize>,
right_key_indices: Vec<usize>,
build_side: JoinSide,
) -> Self
pub fn new( left: Box<dyn Operator>, right: Box<dyn Operator>, join_type: JoinType, left_key_indices: Vec<usize>, right_key_indices: Vec<usize>, build_side: JoinSide, ) -> Self
Create a new hash join operator.
§Arguments
left- Left input operatorright- Right input operatorjoin_type- Type of join (INNER, LEFT, RIGHT, FULL)left_key_indices- Column indices for left join keysright_key_indices- Column indices for right join keysbuild_side- Which side to use as build (typically smaller)
Sourcepub fn with_prebuilt(
probe: Box<dyn Operator>,
hash_state: JoinHashState,
join_type: JoinType,
left_key_indices: Vec<usize>,
right_key_indices: Vec<usize>,
build_is_left: bool,
build_col_count: usize,
) -> Result<Self>
pub fn with_prebuilt( probe: Box<dyn Operator>, hash_state: JoinHashState, join_type: JoinType, left_key_indices: Vec<usize>, right_key_indices: Vec<usize>, build_is_left: bool, build_col_count: usize, ) -> Result<Self>
Create a hash join operator with pre-built hash table and rows.
This avoids the build phase in open() since the hash table is already
constructed. Used by streaming joins where hash table and bloom filter
are built together in a single pass for efficiency.
§Arguments
probe- Probe side operator (will be iterated during join)hash_state- Exact build rows, key layout and their pre-built tablejoin_type- Type of joinleft_key_indices- Key indices for the logical left sideright_key_indices- Key indices for the logical right sidebuild_is_left- Whether build side is left (for schema ordering)
Sourcepub fn self_join(
input: Box<dyn Operator>,
join_type: JoinType,
left_key_indices: Vec<usize>,
right_key_indices: Vec<usize>,
) -> Self
pub fn self_join( input: Box<dyn Operator>, join_type: JoinType, left_key_indices: Vec<usize>, right_key_indices: Vec<usize>, ) -> Self
Create an optimized self-join operator.
For self-joins (t1 JOIN t1), this avoids scanning the table twice by reusing the same materialized data for both build and probe.
Sourcepub fn with_projection(
self,
columns: Vec<ColumnSource>,
projected_schema: Vec<ColumnInfo>,
) -> Self
pub fn with_projection( self, columns: Vec<ColumnSource>, projected_schema: Vec<ColumnInfo>, ) -> Self
Set projection pushdown configuration.
When set, the operator creates projected rows directly from the left/right
sources instead of materializing a full combined join row and projecting it
later. ColumnSource::Outer means the logical left side and
ColumnSource::Inner means the logical right side.
Sourcepub fn with_residual_filters(self, filters: Vec<JoinFilter>) -> Self
pub fn with_residual_filters(self, filters: Vec<JoinFilter>) -> Self
Attach the non-equality part of ON to the hash match-state owner.
Equality hash hits do not count as matches until every residual accepts
the same virtual left/right pair.