MCPcopy Create free account
hub / github.com/apache/pig / definedFunctions

Method definedFunctions

test/org/apache/pig/test/TestMapReduce.java:455–486  ·  view source on GitHub ↗
(String[][] data)

Source from the content-addressed store, hash-verified

453
454
455 public void definedFunctions(String[][] data) throws Throwable {
456
457 File tmpFile=TestHelper.createTempFile(data) ;
458 PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
459 for(int i = 0; i < 1; i++) {
460 ps.println(i);
461 }
462 ps.close();
463 pig.registerFunction("foo",
464 new FuncSpec(MyApply.class.getName()+"('foo')"));
465 String query = "foreach (group (load '"
466 + Util.generateURI(tmpFile.toString(), pig.getPigContext())
467 + "' using " + MyStorage.class.getName() + "()) by "
468 + MyGroup.class.getName()
469 + "('all')) generate flatten(foo($1)) ;";
470 System.out.println(query);
471 pig.registerQuery("asdf_id = " + query);
472 Iterator<Tuple> it = pig.openIterator("asdf_id");
473 tmpFile.delete();
474 Tuple t;
475 int count = 0;
476 while(it.hasNext()) {
477 t = it.next();
478 assertEquals("foo", t.get(0).toString());
479
480 if ( t.get(1).toString() != "" ) {
481 Integer.parseInt(t.get(1).toString());
482 }
483 count++;
484 }
485 assertEquals(count, MyStorage.COUNT);
486 }
487
488
489 @Test

Calls 14

createTempFileMethod · 0.95
generateURIMethod · 0.95
getMethod · 0.95
openIteratorMethod · 0.80
closeMethod · 0.65
deleteMethod · 0.65
registerFunctionMethod · 0.45
getNameMethod · 0.45
toStringMethod · 0.45
getPigContextMethod · 0.45
registerQueryMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected