[
https://issues.apache.org/jira/browse/HADOOP-7444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13064232#comment-13064232
]
Tsz Wo (Nicholas), SZE commented on HADOOP-7444:
------------------------------------------------
Looks good. Some comments.
- Why cast a long to an int and then put the int in a long?
{code}
long calculated = (int)summer.getValue();
{code}
It won't work for 64-bit checksums.
- In line 357, {{calculated}} is redundant.
{code}
long calculated = (int)summer.getValue();
checksums.putInt((int)calculated);
{code}
- Line 382 to 385, {{& 0xff}} are redundant.
{code}
sums[sumsOffset++] = (byte) ((calculated >> 24) & 0xff);
sums[sumsOffset++] = (byte) ((calculated >> 16) & 0xff);
sums[sumsOffset++] = (byte) ((calculated >> 8) & 0xff);
sums[sumsOffset++] = (byte) ((calculated) & 0xff);
{code}
- I would avoid using {{Math.min(..)}}.
> Add Checksum API to verify and calculate checksums "in bulk"
> ------------------------------------------------------------
>
> Key: HADOOP-7444
> URL: https://issues.apache.org/jira/browse/HADOOP-7444
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: Todd Lipcon
> Assignee: Todd Lipcon
> Attachments: hadoop-7444.txt, hadoop-7444.txt
>
>
> Currently, the various checksum types only provide the capability to
> calculate the checksum of a range of a byte array. For HDFS-2080, it's
> advantageous to provide an API that, given a buffer with some number of
> "checksum chunks", can either calculate or verify the checksums of all of the
> chunks. For example, given a 4KB buffer and a 512-byte chunk size, it would
> calculate or verify 8 CRC32s in one call.
> This allows efficient JNI-based checksum implementations since the cost of
> crossing the JNI boundary is amortized across many computations.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira