[ 
https://issues.apache.org/jira/browse/HDFS-5343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13792392#comment-13792392
 ] 

Uma Maheswara Rao G commented on HDFS-5343:
-------------------------------------------

Below blockEnd is getting calculated based on block size. I think in 
snapshotcases, FIleLength may be different when it was snapshotted. But if we 
use blockSize , it may treat blocksize to read but snapshotted fileSize may be 
less than this?
{code}
 // update current position
    if (updatePosition) {
      pos = offset;
      blockEnd = blk.getStartOffset() + blk.getBlockSize() - 1;
      currentLocatedBlock = blk;
    }
{code}


Where as direct read API uses fileLength

{code}
long filelen = getFileLength();
    if ((position < 0) || (position >= filelen)) {
      return -1;
    }
    int realLen = length;
    if ((position + length) > filelen) {
      realLen = (int)(filelen - position);
    }
{code}

Do you think this is the cause for this unexpected bytes read?

> When cat command is issued on snapshot files getting unexpected result
> ----------------------------------------------------------------------
>
>                 Key: HDFS-5343
>                 URL: https://issues.apache.org/jira/browse/HDFS-5343
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs-client
>            Reporter: sathish
>            Assignee: sathish
>
> first if we create one file with some file length and take the snapshot of 
> that file,and again append some data through append method to that file,then 
> if we do cat command operation on snapshot of that file,in general it should 
> dispaly the data what we added with create operation,but it is displaying the 
> total data i.e. create +_ appended data.
> but if we do the same operation and if we read the contents of snapshot file 
> through input stream it is just displaying the data created in snapshoted 
> files.
> in this the behaviour of cat command and reading through inputstream is 
> getting different



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to