jsancio commented on code in PR #22805:
URL: https://github.com/apache/kafka/pull/22805#discussion_r3603477029


##########
raft/src/main/java/org/apache/kafka/raft/internals/DecodingStrategy.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.kafka.raft.internals;
+
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.record.internal.DefaultRecordBatch;
+import org.apache.kafka.common.utils.internals.BufferSupplier;
+import org.apache.kafka.common.utils.internals.ByteUtils;
+import org.apache.kafka.raft.Batch;
+import org.apache.kafka.raft.ControlRecord;
+import org.apache.kafka.server.common.serialization.RecordSerde;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.BiFunction;
+
+/**
+ * Decides which records {@link RecordsIterator} decodes when turning a batch 
into a {@link Batch}:
+ * {@link ControlAndDataDecodingStrategy} decodes both, {@link 
ControlOnlyDecodingStrategy} decodes
+ * only the control records (used by the kraft partition listener, which needs 
no serde), and
+ * {@link DataOnlyDecodingStrategy} decodes only the data records. Skipped 
records are returned as a
+ * {@link Batch#notDecoded} batch carrying only the offset information. The 
static helpers are shared
+ * by the implementations.
+ */
+public interface DecodingStrategy<T> {

Review Comment:
   I think since this interface can only have 4 possible variance you can 
either:
   1. Mark this a sealed and implemented all of the variances in this file 
since they are relatively trivial.
   2. Make this a final class that supports all possible variances through an 
enum of something and add UX static methods for each of the variance. E.g. 
DecodingStrategy.dataOnly(), DecodingStrategy.controlOnly(), 
DecodingStrategy.dataAndControl() and DecodingStrategry.none()
   
   Maybe this type should have a more descriptive name. How about 
RecordsDecodingStrategy?



-- 
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]

Reply via email to