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

Method testStoreFunction

test/org/apache/pig/test/TestLocal.java:181–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179 }
180
181 @Test
182 public void testStoreFunction() throws Throwable {
183 File tmpFile = File.createTempFile("test", ".txt");
184 PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
185 for(int i = 0; i < 10; i++) {
186 ps.println(i+"\t"+i);
187 }
188 ps.close();
189
190 //Load, Execute and Store query
191 String query = "foreach (load '"
192 + Util.generateURI(tmpFile.toString(), pig.getPigContext())
193 + "') generate $0,$1;";
194 System.out.println(query);
195 pig.registerQuery("asdf_id = " + query);
196 try {
197 pig.deleteFile("frog");
198 } catch(Exception e) {}
199 pig.store("asdf_id", "frog", MyStorage.class.getName()+"()");
200
201
202 //verify query
203
204 InputStream is = FileLocalizer.open("frog", pig.getPigContext());
205 BufferedReader br = new BufferedReader(new InputStreamReader(is));
206 String line;
207 int i = 0;
208 while((line = br.readLine()) != null) {
209
210 assertEquals(line, Integer.toString(i) + '-' + Integer.toString(i));
211 i++;
212 }
213 br.close();
214 try {
215 pig.deleteFile("frog");
216 } catch(Exception e) {}
217 tmpFile.delete();
218
219 }
220
221 // This test: "testStoreFunction()" is equivalent to testStoreFunctionNoNulls()
222

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