当前位置: 首页>>代码示例>>Java>>正文


Java LogicalPlan.getOperators方法代码示例

本文整理汇总了Java中org.apache.pig.newplan.logical.relational.LogicalPlan.getOperators方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalPlan.getOperators方法的具体用法?Java LogicalPlan.getOperators怎么用?Java LogicalPlan.getOperators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pig.newplan.logical.relational.LogicalPlan的用法示例。


在下文中一共展示了LogicalPlan.getOperators方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getForEachInnerLogToPhyMap

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
public Map<LOForEach, Map<LogicalRelationalOperator, PhysicalOperator>> getForEachInnerLogToPhyMap(LogicalPlan plan) {
    Map<LOForEach, Map<LogicalRelationalOperator, PhysicalOperator>> result =
        new HashMap<LOForEach, Map<LogicalRelationalOperator, PhysicalOperator>>();
    Iterator<Operator> outerIter = plan.getOperators();
    while (outerIter.hasNext()) {
        Operator oper = outerIter.next();
        if (oper instanceof LOForEach) {
            LogicalPlan innerPlan = ((LOForEach) oper).getInnerPlan();
            Map<LogicalRelationalOperator, PhysicalOperator> innerOpMap = new HashMap<LogicalRelationalOperator, PhysicalOperator>();
            Iterator<Operator> innerIter = innerPlan.getOperators();
            while (innerIter.hasNext()) {
                Operator innerOper = innerIter.next();
                innerOpMap.put(((LogicalRelationalOperator)innerOper), newLogToPhyMap.get(innerOper));
            }
            result.put((LOForEach) oper, innerOpMap);
        }
    }
    return result;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:20,代码来源:HExecutionEngine.java

示例2: testColNameMapping3

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
 * Test that pig sends correct partition column names in setPartitionFilter
 * when the user has a schema in the load statement which renames partition
 * columns - in this test case the filter only has conditions on partition
 * columns
 * @throws Exception
 */
@Test
public void testColNameMapping3() throws Exception {
    TestLoader.partFilter = null;
    String query = "a = load 'foo' using "
        + TestLoader.class.getName() +
        "('srcid:int, mrkt:chararray, dstid:int, name:chararray, age:int', " +
        "'srcid,mrkt,dstid,age') as (f1, f2, f3, f4, f5);" +
        "b = filter a by " +
        "(f5 >= 20 or f2 == 'us') and (f1 == 10 and f3 == 15);" +
        "store b into 'out';";

    LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );

    Assert.assertEquals("checking partition filter:",
            "(((age >= 20) or (mrkt == 'us')) and ((srcid == 10) and " +
            "(dstid == 15)))",
            TestLoader.partFilter.toString());
    Iterator<Operator> it = newLogicalPlan.getOperators();
    while( it.hasNext() ) {
     Assert.assertFalse("Checking that filter has been removed since it contained" +
             " only conditions on partition cols:",
             (it.next() instanceof LOFilter));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:32,代码来源:TestPartitionFilterPushDown.java

示例3: getRelOpsFromPlan

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
 * Find relational operators that are instance of class c
 * @param plan
 * @param c
 * @return
 */
public static List<LogicalRelationalOperator> getRelOpsFromPlan(
        LogicalPlan plan, Class<?> c) {
    Iterator<Operator> it = plan.getOperators();
    ArrayList<LogicalRelationalOperator> ops = 
        new ArrayList<LogicalRelationalOperator>();
    
    while(it.hasNext()){
        Operator op = it.next();
        if(op.getClass() == c){
            ops.add((LogicalRelationalOperator) op);
        }
        if(op instanceof LOForEach){
            ops.addAll(getRelOpsFromPlan(((LOForEach)op).getInnerPlan(), c));
        }
    }
    return ops;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:24,代码来源:NewLogicalPlanUtil.java

示例4: getForEachInnerLogToPhyMap

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
public Map<LOForEach, Map<LogicalRelationalOperator, PhysicalOperator>> getForEachInnerLogToPhyMap(
        LogicalPlan plan) {
    Map<LOForEach, Map<LogicalRelationalOperator, PhysicalOperator>> result = Maps.newHashMap();
    Iterator<Operator> outerIter = plan.getOperators();
    while (outerIter.hasNext()) {
        Operator oper = outerIter.next();
        if (oper instanceof LOForEach) {
            LogicalPlan innerPlan = ((LOForEach) oper).getInnerPlan();
            Map<LogicalRelationalOperator, PhysicalOperator> innerOpMap = Maps.newHashMap();
            Iterator<Operator> innerIter = innerPlan.getOperators();
            while (innerIter.hasNext()) {
                Operator innerOper = innerIter.next();
                innerOpMap.put(((LogicalRelationalOperator) innerOper),
                        newLogToPhyMap.get(innerOper));
            }
            result.put((LOForEach) oper, innerOpMap);
        }
    }
    return result;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:21,代码来源:HExecutionEngine.java

示例5: check

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@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;

    Operator pred = preds.get(0);

    // Limit cannot be pushed up
    if (pred instanceof LOCogroup || pred instanceof LOFilter
            || pred instanceof LOSplit || pred instanceof LODistinct || pred instanceof LOJoin) {
        return false;
    }

    // Limit cannot be pushed in front of ForEach if it has a flatten
    if (pred instanceof LOForEach) {
        LOForEach foreach = (LOForEach) pred;
        LogicalPlan innerPlan = foreach.getInnerPlan();
        Iterator<Operator> it = innerPlan.getOperators();
        while (it.hasNext()) {
            Operator op = it.next();
            if (op instanceof LOGenerate) {
                LOGenerate gen = (LOGenerate) op;
                boolean[] flattenFlags = gen.getFlattenFlags();
                if (flattenFlags != null) {
                    for (boolean flatten : flattenFlags) {
                        if (flatten)
                            return false;
                    }
                }
            }
        }
    }
    return true;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:38,代码来源:LimitOptimizer.java

示例6: testDistinct

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testDistinct() throws Exception {
    //Test for bug where distinct wasn't being pruned properly causing union 
    //to fail to get a schema since the distinct relation had an incompatible schema
    //with the other relation being unioned.
    
    String testQuery = 
            "a = load 'd.txt' as (id, v1, v2);" +
            "b = load 'd.txt' as (id, v1, v2);" +
            "c = distinct a;" +
            "d = union b, c;" +
            "e = foreach d generate id, v1;" +
            "store e into 'empty';";
    
    //Generate optimized plan.
    LogicalPlan newLogicalPlan = buildPlan(testQuery);
    PlanOptimizer optimizer = new MyPlanOptimizer(newLogicalPlan, 3);
    optimizer.optimize();
    
    Iterator<Operator> iter = newLogicalPlan.getOperators();
    while (iter.hasNext()) {
        Operator o = iter.next();
        LogicalRelationalOperator lro = (LogicalRelationalOperator)o;
        if (lro == null || lro.getAlias() == null) continue;
        if (lro.getAlias().equals("d")) {
            assertNotNull(lro.getSchema());
        }
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:30,代码来源:TestNewPlanColumnPrune.java

示例7: visit

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Override
public void visit(LOForEach foreach) throws FrontendException {
    appendOp( foreach ) ;
    
	boolean hasFlatten = false;
    LogicalPlan inner1 = foreach.getInnerPlan();
    Iterator<Operator> it = inner1.getOperators();
    while( it.hasNext() ) {
        Operator op = it.next();
        if( op instanceof LOGenerate ) {
            LOGenerate gen = (LOGenerate)op;
            boolean[] flattenFlags = gen.getFlattenFlags();
            if( flattenFlags != null ) {
                for( boolean flatten : flattenFlags ) {
                    if( flatten ) {
                        hasFlatten = true;
                        break;
                    }
                }
            }
        }
    }

	if (hasFlatten)
		sb.append(" [hasflat=\"true\"]");
	else
		sb.append(" [hasflat=\"false\"]");
    sb.append(";\n");
    appendEdges(foreach);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:OptimizeLimitPlanPrinter.java

示例8: showLPOperators

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
static void showLPOperators(LogicalPlan lp) {
   	System.out.println("Operators:");
   	Iterator<org.apache.pig.newplan.Operator> it = lp.getOperators();
   	while( it.hasNext() ) {
   		System.out.println("    op: " + it.next().getName());
   	}
   	System.out.println();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:9,代码来源:TestMultiQueryCompiler.java

示例9: getForEachOperatorCount

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
private int getForEachOperatorCount(LogicalPlan plan) {
    Iterator<Operator> ops = plan.getOperators();
    int count = 0;
    while( ops.hasNext() ) {
        Operator op = ops.next();
        if( op instanceof LOForEach )
            count++;
    }
    return count;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:11,代码来源:TestMergeForEachOptimization.java

示例10: getForEachOperator

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
private LOForEach getForEachOperator(LogicalPlan plan) throws IOException {
    Iterator<Operator> ops = plan.getOperators();
    while( ops.hasNext() ) {
        Operator op = ops.next();
        if( op instanceof LOForEach ) {
            LOForEach foreach = (LOForEach)op;
            Operator succ = plan.getSuccessors( foreach ).get( 0 );
            if( !(succ instanceof LOForEach ) )
                return foreach;
        }
    }
    return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:TestMergeForEachOptimization.java

示例11: getOperator

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
 * returns first operator that is an instance of given class c
 * @param plan
 * @param c
 * @return instance of class c if any, or null
 * @throws IOException
 */
private Operator getOperator(LogicalPlan plan, Class<? extends Operator> c) throws IOException {
    Iterator<Operator> ops = plan.getOperators();
    while( ops.hasNext() ) {
        Operator op = ops.next();
        if( op.getClass().equals(c)) {
            return op;          
        }
    }
    return null;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:TestMergeForEachOptimization.java

示例12: testFull

import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
private void testFull(String q, String partFilter, String filterExpr, boolean unsupportedExpr) throws Exception {
    TestLoader.partFilter = null;
    LogicalPlan newLogicalPlan = migrateAndOptimizePlan( q );

    if (partFilter != null) {
        Assert.assertEquals("checking partition filter:",
                partFilter,
                TestLoader.partFilter.toString());
    } else {
        Assert.assertTrue(TestLoader.partFilter == null);
    }

    if (filterExpr != null) {
        Operator op = newLogicalPlan.getSinks().get(0);
        LOFilter filter = (LOFilter)newLogicalPlan.getPredecessors(op).get(0);

        String actual = new PartitionFilterExtractor(null, new ArrayList<String>())
                .getExpression((LogicalExpression) filter.getFilterPlan().getSources().get(0)).toString();
        Assert.assertEquals("checking trimmed filter expression:",
                filterExpr, actual);
    } else {
        Iterator<Operator> it = newLogicalPlan.getOperators();
        while( it.hasNext() ) {
            Assert.assertFalse("Checking that filter has been removed since it contained" +
                    " only conditions on partition cols:",
                    (it.next() instanceof LOFilter));
        }
    }

    // Test that the filtered plan can be translated to physical plan (PIG-3657)
    LogToPhyTranslationVisitor translator = new LogToPhyTranslationVisitor(newLogicalPlan);
    translator.visit();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:34,代码来源:TestNewPartitionFilterPushDown.java


注:本文中的org.apache.pig.newplan.logical.relational.LogicalPlan.getOperators方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。