Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ public boolean push(Context context, @Nullable Object[] tuple, Vertex vertex) {
if (pin == 0) { // left
waitRightFinFlag(param);
TupleKey leftKey = HashJoinParam.rtrimTupleKey(new TupleKey(leftMapping.revMap(tuple)));

if (HashJoinParam.containsNull(leftKey)) {
if ("inner".equalsIgnoreCase(param.getJoinType()) || "right".equalsIgnoreCase(param.getJoinType())) {
return true;
} else if ("left".equalsIgnoreCase(param.getJoinType()) || "full".equalsIgnoreCase(param.getJoinType())) {
Object[] newTuple = Arrays.copyOf(tuple, leftLength + rightLength);
Arrays.fill(newTuple, leftLength, leftLength + rightLength, null);
return pushToNext(param, edge, context, newTuple);
}
}

boolean isEmpty = isEmpty(leftKey, param);
if (isEmpty && ("inner".equalsIgnoreCase(param.getJoinType()) || "right".equalsIgnoreCase(param.getJoinType()))) {
return true;
Expand All @@ -87,12 +98,23 @@ public boolean push(Context context, @Nullable Object[] tuple, Vertex vertex) {
}
} else if (pin == 1) { //right
TupleKey rightKey = HashJoinParam.rtrimTupleKey(new TupleKey(rightMapping.revMap(tuple)));
if (isEmpty(rightKey, param) && "inner".equalsIgnoreCase(param.getJoinType())) {
return true;
if (HashJoinParam.containsNull(rightKey)) {
if ("inner".equalsIgnoreCase(param.getJoinType()) || "left".equalsIgnoreCase(param.getJoinType())) {
return true;
} else if ("right".equalsIgnoreCase(param.getJoinType()) || "full".equalsIgnoreCase(param.getJoinType())) {
List<TupleWithJoinFlag> list = param.getHashMap()
.computeIfAbsent(rightKey, k -> Collections.synchronizedList(new LinkedList<>()));
list.add(new TupleWithJoinFlag(tuple));
}
} else {
if (isEmpty(rightKey, param) && "inner".equalsIgnoreCase(param.getJoinType())) {
return true;
}
List<TupleWithJoinFlag> list = param.getHashMap()
.computeIfAbsent(rightKey, k -> Collections.synchronizedList(new LinkedList<>()));
list.add(new TupleWithJoinFlag(tuple));
}
List<TupleWithJoinFlag> list = param.getHashMap()
.computeIfAbsent(rightKey, k -> Collections.synchronizedList(new LinkedList<>()));
list.add(new TupleWithJoinFlag(tuple));

}
return true;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public static Object[] rtrimTuple(Object[] tuple) {
return arrayList.toArray();
}

public static boolean containsNull(TupleKey key) {
for (Object item : key.getTuple()) {
if (item == null) {
return true;
}
}
return false;
}

@Override
public void init(Vertex vertex) {
rightFinFlag = false;
Expand Down