-
After the encoder has finished writing data, the data flushed to the cache using problem reproduce: var buf bytes.Buffer
encoder, err := zstd.NewWriter(&buf)
require.NoError(t, err)
encoder.Write(rawData)
encoder.Flush()
fmt.Printf("use Flush compressed data len: %d bytes\n", len(buf.Bytes()))
buf.Reset()
encoder.Reset(&buf)
encoder.Write(rawData)
encoder.Close()
fmt.Printf("use Close compressed data len: %d bytes\n", len(buf.Bytes())) |
Beta Was this translation helpful? Give feedback.
Answered by
klauspost
Jul 26, 2024
Replies: 1 comment 1 reply
-
Flush does not indicate EOF, but it will allow the reader to read up until where the Flush was used. Therefore a stream ending with a flush is not complete. Unless you have very special requirements you do not need to call Flush. You will know when you need it. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
klauspost
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flush does not indicate EOF, but it will allow the reader to read up until where the Flush was used. Therefore a stream ending with a flush is not complete.
Unless you have very special requirements you do not need to call Flush. You will know when you need it.