Class MultiJoin
public class MultiJoin extends Object
Join unique rows from a set of tables onto a set of common keys.
The multiJoin operation collects the set of distinct keys from the input tables, and then joins one row from each of the input tables onto the result. Input tables need not have a match row for each key, but they may not have multiple matching rows for a given key. The operation can be thought of as a merge of the key columns, followed by a selectDistinct and then a series of iterative naturalJoin operations as follows:
private Table doIterativeMultiJoin(String [] keyColumns, List<? extends Table> inputTables) {
final List<Table> keyTables = inputTables.stream().map(t -> t.view(keyColumns)).collect(Collectors.toList());
final Table base = TableTools.merge(keyTables).selectDistinct(keyColumns);
Table result = base;
for (int ii = 0; ii < inputTables.size(); ++ii) {
result = result.naturalJoin(inputTables.get(ii), Arrays.asList(keyColumns));
}
return result;
}
The multiJoin operation is more efficient than an iterative sequence of naturalJoin, because the Deephaven engine must only keep a single hash table for all of the results as opposed to one for the selectDistinct and another for each table.
All tables must have the same number of key columns, with the same type. The key columns must all have the same
names in the resultant table (the left side of the MatchPair
used to create them). The columns to add
must have unique names in the result table.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultiJoin.JoinDescriptor
A descriptor of an input to a multiJoin. -
Constructor Summary
Constructors Constructor Description MultiJoin()
-
Method Summary
-
Constructor Details
-
MultiJoin
public MultiJoin()
-
-
Method Details
-
multiJoin
Join tables that have common key column names. The keys are specified in MatchPair format. All other columns are brought over to the result.- Parameters:
keys
- the key column pairs in the format "Result=Source" or "ColumnInBoth"inputTables
- the tables to join together- Returns:
- a Table with one row for each key and the corresponding row in each input table
-
multiJoin
Perform a multiJoin for one or more tables.- Parameters:
joinDescriptors
- the description of each table that contributes to the result- Returns:
- a Table with one row for each key and the corresponding row in each input table
-