use of org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment 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.expressions.IVariableEvalSizeEnvironment in project asterixdb by apache.
the class NonTaggedDataFormat method getExpressionEvalSizeComputer.
@Override
public IExpressionEvalSizeComputer getExpressionEvalSizeComputer() {
return new IExpressionEvalSizeComputer() {
@Override
public int getEvalSize(ILogicalExpression expr, IVariableEvalSizeEnvironment env) throws AlgebricksException {
switch(expr.getExpressionTag()) {
case CONSTANT:
{
ConstantExpression c = (ConstantExpression) expr;
if (c == ConstantExpression.MISSING) {
return 1;
} else if (c == ConstantExpression.FALSE || c == ConstantExpression.TRUE) {
return 2;
} else {
AsterixConstantValue acv = (AsterixConstantValue) c.getValue();
IAObject o = acv.getObject();
switch(o.getType().getTypeTag()) {
case DOUBLE:
return 9;
case FLOAT:
return 5;
case BOOLEAN:
return 2;
case MISSING:
return 1;
case NULL:
return 1;
case TINYINT:
return 2;
case SMALLINT:
return 3;
case INTEGER:
return 5;
case BIGINT:
return 9;
default:
return -1;
}
}
}
case FUNCTION_CALL:
{
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
if (f.getFunctionIdentifier().equals(BuiltinFunctions.TID)) {
return 5;
} else {
// TODO
return -1;
}
}
default:
{
// TODO
return -1;
}
}
}
};
}
Aggregations