Giter Site home page Giter Site logo

Comments (7)

anshulchaurasia avatar anshulchaurasia commented on August 17, 2024

@Viq111 I hope you can help with this

from zstd.

Viq111 avatar Viq111 commented on August 17, 2024

Hi @anshulchaurasia

It looks like you are not consuming after doing a zr.Close(). When you close it actually flush the frame finish so you need to consume the rest via reading remaining data fromzr.

It looks like it would be a common pitfall so I'll add to the documentation the exact code snippet

from zstd.

anshulchaurasia avatar anshulchaurasia commented on August 17, 2024

hi @Viq111

Could you please post the snippet here it will be very helpful.
As I am getting the error on the following line:

buf, err = ioutil.ReadAll(zr)

it's before calling Close().

from zstd.

Viq111 avatar Viq111 commented on August 17, 2024

Oh sorry, I read it incorrectly and though you were compressing and not decompressing.
For decompression, zstd will try to interpret your padding as compressed data and will fail. You have to provide to the reader exactly the compressed data.

In your case (unrelated to zstd), you would probably want to prefix the data block by how much padding you are adding.

Something like: https://play.golang.org/p/7muxEHDJDTl

from zstd.

anshulchaurasia avatar anshulchaurasia commented on August 17, 2024

Hi @Viq111
As a consumer I am not aware how much padding is added so not able to remove it.
According to your previous comment I have to provide exactly the compressed data whereas decompression is working fine with padding upto 4 bytes.(verified with a sample code)
Can you please explain how it is working and is there any possible way to work with any numbers of padded bytes?

Thanks

from zstd.

anshulchaurasia avatar anshulchaurasia commented on August 17, 2024

Hi @Viq111

Any suggestion from your side?

Thanks

from zstd.

Viq111 avatar Viq111 commented on August 17, 2024

I haven't looked too much at the internals of the compression algorithm of zstd unfortunately ( https://github.com/facebook/zstd/issues would probably be a better place to ask about it) so I'm not sure about the guarantee of the end of frame (i.e: can a frame finish with zero bytes).
It's usually pretty common for systems adding padding to provide the size of it because you cannot know if the extra pad is real data or not

from zstd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.