You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Yin Huai <hu...@gmail.com> on 2012/11/16 22:15:46 UTC

question about ChecksumFSInputChecker

Hi All,

I have a question about the method read in CheckSumFSInputChecker. Can you
let me know why the file will be opened and closed for every read operation?

thanks,

Yin

Here is the code of CheckSumFSInputChecker.read(...) ...
public int read(long position, byte[] b, int off, int len)
      throws IOException {
      // parameter check
      if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
        throw new IndexOutOfBoundsException();
      } else if (len == 0) {
        return 0;
      }
      if( position<0 ) {
        throw new IllegalArgumentException(
            "Parameter position can not to be negative");
      }

      ChecksumFSInputChecker checker = new ChecksumFSInputChecker(fs, file);
      checker.seek(position);
      int nread = checker.read(b, off, len);
      checker.close();
      return nread;
    }

Re: question about ChecksumFSInputChecker

Posted by Yin Huai <hu...@gmail.com>.
Is there anyone who can answer my question?

Thansk,

Yin

On Fri, Nov 16, 2012 at 4:15 PM, Yin Huai <hu...@gmail.com> wrote:

> Hi All,
>
> I have a question about the method read in CheckSumFSInputChecker. Can you
> let me know why the file will be opened and closed for every read operation?
>
> thanks,
>
> Yin
>
> Here is the code of CheckSumFSInputChecker.read(...) ...
> public int read(long position, byte[] b, int off, int len)
>       throws IOException {
>       // parameter check
>       if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
>         throw new IndexOutOfBoundsException();
>       } else if (len == 0) {
>         return 0;
>       }
>       if( position<0 ) {
>         throw new IllegalArgumentException(
>             "Parameter position can not to be negative");
>       }
>
>       ChecksumFSInputChecker checker = new ChecksumFSInputChecker(fs,
> file);
>       checker.seek(position);
>       int nread = checker.read(b, off, len);
>       checker.close();
>       return nread;
>     }
>
>

Re: question about ChecksumFSInputChecker

Posted by Yin Huai <hu...@gmail.com>.
Is there anyone who can answer my question?

Thansk,

Yin

On Fri, Nov 16, 2012 at 4:15 PM, Yin Huai <hu...@gmail.com> wrote:

> Hi All,
>
> I have a question about the method read in CheckSumFSInputChecker. Can you
> let me know why the file will be opened and closed for every read operation?
>
> thanks,
>
> Yin
>
> Here is the code of CheckSumFSInputChecker.read(...) ...
> public int read(long position, byte[] b, int off, int len)
>       throws IOException {
>       // parameter check
>       if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
>         throw new IndexOutOfBoundsException();
>       } else if (len == 0) {
>         return 0;
>       }
>       if( position<0 ) {
>         throw new IllegalArgumentException(
>             "Parameter position can not to be negative");
>       }
>
>       ChecksumFSInputChecker checker = new ChecksumFSInputChecker(fs,
> file);
>       checker.seek(position);
>       int nread = checker.read(b, off, len);
>       checker.close();
>       return nread;
>     }
>
>

Re: question about ChecksumFSInputChecker

Posted by Yin Huai <hu...@gmail.com>.
Is there anyone who can answer my question?

Thansk,

Yin

On Fri, Nov 16, 2012 at 4:15 PM, Yin Huai <hu...@gmail.com> wrote:

> Hi All,
>
> I have a question about the method read in CheckSumFSInputChecker. Can you
> let me know why the file will be opened and closed for every read operation?
>
> thanks,
>
> Yin
>
> Here is the code of CheckSumFSInputChecker.read(...) ...
> public int read(long position, byte[] b, int off, int len)
>       throws IOException {
>       // parameter check
>       if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
>         throw new IndexOutOfBoundsException();
>       } else if (len == 0) {
>         return 0;
>       }
>       if( position<0 ) {
>         throw new IllegalArgumentException(
>             "Parameter position can not to be negative");
>       }
>
>       ChecksumFSInputChecker checker = new ChecksumFSInputChecker(fs,
> file);
>       checker.seek(position);
>       int nread = checker.read(b, off, len);
>       checker.close();
>       return nread;
>     }
>
>

Re: question about ChecksumFSInputChecker

Posted by Yin Huai <hu...@gmail.com>.
Is there anyone who can answer my question?

Thansk,

Yin

On Fri, Nov 16, 2012 at 4:15 PM, Yin Huai <hu...@gmail.com> wrote:

> Hi All,
>
> I have a question about the method read in CheckSumFSInputChecker. Can you
> let me know why the file will be opened and closed for every read operation?
>
> thanks,
>
> Yin
>
> Here is the code of CheckSumFSInputChecker.read(...) ...
> public int read(long position, byte[] b, int off, int len)
>       throws IOException {
>       // parameter check
>       if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
>         throw new IndexOutOfBoundsException();
>       } else if (len == 0) {
>         return 0;
>       }
>       if( position<0 ) {
>         throw new IllegalArgumentException(
>             "Parameter position can not to be negative");
>       }
>
>       ChecksumFSInputChecker checker = new ChecksumFSInputChecker(fs,
> file);
>       checker.seek(position);
>       int nread = checker.read(b, off, len);
>       checker.close();
>       return nread;
>     }
>
>