Skip to content

Commit

Permalink
Tests passing code coverage examined. 100% reached in main lines, not…
Browse files Browse the repository at this point in the history
… 100% in alternate.
  • Loading branch information
lbooker42 committed Jan 30, 2025
1 parent d87b622 commit b6cb1e0
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,26 @@ public WritableRowRedirection buildRowRedirectionFromRedirections(QueryTable lef
final WritableRowSet leftRowSet = this.mainLeftRowSet.getUnsafe(ii);
if (leftRowSet != null && !leftRowSet.isEmpty()) {
final long rightRowKeyForState = mainRightRowKey.getUnsafe(ii);
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
if (rightRowKeyForState == RowSet.NULL_ROW_KEY) {
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
} else if (rightRowKeyForState <= FIRST_DUPLICATE) {
// Multiple RHS rows, we may have an error state
if (joinType == NaturalJoinType.FIRST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long firstKey = rightSideDuplicateRowSets.getUnsafe(location).firstRowKey();
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = firstKey);
} else if (joinType == NaturalJoinType.LAST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long lastKey = rightSideDuplicateRowSets.getUnsafe(location).lastRowKey();
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = lastKey);
} else {
throw new IllegalStateException("Natural Join found duplicate right key for "
+ extractKeyStringFromSourceTable(leftRowSet.firstRowKey()));
}
} else {
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
}
}
}

Expand Down Expand Up @@ -613,10 +631,24 @@ public WritableRowRedirection buildRowRedirectionFromRedirections(QueryTable lef
final WritableRowSet leftRowSet = this.mainLeftRowSet.getUnsafe(ii);
if (leftRowSet != null && !leftRowSet.isEmpty()) {
final long rightRowKeyForState = mainRightRowKey.getUnsafe(ii);
if (rightRowKeyForState != RowSet.NULL_ROW_KEY) {
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, rightRowKeyForState));
} else {
if (rightRowKeyForState == RowSet.NULL_ROW_KEY) {
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
} else if (rightRowKeyForState <= FIRST_DUPLICATE) {
// Multiple RHS rows, we may have an error state
if (joinType == NaturalJoinType.FIRST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long firstKey = rightSideDuplicateRowSets.getUnsafe(location).firstRowKey();
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, firstKey));
} else if (joinType == NaturalJoinType.LAST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long lastKey = rightSideDuplicateRowSets.getUnsafe(location).lastRowKey();
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, lastKey));
} else {
throw new IllegalStateException("Natural Join found duplicate right key for "
+ extractKeyStringFromSourceTable(leftRowSet.firstRowKey()));
}
} else {
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, rightRowKeyForState));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,26 @@ public WritableRowRedirection buildRowRedirectionFromHashSlot(QueryTable leftTab
final WritableRowSet leftRowSet = this.leftRowSet.getUnsafe(ii);
if (leftRowSet != null) {
final long rightRowKeyForState = rightRowKey.getUnsafe(ii);
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
if (rightRowKeyForState == RowSet.NULL_ROW_KEY) {
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
} else if (rightRowKeyForState <= FIRST_DUPLICATE) {
// Multiple RHS rows, we may have an error state
if (joinType == NaturalJoinType.FIRST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long firstKey = rightSideDuplicateRowSets.getUnsafe(location).firstRowKey();
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = firstKey);
} else if (joinType == NaturalJoinType.LAST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long lastKey = rightSideDuplicateRowSets.getUnsafe(location).lastRowKey();
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = lastKey);
} else {
throw new IllegalStateException("Natural Join found duplicate right key for "
+ extractKeyStringFromSourceTable(leftRowSet.firstRowKey()));
}
} else {
leftRowSet.forAllRowKeys(pos -> innerIndex[(int) pos] = rightRowKeyForState);
}
}
}

Expand Down Expand Up @@ -352,8 +370,23 @@ public WritableRowRedirection buildRowRedirectionFromHashSlot(QueryTable leftTab
final WritableRowSet leftRowSet = this.leftRowSet.getUnsafe(ii);
if (leftRowSet != null) {
final long rightRowKeyForState = rightRowKey.getUnsafe(ii);
if (rightRowKeyForState != RowSet.NULL_ROW_KEY) {
if (rightRowKeyForState == RowSet.NULL_ROW_KEY) {
checkExactMatch(joinType, leftRowSet.firstRowKey(), rightRowKeyForState);
} else if (rightRowKeyForState <= FIRST_DUPLICATE) {
// Multiple RHS rows, we may have an error state
if (joinType == NaturalJoinType.FIRST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long firstKey = rightSideDuplicateRowSets.getUnsafe(location).firstRowKey();
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, firstKey));
} else if (joinType == NaturalJoinType.LAST_MATCH) {
final long location = duplicateLocationFromRowKey(rightRowKeyForState);
final long lastKey = rightSideDuplicateRowSets.getUnsafe(location).lastRowKey();
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, lastKey));
} else {
throw new IllegalStateException("Natural Join found duplicate right key for "
+ extractKeyStringFromSourceTable(leftRowSet.firstRowKey()));
}
} else {
leftRowSet.forAllRowKeys(pos -> rowRedirection.put(pos, rightRowKeyForState));
}
}
Expand Down
Loading

0 comments on commit b6cb1e0

Please sign in to comment.