walterddr commented on code in PR #11112:
URL: https://github.com/apache/pinot/pull/11112#discussion_r1263916123
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/HashJoinOperator.java:
##########
@@ -213,57 +218,97 @@ private TransferableBlock
buildJoinedDataBlock(TransferableBlock leftBlock)
_isTerminated = true;
return new TransferableBlock(returnRows, _resultSchema,
DataBlock.Type.ROW);
}
- List<Object[]> rows = new ArrayList<>();
- List<Object[]> container = leftBlock.isEndOfStreamBlock() ? new
ArrayList<>() : leftBlock.getContainer();
- for (Object[] leftRow : container) {
- Key key = new Key(_leftKeySelector.getKey(leftRow));
+ List<Object[]> rows;
+ if (leftBlock.isEndOfStreamBlock()) {
+ rows = new ArrayList<>();
+ } else {
switch (_joinType) {
- case SEMI:
- // SEMI-JOIN only checks existence of the key
- if (_broadcastRightTable.containsKey(key)) {
- rows.add(joinRow(leftRow, null));
- }
+ case SEMI: {
+ rows = buildJoinedDataBlockSemi(leftBlock);
break;
- case ANTI:
- // ANTI-JOIN only checks non-existence of the key
- if (!_broadcastRightTable.containsKey(key)) {
- rows.add(joinRow(leftRow, null));
- }
+ }
+ case ANTI: {
+ rows = buildJoinedDataBlockAnti(leftBlock);
break;
- default: // INNER, LEFT, RIGHT, FULL
- // NOTE: Empty key selector will always give same hash code.
- List<Object[]> matchedRightRows =
_broadcastRightTable.getOrDefault(key, null);
- if (matchedRightRows == null) {
- if (needUnmatchedLeftRows()) {
- rows.add(joinRow(leftRow, null));
- }
- continue;
- }
- boolean hasMatchForLeftRow = false;
- for (int i = 0; i < matchedRightRows.size(); i++) {
- Object[] rightRow = matchedRightRows.get(i);
- // TODO: Optimize this to avoid unnecessary object copy.
- Object[] resultRow = joinRow(leftRow, rightRow);
- if (_joinClauseEvaluators.isEmpty() ||
_joinClauseEvaluators.stream().allMatch(
- evaluator -> (Boolean)
TypeUtils.convert(evaluator.apply(resultRow),
- DataSchema.ColumnDataType.BOOLEAN))) {
- rows.add(resultRow);
- hasMatchForLeftRow = true;
- if (_matchedRightRows != null) {
- HashSet<Integer> matchedRows =
_matchedRightRows.computeIfAbsent(key, k -> new HashSet<>());
- matchedRows.add(i);
- }
- }
- }
- if (!hasMatchForLeftRow && needUnmatchedLeftRows()) {
- rows.add(joinRow(leftRow, null));
- }
+ }
+ default: {
+ rows = buildJoinedDataBlockDefault(leftBlock);
break;
+ }
}
}
return new TransferableBlock(rows, _resultSchema, DataBlock.Type.ROW);
}
+ // INNER, LEFT, RIGHT, FULL
Review Comment:
the comment is meant for next private method?
--
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]