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

Wei-Chiu Chuang commented on HDFS-3246:
---------------------------------------

I"m trying to understand the implementation within CryptoInputStream but it's 
not that straightforward and my math is rough.

That said, I think you were trying to imitate {{decrypt(long position, byte[] 
buffer, int offset, int length)}}, and I think I spot some math errors. The 
variable names are confusing, which probably explains part of the errors.

 
{code:java}
while (len < n) {
  buf.position(start + len);
  buf.limit(start + len + Math.min(n - len, inBuffer.remaining()));
  inBuffer.put(buf);
  // Do decryption
  try {
    decrypt(decryptor, inBuffer, outBuffer, padding);
    buf.position(start + len); --> not needed?
    buf.limit(limit); --> not needed?
    len += outBuffer.remaining(); --> len += Math.min(n - len, 
inBuffer.remaining())?
    buf.put(outBuffer);
  } finally {
    padding = afterDecryption(decryptor, inBuffer, "position + n", iv); --> 
position + len?
  }
}
{code}
 

> pRead equivalent for direct read path
> -------------------------------------
>
>                 Key: HDFS-3246
>                 URL: https://issues.apache.org/jira/browse/HDFS-3246
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: hdfs-client, performance
>    Affects Versions: 3.0.0-alpha1
>            Reporter: Henry Robinson
>            Assignee: Sahil Takiar
>            Priority: Major
>         Attachments: HDFS-3246.001.patch, HDFS-3246.002.patch, 
> HDFS-3246.003.patch, HDFS-3246.004.patch, HDFS-3246.005.patch, 
> HDFS-3246.006.patch
>
>
> There is no pread equivalent in ByteBufferReadable. We should consider adding 
> one. It would be relatively easy to implement for the distributed case 
> (certainly compared to HDFS-2834), since DFSInputStream does most of the 
> heavy lifting.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to