-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support HashJoin with default implementation of memory hash table
Signed-off-by: Lantao Jin <ltjin@amazon.com>
- Loading branch information
Showing
9 changed files
with
1,340 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
core/src/main/java/org/opensearch/sql/planner/physical/join/DefaultHashedRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.opensearch.sql.planner.physical.join; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.opensearch.sql.data.model.ExprValue; | ||
|
||
public class DefaultHashedRelation implements HashedRelation, Serializable { | ||
|
||
private final Map<ExprValue, List<ExprValue>> map = new HashMap<>(); | ||
private int numKeys; | ||
private int numValues; | ||
|
||
@Override | ||
public List<ExprValue> get(ExprValue key) { | ||
return map.get(key); | ||
} | ||
|
||
@Override | ||
public ExprValue getValue(ExprValue key) { | ||
List<ExprValue> values = map.get(key); | ||
return values != null && !values.isEmpty() ? values.getFirst() : null; | ||
} | ||
|
||
@Override | ||
public boolean containsKey(ExprValue key) { | ||
return map.containsKey(key); | ||
} | ||
|
||
@Override | ||
public Iterator<ExprValue> keyIterator() { | ||
return map.keySet().iterator(); | ||
} | ||
|
||
@Override | ||
public boolean isUniqueKey() { | ||
return numKeys == numValues; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
map.clear(); | ||
} | ||
|
||
@Override | ||
public void put(ExprValue key, ExprValue value) { | ||
map.computeIfAbsent(key, k -> new ArrayList<>()).add(value); | ||
numKeys++; | ||
numValues++; | ||
} | ||
} |
Oops, something went wrong.