3
3
//
4
4
package io .deephaven .engine .table .impl ;
5
5
6
+ import io .deephaven .api .NaturalJoinType ;
6
7
import io .deephaven .engine .rowset .RowSequence ;
7
8
import io .deephaven .engine .rowset .RowSet ;
8
9
import io .deephaven .engine .table .ColumnSource ;
@@ -20,14 +21,21 @@ public abstract class StaticNaturalJoinStateManager {
20
21
public static final long NO_RIGHT_ENTRY_VALUE = RowSequence .NULL_ROW_KEY ;
21
22
22
23
protected final ColumnSource <?>[] keySourcesForErrorMessages ;
24
+ protected final NaturalJoinType joinType ;
25
+ protected final boolean addOnly ;
23
26
24
- protected StaticNaturalJoinStateManager (ColumnSource <?>[] keySourcesForErrorMessages ) {
27
+ protected StaticNaturalJoinStateManager (
28
+ ColumnSource <?>[] keySourcesForErrorMessages ,
29
+ NaturalJoinType joinType ,
30
+ boolean addOnly ) {
25
31
this .keySourcesForErrorMessages = keySourcesForErrorMessages ;
32
+ this .joinType = joinType ;
33
+ this .addOnly = addOnly ;
26
34
}
27
35
28
36
@ SuppressWarnings ("WeakerAccess" )
29
- public void checkExactMatch (boolean exactMatch , long leftKeyIndex , long rightSide ) {
30
- if (exactMatch && rightSide == NO_RIGHT_ENTRY_VALUE ) {
37
+ public void checkExactMatch (long leftKeyIndex , long rightSide ) {
38
+ if (joinType == NaturalJoinType . EXACTLY_ONE_MATCH && rightSide == NO_RIGHT_ENTRY_VALUE ) {
31
39
throw new RuntimeException ("Tables don't have one-to-one mapping - no mappings for key "
32
40
+ extractKeyStringFromSourceTable (leftKeyIndex ) + "." );
33
41
}
@@ -42,8 +50,8 @@ protected String extractKeyStringFromSourceTable(long leftKey) {
42
50
.collect (Collectors .joining (", " )) + "]" ;
43
51
}
44
52
45
- public WritableRowRedirection buildRowRedirection (QueryTable leftTable , boolean exactMatch ,
46
- LongUnaryOperator rightSideFromSlot , JoinControl .RedirectionType redirectionType ) {
53
+ public WritableRowRedirection buildRowRedirection (QueryTable leftTable , LongUnaryOperator rightSideFromSlot ,
54
+ JoinControl .RedirectionType redirectionType ) {
47
55
switch (redirectionType ) {
48
56
case Contiguous : {
49
57
if (!leftTable .isFlat ()) {
@@ -53,7 +61,7 @@ public WritableRowRedirection buildRowRedirection(QueryTable leftTable, boolean
53
61
final long [] innerIndex = new long [leftTable .intSize ("contiguous redirection build" )];
54
62
for (int ii = 0 ; ii < innerIndex .length ; ++ii ) {
55
63
final long rightSide = rightSideFromSlot .applyAsLong (ii );
56
- checkExactMatch (exactMatch , leftTable .getRowSet ().get (ii ), rightSide );
64
+ checkExactMatch (leftTable .getRowSet ().get (ii ), rightSide );
57
65
innerIndex [ii ] = rightSide ;
58
66
}
59
67
return new ContiguousWritableRowRedirection (innerIndex );
@@ -65,7 +73,7 @@ public WritableRowRedirection buildRowRedirection(QueryTable leftTable, boolean
65
73
for (final RowSet .Iterator it = leftTable .getRowSet ().iterator (); it .hasNext ();) {
66
74
final long next = it .nextLong ();
67
75
final long rightSide = rightSideFromSlot .applyAsLong (leftPosition ++);
68
- checkExactMatch (exactMatch , leftTable .getRowSet ().get (next ), rightSide );
76
+ checkExactMatch (leftTable .getRowSet ().get (next ), rightSide );
69
77
if (rightSide != NO_RIGHT_ENTRY_VALUE ) {
70
78
sparseRedirections .set (next , rightSide );
71
79
}
@@ -80,7 +88,7 @@ public WritableRowRedirection buildRowRedirection(QueryTable leftTable, boolean
80
88
for (final RowSet .Iterator it = leftTable .getRowSet ().iterator (); it .hasNext ();) {
81
89
final long next = it .nextLong ();
82
90
final long rightSide = rightSideFromSlot .applyAsLong (leftPosition ++);
83
- checkExactMatch (exactMatch , leftTable .getRowSet ().get (next ), rightSide );
91
+ checkExactMatch (leftTable .getRowSet ().get (next ), rightSide );
84
92
if (rightSide != NO_RIGHT_ENTRY_VALUE ) {
85
93
rowRedirection .put (next , rightSide );
86
94
}
0 commit comments