Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty slices cannot be compressed #41

Closed
bobrik opened this issue Oct 1, 2018 · 1 comment
Closed

Empty slices cannot be compressed #41

bobrik opened this issue Oct 1, 2018 · 1 comment

Comments

@bobrik
Copy link

bobrik commented Oct 1, 2018

What did you do?

Tried to compress empty slice.

What did you expect to see?

Empty slice is compressed consistently with zstd:

$ touch empty

$ zstd empty
empty                :1300.00%   (     0 =>     13 bytes, empty.zst)

$ ls -la empty empty.zst
-rw-r--r--  1 bobrik  staff   0 Sep 30 17:09 empty
-rw-r--r--  1 bobrik  staff  13 Sep 30 17:09 empty.zst

$ cat empty.zst | hexdump -C
00000000  28 b5 2f fd 24 00 01 00  00 99 e9 d8 51           |(./.$.......Q|
0000000d

What did you see instead?

Error ErrEmptySlice (Bytes slice is empty) is generated: 6114686.

cc @Viq111

@Viq111
Copy link
Collaborator

Viq111 commented Oct 1, 2018

Hi @bobrik,

Thanks for reporting!
Indeed it looks like here this behavior is not desired as we can easily avoid return EmptySlice. There is also a difference of behavior between the streaming and non-streaming version.

I fixed it in #42 if you want to test it.
For zstd 1.3.4, the compressed message of the empty slice is 0x28b52ffd0050010000

@Viq111 Viq111 closed this as completed in #42 Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants