• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParserException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getEscapedSchemaFromString

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
public static Schema getEscapedSchemaFromString(String schemaStr) {
    schemaStr = schemaStr.replaceAll("[\\r\\n]", "");
    String[] fieldSchemaStrs = schemaStr.split(",");
    StringBuilder escapedSchemaBuilder = new StringBuilder();

    for (int i = 0; i < fieldSchemaStrs.length; i++) {
        escapedSchemaBuilder.append(escapeFieldSchemaStr(fieldSchemaStrs[i]));
        if (i != fieldSchemaStrs.length - 1)
            escapedSchemaBuilder.append(",");
    }

    try {
        return Utils.getSchemaFromString(escapedSchemaBuilder.toString());
    } catch (ParserException pe) {
        throw new IllegalArgumentException("Invalid schema format: " + pe.getMessage());
    }
}
 
开发者ID:mortardata,项目名称:pig-json,代码行数:18,代码来源:JsonLoader.java


示例2: testForeachStarSchemaUnkown

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testForeachStarSchemaUnkown() throws IOException, ParserException{
    PigServer pig = new PigServer(ExecType.LOCAL);
    String query =
        "  l1 = load '" + INPUT_FILE + "' ;"
        + "f1 = foreach l1 generate * ;"
    ; 
    Util.registerMultiLineQuery(pig, query);
    pig.explain("f1",System.out);
    Iterator<Tuple> it = pig.openIterator("f1");
    
    
    Tuple expectedResCharArray = (Tuple)Util.getPigConstant("('one','two')");
    Tuple expectedRes = TupleFactory.getInstance().newTuple();
    for(Object field :  expectedResCharArray.getAll() ){
        expectedRes.append(new DataByteArray(field.toString()));
    }
    assertTrue("has output", it.hasNext());
    assertEquals(expectedRes, it.next());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:21,代码来源:TestForEachStar.java


示例3: testFilterCount3

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testFilterCount3() throws IOException, ParserException {
    String query = "TESTDATA =  load '"+TEST_FILTER_COUNT3_INPUT+"' using PigStorage() as (timestamp:chararray, testid:chararray, userid: chararray, sessionid:chararray, value:long, flag:int);" +
            "TESTDATA_FILTERED = filter TESTDATA by (timestamp gte '1230800400000' and timestamp lt '1230804000000' and value != 0);" +
            "TESTDATA_GROUP = group TESTDATA_FILTERED by testid;" +
            "TESTDATA_AGG = foreach TESTDATA_GROUP {" +
            "                        A = filter TESTDATA_FILTERED by (userid eq sessionid);" +
            "                        C = distinct A.userid;" +
            "                        generate group as testid, COUNT(TESTDATA_FILTERED) as counttestdata, COUNT(C) as distcount, SUM(TESTDATA_FILTERED.flag) as total_flags;" +
            "                }" +
            "TESTDATA_AGG_1 = group TESTDATA_AGG ALL;" +
            "TESTDATA_AGG_2 = foreach TESTDATA_AGG_1 generate COUNT(TESTDATA_AGG);" ;
    pigServer.registerQuery(query);
    Iterator<Tuple> it = pigServer.openIterator("TESTDATA_AGG_2");

    int i = 0;
    while(it.hasNext()) {
        Tuple actual = it.next();
        assertEquals(20l, actual.get(0));
        i++;
    }
    assertEquals(1, i);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:24,代码来源:TestRelationToExprProject.java


示例4: testUnionOnSchemaSameSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * Test UNION ONSCHEMA on two inputs with same schema
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testUnionOnSchemaSameSchema() throws IOException, ParserException {
    PigServer pig = new PigServer(ExecType.LOCAL);
    String query =
        "  l1 = load '" + INP_FILE_2NUMS + "' as (i : int, j : int);"
        + "l2 = load '" + INP_FILE_2NUMS + "' as (i : int, j : int);"
        + "u = union onschema l1, l2;"
    ; 
    Util.registerMultiLineQuery(pig, query);
    Schema expectedSch = Utils.getSchemaFromString("i: int, j: int");
    Schema sch = pig.dumpSchema("u");
    assertEquals("Checking expected schema",sch, expectedSch);
    Iterator<Tuple> it = pig.openIterator("u");
    
    List<Tuple> expectedRes = 
        Util.getTuplesFromConstantTupleStrings(
                new String[] {
                        "(1,2)",
                        "(5,3)",
                        "(1,2)",
                        "(5,3)"
                });
    Util.checkQueryOutputsAfterSort(it, expectedRes);

}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:TestUnionOnSchema.java


示例5: testUnionOnSchemaCastOnByteArray

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * Test UNION ONSCHEMA with cast from bytearray to another type
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testUnionOnSchemaCastOnByteArray() throws IOException, ParserException {
    PigServer pig = new PigServer(ExecType.LOCAL);
    String query =
        "  l1 = load '" + INP_FILE_2NUMS + "' as (i, j);"
        + " f1 = foreach l1 generate (int)i, (int)j;"
        + "u = union onschema f1, l1;"
    ; 
    Util.registerMultiLineQuery(pig, query);
    Iterator<Tuple> it = pig.openIterator("u");
    
    List<Tuple> expectedRes = 
        Util.getTuplesFromConstantTupleStrings(
                new String[] {
                        "(1,2)",
                        "(5,3)",
                        "(1,2)",
                        "(5,3)"
                });
    Util.checkQueryOutputsAfterSort(it, expectedRes);

}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:TestUnionOnSchema.java


示例6: testUnionOnSchemaScopedColumnNameNeg

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * Test UNION ONSCHEMA where a common column has additional 'namespace' part
 *  in the column name in one of the inputs.
 *  Negative test case
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testUnionOnSchemaScopedColumnNameNeg() throws IOException, ParserException {
    
    String expectedErr = "Found more than one match: l1::i, l2::i";
    String query_prefix =
        "  l1 = load '/tmp/fn' as (i : int, j : long); "
        + "l2 = load '/tmp/fn' as (i : int, j : long); "
        + "cg = cogroup l1 by i, l2 by i;"
        + "f = foreach cg generate flatten(l1), flatten(l2); "
        + "l3 = load '/tmp/fn2' as (i : int, j : long); "
        ;
    String query = query_prefix +  "u = union onschema f, l3; ";
    checkSchemaEx(query, expectedErr);

    // now try reversing the order of relation
    query = query_prefix +  "u = union onschema l3, f; ";
    checkSchemaEx(query, expectedErr);

}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:27,代码来源:TestUnionOnSchema.java


示例7: testUnionOnSchemaDiffNumType

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * Test UNION ONSCHEMA on two inputs with same column names, but different
 * numeric types - test type promotion
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testUnionOnSchemaDiffNumType() throws IOException, ParserException {
    PigServer pig = new PigServer(ExecType.LOCAL);
    String query =
        "  l1 = load '" + INP_FILE_2NUMS + "' as (i : int, j : double);"
        + "l2 = load '" + INP_FILE_2NUMS + "' as (i : long, j : float);"
        + "u = union onschema l1, l2;"
    ; 
    Util.registerMultiLineQuery(pig, query);
    Iterator<Tuple> it = pig.openIterator("u");
    
    List<Tuple> expectedRes = 
        Util.getTuplesFromConstantTupleStrings(
                new String[] {
                        "(1L,2.0)",
                        "(5L,3.0)",
                        "(1L,2.0)",
                        "(5L,3.0)"
                });
    Util.checkQueryOutputsAfterSort(it, expectedRes);

}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:29,代码来源:TestUnionOnSchema.java


示例8: outputSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
  if (null != this.schemaFunction) {
    try {
      Tuple t = TupleFactory.getInstance().newTuple(1);
      // Strip enclosing '{}' from schema
      t.set(0, input.toString().replaceAll("^\\{", "").replaceAll("\\}$", ""));
      return Utils.getSchemaFromString((String) this.schemaFunction.exec(t));
    } catch (ParserException pe) {
      throw new RuntimeException(pe);
    } catch (IOException ioe) {
      throw new RuntimeException(ioe);
    }
  } else {
    return this.schema;
  }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:GroovyEvalFunc.java


示例9: JsFunction

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
public JsFunction(String functionName) {
    this.jsScriptEngine = JsScriptEngine.getInstance();
    this.functionName = functionName;
    Object outputSchemaObj = jsScriptEngine.jsEval(this.getClass().getName() + "(String)",
            functionName + ".outputSchema");
    //if no schema defined, fall back to bytearray
    if (outputSchemaObj == null || outputSchemaObj instanceof Undefined) {
        this.outputSchema = new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY));
    }
    else {
        try {
            this.outputSchema = Utils.getSchemaFromString(outputSchemaObj.toString());
        }
        catch (ParserException e) {
            throw new IllegalArgumentException(functionName
                    + ".outputSchema is not a valid schema: " + e.getMessage(), e);
        }
    }

}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:21,代码来源:JsFunction.java


