org.apache.calcite.adapter.enumerable.EnumerableMergeJoin Java Examples

The following examples show how to use org.apache.calcite.adapter.enumerable.EnumerableMergeJoin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalcitePlanner.java    From herddb with Apache License 2.0 6 votes vote down vote up
private PlannerOp planEnumerableMergeJoin(EnumerableMergeJoin op, RelDataType rowType) {
    // please note that EnumerableMergeJoin has a condition field which actually is not useful
    PlannerOp left = convertRelNode(op.getLeft(), null, false, false);
    PlannerOp right = convertRelNode(op.getRight(), null, false, false);
    final JoinInfo analyzeCondition = op.analyzeCondition();
    int[] leftKeys = analyzeCondition.leftKeys.toIntArray();
    int[] rightKeys = analyzeCondition.rightKeys.toIntArray();
    boolean generateNullsOnLeft = op.getJoinType().generatesNullsOnLeft();
    boolean generateNullsOnRight = op.getJoinType().generatesNullsOnRight();
    final RelDataType _rowType = rowType == null ? op.getRowType() : rowType;
    List<CompiledSQLExpression> nonEquiConditions = convertJoinNonEquiConditions(analyzeCondition);
    List<RelDataTypeField> fieldList = _rowType.getFieldList();
    Column[] columns = new Column[fieldList.size()];
    String[] fieldNames = new String[columns.length];
    int i = 0;
    for (RelDataTypeField field : fieldList) {
        Column col = Column.column(field.getName().toLowerCase(),
                convertToHerdType(field.getType()));
        fieldNames[i] = col.name;
        columns[i++] = col;
    }
    return new JoinOp(fieldNames, columns,
            leftKeys, left, rightKeys, right,
            generateNullsOnLeft, generateNullsOnRight, true,
            nonEquiConditions);
}
 
Example #2
Source File: FlinkRelMdCollation.java    From flink with Apache License 2.0 5 votes vote down vote up
public com.google.common.collect.ImmutableList<RelCollation> collations(
		EnumerableMergeJoin join,
		RelMetadataQuery mq) {
	// In general a join is not sorted. But a merge join preserves the sort
	// order of the left and right sides.
	return com.google.common.collect.ImmutableList.copyOf(mergeJoin(
			mq,
			join.getLeft(),
			join.getRight(),
			join.analyzeCondition().leftKeys,
			join.analyzeCondition().rightKeys));
}
 
Example #3
Source File: RelMdCollation.java    From calcite with Apache License 2.0 5 votes vote down vote up
public ImmutableList<RelCollation> collations(EnumerableMergeJoin join,
    RelMetadataQuery mq) {
  // In general a join is not sorted. But a merge join preserves the sort
  // order of the left and right sides.
  return ImmutableList.copyOf(
      RelMdCollation.mergeJoin(mq, join.getLeft(), join.getRight(),
          join.analyzeCondition().leftKeys, join.analyzeCondition().rightKeys,
          join.getJoinType()));
}