Search in sources :

Example 1 with ObjectArrayKey

use of com.hazelcast.jet.sql.impl.ObjectArrayKey in project hazelcast by hazelcast.

the class SqlHashJoinP method tryProcess1.

@Override
protected boolean tryProcess1(@Nonnull Object item) {
    if (hashMap.size() == maxItemsInHashTable) {
        throw new AccumulationLimitExceededException();
    }
    JetSqlRow rightRow = (JetSqlRow) item;
    ObjectArrayKey joinKeys = ObjectArrayKey.project(rightRow, joinInfo.rightEquiJoinIndices());
    // if there's a null in the key, then `null = null` is UNKNOWN in SQL, ignore such keys
    if (joinKeys.containsNull()) {
        return true;
    }
    hashMap.put(joinKeys, rightRow);
    return true;
}
Also used : ObjectArrayKey(com.hazelcast.jet.sql.impl.ObjectArrayKey) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) AccumulationLimitExceededException(com.hazelcast.jet.impl.memory.AccumulationLimitExceededException)

Example 2 with ObjectArrayKey

use of com.hazelcast.jet.sql.impl.ObjectArrayKey in project hazelcast by hazelcast.

the class SqlHashJoinP method join.

private Traverser<JetSqlRow> join(JetSqlRow leftRow) {
    ObjectArrayKey joinKeys = ObjectArrayKey.project(leftRow, joinInfo.leftEquiJoinIndices());
    Collection<JetSqlRow> matchedRows = hashMap.get(joinKeys);
    List<JetSqlRow> output = matchedRows.stream().map(right -> ExpressionUtil.join(leftRow, right, joinInfo.nonEquiCondition(), evalContext)).filter(Objects::nonNull).collect(Collectors.toList());
    if (joinInfo.isLeftOuter() && output.isEmpty()) {
        return Traversers.singleton(leftRow.extendedRow(rightInputColumnCount));
    }
    return Traversers.traverseIterable(output);
}
Also used : ObjectArrayKey(com.hazelcast.jet.sql.impl.ObjectArrayKey) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Aggregations

ObjectArrayKey (com.hazelcast.jet.sql.impl.ObjectArrayKey)2 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)2 AccumulationLimitExceededException (com.hazelcast.jet.impl.memory.AccumulationLimitExceededException)1