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

Method testStoreFunction

test/org/apache/pig/test/TestMapReduce.java:237–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

235
236
237 @Test
238 public void testStoreFunction() throws Throwable {
239 File tmpFile = File.createTempFile("test", ".txt");
240 PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
241 for(int i = 0; i < 10; i++) {
242 ps.println(i+"\t"+i);
243 }
244 ps.close();
245
246 //Load, Execute and Store query
247 String query = "foreach (load '"
248 + Util.generateURI(tmpFile.toString(), pig.getPigContext())
249 + "') generate $0,$1;";
250 System.out.println(query);
251 pig.registerQuery("asdf_id = " + query);
252 try {
253 pig.deleteFile("frog");
254 } catch(Exception e) {}
255 pig.store("asdf_id", "frog", MyStorage.class.getName()+"()");
256
257
258 //verify query
259
260 InputStream is = FileLocalizer.open("frog", pig.getPigContext());
261 BufferedReader br = new BufferedReader(new InputStreamReader(is));
262 String line;
263 int i = 0;
264 while((line = br.readLine()) != null) {
265
266 assertEquals(line, Integer.toString(i) + '-' + Integer.toString(i));
267 i++;
268 }
269 br.close();
270 try {
271 pig.deleteFile("frog");
272 } catch(Exception e) {}
273 tmpFile.delete();
274
275 }
276
277 // This test: "testStoreFunction()" is equivalent to testStoreFunctionNoNulls()
278

Callers

nothing calls this directly

Calls 13

generateURIMethod · 0.95
openMethod · 0.95
closeMethod · 0.65
deleteMethod · 0.65
createTempFileMethod · 0.45
toStringMethod · 0.45
getPigContextMethod · 0.45
registerQueryMethod · 0.45
deleteFileMethod · 0.45
storeMethod · 0.45
getNameMethod · 0.45
readLineMethod · 0.45

Tested by

no test coverage detected