public void testLFPig() throws Exception {
Util.createInputFile(cluster, "input.txt", new String[]
{"this:is:delimited:by:a:colon\n"});
int arity1 = 6;
LoadFunc lf = new PigStorage(":");
LoadFunc p1 = new ReadToEndLoader(lf, ConfigurationUtil.
toConfiguration(cluster.getProperties()), "input.txt", 0);
Tuple f1 = p1.getNext();
assertTrue(f1.size() == arity1);
Util.deleteFile(cluster, "input.txt");
int LOOP_COUNT = 100;
String[] input = new String[LOOP_COUNT * LOOP_COUNT];
int n = 0;
for (int i = 0; i < LOOP_COUNT; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
input[n++] = (i + "\t" + i + "\t" + j % 2);
}
}
Util.createInputFile(cluster, "input.txt", input);
LoadFunc p15 = new ReadToEndLoader(new PigStorage(), ConfigurationUtil.
toConfiguration(cluster.getProperties()), "input.txt", 0);
int count = 0;
while (true) {
Tuple f15 = p15.getNext();
if (f15 == null)
break;
count++;
assertEquals(3, f15.size());
}
assertEquals(LOOP_COUNT * LOOP_COUNT, count);
Util.deleteFile(cluster, "input.txt");
String input2 = ":this:has:a:leading:colon\n";
int arity2 = 6;
Util.createInputFile(cluster, "input.txt", new String[] {input2});
LoadFunc p2 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
toConfiguration(cluster.getProperties()), "input.txt", 0);
Tuple f2 = p2.getNext();
assertTrue(f2.size() == arity2);
Util.deleteFile(cluster, "input.txt");
String input3 = "this:has:a:trailing:colon:\n";
int arity3 = 6;
Util.createInputFile(cluster, "input.txt", new String[] {input2});
LoadFunc p3 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
toConfiguration(cluster.getProperties()), "input.txt", 0);
Tuple f3 = p3.getNext();
assertTrue(f3.size() == arity3);
Util.deleteFile(cluster, "input.txt");
}