MAPREDUCE-4479. Fix parameter order in assertEquals() in TestCombineInputFileFormat.java (Mariappan Asokan via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1400192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Joseph Evans 2012-10-19 17:51:33 +00:00
parent ae15ad6202
commit a234472d1c
2 changed files with 193 additions and 190 deletions

View File

@ -590,6 +590,9 @@ Release 0.23.5 - UNRELEASED
MAPREDUCE-4721. Task startup time in JHS is same as job startup time. MAPREDUCE-4721. Task startup time in JHS is same as job startup time.
(Ravi Prakash via bobby) (Ravi Prakash via bobby)
MAPREDUCE-4479. Fix parameter order in assertEquals() in
TestCombineInputFileFormat.java (Mariappan Asokan via bobby)
Release 0.23.4 - UNRELEASED Release 0.23.4 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -317,7 +317,7 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test0): " + split); System.out.println("File split(Test0): " + split);
} }
assertEquals(splits.size(), 1); assertEquals(1, splits.size());
CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0); CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(2, fileSplit.getNumPaths()); assertEquals(2, fileSplit.getNumPaths());
assertEquals(1, fileSplit.getLocations().length); assertEquals(1, fileSplit.getLocations().length);
@ -347,24 +347,24 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test1): " + split); System.out.println("File split(Test1): " + split);
} }
assertEquals(splits.size(), 2); assertEquals(2, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], hosts2[0]); // should be on r2 assertEquals(hosts2[0], fileSplit.getLocations()[0]); // should be on r2
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file1.getName()); assertEquals(file1.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getLocations()[0], hosts1[0]); // should be on r1 assertEquals(hosts1[0], fileSplit.getLocations()[0]); // should be on r1
// create another file on 3 datanodes and 3 racks. // create another file on 3 datanodes and 3 racks.
dfs.startDataNodes(conf, 1, true, null, rack3, hosts3, null); dfs.startDataNodes(conf, 1, true, null, rack3, hosts3, null);
@ -378,37 +378,37 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test2): " + split); System.out.println("File split(Test2): " + split);
} }
assertEquals(splits.size(), 3); assertEquals(3, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 3); assertEquals(3, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getLocations()[0], hosts3[0]); // should be on r3 assertEquals(hosts3[0], fileSplit.getLocations()[0]); // should be on r3
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], hosts2[0]); // should be on r2 assertEquals(hosts2[0], fileSplit.getLocations()[0]); // should be on r2
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file1.getName()); assertEquals(file1.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getLocations()[0], hosts1[0]); // should be on r1 assertEquals(hosts1[0], fileSplit.getLocations()[0]); // should be on r1
// create file4 on all three racks // create file4 on all three racks
Path file4 = new Path(dir4 + "/file4"); Path file4 = new Path(dir4 + "/file4");
@ -420,37 +420,37 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test3): " + split); System.out.println("File split(Test3): " + split);
} }
assertEquals(splits.size(), 3); assertEquals(3, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 6); assertEquals(6, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getLocations()[0], hosts3[0]); // should be on r3 assertEquals(hosts3[0], fileSplit.getLocations()[0]); // should be on r3
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], hosts2[0]); // should be on r2 assertEquals(hosts2[0], fileSplit.getLocations()[0]); // should be on r2
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file1.getName()); assertEquals(file1.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getLocations()[0], hosts1[0]); // should be on r1 assertEquals(hosts1[0], fileSplit.getLocations()[0]); // should be on r1
// maximum split size is 2 blocks // maximum split size is 2 blocks
inFormat = new DummyInputFormat(); inFormat = new DummyInputFormat();
@ -462,35 +462,35 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test4): " + split); System.out.println("File split(Test4): " + split);
} }
assertEquals(splits.size(), 5); assertEquals(5, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), 0); assertEquals(0, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
// maximum split size is 3 blocks // maximum split size is 3 blocks
inFormat = new DummyInputFormat(); inFormat = new DummyInputFormat();
@ -502,48 +502,48 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test5): " + split); System.out.println("File split(Test5): " + split);
} }
assertEquals(splits.size(), 4); assertEquals(4, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 3); assertEquals(3, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getPath(0).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), 2 * BLOCKSIZE); assertEquals( 2 * BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getLocations()[0], "host2.rack2.com"); assertEquals("host2.rack2.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(3); fileSplit = (CombineFileSplit) splits.get(3);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file1.getName()); assertEquals(file1.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getLocations()[0], "host1.rack1.com"); assertEquals("host1.rack1.com", fileSplit.getLocations()[0]);
// maximum split size is 4 blocks // maximum split size is 4 blocks
inFormat = new DummyInputFormat(); inFormat = new DummyInputFormat();
@ -553,42 +553,42 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test6): " + split); System.out.println("File split(Test6): " + split);
} }
assertEquals(splits.size(), 3); assertEquals(3, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 4); assertEquals(4, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file3.getName()); assertEquals(file3.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), 2 * BLOCKSIZE); assertEquals(2 * BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 4); assertEquals(4, fileSplit.getNumPaths());
assertEquals(fileSplit.getPath(0).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getPath(1).getName(), file2.getName()); assertEquals(file2.getName(), fileSplit.getPath(1).getName());
assertEquals(fileSplit.getOffset(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(1));
assertEquals(fileSplit.getLength(1), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(1));
assertEquals(fileSplit.getPath(2).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(2).getName());
assertEquals(fileSplit.getOffset(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getOffset(2));
assertEquals(fileSplit.getLength(2), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(2));
assertEquals(fileSplit.getPath(3).getName(), file4.getName()); assertEquals(file4.getName(), fileSplit.getPath(3).getName());
assertEquals(fileSplit.getOffset(3), 2 * BLOCKSIZE); assertEquals( 2 * BLOCKSIZE, fileSplit.getOffset(3));
assertEquals(fileSplit.getLength(3), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(3));
assertEquals(fileSplit.getLocations()[0], "host2.rack2.com"); assertEquals("host2.rack2.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getPath(0).getName(), file1.getName()); assertEquals(file1.getName(), fileSplit.getPath(0).getName());
assertEquals(fileSplit.getOffset(0), 0); assertEquals(0, fileSplit.getOffset(0));
assertEquals(fileSplit.getLength(0), BLOCKSIZE); assertEquals(BLOCKSIZE, fileSplit.getLength(0));
assertEquals(fileSplit.getLocations()[0], hosts1[0]); // should be on r1 assertEquals(hosts1[0], fileSplit.getLocations()[0]); // should be on r1
// maximum split size is 7 blocks and min is 3 blocks // maximum split size is 7 blocks and min is 3 blocks
inFormat = new DummyInputFormat(); inFormat = new DummyInputFormat();
@ -601,15 +601,15 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test7): " + split); System.out.println("File split(Test7): " + split);
} }
assertEquals(splits.size(), 2); assertEquals(2, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 6); assertEquals(6, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getLocations()[0], "host3.rack3.com"); assertEquals("host3.rack3.com", fileSplit.getLocations()[0]);
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 3); assertEquals(3, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getLocations()[0], "host1.rack1.com"); assertEquals("host1.rack1.com", fileSplit.getLocations()[0]);
// Rack 1 has file1, file2 and file3 and file4 // Rack 1 has file1, file2 and file3 and file4
// Rack 2 has file2 and file3 and file4 // Rack 2 has file2 and file3 and file4
@ -624,19 +624,19 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test1): " + split); System.out.println("File split(Test1): " + split);
} }
assertEquals(splits.size(), 3); assertEquals(3, splits.size());
fileSplit = (CombineFileSplit) splits.get(0); fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(fileSplit.getNumPaths(), 2); assertEquals(2, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getLocations()[0], hosts2[0]); // should be on r2 assertEquals(hosts2[0], fileSplit.getLocations()[0]); // should be on r2
fileSplit = (CombineFileSplit) splits.get(1); fileSplit = (CombineFileSplit) splits.get(1);
assertEquals(fileSplit.getNumPaths(), 1); assertEquals(1, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getLocations()[0], hosts1[0]); // should be on r1 assertEquals(hosts1[0], fileSplit.getLocations()[0]); // should be on r1
fileSplit = (CombineFileSplit) splits.get(2); fileSplit = (CombineFileSplit) splits.get(2);
assertEquals(fileSplit.getNumPaths(), 6); assertEquals(6, fileSplit.getNumPaths());
assertEquals(fileSplit.getLocations().length, 1); assertEquals(1, fileSplit.getLocations().length);
assertEquals(fileSplit.getLocations()[0], hosts3[0]); // should be on r3 assertEquals(hosts3[0], fileSplit.getLocations()[0]); // should be on r3
// measure performance when there are multiple pools and // measure performance when there are multiple pools and
// many files in each pool. // many files in each pool.
@ -669,7 +669,7 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test8): " + split); System.out.println("File split(Test8): " + split);
} }
assertEquals(6, splits.size()); assertEquals(splits.size(), 6);
} finally { } finally {
if (dfs != null) { if (dfs != null) {
@ -750,7 +750,7 @@ public class TestCombineFileInputFormat extends TestCase {
for (InputSplit split : splits) { for (InputSplit split : splits) {
System.out.println("File split(Test0): " + split); System.out.println("File split(Test0): " + split);
} }
assertEquals(splits.size(), 1); assertEquals(1, splits.size());
CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0); CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(2, fileSplit.getNumPaths()); assertEquals(2, fileSplit.getNumPaths());
assertEquals(1, fileSplit.getLocations().length); assertEquals(1, fileSplit.getLocations().length);
@ -1135,7 +1135,7 @@ public class TestCombineFileInputFormat extends TestCase {
Job job = Job.getInstance(conf); Job job = Job.getInstance(conf);
FileInputFormat.setInputPaths(job, "test"); FileInputFormat.setInputPaths(job, "test");
List<InputSplit> splits = inFormat.getSplits(job); List<InputSplit> splits = inFormat.getSplits(job);
assertEquals(splits.size(), 1); assertEquals(1, splits.size());
CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0); CombineFileSplit fileSplit = (CombineFileSplit) splits.get(0);
assertEquals(1, fileSplit.getNumPaths()); assertEquals(1, fileSplit.getNumPaths());
assertEquals(file.getName(), fileSplit.getPath(0).getName()); assertEquals(file.getName(), fileSplit.getPath(0).getName());