示例10: testDereferenceTypeSet

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testDereferenceTypeSet() throws IOException, ParserException {
    String query = "a = load 'a' as (i : int, j : int);"
    + " b = foreach a generate i, j/10.1 as jd;"
    + " c = group b by i;"
    + " d = foreach c generate MAX(b.jd) as mx;";

    PigServer pig = new PigServer(ExecType.LOCAL);
    Util.registerMultiLineQuery(pig, query);

    Schema expectedSch =
        Utils.getSchemaFromString("mx: double");
    Schema sch = pig.dumpSchema("d");
    assertEquals("Checking expected schema", expectedSch, sch);

}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:17,代码来源:TestTypeCheckingValidatorNewLP.java


示例11: testCastEmptyInnerSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testCastEmptyInnerSchema() throws IOException, ParserException{
    final String INP_FILE = "testCastEmptyInnerSchema.txt";
    PrintWriter w = new PrintWriter(new FileWriter(INP_FILE));
    w.println("(1,2)");
    w.println("(2,3)");
    w.close();
    PigServer pigServer = new PigServer(LOCAL);

    String query = "a = load '" + INP_FILE + "' as (t:tuple());" +
    "b = foreach a generate (tuple(int, long))t;" +
    "c = foreach b generate t.$0 + t.$1;";

    Util.registerMultiLineQuery(pigServer, query);

    List<Tuple> expectedRes =
        Util.getTuplesFromConstantTupleStrings(
                new String[] {
                        "(3L)",
                        "(5L)",
                });
    Iterator<Tuple> it = pigServer.openIterator("c");
    Util.checkQueryOutputs(it, expectedRes);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:25,代码来源:TestTypeCheckingValidatorNewLP.java


示例12: read

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
private static void read(PageReadStore columns, String pigSchemaString, String message) throws ParserException {
    System.out.println(message);
    MessageColumnIO columnIO = newColumnFactory(pigSchemaString);
    TupleReadSupport tupleReadSupport = new TupleReadSupport();
    Map<String, String> pigMetaData = pigMetaData(pigSchemaString);
    MessageType schema = new PigSchemaConverter().convert(Utils.getSchemaFromString(pigSchemaString));
    ReadContext init = tupleReadSupport.init(null, pigMetaData, schema);
    RecordMaterializer<Tuple> recordConsumer = tupleReadSupport.prepareForRead(null, pigMetaData, schema, init);
    RecordReader<Tuple> recordReader = columnIO.getRecordReader(columns, recordConsumer);
    // TODO: put this back
//  if (DEBUG) {
//    recordConsumer = new RecordConsumerLoggingWrapper(recordConsumer);
//  }
    read(recordReader, 10000, pigSchemaString);
    read(recordReader, 10000, pigSchemaString);
    read(recordReader, 10000, pigSchemaString);
    read(recordReader, 10000, pigSchemaString);
    read(recordReader, 10000, pigSchemaString);
    read(recordReader, 100000, pigSchemaString);
    read(recordReader, 1000000, pigSchemaString);
    System.out.println();
  }
 
开发者ID:apache,项目名称:parquet-mr,代码行数:23,代码来源:TupleConsumerPerfTest.java


示例13: testBinStorageGetSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testBinStorageGetSchema() throws IOException, ParserException {
    String input[] = new String[] { "hello\t1\t10.1", "bye\t2\t20.2" };
    String inputFileName = "testGetSchema-input.txt";
    String outputFileName = "testGetSchema-output.txt";
    try {
        Util.createInputFile(pig.getPigContext(),
                inputFileName, input);
        String query = "a = load '" + inputFileName + "' as (c:chararray, " +
                "i:int,d:double);store a into '" + outputFileName + "' using " +
                        "BinStorage();";
        pig.setBatchOn();
        Util.registerMultiLineQuery(pig, query);
        pig.executeBatch();
        ResourceSchema rs = new BinStorage().getSchema(outputFileName,
                new Job(ConfigurationUtil.toConfiguration(pig.getPigContext().
                        getProperties())));
        Schema expectedSchema = Utils.getSchemaFromString(
                "c:chararray,i:int,d:double");
        assertTrue("Checking binstorage getSchema output", Schema.equals(
                expectedSchema, Schema.getPigSchema(rs), true, true));
    } finally {
        Util.deleteFile(pig.getPigContext(), inputFileName);
        Util.deleteFile(pig.getPigContext(), outputFileName);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:27,代码来源:TestStore.java


示例14: testProjectStarMulti

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * Test projecting multiple *
 * @throws IOException
 * @throws ParseException
 */
@Test
public void testProjectStarMulti() throws IOException, ParserException {
    PigServer pig = new PigServer(ExecType.LOCAL);
    String query =
        "  l1 = load '" + INP_FILE_5FIELDS + "' as (a : int, b : int, c : int);"
        + "f = foreach l1 generate * as (aa, bb, cc), *;"
    ; 

    Util.registerMultiLineQuery(pig, query);
   
    Schema expectedSch = Utils.getSchemaFromString(
            "aa : int, bb : int, cc : int, a : int, b : int, c : int");
    Schema sch = pig.dumpSchema("f");
    assertEquals("Checking expected schema", expectedSch, sch);
    List<Tuple> expectedRes = 
        Util.getTuplesFromConstantTupleStrings(
                new String[] {
                        "(10,20,30,10,20,30)",
                        "(11,21,31,11,21,31)",
                });
    Iterator<Tuple> it = pig.openIterator("f");
    Util.checkQueryOutputsAfterSort(it, expectedRes);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:29,代码来源:TestProjectStarExpander.java


示例15: testNegativeForeachNOSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * -ve test cases
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testNegativeForeachNOSchema() throws IOException, ParserException {
    String query;
    query =
        "  l1 = load '" + INP_FILE_5FIELDS + "';"
        + "f = foreach l1 generate  $3 .. $1;"
        ;
    Util.checkExceptionMessage(query, "f",
            "start column appears after end column in range projection");

    query =
        "  l1 = load '" + INP_FILE_5FIELDS + "' ;"
        + "f = foreach l1 generate  a .. b;"
        ;
    Util.checkExceptionMessage(query, "f",
            "Invalid field projection. Projected field [a] does not exist.");
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:23,代码来源:TestProjectRange.java


示例16: testNegativeForeachWSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
/**
 * -ve test cases
 * @throws IOException
 * @throws ParserException
 */
@Test
public void testNegativeForeachWSchema() throws IOException, ParserException {
    String query;
    query =
        "  l1 = load '" + INP_FILE_5FIELDS + "' as (a : int, b : float, c : int, d : int, e : int);"
        + "f = foreach l1 generate  $3 .. $1;"
        ;
    Util.checkExceptionMessage(query, "f",
            "start column appears after end column in range projection");

    query =
        "  l1 = load '" + INP_FILE_5FIELDS + "' as (a : int, b : float, c : int, d : int, e : int);"
        + "f = foreach l1 generate  c .. b;"
        ;
    Util.checkExceptionMessage(query, "f",
            "start column appears after end column in range projection");
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:23,代码来源:TestProjectRange.java


示例17: getPigSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
public static Schema getPigSchema(String schemaString) {
    Schema schema = null;
    schemaString = schemaString.replace("/", "_");
    schemaString = "{(" + schemaString + ")}";
    try {
        schema = Utils.getSchemaFromString(schemaString);
    } catch (ParserException e) {
        e.printStackTrace();
    }
    return schema;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:12,代码来源:VespaQuerySchema.java


示例18: outputSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
    try {
        return Utils.getSchemaFromString("m:map[chararray]");
    } catch (ParserException e) {
        return null;
    }
}
 
开发者ID:openaire,项目名称:iis,代码行数:9,代码来源:EmptyMap.java


示例19: getSchema

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
private Schema getSchema() {
    try {
        final String schemaString = getProperties().getProperty(SCHEMA);
        if (schemaString == null) {
            throw new ParquetEncodingException("Can not store relation in Parquet as the schema is unknown");
        }
        return Utils.getSchemaFromString(schemaString);
    } catch (ParserException e) {
        throw new ParquetEncodingException("can not get schema from context", e);
    }
}
 
开发者ID:saikocat,项目名称:parquet-mr-contrib,代码行数:12,代码来源:ParquetMultiStorer.java


示例20: testSimpleMapKeyLookup

import org.apache.pig.parser.ParserException; //导入依赖的package包/类
@Test
public void testSimpleMapKeyLookup() throws IOException, ParserException {
    PigServer pig = new PigServer(ExecType.LOCAL, new Properties());
    String[] input = {
            "[key#1,key2#2]",
            "[key#2]",
    };

    Util.createInputFile(FileSystem.getLocal(new Configuration()), tmpDirName + "/testSimpleMapKeyLookup", input);

    String query =
        "a = load '" + tmpDirName + "/testSimpleMapKeyLookup' as (m:map[int]);" +
        "b = foreach a generate m#'key';";
    Util.registerMultiLineQuery(pig, query);
    Schema sch = pig.dumpSchema("b");
    assertEquals("Checking expected schema",sch.toString(), "{int}");
    Iterator<Tuple> it = pig.openIterator("b");

    Assert.assertTrue(it.hasNext());
    Tuple t = it.next();
    Assert.assertTrue(t.size()==1);
    Assert.assertTrue((Integer)t.get(0)==1);

    Assert.assertTrue(it.hasNext());
    t = it.next();
    Assert.assertTrue(t.size()==1);
    Assert.assertTrue((Integer)t.get(0)==2);

    Assert.assertFalse(it.hasNext());
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:31,代码来源:TestTypedMap.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ACC类代码示例发布时间:2022-05-21
下一篇:
Java MalformedChallengeException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap