(String[][] data)
| 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 |
no test coverage detected