Skip to content

Commit 22f7d55

Browse files
committed
HADOOP-6991. Fix SequenceFile::Reader to honor file lengths and call
openFile (cdouglas via omalley) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1028473 13f79535-47bb-0310-9956-ffa450edef68
1 parent 584788c commit 22f7d55

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ Trunk (unreleased changes)
286286
HADOOP-6663. BlockDecompressorStream get EOF exception when decompressing
287287
the file compressed from empty file. (Kang Xiao via tomwhite)
288288

289+
HADOOP-6991. Fix SequenceFile::Reader to honor file lengths and call
290+
openFile (cdouglas via omalley)
291+
289292
Release 0.21.1 - Unreleased
290293

291294
IMPROVEMENTS

src/java/org/apache/hadoop/io/SequenceFile.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ public static Option compression(CompressionType value,
951951
blockSizeOption.getValue();
952952
Progressable progress = progressOption == null ? null :
953953
progressOption.getValue();
954-
out = fs.create(p, false, bufferSize, replication, blockSize, progress);
954+
out = fs.create(p, true, bufferSize, replication, blockSize, progress);
955955
} else {
956956
out = streamOption.getValue();
957957
}
@@ -1563,14 +1563,17 @@ public Reader(Configuration conf, Option... opts) throws IOException {
15631563
// figure out the real values
15641564
Path filename = null;
15651565
FSDataInputStream file;
1566-
long len = lenOpt == null ? Long.MAX_VALUE : lenOpt.getValue();
1566+
final long len;
15671567
if (fileOpt != null) {
15681568
filename = fileOpt.getValue();
15691569
FileSystem fs = filename.getFileSystem(conf);
15701570
int bufSize = bufOpt == null ? getBufferSize(conf): bufOpt.getValue();
1571-
file = fs.open(filename, bufSize);
1572-
len = fs.getFileStatus(filename).getLen();
1571+
len = null == lenOpt
1572+
? fs.getFileStatus(filename).getLen()
1573+
: lenOpt.getValue();
1574+
file = openFile(fs, filename, bufSize, len);
15731575
} else {
1576+
len = null == lenOpt ? Long.MAX_VALUE : lenOpt.getValue();
15741577
file = streamOpt.getValue();
15751578
}
15761579
long start = startOpt == null ? 0 : startOpt.getValue();
@@ -1589,9 +1592,7 @@ public Reader(Configuration conf, Option... opts) throws IOException {
15891592
@Deprecated
15901593
public Reader(FileSystem fs, Path file,
15911594
Configuration conf) throws IOException {
1592-
initialize(file,
1593-
fs.open(file, getBufferSize(conf)),
1594-
0L, fs.getFileStatus(file).getLen(), conf, false);
1595+
this(conf, file(file.makeQualified(fs)));
15951596
}
15961597

15971598
/**
@@ -1607,7 +1608,7 @@ public Reader(FileSystem fs, Path file,
16071608
@Deprecated
16081609
public Reader(FSDataInputStream in, int buffersize,
16091610
long start, long length, Configuration conf) throws IOException {
1610-
initialize(null, in, start, length, conf, false);
1611+
this(conf, stream(in), start(start), length(length));
16111612
}
16121613

16131614
/** Common work of the constructors. */

0 commit comments

Comments
 (0)