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

Method createTempFile

test/org/apache/pig/test/utils/TestHelper.java:253–275  ·  view source on GitHub ↗

Create temp file from a given dataset This assumes 1) The dataset has at least 1 record 2) All records are of the same size

(String[][] data)

Source from the content-addressed store, hash-verified

251 * 2) All records are of the same size
252 */
253 public static File createTempFile(String[][] data) throws IOException {
254
255 File fp1 = File.createTempFile("test", "txt");
256 PrintStream ps = new PrintStream(new FileOutputStream(fp1));
257
258 for(int i = 0; i < data.length ; i++) {
259
260 // Building up string for each line
261 StringBuilder sb = new StringBuilder() ;
262 for(int j = 0 ; j < data[0].length ; j++) {
263 if (j != 0) {
264 sb.append("\t") ;
265 }
266 sb.append(data[i][j]) ;
267 }
268
269 // Write the line to file
270 ps.println(sb.toString());
271 }
272
273 ps.close();
274 return fp1 ;
275 }
276
277 //a quick way to check for map equality as the map value returned by PigStorage has byte array
278 public static boolean mapEquals(Map<String, Object> expectedMap, Map<String, Object> convertedMap) {

Callers 15

storeFunctionMethod · 0.95
definedFunctionsMethod · 0.95
genDataSetFileMethod · 0.95
genDataSetFile1Method · 0.95
storeFunctionMethod · 0.95
definedFunctionsMethod · 0.95
genDataSetFile1Method · 0.95
genDataSetFileMethod · 0.95
testlog4jConfMethod · 0.45
testProcessRemoveMethod · 0.45

Calls 3

appendMethod · 0.65
closeMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected