Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 3rd, 2012  |  syntax: Java  |  size: 0.89 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         @Test
  2.         public void testFiltering() throws ExecException {
  3.                 String[] expected = {
  4.                         "(4,323,242,http://www.google.com/url&url=http%3A%2F%2Fwww.tagesschau.de&q=barack%20obama)",
  5.                         "(5,423,342,http://www.google.com/url&url=http%3A%2F%2Fwww.bild.de&q=obama)"
  6.                 };
  7.  
  8.  
  9.                 pigServer = new PigServer(ExecType.LOCAL);
  10.  
  11.                 try {
  12.                         Util.registerMultiLineQuery(pigServer, "a = LOAD '" + INPUT_FILE +
  13.                                         "' AS (id:int, grp:int, additional:int, referer:chararray); " +
  14.                                         "b = FILTER a BY " +
  15.                                         "com.adition.pig.filtering.string.CONTAINS(referer, 'obama');");
  16.  
  17.                         Iterator<Tuple> iter = pigServer.openIterator("b");
  18.                         int counter = 0;
  19.                         while (iter.hasNext()){
  20.                                 assertEquals(expected[counter++].toString(), iter.next().toString());
  21.                         }
  22.  
  23.                         assertEquals(expected.length, counter);
  24.  
  25.                 } catch (Exception e) {
  26.                         e.printStackTrace();
  27.                         Assert.fail();
  28.                 }
  29.  
  30.                 pigServer.shutdown();
  31.  
  32.         }
clone this paste RAW Paste Data