Giter Site home page Giter Site logo

Comments (10)

lsching17 avatar lsching17 commented on May 25, 2024
  1. Do the output buffer need to be "clean" before each operation. i.e. can i reuse buffer for every compress/uncompress operation?

from lz4-java.

broneill avatar broneill commented on May 25, 2024

Javadocs indicate that compressors and decompressors are thread safe. Looking at the code I see no synchronization, and so no state is shared or re-used. I would expect to see the same performance no matter what you do. Measure it and go for the simplest thing.

from lz4-java.

lsching17 avatar lsching17 commented on May 25, 2024
  1. What is the behaviour of safe decompressor/fast decompressor if the output size is larger than the specified decompressedLength/allocated_buffer_size?

    an exception is thrown or memory corruption occur?

  2. Do the output buffer need to be "clean" before each operation. i.e. can i reuse buffer for every compress/uncompress operation?

On 05/07/2014 08:10 AM, broneill wrote:

Javadocs indicate that compressors and decompressors are thread safe. Looking at the code I see no synchronization, and so no state is shared or re-used. I would expect to see the same performance no matter what you do. Measure it and go for the simplest thing.


Reply to this email directly or view it on GitHub #41 (comment).

from lz4-java.

broneill avatar broneill commented on May 25, 2024

Why not try it out? It's not that hard to write some test code.

from lz4-java.

lsching17 avatar lsching17 commented on May 25, 2024

Other user may have similar enquiry about thread safety, scalability, error handling, buffer reuse..

if it is available in the documentation, it should benefit other user.

Furthermore, for unclean buffer: it is hard to write test scripts to prove the code work for EVERY unclean buffer, the only possible way for user is to study documentation or examine the related code himself (and he must be a C-JNI expert).

On 06/07/2014 07:04 AM, broneill wrote:

Why not try it out? It's not that hard to write some test code.


Reply to this email directly or view it on GitHub #41 (comment).

from lz4-java.

broneill avatar broneill commented on May 25, 2024

Good points. There are however, a few assumptions regarding the safety of Java APIs. Although the use of JNI can lead to problems, any memory corruption caused by the API is a bug. Documenting that checks are in place is just a promise anyhow, because the implementation might still be defective. The only way to be convinced of the safety is to look at the tests and look at the code.

from lz4-java.

jpountz avatar jpountz commented on May 25, 2024
  • all APIs are thread-safe
  • if the output buffer is not large enough, an exception is supposed to be thrown. If not, that is a bug. :-)
  • the output buffer doesn't need to be clean before compressing or decompressing.

from lz4-java.

lsching17 avatar lsching17 commented on May 25, 2024

Thank you very much for all your help.

But why there is a need for "safe decompressor"? The fast decompressor throw exception when buffer is not large enough

from lz4-java.

jpountz avatar jpountz commented on May 25, 2024

The additional guarantees of the safe decompressor are not about the output buffer but the input buffer: it allows you to specify the number of bytes that it is allowed to read in order to decompress data.

from lz4-java.

lsching17 avatar lsching17 commented on May 25, 2024

thank a lot!

from lz4-java.

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.