leonbloy
leonbloy

Reputation: 76006

SYNC_FLUSH/FULL_FLUSH parameters in Java Deflater: relation to DEFLATE blocks?

In Java 7, Deflater has added support for some compression parameters (modes: FULL_FLUSH, SYNC_FLUSH). I guess that they correspond to Zlib similar constants in the standard API (though this one has more modes).

My doubt is how those modes are related to the "blocks" of the DEFLATE stream (these blocks are compressed independently, except that a pointer inside a block might point to a raw substring of a previous block).

Does one (or both) of these modes implies that a flush terminates a (non final) DEFLATE block? Can the caller predict and/or suggest these block boundaries?

Specifically, I'd wish to tell the Deflater object the following: "I will feed you with N raw bytes in sections of predetermined length (M), and because I know that these sections are quite long and statistically different, and because I know that there is little to loose and something to gain in compressing them independently, I suggest you that compress them in separated DEFLATE blocks". Can I do this?

Upvotes: 2

Views: 961

Answers (1)

Mark Adler
Mark Adler

Reputation: 112502

Yes, both flushes terminate the current block after the provided input data.

FULL_FLUSH furthermore prevents the following blocks from using matching strings in the blocks before it.

Upvotes: 4

Related Questions