
Untitled
By: a guest on
Jul 3rd, 2012 | syntax:
Java | size: 0.89 KB | hits: 22 | expires: Never
@Test
public void testFiltering() throws ExecException {
String[] expected = {
"(4,323,242,http://www.google.com/url&url=http%3A%2F%2Fwww.tagesschau.de&q=barack%20obama)",
"(5,423,342,http://www.google.com/url&url=http%3A%2F%2Fwww.bild.de&q=obama)"
};
pigServer = new PigServer(ExecType.LOCAL);
try {
Util.registerMultiLineQuery(pigServer, "a = LOAD '" + INPUT_FILE +
"' AS (id:int, grp:int, additional:int, referer:chararray); " +
"b = FILTER a BY " +
"com.adition.pig.filtering.string.CONTAINS(referer, 'obama');");
Iterator<Tuple> iter = pigServer.openIterator("b");
int counter = 0;
while (iter.hasNext()){
assertEquals(expected[counter++].toString(), iter.next().toString());
}
assertEquals(expected.length, counter);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
pigServer.shutdown();
}