MAPREDUCE-4969. TestKeyValueTextInputFormat test fails with Open JDK 7. Contributed by Arpit Agarwal.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1441069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e7380b4f9c
commit
ac21e15a39
@ -281,6 +281,9 @@ Release 2.0.3-alpha - Unreleased
|
|||||||
MAPREDUCE-2264. Job status exceeds 100% in some cases.
|
MAPREDUCE-2264. Job status exceeds 100% in some cases.
|
||||||
(devaraj.k and sandyr via tucu)
|
(devaraj.k and sandyr via tucu)
|
||||||
|
|
||||||
|
MAPREDUCE-4969. TestKeyValueTextInputFormat test fails with Open JDK 7.
|
||||||
|
(Arpit Agarwal via suresh)
|
||||||
|
|
||||||
Release 2.0.2-alpha - 2012-09-07
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -136,32 +136,47 @@ private LineReader makeStream(String str) throws IOException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testUTF8() throws Exception {
|
public void testUTF8() throws Exception {
|
||||||
LineReader in = makeStream("abcd\u20acbdcd\u20ac");
|
LineReader in = null;
|
||||||
Text line = new Text();
|
|
||||||
in.readLine(line);
|
try {
|
||||||
assertEquals("readLine changed utf8 characters",
|
in = makeStream("abcd\u20acbdcd\u20ac");
|
||||||
"abcd\u20acbdcd\u20ac", line.toString());
|
Text line = new Text();
|
||||||
in = makeStream("abc\u200axyz");
|
in.readLine(line);
|
||||||
in.readLine(line);
|
assertEquals("readLine changed utf8 characters",
|
||||||
assertEquals("split on fake newline", "abc\u200axyz", line.toString());
|
"abcd\u20acbdcd\u20ac", line.toString());
|
||||||
|
in = makeStream("abc\u200axyz");
|
||||||
|
in.readLine(line);
|
||||||
|
assertEquals("split on fake newline", "abc\u200axyz", line.toString());
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNewLines() throws Exception {
|
public void testNewLines() throws Exception {
|
||||||
LineReader in = makeStream("a\nbb\n\nccc\rdddd\r\neeeee");
|
LineReader in = null;
|
||||||
Text out = new Text();
|
try {
|
||||||
in.readLine(out);
|
in = makeStream("a\nbb\n\nccc\rdddd\r\neeeee");
|
||||||
assertEquals("line1 length", 1, out.getLength());
|
Text out = new Text();
|
||||||
in.readLine(out);
|
in.readLine(out);
|
||||||
assertEquals("line2 length", 2, out.getLength());
|
assertEquals("line1 length", 1, out.getLength());
|
||||||
in.readLine(out);
|
in.readLine(out);
|
||||||
assertEquals("line3 length", 0, out.getLength());
|
assertEquals("line2 length", 2, out.getLength());
|
||||||
in.readLine(out);
|
in.readLine(out);
|
||||||
assertEquals("line4 length", 3, out.getLength());
|
assertEquals("line3 length", 0, out.getLength());
|
||||||
in.readLine(out);
|
in.readLine(out);
|
||||||
assertEquals("line5 length", 4, out.getLength());
|
assertEquals("line4 length", 3, out.getLength());
|
||||||
in.readLine(out);
|
in.readLine(out);
|
||||||
assertEquals("line5 length", 5, out.getLength());
|
assertEquals("line5 length", 4, out.getLength());
|
||||||
assertEquals("end of file", 0, in.readLine(out));
|
in.readLine(out);
|
||||||
|
assertEquals("line5 length", 5, out.getLength());
|
||||||
|
assertEquals("end of file", 0, in.readLine(out));
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeFile(FileSystem fs, Path name,
|
private static void writeFile(FileSystem fs, Path name,
|
||||||
@ -183,13 +198,20 @@ private static List<Text> readSplit(KeyValueTextInputFormat format,
|
|||||||
InputSplit split,
|
InputSplit split,
|
||||||
JobConf job) throws IOException {
|
JobConf job) throws IOException {
|
||||||
List<Text> result = new ArrayList<Text>();
|
List<Text> result = new ArrayList<Text>();
|
||||||
RecordReader<Text, Text> reader = format.getRecordReader(split, job,
|
RecordReader<Text, Text> reader = null;
|
||||||
voidReporter);
|
|
||||||
Text key = reader.createKey();
|
try {
|
||||||
Text value = reader.createValue();
|
reader = format.getRecordReader(split, job, voidReporter);
|
||||||
while (reader.next(key, value)) {
|
Text key = reader.createKey();
|
||||||
result.add(value);
|
Text value = reader.createValue();
|
||||||
value = reader.createValue();
|
while (reader.next(key, value)) {
|
||||||
|
result.add(value);
|
||||||
|
value = (Text) reader.createValue();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user