[ 
https://issues.apache.org/jira/browse/AVRO-2162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16410198#comment-16410198
 ] 

ASF GitHub Bot commented on AVRO-2162:
--------------------------------------

scottcarey commented on a change in pull request #303: AVRO-2162 Adds Zstandard 
compression to the Avro File Format (Java)
URL: https://github.com/apache/avro/pull/303#discussion_r176555679
 
 

 ##########
 File path: lang/java/avro/src/main/java/org/apache/avro/file/BZip2Codec.java
 ##########
 @@ -42,64 +40,20 @@ protected Codec createInstance() {
   public String getName() { return DataFileConstants.BZIP2_CODEC; }
 
   @Override
-  public ByteBuffer compress(ByteBuffer uncompressedData) throws IOException {
-
-    ByteArrayOutputStream baos = getOutputBuffer(uncompressedData.remaining());
-    BZip2CompressorOutputStream outputStream = new 
BZip2CompressorOutputStream(baos);
-
-    try {
-      outputStream.write(uncompressedData.array(),
-                         uncompressedData.position(),
-                         uncompressedData.remaining());
-    } finally {
-      outputStream.close();
-    }
-
-    ByteBuffer result = ByteBuffer.wrap(baos.toByteArray());
-    return result;
+  protected OutputStream compressedStream(OutputStream output)
+      throws IOException {
+    return new BZip2CompressorOutputStream(output);
   }
 
   @Override
-  public ByteBuffer decompress(ByteBuffer compressedData) throws IOException {
-    ByteArrayInputStream bais = new 
ByteArrayInputStream(compressedData.array());
-    BZip2CompressorInputStream inputStream = new 
BZip2CompressorInputStream(bais);
 
 Review comment:
   Most of the Codecs are internally based on InputStreams and OutputStreams.  
I refactored the commonalities out into two abstract classes (these would be 
better as 'mix-in' interfaces in Java 8+).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Add Zstandard compression to avro file format
> ---------------------------------------------
>
>                 Key: AVRO-2162
>                 URL: https://issues.apache.org/jira/browse/AVRO-2162
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Scott Carey
>            Priority: Major
>
> I'd like to add Zstandard compression for Avro. 
> At compression level 1 It is almost as fast as Snappy at compression, with 
> compression ratios more like gzip.  At higher levels of compression, it is 
> more compact than gzip -9 with much lower CPU when compressing and roughly 3x 
> faster decompression.
>  
> Adding it to Java is fairly easy.  We'll need to say something about it in 
> the spec however, as an 'optinal' codec.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to