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

Method makeMockTempFile

test/org/apache/pig/pigunit/PigTest.java:310–321  ·  view source on GitHub ↗

Creates a temp file and populates it with the specified mock data. @param alias alias that the temp file is for @param mockData data that is being mocked for the alias @return path to the temp file

(String alias, String[] mockData)

Source from the content-addressed store, hash-verified

308 * @return path to the temp file
309 */
310 private String makeMockTempFile(String alias, String[] mockData) throws IOException {
311 //The FileLocalizer uses a random variable, but that can have collisions. By using the current time, thread,
312 //and alias we should be able to guaratee a unique file
313 String uniqueSuffix = alias + "." + System.currentTimeMillis() + "." + Thread.currentThread().getId();
314 //PigServer/Cluster is not initialized yet. Let's initialize it.
315 if (getPigServer() == null) {
316 getCluster();
317 }
318 String path = FileLocalizer.getTemporaryPath(getPigServer().getPigContext(), uniqueSuffix).toString();
319 getCluster().copyFromLocalFile(mockData, path, true);
320 return path;
321 }
322
323 private String getActualResults(String alias, boolean ignoreOrder) throws IOException, ParseException {
324 //Tuples are sortable, but we should sort it as Strings for convenience when comparing to expected data

Callers 1

mockAliasMethod · 0.95

Calls 7

getPigServerMethod · 0.95
getClusterMethod · 0.95
getTemporaryPathMethod · 0.95
copyFromLocalFileMethod · 0.80
getIdMethod · 0.45
toStringMethod · 0.45
getPigContextMethod · 0.45

Tested by

no test coverage detected