Skip to content

zstd: Flush vs Close  #983

@fhkong

Description

@fhkong

After the encoder has finished writing data, the data flushed to the cache using Flush and Close functions is different.
Moreover, the data flushed into the cache using Flush function cannot be decoded.

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()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions