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


Java PlanValidationException类代码示例

本文整理汇总了Java中org.apache.pig.impl.plan.PlanValidationException的典型用法代码示例。如果您正苦于以下问题:Java PlanValidationException类的具体用法?Java PlanValidationException怎么用?Java PlanValidationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlanValidationException类属于org.apache.pig.impl.plan包,在下文中一共展示了PlanValidationException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValidation

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testValidation() throws Exception{
    String outputFileName = "test-output.txt";
    try {
        String query = "a = load '" + inputFileName + "' as (c:chararray, " +
                       "i:int,d:double);" +
                       "store a into '" + outputFileName + "' using " + "PigStorage();";
        org.apache.pig.newplan.logical.relational.LogicalPlan lp = Util.buildLp( pig, query );
        new InputOutputFileValidator(lp, pig.getPigContext()).validate();
    } catch (PlanValidationException e){
            // Since output file is not present, validation should pass
            // and not throw this exception.
            fail("Store validation test failed.");
    } finally {
        Util.deleteFile(pig.getPigContext(), outputFileName);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:TestStore.java

示例2: testValidation

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testValidation() throws Exception{
    String outputFileName = "test-output.txt";
    try {
        String query = "a = load '" + inputFileName + "' as (c:chararray, " +
                       "i:int,d:double);" +
                       "store a into '" + outputFileName + "' using " + "PigStorage();";
        org.apache.pig.newplan.logical.relational.LogicalPlan lp = Util.buildLp( pig, query );
    } catch (PlanValidationException e){
            // Since output file is not present, validation should pass
            // and not throw this exception.
            fail("Store validation test failed.");
    } finally {
        Util.deleteFile(pig.getPigContext(), outputFileName);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:17,代码来源:TestStore.java

示例3: testValidation

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testValidation() throws Exception{
    String outputFileName = "test-output.txt";
    try {
        String query = "a = load '" + inputFileName + "' as (c:chararray, " +
                       "i:int,d:double);" +
                       "store a into '" + outputFileName + "' using " + "PigStorage();";
        org.apache.pig.newplan.logical.relational.LogicalPlan lp = Util.buildLp( pig, query );
        new InputOutputFileValidator(lp, pig.getPigContext()).validate();
    } catch (PlanValidationException e){
            // Since output file is not present, validation should pass
            // and not throw this exception.
            fail("Store validation test failed.");                
    } finally {
        Util.deleteFile(pig.getPigContext(), outputFileName);
    }
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:18,代码来源:TestStore.java

示例4: findColNum

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
private int findColNum(String alias) throws FrontendException {
    LogicalPlan lp = (LogicalPlan)attachedRelationalOp.getPlan();
    List<Operator> inputs = lp.getPredecessors( attachedRelationalOp );
    LogicalRelationalOperator input = (LogicalRelationalOperator)inputs.get( getInputNum() );
    LogicalSchema inputSchema = input.getSchema();

    if( alias != null ) {
        int colNum = inputSchema == null ? -1 : inputSchema.getFieldPosition( alias );
        if( colNum == -1 ) {
        	String msg = "Invalid field projection. Projected field [" + alias + "] does not exist";
            if( inputSchema != null )
            	msg += " in schema: " + inputSchema.toString( false );
            msg += ".";
            throw new PlanValidationException( this, msg, 1025 );
        }
        return colNum;
    } else {
        int col = getColNum();
        if( inputSchema != null && col >= inputSchema.size() ) {
            throw new PlanValidationException( this,
                    "Out of bound access. Trying to access non-existent column: " +
                    col + ". Schema " +  inputSchema.toString(false) +
                    " has " + inputSchema.size() + " column(s)." , 1000);
        }
        return col;
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:ProjectExpression.java

示例5: testNegative2

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testNegative2() throws RecognitionException, ParsingFailureException, IOException {
    String query = "A = load 'x' as ( u:bag{tuple(x, y)}, v:long, w:bytearray); " + 
                   "B = foreach A generate u.(x, y), v, $5; " +
                   "C = store B into 'output';";
    try {
        validate( query );
    } catch(PlanValidationException ex) {
        return;
    }
    Assert.fail( "Query should fail to validate." );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:TestColumnAliasConversion.java

示例6: testNegative3

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testNegative3() throws RecognitionException, ParsingFailureException, IOException {
    String query = "A = load 'x' as ( u:bag{tuple(x, y)}, v:long, w:bytearray); " + 
                   "B = foreach A generate u.(x, y), v, x; " +
                   "C = store B into 'output';";
    try {
        validate( query );
    } catch(PlanValidationException ex) {
        return;
    }
    Assert.fail( "Query should fail to validate." );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:TestColumnAliasConversion.java

示例7: testNegative5

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testNegative5() throws RecognitionException, ParsingFailureException, IOException {
    String query = "A = load 'x';" + 
                   "B = foreach A generate u, $1; " +
                   "C = store B into 'output';";
    try {
        validate( query );
    } catch(PlanValidationException ex) {
        return;
    }
    Assert.fail( "Query should fail to validate." );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:13,代码来源:TestColumnAliasConversion.java

示例8: testNegative1

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
public void testNegative1() throws RecognitionException, ParsingFailureException, IOException {
    String query = "A = load 'x' as ( u:int, v:long, w:bytearray); " + 
                   "B = foreach A generate $0, v, $0; " +
                   "C = store B into 'output';";
    try {
        validate( query );
    } catch(PlanValidationException ex) {
        Assert.assertTrue( ex.getMessage().contains( "Duplicate schema alias" ) );
        return;
    }
    Assert.fail( "Query should fail to validate." );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:TestSchemaAliasVisitor.java

示例9: testNegative2

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Test
// See PIG-644
public void testNegative2() throws RecognitionException, ParsingFailureException, IOException {
     String query = "a = load '1.txt' as (a0:int, a1:int);" + 
                    "b = foreach a generate a0, a1 as a0;" +
                    "c = store b into 'output';";
     try {
         validate( query );
     } catch(PlanValidationException ex) {
         Assert.assertTrue( ex.getMessage().contains( "Duplicate schema alias" ) );
         return;
     }
     Assert.fail( "Query should fail to validate." );
 }
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:TestSchemaAliasVisitor.java

示例10: findColNum

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
private int findColNum(String alias) throws FrontendException {
    LogicalPlan lp = (LogicalPlan)attachedRelationalOp.getPlan();
    List<Operator> inputs = lp.getPredecessors( attachedRelationalOp );
    LogicalRelationalOperator input = (LogicalRelationalOperator)inputs.get( getInputNum() );
    LogicalSchema inputSchema = input.getSchema();
    
    if( alias != null ) {
        int colNum = inputSchema == null ? -1 : inputSchema.getFieldPosition( alias );
        if( colNum == -1 ) {
        	String msg = "Invalid field projection. Projected field [" + alias + "] does not exist";
            if( inputSchema != null )
            	msg += " in schema: " + inputSchema.toString( false );
            msg += ".";
            throw new PlanValidationException( this, msg, 1025 );
        }
        return colNum;
    } else {
        int col = getColNum();
        if( inputSchema != null && col >= inputSchema.size() ) {
            throw new PlanValidationException( this,
                    "Out of bound access. Trying to access non-existent column: " + 
                    col + ". Schema " +  inputSchema.toString(false) + 
                    " has " + inputSchema.size() + " column(s)." , 1000);
        }
        return col;
    }
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:28,代码来源:ProjectExpression.java

示例11: getVisitor

import org.apache.pig.impl.plan.PlanValidationException; //导入依赖的package包/类
@Override
protected LogicalExpressionVisitor getVisitor(final LogicalExpressionPlan exprPlan)
throws FrontendException {
    return new LogicalExpressionVisitor( exprPlan, new DependencyOrderWalker( exprPlan ) ) {

        @Override
        public void visit(ScalarExpression expr) throws FrontendException {
            // This is a scalar udf.
            ConstantExpression filenameConst = (ConstantExpression)exprPlan.getSuccessors( expr ).get( 1 );

            Operator refOp = expr.getImplicitReferencedOperator();
            Operator attachedOp = expr.getAttachedLogicalOperator();
            LogicalPlan lp = (LogicalPlan) attachedOp.getPlan();
            List<Operator> succs = lp.getSuccessors( refOp );
            LOStore store = null;
            if( succs != null ) {
                for( Operator succ : succs ) {
                    if( succ instanceof LOStore ) {
                        store = (LOStore)succ;
                        break;
                    }
                }
            }

            if( store == null ) {
                FuncSpec funcSpec = new FuncSpec(InterStorage.class.getName());
                FileSpec fileSpec;
                try {
                    fileSpec = new FileSpec( FileLocalizer.getTemporaryPath( pigContext ).toString(), funcSpec );                    // TODO: need to hookup the pigcontext.
                } catch (IOException e) {
                    throw new PlanValidationException( expr, "Failed to process scalar" + e);
                }
                store = new LOStore( lp, fileSpec );
                store.setTmpStore(true);
                lp.add( store );
                lp.connect( refOp, store );
                expr.setImplicitReferencedOperator(store);
            }

            filenameConst.setValue( store.getOutputSpec().getFileName() );
            
            if( lp.getSoftLinkSuccessors( store ) == null || 
                !lp.getSoftLinkSuccessors( store ).contains( attachedOp ) ) {
                lp.createSoftLink( store, attachedOp );
            }
        }

    };
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:50,代码来源:ScalarVisitor.java


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