use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitUnionOperator.
@Override
public ILogicalOperator visitUnionOperator(UnionAllOperator op, ILogicalOperator arg) throws AlgebricksException {
List<Mutable<ILogicalOperator>> copiedInputs = new ArrayList<>();
for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
copiedInputs.add(deepCopyOperatorReference(childRef, null));
}
List<List<LogicalVariable>> liveVarsInInputs = new ArrayList<>();
for (Mutable<ILogicalOperator> inputOpRef : copiedInputs) {
List<LogicalVariable> liveVars = new ArrayList<>();
VariableUtilities.getLiveVariables(inputOpRef.getValue(), liveVars);
liveVarsInInputs.add(liveVars);
}
List<LogicalVariable> liveVarsInLeftInput = liveVarsInInputs.get(0);
List<LogicalVariable> liveVarsInRightInput = liveVarsInInputs.get(1);
List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> copiedTriples = new ArrayList<>();
int index = 0;
for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple : op.getVariableMappings()) {
LogicalVariable producedVar = deepCopyVariable(triple.third);
Triple<LogicalVariable, LogicalVariable, LogicalVariable> copiedTriple = new Triple<>(liveVarsInLeftInput.get(index), liveVarsInRightInput.get(index), producedVar);
copiedTriples.add(copiedTriple);
++index;
}
UnionAllOperator opCopy = new UnionAllOperator(copiedTriples);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
return opCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.
the class LogicalPropertiesVisitor method propagateCardinality.
private LogicalPropertiesVectorImpl propagateCardinality(ILogicalOperator op, IOptimizationContext context) {
ILogicalOperator op0 = op.getInputs().get(0).getValue();
ILogicalPropertiesVector v0 = context.getLogicalPropertiesVector(op0);
if (v0 == null) {
return null;
}
LogicalPropertiesVectorImpl v = new LogicalPropertiesVectorImpl();
v.setNumberOfTuples(v0.getNumberOfTuples());
context.putLogicalPropertiesVector(op, v);
return v;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitNestedTupleSourceOperator.
@Override
public ILogicalOperator visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg) throws AlgebricksException {
Mutable<ILogicalOperator> dataSourceReference = arg == null ? op.getDataSourceReference() : new MutableObject<ILogicalOperator>(arg);
NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(dataSourceReference);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
return opCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.
the class LogicalPropertiesVisitor method visitAssignment.
private void visitAssignment(AbstractAssignOperator op, IOptimizationContext context) throws AlgebricksException {
LogicalPropertiesVectorImpl v = propagateCardinality(op, context);
if (v != null && v.getNumberOfTuples() != null) {
IVariableEvalSizeEnvironment varSizeEnv = context.getVariableEvalSizeEnvironment();
IExpressionEvalSizeComputer evalSize = context.getExpressionEvalSizeComputer();
if (evalSize != null) {
ILogicalOperator op0 = op.getInputs().get(0).getValue();
ILogicalPropertiesVector v0 = context.getLogicalPropertiesVector(op0);
if (v0 != null) {
long frames0 = v0.getMaxOutputFrames();
// added per tuple
long overhead = 0;
for (Mutable<ILogicalExpression> exprRef : op.getExpressions()) {
int sz = evalSize.getEvalSize(exprRef.getValue(), varSizeEnv);
if (sz == -1) {
return;
}
overhead += sz;
}
int frameSize = context.getPhysicalOptimizationConfig().getFrameSize();
if (frameSize > 0) {
long sz = frames0 * frameSize + overhead * v.getNumberOfTuples();
int frames1 = (int) (sz / frameSize);
if (sz % frameSize > 0) {
frames1++;
}
v.setMaxOutputFrames(frames1);
}
}
}
}
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.
the class IsomorphismVariableMappingVisitor method visitNestedTupleSourceOperator.
@Override
public Void visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg) throws AlgebricksException {
ILogicalOperator inputToCreator1 = op.getSourceOperator();
NestedTupleSourceOperator nts = (NestedTupleSourceOperator) arg;
ILogicalOperator inputToCreator2 = nts.getSourceOperator();
inputToCreator1.accept(this, inputToCreator2);
return null;
}
Aggregations