Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  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.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement