Skip to content

Commit 67f2e72

Browse files
authored
Merge branch 'deephaven:main' into fix-java-coverage-enabled-in-build
2 parents deec751 + 46579d3 commit 67f2e72

File tree

88 files changed

+6562
-3192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6562
-3192
lines changed

engine/query-constants/src/main/java/io/deephaven/util/BooleanUtils.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
public class BooleanUtils {
1010

1111
/**
12-
* The byte encoding of null booleans.
12+
* The byte encoding of null booleans. Do not use to compare values, use {@link #isNull(byte)} instead.
1313
*/
1414
public static final byte NULL_BOOLEAN_AS_BYTE = QueryConstants.NULL_BYTE;
1515

1616
/**
17-
* The byte encoding of true booleans.
17+
* The byte encoding of true booleans. Do not use to compare values, use {@link #byteAsBoolean(byte)} instead.
1818
*/
1919
public static final byte TRUE_BOOLEAN_AS_BYTE = (byte) 1;
2020

2121
/**
22-
* The byte encoding of false booleans.
22+
* The byte encoding of false booleans. This is the only safe value to use when comparing byte representations.
2323
*/
2424
public static final byte FALSE_BOOLEAN_AS_BYTE = (byte) 0;
2525

@@ -36,7 +36,17 @@ public class BooleanUtils {
3636
* @return the boxed boolean represented by byteValue
3737
*/
3838
public static Boolean byteAsBoolean(final byte byteValue) {
39-
return byteValue == FALSE_BOOLEAN_AS_BYTE ? Boolean.FALSE : byteValue > 0 ? Boolean.TRUE : null;
39+
return isNull(byteValue) ? null : byteValue > FALSE_BOOLEAN_AS_BYTE;
40+
}
41+
42+
/**
43+
* Check if a byte represents a null boolean.
44+
*
45+
* @param byteValue the byte to check if it represents a null boolean
46+
* @return true if byteValue represents a null boolean
47+
*/
48+
public static boolean isNull(final byte byteValue) {
49+
return byteValue < 0;
4050
}
4151

4252
/**

engine/table/src/main/java/io/deephaven/engine/table/impl/BothIncrementalNaturalJoinStateManager.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public interface BothIncrementalNaturalJoinStateManager extends IncrementalNatur
2121

2222
void compactAll();
2323

24-
WritableRowRedirection buildIndexedRowRedirection(QueryTable leftTable, boolean exactMatch, InitialBuildContext ibc,
24+
WritableRowRedirection buildIndexedRowRedirection(QueryTable leftTable, InitialBuildContext ibc,
2525
ColumnSource<RowSet> indexRowSets, JoinControl.RedirectionType redirectionType);
2626

27-
WritableRowRedirection buildRowRedirectionFromRedirections(QueryTable leftTable, boolean exactMatch,
28-
InitialBuildContext ibc, JoinControl.RedirectionType redirectionType);
27+
WritableRowRedirection buildRowRedirectionFromRedirections(QueryTable leftTable, InitialBuildContext ibc,
28+
JoinControl.RedirectionType redirectionType);
2929

3030
Context makeProbeContext(ColumnSource<?>[] probeSources, long maxSize);
3131

engine/table/src/main/java/io/deephaven/engine/table/impl/IncrementalNaturalJoinStateManager.java

+47-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,58 @@
33
//
44
package io.deephaven.engine.table.impl;
55

6+
import io.deephaven.api.NaturalJoinType;
7+
import io.deephaven.base.verify.Assert;
68
import io.deephaven.engine.rowset.RowSet;
9+
import io.deephaven.engine.rowset.WritableRowSet;
710

811
public interface IncrementalNaturalJoinStateManager {
9-
long getRightIndex(int slot);
12+
long getRightRowKey(int slot);
1013

11-
RowSet getLeftIndex(int slot);
14+
RowSet getRightRowSet(int slot);
15+
16+
RowSet getLeftRowSet(int slot);
1217

1318
String keyString(int slot);
1419

15-
void checkExactMatch(boolean exactMatch, long leftKeyIndex, long rightSide);
20+
void checkExactMatch(long leftKeyIndex, long rightSide);
21+
22+
/**
23+
* Given the join type, return the correct row key from the set of RHS duplicates.
24+
*/
25+
default long getRightRowKeyFromDuplicates(final WritableRowSet duplicates, final NaturalJoinType joinType) {
26+
if (joinType == NaturalJoinType.LAST_MATCH) {
27+
return duplicates.lastRowKey();
28+
}
29+
return duplicates.firstRowKey();
30+
}
31+
32+
/**
33+
* Add a key to the RHS duplicates, return the appropriate row key from this set *AFTER* the addition.
34+
*/
35+
default long addRightRowKeyToDuplicates(final WritableRowSet duplicates, final long keyToRemove,
36+
final NaturalJoinType joinType) {
37+
duplicates.insert(keyToRemove);
38+
return getRightRowKeyFromDuplicates(duplicates, joinType);
39+
}
40+
41+
/**
42+
* Remove the key from the RHS duplicates, return the appropriate row key from this set *BEFORE* the removal.
43+
*/
44+
default long removeRightRowKeyFromDuplicates(final WritableRowSet duplicates, final long keyToRemove,
45+
final NaturalJoinType joinType) {
46+
final long originalRowKey = getRightRowKeyFromDuplicates(duplicates, joinType);
47+
duplicates.remove(keyToRemove);
48+
return originalRowKey;
49+
}
50+
51+
/**
52+
* Shift a key in the RHS duplicate row set.
53+
*/
54+
default void shiftOneKey(WritableRowSet duplicates, long shiftedKey, long shiftDelta) {
55+
final long sizeBefore = duplicates.size();
56+
duplicates.remove(shiftedKey - shiftDelta);
57+
duplicates.insert(shiftedKey);
58+
Assert.eq(duplicates.size(), "duplicates.size()", sizeBefore, "sizeBefore");
59+
}
1660
}

0 commit comments

Comments
 (0)