user2589299
user2589299

Reputation: 129

Zstd decompression error - Unknown frame descriptor

I'm trying to decompress a .zst file the following way :

public byte[] decompress() {
byte[] compressedBytes = Files.readAllBytes(Paths.get(PATH_TO_ZST));
final long size = Zstd.decompressedSize(compressedBytes);
return Zstd.decompress(compressedBytes, (int)size);
}

and I'm running into this :

com.github.luben.zstd.ZstdException: Unknown frame descriptor [java] com.github.luben.zstd.ZstdDecompressCtx.decompressByteArray(ZstdDecompressCtx.java:157) [java] com.github.luben.zstd.ZstdDecompressCtx.decompress(ZstdDecompressCtx.java:214) [java]

Has anyone faced something similar? Thanks!

Upvotes: 5

Views: 13235

Answers (2)

James Wang
James Wang

Reputation: 43

public byte[] decompress() {
     byte[] compressedBytes = Files.readAllBytes(Paths.get(PATH_TO_ZST));
     final long size = Zstd.decompressedSize(compressedBytes);
     byte[] deCompressedBytes = new byte[size];
     Zstd.decompress(deCompressedBytes,compressedBytes);
     return deCompressedBytes;
}

Upvotes: 0

Nick
Nick

Reputation: 407

That error means zstd doesn't recognize the first 4 bytes of the frame. This can be because either:

  1. The data is not in zstd format,
  2. There is excess data at the end of the zstd frame.

You'll also want to check the output of Zstd.decompressedSize() for 0, which means the frame is corrupted, or the size wasn't present in the frame header. See the documentation.

Upvotes: 0

Related Questions