2010YOUY01 commented on code in PR #27746:
URL: https://github.com/apache/datafusion/pull/27746#discussion_r4705904352
##########
datafusion/physical-plan/src/joins/join_index.rs:
##########
@@ -0,0 +1,182 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF)
under one or more contributor license agreements
+
+//! Immutable join index, independent of payload storage.
+//!
+//! Lookup resolves exact keys; the join operator handles output batching and
+//! residual predicates. For build keys `[A, B, A]`, the directory maps `A` to
+//! group `[0, 2]` and `B` to row `1`. An all-unique build returns verified row
+//! pairs, avoiding handle-to-pair conversion during output.
+//!
+//! `directory` owns layouts and construction, `keys` owns hashing and exact
+//! comparison, and `matches` owns grouped row IDs and lookup-result memory.
+
+mod directory;
+mod keys;
+mod matches;
+
+use std::mem::size_of;
+use std::ops::Deref;
+
+use arrow::array::{ArrayRef, BooleanArray};
+use datafusion_common::hash_utils::RandomState;
+use datafusion_common::{NullEquality, Result};
+use datafusion_execution::memory_pool::MemoryReservation;
+
+use directory::IndexWidth;
+pub(crate) use keys::LookupScratch;
+pub(crate) use matches::{
+ GroupRows, LookupResult, MatchHandle, MatchHandleArray, MatchHandles,
RowId,
+ UniqueMatches,
+};
+
+/// Maps exact join keys (one or more columns) to matching build-row IDs.
+/// Lookup returns row pairs or group handles for the join processor to
consume.
+/// See [`directory::JoinHashIndex`] for the storage design and a small
example.
+#[derive(Debug)]
+pub(crate) struct JoinIndexMap {
+ /// Index implementation specialized on row-id width.
+ index: IndexWidth,
+ random_state: RandomState,
+ /// See [`NullEquality`] for semantics.
+ ///
+ /// For implementation:
+ /// - `NullEqualsNothing`: skip NULL-key rows during build and probe.
+ /// - `NullEqualsNull`: hash and compare NULL keys
+ null_equality: NullEquality,
Review Comment:
Good point. Added some UTs covering combinations for
- join Null semantics
- row width specialization u32/u64
- directory dense/integer/general
- duplicated matches/unique matches
In
[5eb078b](https://github.com/apache/datafusion/pull/27746/commits/5eb078ba3678dab5708b311f98537b66fc3d86ba)
I think this u64 row-width is also good to get covered in SQL test, maybe by
exposing a test-only config to force this path. This could be done in
follow-ups.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]