maedhroz commented on code in PR #2782: URL: https://github.com/apache/cassandra/pull/2782#discussion_r1365929551
########## src/java/org/apache/cassandra/index/sai/disk/io/BufferedChecksumCrc32cIndexInput.java: ########## @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.index.sai.disk.io; + +import org.apache.lucene.store.BufferedChecksum; +import org.apache.lucene.store.ChecksumIndexInput; +import org.apache.lucene.store.IndexInput; + +import java.io.IOException; +import java.util.zip.CRC32C; +import java.util.zip.Checksum; + +import static org.apache.cassandra.index.sai.disk.io.IndexFileUtils.CHECKSUM_CRC32C_FACTORY; + +/** + * This implementation of {@link ChecksumIndexInput} is based on {@link org.apache.lucene.store.BufferedChecksumIndexInput} + * but uses {@link CRC32C} checksum algorithm instead of {@code CRC32} for performance reasons. + * + * @see org.apache.cassandra.index.sai.disk.io.IndexFileUtils.ChecksummingWriter + */ +public class BufferedChecksumCrc32cIndexInput extends ChecksumIndexInput +{ + final IndexInput main; + final Checksum digest; + + public BufferedChecksumCrc32cIndexInput(IndexInput main) { + super("BufferedChecksumCrc32cIndexInput(" + main + ')'); + this.main = main; + this.digest = new BufferedChecksum(CHECKSUM_CRC32C_FACTORY.get()); Review Comment: Why limit this class to a particular `Checksum` implementation? Here's what I would consider... 1.) Rename the class `BufferedChecksumIndexInput`. 2.) Pass the `Checksum` to the constructor along w/ the delegate. 3.) Update any relevant comments to reflect this, etc. Lucene should have done this w/ its own `BufferedChecksumIndexInput`, but they made it unnecessarily brittle. -- 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]

