maedhroz commented on code in PR #2782:
URL: https://github.com/apache/cassandra/pull/2782#discussion_r1365948559
##########
src/java/org/apache/cassandra/index/sai/disk/v1/SAICodecUtils.java:
##########
@@ -99,9 +100,26 @@ public static void validate(IndexInput input, long
footerPointer) throws IOExcep
input.seek(current);
}
+ /**
+ * See the {@link
org.apache.lucene.codecs.CodecUtil#checksumEntireFile(org.apache.lucene.store.IndexInput)}.
+ * @param input IndexInput to validate.
+ * @throws IOException if a corruption is detected.
+ */
public static void validateChecksum(IndexInput input) throws IOException
{
- CodecUtil.checksumEntireFile(input);
+ IndexInput clone = input.clone();
+ clone.seek(0L);
+ ChecksumIndexInput in = new BufferedChecksumCrc32cIndexInput(clone);
+
+ assert in.getFilePointer() == 0L;
+
+ if (in.length() < (long) footerLength())
+ throw new CorruptIndexException("misplaced codec footer (file
truncated?): length=" + in.length() + " but footerLength==" + footerLength(),
input);
+ else
+ {
+ in.seek(in.length() - (long) footerLength());
+ checkFooter(in);
Review Comment:
So with the changes in this patch, we now have the methods in this class
`readCRC()` and `writeCRC()` that both have imprecise names, comments, and
`IllegalStateException` error messages. One simple solution is to leave the
method names the same and add a "C" to the instances of "CRC32" and "CRC-32".
The other is to just rename the methods `readChecksum()` and `writeChecksum()`,
then remove the specific language. (ex. "Illegal CRC-32 checksum: " -> "Illegal
checksum: ")
I'm fine w/ either approach.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]