hyperxpro/Brotli4j

[Bug] Data changes when encode and then decode with dictionary

tohkayuri opened this issue · 3 comments

  1. I trained a dict using https://github.com/google/brotli/blob/master/research/dictionary_generator.cc
  2. encode a byte array using this dict
  3. and then decode it
  4. I got different bytes compare to the original

So what's the problem?

I guess it may be brotli's bug, so I wonder if the new release version can solve this problem.

Hey, Sorry I couldn't follow up since I was on vacation. Since you closed the issue, would you mind explaining how you fixed it?

I mistakenly used the decompressed sdk. I should pass the raw dict data not PreparedDictionary.getData() to brotliOutputStream.attachDictionary. I have no idea why the compress and decompress have such a different interface.

I agree about the problems with the Brotli API design. It's coming directly from the official repo. For 1.x releases, I choose to use the majority of official APIs but for 2.x release, I will re-write user-friendly APIs from scratch.