Package org.apache.pig.impl.logicalLayer

Examples of org.apache.pig.impl.logicalLayer.LogicalOperator


        }
    }
    private LogicalPlan getPlanFromAlias(
            String alias,
            String operation) throws FrontendException {
        LogicalOperator lo = currDAG.getAliasOp().get(alias);
        if (lo == null) {
            int errCode = 1004;
            String msg = "No alias " + alias + " to " + operation;
            throw new FrontendException(msg, errCode, PigException.INPUT, false, null);
        }
View Full Code Here


        for (int i = 0; i < joinTypes.length; i++) {
            pigServer.setBatchOn();
            pigServer.registerQuery("a = load '/tmp' as (foo, bar);");
            pigServer.registerQuery("b = load '/tmp' as (foo, bar);");
            pigServer.registerQuery("c = join a by foo, b by foo using \""+joinTypes[i]+"\";");
            LogicalOperator op = getOpByAlias(pigServer.getAliases().get("c"), "c");
            assertTrue("did "+joinTypes[i]+" join get pinned? ",
                    op.isPinnedOption(LOJoin.OPTION_JOIN));
            assertEquals("did the right join type get set? ",
                    ((LOJoin) op).getJoinType().toString(), expectedJoinTypes[i]);
            pigServer.discardBatch();
        }
    }
View Full Code Here

    @Test
    public void testNotPinnedJinOption() throws IOException {
        pigServer.registerQuery("a = load '/tmp' as (foo, bar);");
        pigServer.registerQuery("b = load '/tmp' as (foo, bar);");
        pigServer.registerQuery("c = join a by foo, b by foo;");
        LogicalOperator op = getOpByAlias(pigServer.getAliases().get("c"), "c");
        assertEquals("default join should be hash",
                ((LOJoin) op).getJoinType().toString(), "HASH");
        assertFalse(op.isPinnedOption(LOJoin.OPTION_JOIN));
    }
View Full Code Here

    public void testGroupOptions() throws IOException {
        pigServer.setBatchOn();
        pigServer.registerQuery("a = load '/tmp' as (foo, bar);");
        pigServer.registerQuery("b = group a by foo;");
       
        LogicalOperator op = getOpByAlias(pigServer.getAliases().get("b"), "b");
        assertFalse(op.isPinnedOption(LOCogroup.OPTION_GROUPTYPE));
        pigServer.discardBatch();
       
        pigServer.setBatchOn();
        pigServer.registerQuery("a = load '/tmp' as (foo, bar);");
        pigServer.registerQuery("b = group a by foo using \"collected\";");
        op = getOpByAlias(pigServer.getAliases().get("b"), "b");
        assertTrue(op.isPinnedOption(LOCogroup.OPTION_GROUPTYPE));
        pigServer.discardBatch();
    }
View Full Code Here

                                           aliases,
                                           logicalOpTable,
                                           aliasOp,
                                           fileNameMap);
            Assert.assertTrue(lp.size()>0);
            LogicalOperator op = lp.getRoots().get(0);
           
            Assert.assertTrue(op instanceof LOLoad);
            LOLoad load = (LOLoad)op;
   
            String p = load.getInputFile().getFileName();
View Full Code Here

        for (LogicalOperator op : cg.getInputs()) {
            List<LogicalPlan> groupByPlans = (List<LogicalPlan>) cg
                    .getGroupByPlans().get(op);
            List<Integer> groupCols = new ArrayList<Integer>();
            for (LogicalPlan plan : groupByPlans) {
                LogicalOperator leaf = plan.getLeaves().get(0);
                if (leaf instanceof LOProject) {
                    groupCols.add(((LOProject) leaf).getCol());
                } else {
                    ableToHandle = false;
                    break;
View Full Code Here

        if (outputConstraints == null || outputConstraints.size() == 0)
            // we dont have to do anything in this case
            return;

        for (LogicalPlan plan : plans) {
            LogicalOperator op = plan.getLeaves().get(0);
            if (op instanceof LOCast) {
                cast = true;
                op = ((LOCast) op).getExpression();
            }
View Full Code Here

        if (pred.getLhsOperand() instanceof LOConst) {
            leftIsConst = true;
            leftConst = ((LOConst) (pred.getLhsOperand())).getValue();
        } else {
            LogicalOperator lhs = pred.getLhsOperand();
            if (lhs instanceof LOCast)
                lhs = ((LOCast) lhs).getExpression();
            // if (!(pred.getLhsOperand() instanceof LOProject && ((LOProject)
            // pred
            // .getLhsOperand()).getProjection().size() == 1))
            // return; // too hard
            if (!(lhs instanceof LOProject && ((LOProject) lhs).getProjection()
                    .size() == 1))
                return;
            leftCol = ((LOProject) lhs).getCol();
            leftDataType = ((LOProject) lhs).getType();

            Object d = t.get(leftCol);
            if (d != null) {
                leftIsConst = true;
                leftConst = d;
            }
        }

        if (pred.getRhsOperand() instanceof LOConst) {
            rightIsConst = true;
            rightConst = ((LOConst) (pred.getRhsOperand())).getValue();
        } else {
            LogicalOperator rhs = pred.getRhsOperand();
            if (rhs instanceof LOCast)
                rhs = ((LOCast) rhs).getExpression();
            // if (!(pred.getRhsOperand() instanceof LOProject && ((LOProject)
            // pred
            // .getRhsOperand()).getProjection().size() == 1))
View Full Code Here

            // the parser would have marked the side
            // where we need to keep empty bags on
            // non matched as outer (innerFlags[i] would be
            // false)
            if(!(innerFlags[i])) {
                LogicalOperator joinInput = inputs.get(i);
                // for outer join add a bincond
                // which will project nulls when bag is
                // empty
                try {
                    updateWithEmptyBagCheck(ep, joinInput);
View Full Code Here

        for (Iterator<Tuple> it = derivedData.get(op).iterator(); it.hasNext();) {
            pass.add(it.next());
        }

        LogicalOperator input = op.getInput();

        for (Iterator<Tuple> it = derivedData.get(input).iterator(); it
                .hasNext();) {
            Tuple t = it.next();
            if (pass.contains(t))
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.LogicalOperator

Copyright © 2018 www.massapicom. 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.