Search in sources :

Example 1 with ILogicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector 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;
}
Also used : ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) LogicalPropertiesVectorImpl(org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Example 2 with ILogicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector 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);
                }
            }
        }
    }
}
Also used : IVariableEvalSizeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment) ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) LogicalPropertiesVectorImpl(org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) IExpressionEvalSizeComputer(org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer)

Example 3 with ILogicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector 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());
    }
}
Also used : ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) LogicalPropertiesVectorImpl(org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Example 4 with ILogicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector in project asterixdb by apache.

the class JoinUtils method hybridToInMemHashJoin.

private static void hybridToInMemHashJoin(AbstractBinaryJoinOperator op, IOptimizationContext context) throws AlgebricksException {
    ILogicalOperator opBuild = op.getInputs().get(1).getValue();
    LogicalPropertiesVisitor.computeLogicalPropertiesDFS(opBuild, context);
    ILogicalPropertiesVector v = context.getLogicalPropertiesVector(opBuild);
    AlgebricksConfig.ALGEBRICKS_LOGGER.fine("// HybridHashJoin inner branch -- Logical properties for " + opBuild + ": " + v + "\n");
    if (v != null) {
        int size2 = v.getMaxOutputFrames();
        HybridHashJoinPOperator hhj = (HybridHashJoinPOperator) op.getPhysicalOperator();
        if (size2 > 0 && size2 * hhj.getFudgeFactor() <= hhj.getMemSizeInFrames()) {
            AlgebricksConfig.ALGEBRICKS_LOGGER.fine("// HybridHashJoin inner branch " + opBuild + " fits in memory\n");
            // maintains the local properties on the probe side
            op.setPhysicalOperator(new InMemoryHashJoinPOperator(hhj.getKind(), hhj.getPartitioningType(), hhj.getKeysLeftBranch(), hhj.getKeysRightBranch(), v.getNumberOfTuples() * 2, hhj.getMemSizeInFrames()));
        }
    }
}
Also used : ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) HybridHashJoinPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.HybridHashJoinPOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) InMemoryHashJoinPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryHashJoinPOperator)

Aggregations

ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)4 ILogicalPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector)4 LogicalPropertiesVectorImpl (org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl)3 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)1 IExpressionEvalSizeComputer (org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer)1 IVariableEvalSizeEnvironment (org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment)1 HybridHashJoinPOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.HybridHashJoinPOperator)1 InMemoryHashJoinPOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryHashJoinPOperator)1