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

Class TestLargeFile

test/org/apache/pig/test/TestLargeFile.java:44–173  ·  view source on GitHub ↗

This class tests pig behavior with large file spanning multiple blocks along with group and count functions Order and Distinct functions are also tested. This test takes long time because of the large test files.

Source from the content-addressed store, hash-verified

42 * Order and Distinct functions are also tested. This test takes long time because of the large test files.
43 */
44public class TestLargeFile {
45
46 File datFile;
47
48 private long defaultBlockSize = (new Configuration()).getLong("dfs.block.size", 0);
49
50 private long total = defaultBlockSize >> 1;
51 private int max_rand = 500;
52 static MiniCluster cluster = MiniCluster.buildCluster();
53
54 Integer[] COUNT = new Integer[max_rand];
55
56 PigServer pig;
57 String fileName, tmpFile1;
58
59 @Before
60 public void setUp() throws Exception{
61
62 System.out.println("Generating test data...");
63 System.out.println("Default block size = " + defaultBlockSize);
64 System.out.println("Total no. of iterations to run for the test data = " + total);
65
66 datFile = File.createTempFile("StoreTest", ".dat");
67
68 FileOutputStream dat = new FileOutputStream(datFile);
69
70 Random rand = new Random();
71
72 for(int i = 0; i < max_rand; i++) {
73 COUNT[i] = 0;
74 }
75
76 for(long i = 0; i < total; i++) {
77 Integer x = new Integer(rand.nextInt(max_rand));
78 COUNT[x.intValue()]++;
79 dat.write((x.toString() + "\n").getBytes());
80 }
81
82 dat.close();
83
84 pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
85
86 fileName = "'" + FileLocalizer.hadoopify(datFile.toString(), pig.getPigContext()) + "'";
87 tmpFile1 = "'" + FileLocalizer.getTemporaryPath(pig.getPigContext()).toString() + "'";
88
89 datFile.delete();
90 }
91
92 @After
93 public void tearDown() throws Exception {
94 pig.shutdown();
95 }
96
97 @AfterClass
98 public static void oneTimeTearDown() throws Exception {
99 cluster.shutDown();
100 }
101

Callers

nothing calls this directly

Calls 2

buildClusterMethod · 0.95
getLongMethod · 0.65

Tested by

no test coverage detected