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

Method definedFunctions

test/org/apache/pig/test/TestLocal.java:399–430  ·  view source on GitHub ↗
(String[][] data)

Source from the content-addressed store, hash-verified

397
398
399 public void definedFunctions(String[][] data) throws Throwable {
400
401 File tmpFile=TestHelper.createTempFile(data) ;
402 PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
403 for(int i = 0; i < 1; i++) {
404 ps.println(i);
405 }
406 ps.close();
407 pig.registerFunction("foo",
408 new FuncSpec(MyApply.class.getName()+"('foo')"));
409 String query = "foreach (group (load '"
410 + Util.generateURI(tmpFile.toString(), pig.getPigContext())
411 + "' using " + MyStorage.class.getName() + "()) by "
412 + MyGroup.class.getName()
413 + "('all')) generate flatten(foo($1)) ;";
414 System.out.println(query);
415 pig.registerQuery("asdf_id = " + query);
416 Iterator it = pig.openIterator("asdf_id");
417 tmpFile.delete();
418 Tuple t;
419 int count = 0;
420 while(it.hasNext()) {
421 t = (Tuple) it.next();
422 assertEquals("foo", t.get(0).toString());
423
424 if ( t.get(1).toString() != "" ) {
425 Integer.parseInt(t.get(1).toString());
426 }
427 count++;
428 }
429 assertEquals(count, MyStorage.COUNT);
430 }
431
432
433// @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