@@ -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