mimaison commented on code in PR #15516:
URL: https://github.com/apache/kafka/pull/15516#discussion_r1600241274


##########
clients/src/main/java/org/apache/kafka/common/compress/NoCompression.java:
##########
@@ -14,37 +14,48 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.kafka.common.compress;
 
-import org.apache.kafka.common.KafkaException;
+import org.apache.kafka.common.record.CompressionType;
+import org.apache.kafka.common.utils.BufferSupplier;
 import org.apache.kafka.common.utils.ByteBufferInputStream;
 import org.apache.kafka.common.utils.ByteBufferOutputStream;
-import org.xerial.snappy.SnappyInputStream;
-import org.xerial.snappy.SnappyOutputStream;
 
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 
-public class SnappyFactory {
+public class NoCompression implements Compression {
 
-    private SnappyFactory() { }
+    @Override
+    public CompressionType type() {
+        return CompressionType.NONE;
+    }
 
-    public static OutputStream wrapForOutput(ByteBufferOutputStream buffer) {
-        try {
-            return new SnappyOutputStream(buffer);
-        } catch (Throwable e) {
-            throw new KafkaException(e);
-        }
+    @Override
+    public OutputStream wrapForOutput(ByteBufferOutputStream bufferStream, 
byte messageVersion) {
+        return bufferStream;
     }
 
-    public static InputStream wrapForInput(ByteBuffer buffer) {
-        try {
-            return new SnappyInputStream(new ByteBufferInputStream(buffer));
-        } catch (Throwable e) {
-            throw new KafkaException(e);
-        }
+    @Override
+    public InputStream wrapForInput(ByteBuffer buffer, byte messageVersion, 
BufferSupplier decompressionBufferSupplier) {
+        return new ByteBufferInputStream(buffer);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return o instanceof NoCompression;
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();

Review Comment:
   Actually I don't think we need to override the default hashCode/equals 
methods. Initially I wanted to make this a singleton but I don't think it's 
necessary.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to