com.hazelcast.org.apache.calcite.rel.logical.LogicalCorrelate Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in com.hazelcast.com.liance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.com.hazelcast.org.licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.org.apache.calcite.rel.logical;
import com.hazelcast.org.apache.calcite.config.CalciteSystemProperty;
import com.hazelcast.org.apache.calcite.plan.Convention;
import com.hazelcast.org.apache.calcite.plan.RelOptCluster;
import com.hazelcast.org.apache.calcite.plan.RelTraitSet;
import com.hazelcast.org.apache.calcite.rel.RelInput;
import com.hazelcast.org.apache.calcite.rel.RelNode;
import com.hazelcast.org.apache.calcite.rel.RelShuttle;
import com.hazelcast.org.apache.calcite.rel.core.Correlate;
import com.hazelcast.org.apache.calcite.rel.core.CorrelationId;
import com.hazelcast.org.apache.calcite.rel.core.JoinRelType;
import com.hazelcast.org.apache.calcite.util.ImmutableBitSet;
import com.hazelcast.org.apache.calcite.util.Litmus;
/**
* A relational operator that performs nested-loop joins.
*
* It behaves like a kind of {@link com.hazelcast.org.apache.calcite.rel.core.Join},
* but works by setting variables in its environment and restarting its
* right-hand input.
*
*
A LogicalCorrelate is used to represent a correlated query. One
* implementation strategy is to de-correlate the expression.
*
* @see com.hazelcast.org.apache.calcite.rel.core.CorrelationId
*/
public final class LogicalCorrelate extends Correlate {
//~ Instance fields --------------------------------------------------------
//~ Constructors -----------------------------------------------------------
/**
* Creates a LogicalCorrelate.
* @param cluster cluster this relational expression belongs to
* @param left left input relational expression
* @param right right input relational expression
* @param correlationId variable name for the row of left input
* @param requiredColumns Required columns
* @param joinType join type
*/
public LogicalCorrelate(
RelOptCluster cluster,
RelTraitSet traitSet,
RelNode left,
RelNode right,
CorrelationId correlationId,
ImmutableBitSet requiredColumns,
JoinRelType joinType) {
super(
cluster,
traitSet,
left,
right,
correlationId,
requiredColumns,
joinType);
assert !CalciteSystemProperty.DEBUG.value() || isValid(Litmus.THROW, null);
}
/**
* Creates a LogicalCorrelate by parsing serialized output.
*/
public LogicalCorrelate(RelInput input) {
this(input.getCluster(), input.getTraitSet(), input.getInputs().get(0),
input.getInputs().get(1),
new CorrelationId((Integer) input.get("correlation")),
input.getBitSet("requiredColumns"),
input.getEnum("joinType", JoinRelType.class));
}
/** Creates a LogicalCorrelate. */
public static LogicalCorrelate create(RelNode left, RelNode right,
CorrelationId correlationId, ImmutableBitSet requiredColumns,
JoinRelType joinType) {
final RelOptCluster cluster = left.getCluster();
final RelTraitSet traitSet = cluster.traitSetOf(Convention.NONE);
return new LogicalCorrelate(cluster, traitSet, left, right, correlationId,
requiredColumns, joinType);
}
//~ Methods ----------------------------------------------------------------
@Override public LogicalCorrelate copy(RelTraitSet traitSet,
RelNode left, RelNode right, CorrelationId correlationId,
ImmutableBitSet requiredColumns, JoinRelType joinType) {
assert traitSet.containsIfApplicable(Convention.NONE);
return new LogicalCorrelate(getCluster(), traitSet, left, right,
correlationId, requiredColumns, joinType);
}
@Override public RelNode accept(RelShuttle shuttle) {
return shuttle.visit(this);
}
}