You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2025/03/11 15:44:04 UTC
(ignite-3) 04/04: Optimize HashJoinNode preventing read left source when right is empty.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-24765
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 11c4aeccbceb5785c144ebe3e9a8c024d4ea29ea
Author: amashenkov <am...@apache.org>
AuthorDate: Tue Mar 11 18:36:20 2025 +0300
Optimize HashJoinNode preventing read left source when right is empty.
---
.../internal/sql/engine/exec/rel/AbstractNode.java | 4 ++
.../internal/sql/engine/exec/rel/HashJoinNode.java | 57 ++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/AbstractNode.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/AbstractNode.java
index 4c8229b100c..d0021e9c7a0 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/AbstractNode.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/AbstractNode.java
@@ -34,12 +34,16 @@ public abstract class AbstractNode<RowT> implements Node<RowT> {
/** Special value to highlights that all row were received and we are not waiting any more. */
static final int NOT_WAITING = -1;
+ /** Batch size for DML operations. */
public static final int MODIFY_BATCH_SIZE = 100;
+ /** Batch size for network operations. */
static final int IO_BATCH_SIZE = Commons.IO_BATCH_SIZE;
+ /** Max count for parallel network requests. */
static final int IO_BATCH_CNT = Commons.IO_BATCH_COUNT;
+ /** Execution node buffer size. */
protected final int inBufSize;
private final ExecutionContext<RowT> ctx;
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/HashJoinNode.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/HashJoinNode.java
index 1da002714d4..2fd0f3188ca 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/HashJoinNode.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/HashJoinNode.java
@@ -155,6 +155,25 @@ public abstract class HashJoinNode<RowT> extends AbstractRightMaterializedJoinNo
super(ctx, joinInfo, outputRowFactory, nonEquiCondition);
}
+ @Override
+ protected void pushLeft(RowT row) throws Exception {
+ // Prefent fetching left if right is empty.
+ if (waitingRight == NOT_WAITING && hashStore.isEmpty()) {
+ waitingLeft--;
+
+ if (waitingLeft == 0) {
+ waitingLeft = NOT_WAITING;
+ leftInBuf.clear();
+
+ join();
+ }
+
+ return;
+ }
+
+ super.pushLeft(row);
+ }
+
@Override
protected void join() throws Exception {
if (waitingRight == NOT_WAITING) {
@@ -333,6 +352,25 @@ public abstract class HashJoinNode<RowT> extends AbstractRightMaterializedJoinNo
super.rewindInternal();
}
+ @Override
+ protected void pushLeft(RowT row) throws Exception {
+ // Prefent fetching left if right is empty.
+ if (waitingRight == NOT_WAITING && hashStore.isEmpty()) {
+ waitingLeft--;
+
+ if (waitingLeft == 0) {
+ waitingLeft = NOT_WAITING;
+ leftInBuf.clear();
+
+ join();
+ }
+
+ return;
+ }
+
+ super.pushLeft(row);
+ }
+
@Override
protected void join() throws Exception {
if (waitingRight == NOT_WAITING) {
@@ -588,6 +626,25 @@ public abstract class HashJoinNode<RowT> extends AbstractRightMaterializedJoinNo
super(ctx, joinInfo, outputRowFactory, nonEquiCondition);
}
+ @Override
+ protected void pushLeft(RowT row) throws Exception {
+ // Prefent fetching left if right is empty.
+ if (waitingRight == NOT_WAITING && hashStore.isEmpty()) {
+ waitingLeft--;
+
+ if (waitingLeft == 0) {
+ waitingLeft = NOT_WAITING;
+ leftInBuf.clear();
+
+ join();
+ }
+
+ return;
+ }
+
+ super.pushLeft(row);
+ }
+
/** {@inheritDoc} */
@Override
protected void join() throws Exception {