String input1 = "this:is:delimited:by:a:colon\n";
int arity1 = 6;
LoadFunc p1 = new PigStorage(":");
FakeFSInputStream ffis1 = new FakeFSInputStream(input1.getBytes());
p1.bindTo(null, new BufferedPositionedInputStream(ffis1), 0, input1.getBytes().length);
Tuple f1 = p1.getNext();
assertTrue(f1.arity() == arity1);
LoadFunc p15 = new PigStorage();
StringBuilder sb = new StringBuilder();
int LOOP_COUNT = 1024;
for (int i = 0; i < LOOP_COUNT; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
sb.append(i);
sb.append("\t");
sb.append(i);
sb.append("\t");
sb.append(j % 2);
sb.append("\n");
}
}
byte bytes[] = sb.toString().getBytes();
FakeFSInputStream ffis15 = new FakeFSInputStream(bytes);
p15.bindTo(null, new BufferedPositionedInputStream(ffis15), 0, bytes.length);
int count = 0;
while (true) {
Tuple f15 = p15.getNext();
if (f15 == null)
break;
count++;
assertEquals(3, f15.arity());
}
assertEquals(LOOP_COUNT * LOOP_COUNT, count);
String input2 = ":this:has:a:leading:colon\n";
int arity2 = 6;
LoadFunc p2 = new PigStorage(":");
FakeFSInputStream ffis2 = new FakeFSInputStream(input2.getBytes());
p2.bindTo(null, new BufferedPositionedInputStream(ffis2), 0, input2.getBytes().length);
Tuple f2 = p2.getNext();
assertTrue(f2.arity() == arity2);
String input3 = "this:has:a:trailing:colon:\n";
int arity3 = 6;
LoadFunc p3 = new PigStorage(":");
FakeFSInputStream ffis3 = new FakeFSInputStream(input3.getBytes());
p3.bindTo(null, new BufferedPositionedInputStream(ffis3), 0, input1.getBytes().length);
Tuple f3 = p3.getNext();
assertTrue(f3.arity() == arity3);
}