use of org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl 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.properties.LogicalPropertiesVectorImpl in project asterixdb by apache.
the class LogicalPropertiesVisitor method visitOrderOperator.
@Override
public Void visitOrderOperator(OrderOperator op, IOptimizationContext arg) throws AlgebricksException {
Object annot1 = op.getAnnotations().get(OperatorAnnotations.CARDINALITY);
if (annot1 == null) {
return null;
}
Integer m = (Integer) annot1;
LogicalPropertiesVectorImpl v = new LogicalPropertiesVectorImpl();
v.setNumberOfTuples(m);
Object annot2 = op.getAnnotations().get(OperatorAnnotations.MAX_NUMBER_FRAMES);
if (annot2 != null) {
Integer f = (Integer) annot2;
v.setMaxOutputFrames(f);
}
arg.putLogicalPropertiesVector(op, v);
return null;
}
use of org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl 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.properties.LogicalPropertiesVectorImpl in project asterixdb by apache.
the class LogicalPropertiesVisitor method propagateCardinalityAndFrameNumber.
public void propagateCardinalityAndFrameNumber(ILogicalOperator op, IOptimizationContext context) throws AlgebricksException {
LogicalPropertiesVectorImpl v = propagateCardinality(op, context);
// propagate also max number of frames (conservatively)
ILogicalOperator op0 = op.getInputs().get(0).getValue();
ILogicalPropertiesVector v0 = context.getLogicalPropertiesVector(op0);
if (v0 != null) {
v.setMaxOutputFrames(v0.getMaxOutputFrames());
}
}
Aggregations