Examples of LOLimit


Examples of org.apache.pig.newplan.logical.relational.LOLimit

    }

    @Override
    protected OperatorPlan buildPattern() {
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator limit = new LOLimit(plan, 0);
        plan.add(limit);
        return plan;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

    public class OptimizeLimitTransformer extends Transformer {

        @Override
        public boolean check(OperatorPlan matched) {
            LOLimit limit = (LOLimit) matched.getSources().get(0);
            // Match each foreach.
            List<Operator> preds = currentPlan.getPredecessors(limit);
            if (preds == null || preds.size() == 0)
                return false;
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

        }

        @Override
        public void transform(OperatorPlan matched) throws FrontendException {

            LOLimit limit = (LOLimit) matched.getSources().get(0);

            // Find the next foreach operator.
            List<Operator> preds = currentPlan.getPredecessors(limit);
            Operator pred = preds.get(0);

            if (pred instanceof LOForEach) {
                // We can safely move LOLimit up
                // Get operator before LOForEach
                Operator prepredecessor = currentPlan.getPredecessors(pred)
                    .get(0);
               
                List<Operator> softPrepredecessors=null;
                // get a clone of softPrepredecessors to avoid ConcurrentModificationException
                if (currentPlan.getSoftLinkPredecessors(limit)!=null) {
                    softPrepredecessors=new ArrayList<Operator>(
                            currentPlan.getSoftLinkPredecessors(limit));
                }
                if (softPrepredecessors!=null) {
                    for (Operator op : softPrepredecessors) {
                        currentPlan.removeSoftLink(op, limit);
                    }
                }
                currentPlan.removeAndReconnect(limit);
                currentPlan.insertBetween(prepredecessor, limit, pred);
                if (softPrepredecessors!=null) {
                    for (Operator op : softPrepredecessors) {
                        currentPlan.createSoftLink(op, limit);
                    }
                }
            } else if (limit.getLimitPlan() == null) {
                // TODO selectively enable optimizations for variable limit
                if (pred instanceof LOCross || pred instanceof LOUnion) {
                // Limit can be duplicated, and the new instance pushed in front
                // of an operator for the following operators
                // (that is, if you have X->limit, you can transform that to
                // limit->X->limit):
                LOLimit newLimit = null;
                List<Operator> nodesToProcess = new ArrayList<Operator>();
                for (Operator prepredecessor : currentPlan
                        .getPredecessors(pred))
                    nodesToProcess.add(prepredecessor);
                for (Operator prepredecessor : nodesToProcess) {
                    if (prepredecessor instanceof LOLimit) {
                        LOLimit l = (LOLimit) prepredecessor;
                        l.setLimit(l.getLimit() < limit.getLimit() ? l
                                .getLimit() : limit.getLimit());
                    } else {
                        newLimit = new LOLimit((LogicalPlan) currentPlan, limit
                                .getLimit());
                        currentPlan.insertBetween(prepredecessor, newLimit, pred);
                    }
                }
            } else if (pred instanceof LOSort) {
                LOSort sort = (LOSort) pred;
                if (sort.getLimit() == -1)
                    sort.setLimit(limit.getLimit());
                else
                    sort.setLimit(sort.getLimit() < limit.getLimit() ? sort
                            .getLimit() : limit.getLimit());

                // remove the limit
                currentPlan.removeAndReconnect(limit);
            } else if (pred instanceof LOLoad) {
                // Push limit to load
                LOLoad load = (LOLoad) pred;
                if (load.getLimit() == -1)
                    load.setLimit(limit.getLimit());
                else
                    load.setLimit(load.getLimit() < limit.getLimit() ? load
                            .getLimit() : limit.getLimit());
            } else if (pred instanceof LOLimit) {
                // Limit is merged into another LOLimit
                LOLimit beforeLimit = (LOLimit) pred;
                beforeLimit
                        .setLimit(beforeLimit.getLimit() < limit.getLimit() ? beforeLimit
                                .getLimit()
                                : limit.getLimit());
                // remove the limit
                currentPlan.removeAndReconnect(limit);
            } else if (pred instanceof LOSplitOutput) {
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

    LOFilter createFilterOp() {
        return new LOFilter( plan );
    }

    LOLimit createLimitOp() {
        return new LOLimit( plan );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

        LODistinct op = new LODistinct( plan );
        return buildOp( loc, op, alias, inputAlias, partitioner );
    }

    String buildLimitOp(SourceLocation loc, String alias, String inputAlias, long limit) throws ParserValidationException {
        LOLimit op = new LOLimit( plan, limit );
        return buildOp( loc, op, alias, inputAlias, null );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

    static LOFilter createNestedFilterOp(LogicalPlan plan) {
        return new LOFilter( plan );
    }

    static LOLimit createNestedLimitOp(LogicalPlan plan) {
        return new LOLimit ( plan );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

        buildNestedOp( loc, plan, op, alias, inputOp );
        return op;
    }

    Operator buildNestedLimitOp(SourceLocation loc, LogicalPlan plan, String alias, Operator inputOp, long limit) {
        LOLimit op = new LOLimit( plan, limit );
        buildNestedOp( loc, plan, op, alias, inputOp );
        return op;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

            + "store F into 'output';";
        LogicalPlan newLogicalPlan = Util.buildLp(pigServer, query);;
        optimizePlan(newLogicalPlan);
        LOStore store = (LOStore)newLogicalPlan.getSinks().get(0);
        LOForEach foreach1 = (LOForEach)newLogicalPlan.getPredecessors(store).get(0);
        LOLimit limit = (LOLimit)newLogicalPlan.getPredecessors(foreach1).get(0);
        Assert.assertTrue(newLogicalPlan.getSoftLinkPredecessors(limit).get(0) instanceof LOStore);
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

    LOFilter createFilterOp() {
        return new LOFilter( plan );
    }

    LOLimit createLimitOp() {
        return new LOLimit( plan );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.relational.LOLimit

        LODistinct op = new LODistinct( plan );
        return buildOp( loc, op, alias, inputAlias, partitioner );
    }

    String buildLimitOp(SourceLocation loc, String alias, String inputAlias, long limit) throws ParserValidationException {
        LOLimit op = new LOLimit( plan, limit );
        return buildOp( loc, op, alias, inputAlias, null );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.