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


Java Util.encodeEscape方法代码示例

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


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

示例1: testRecordWithFieldSchemaFromTextWithSchemaFile

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecordWithFieldSchemaFromTextWithSchemaFile() throws IOException {
    PigSchema2Avro.setTupleIndex(1);
    String output= outbasedir + "testRecordWithFieldSchemaFromTextWithSchemaFile";
    String expected = basedir + "expected_testRecordWithFieldSchema.avro";
    deleteDirectory(new File(output));
    String [] queries = {
       " avro = LOAD '" + Util.encodeEscape(testTextFile) + "' AS (member_id:int, browser_id:chararray, tracking_time:long, act_content:bag{inner:tuple(key:chararray, value:chararray)});",
      " avro1 = FILTER avro BY member_id > 1211;",
      " avro2 = FOREACH avro1 GENERATE member_id, browser_id, tracking_time, act_content ;",
      " STORE avro2 INTO '" + output + "' " +
            " USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
            "'{\"schema_file\":  \"" + Util.encodeEscape(testRecordSchema) + "\" ," +
            "  \"field0\": \"int\", " +
             " \"field1\":  \"def:browser_id\", " +
            "  \"field3\": \"def:act_content\" " +
           " }');"
       };
    testAvroStorage( queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:22,代码来源:TestAvroStorage.java

示例2: testRecursiveRecordInArray

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecursiveRecordInArray() throws IOException {
    // Verify that recursive records in array can be loaded/saved.
    String output= outbasedir + "testRecursiveRecordInArray";
    String expected = testRecursiveRecordInArray;
    deleteDirectory(new File(output));
    String [] queries = {
      " in = LOAD '" + Util.encodeEscape(testRecursiveRecordInArray) +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
      " STORE in INTO '" + output +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
          " 'no_schema_check'," +
          " 'schema', '" + recursiveRecordInArray + "' );"
       };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:TestAvroStorage.java

示例3: testRecursiveRecordInRecord

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecursiveRecordInRecord() throws IOException {
    // Verify that recursive records in record can be loaded/saved.
    String output= outbasedir + "testRecursiveRecordInRecord";
    String expected = testRecursiveRecordInRecord;
    deleteDirectory(new File(output));
    String [] queries = {
      " in = LOAD '" + Util.encodeEscape(testRecursiveRecordInRecord) +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
      " STORE in INTO '" + output +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
          " 'no_schema_check'," +
          " 'schema', '" + Util.encodeEscape(recursiveRecordInRecord) + "' );"
       };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:TestAvroStorage.java

示例4: testRecursiveRecordInMap

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecursiveRecordInMap() throws IOException {
    // Verify that recursive records in map can be loaded/saved.
    String output= outbasedir + "testRecursiveRecordInMap";
    String expected = testRecursiveRecordInMap;
    deleteDirectory(new File(output));
    String [] queries = {
      " in = LOAD '" + Util.encodeEscape(testRecursiveRecordInMap) +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
      " STORE in INTO '" + output +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
          " 'no_schema_check'," +
          " 'schema', '" + recursiveRecordInMap + "' );"
       };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:TestAvroStorage.java

示例5: testRecursiveRecordWithData

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecursiveRecordWithData() throws IOException {
    // Verify that recursive records cannot be stored if avro schema is specified by 'data'.
    String output= outbasedir + "testRecursiveWithData";
    deleteDirectory(new File(output));
    String [] queries = {
      " in = LOAD '" + Util.encodeEscape(testRecursiveRecordInUnion) +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
      " STORE in INTO '" + output +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
          " 'no_schema_check'," +
          " 'data', '" + Util.encodeEscape(testRecursiveRecordInUnion) + "' );"
       };
    try {
        testAvroStorage(queries);
        Assert.fail("Negative test to test an exception. Should not be succeeding!");
    } catch (FrontendException e) {
        // The IOException thrown by AvroSchemaManager for recursive record is caught
        // by the Pig frontend, and FrontendException is re-thrown.
        assertTrue(e.getMessage().contains("could not instantiate 'org.apache.pig.piggybank.storage.avro.AvroStorage'"));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:23,代码来源:TestAvroStorage.java

示例6: testGlob1

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testGlob1() throws IOException {
    // Verify that the a glob pattern matches files properly.
    String output = outbasedir + "testGlob1";
    String expected = basedir + "expected_testDir.avro";
    deleteDirectory(new File(output));
    String [] queries = {
       " in = LOAD '" + Util.encodeEscape(testDir1AllFiles) + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
       " STORE in INTO '" + output + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
           "   'schema', '{\"type\":\"array\",\"items\":\"float\"}'  );"
        };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:15,代码来源:TestAvroStorage.java

示例7: testGlob3

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testGlob3() throws IOException {
    // Verify that comma-separated filenames are escaped properly.
    String output = outbasedir + "testGlob3";
    String expected = basedir + "expected_test_dir_1.avro";
    deleteDirectory(new File(output));
    String [] queries = {
       " in = LOAD '" + Util.encodeEscape(testDir1Files321) + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
       " STORE in INTO '" + output + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
           "   'schema', '{\"type\":\"array\",\"items\":\"float\"}'  );"
        };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:TestAvroStorage.java

示例8: testXMLLoaderShouldLoadBasicBzip2Files

import org.apache.pig.test.Util; //导入方法依赖的package包/类
public void testXMLLoaderShouldLoadBasicBzip2Files() throws Exception {
 String filename = TestHelper.createTempFile(data, "");
 Process bzipProc = Runtime.getRuntime().exec("bzip2 "+filename);
 int waitFor = bzipProc.waitFor();

 if(waitFor != 0) {
     fail ("Failed to create the class");
 }

 filename = filename + ".bz2";

 try {
     PigServer pigServer = new PigServer (ExecType.LOCAL);
     String loadQuery = "A = LOAD '" + Util.encodeEscape(filename) + "' USING org.apache.pig.piggybank.storage.XMLLoader('property') as (doc:chararray);";
     pigServer.registerQuery(loadQuery);

     Iterator<Tuple> it = pigServer.openIterator("A");
     int tupleCount = 0;
     while (it.hasNext()) {
         Tuple tuple = (Tuple) it.next();
         if (tuple == null)
             break;
         else {
             //TestHelper.examineTuple(expected, tuple, tupleCount);
             if (tuple.size() > 0) {
                 tupleCount++;
             }
         }
     }
     assertEquals(2, tupleCount);

 } finally {
     new File(filename).delete();
 }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:36,代码来源:TestXMLLoader.java

示例9: testArrayWithSchemaURI

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testArrayWithSchemaURI() throws IOException {
    String output= outbasedir + "testArrayWithSchemaURI";
    String expected = basedir + "expected_testArrayWithSchemaURI.avro"; // doubles (not floats) stored
    deleteDirectory(new File(output));
    String [] queries = {
       " in = LOAD '" + Util.encodeEscape(testArrayFile) + " ' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
       " STORE in INTO '" + output +
           "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ( "  +
           "   'schema_uri', '" + Util.encodeEscape(testArraySchema)  + "'  );"
        };
    testAvroStorage( queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:TestAvroStorage.java

示例10: testSingleFieldTuples

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testSingleFieldTuples() throws IOException {
    String output= outbasedir + "testSingleFieldTuples";
    String expected = basedir + "expected_testSingleFieldTuples.avro";
    deleteDirectory(new File(output));
    String [] queries = {
            " messages = LOAD '" + Util.encodeEscape(testSingleTupleBagFile) + " ' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
            " a = foreach (group messages by user_id) { sorted = order messages by message_id DESC; GENERATE group AS user_id, sorted AS messages; };",
            " STORE a INTO '" + output + "' " +
                    " USING org.apache.pig.piggybank.storage.avro.AvroStorage ();"
    };
    testAvroStorage( queries);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:14,代码来源:TestAvroStorage.java

示例11: testGlob5

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testGlob5() throws IOException {
    // Verify that comma-separated directory names are escaped properly.
    String output = outbasedir + "testGlob5";
    String expected = basedir + "expected_test_dir_1_2.avro";
    deleteDirectory(new File(output));
    String [] queries = {
       " in = LOAD '" + Util.encodeEscape(testDir21AllFiles) + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
       " STORE in INTO '" + output + "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
           "   'schema', '{\"type\":\"array\",\"items\":\"float\"}'  );"
        };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:TestAvroStorage.java

示例12: testArrayWithSchema

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testArrayWithSchema() throws IOException {
    String output= outbasedir + "testArrayWithSchema";
    String expected = basedir + "expected_testArrayWithSchema.avro";
    deleteDirectory(new File(output));
    String [] queries = {
            " in = LOAD '" + Util.encodeEscape(testArrayFile) + " ' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
            " STORE in INTO '" + output +
            "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ( "  +
            "   'schema', '{\"type\":\"array\",\"items\":\"float\"}'  );"
    };
    testAvroStorage( queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:15,代码来源:TestAvroStorage.java

示例13: testRecursiveRecordReference3

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecursiveRecordReference3() throws IOException {
    // The relation 'in' looks like this:
    //  (1,(2,(3,)))
    //  (2,(3,))
    //  (3,)
    // $1.$1.$0 looks like this:
    //  (3)
    //  ()
    //  ()
    // Avro file stored after filtering out nulls looks like this:
    //  3
    String output= outbasedir + "testRecursiveRecordReference3";
    String expected = basedir + "expected_testRecursiveRecordReference3.avro";
    deleteDirectory(new File(output));
    String [] queries = {
      " in = LOAD '" + Util.encodeEscape(testRecursiveRecordInUnion) +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
      " third = FOREACH in GENERATE $1.$1.$0 AS value;",
      " filtered = FILTER third BY value is not null;",
      " STORE filtered INTO '" + output +
          "' USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
          " 'no_schema_check'," +
          " 'schema', '\"int\"' );"
       };
    testAvroStorage(queries);
    verifyResults(output, expected);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:29,代码来源:TestAvroStorage.java

示例14: testLoaderShouldLoadBasicGzFile

import org.apache.pig.test.Util; //导入方法依赖的package包/类
public void testLoaderShouldLoadBasicGzFile() throws Exception {
   String filename = TestHelper.createTempFile(data, "");

   Process bzipProc = Runtime.getRuntime().exec("gzip "+filename);
   int waitFor = bzipProc.waitFor();

   if(waitFor != 0) {
       fail ("Failed to create the class");
   }

   filename = filename + ".gz";

   try {
       PigServer pigServer = new PigServer (ExecType.LOCAL);
       String loadQuery = "A = LOAD '" + Util.encodeEscape(filename) + "' USING org.apache.pig.piggybank.storage.XMLLoader('property') as (doc:chararray);";
       pigServer.registerQuery(loadQuery);

       Iterator<Tuple> it = pigServer.openIterator("A");
       int tupleCount = 0;
       while (it.hasNext()) {
           Tuple tuple = (Tuple) it.next();
           if (tuple == null)
               break;
           else {
               if (tuple.size() > 0) {
                   tupleCount++;
               }
           }
       }
       assertEquals(2, tupleCount);

   } finally {
       new File(filename).delete();
   }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:36,代码来源:TestXMLLoader.java

示例15: testRecordWithSplit

import org.apache.pig.test.Util; //导入方法依赖的package包/类
@Test
public void testRecordWithSplit() throws IOException {
    PigSchema2Avro.setTupleIndex(0);
    String output1= outbasedir + "testRecordSplit1";
    String output2= outbasedir + "testRecordSplit2";
    String expected1 = basedir + "expected_testRecordSplit1.avro";
    String expected2 = basedir + "expected_testRecordSplit2.avro";
    deleteDirectory(new File(output1));
    deleteDirectory(new File(output2));
    String [] queries = {
       " avro = LOAD '" + Util.encodeEscape(testRecordFile) + " ' USING org.apache.pig.piggybank.storage.avro.AvroStorage ();",
       " groups = GROUP avro BY member_id;",
       " sc = FOREACH groups GENERATE group AS key, COUNT(avro) AS cnt;",
       " STORE sc INTO '" + output1 + "' " +
             " USING org.apache.pig.piggybank.storage.avro.AvroStorage (" +
             "'{\"index\": 1, " +
             "  \"schema\": {\"type\":\"record\", " +
                                    " \"name\":\"result\", " +
                                   "  \"fields\":[ {\"name\":\"member_id\",\"type\":\"int\"}, " +
                                                         "{\"name\":\"count\", \"type\":\"long\"} " +
                                                      "]" +
                                     "}" +
            " }');",
        " STORE sc INTO '" + output2 +
                " 'USING org.apache.pig.piggybank.storage.avro.AvroStorage ('index', '2');"
        };
    testAvroStorage( queries);
    verifyResults(output1, expected1);
    verifyResults(output2, expected2);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:TestAvroStorage.java


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