Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to read header from separate reader has been added #163

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
@@ -1,3 +1,3 @@
module github.com/linkedin/goavro
module github.com/Exactpro/goavro

require github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
21 changes: 21 additions & 0 deletions ocf_writer.go
Expand Up @@ -106,6 +106,27 @@ func NewOCFWriter(config OCFConfig) (*OCFWriter, error) {
return ocf, nil // another happy case for creation of new OCF
}

// NewOCFWriterAppender returns a new OCFWriter instance that may be used only for appending
// binary Avro data to an existing OCF file. 'existingFile' is using for reading header from
// the existing OCF file. 'output' is a io.Writer that appending data to the end of the existing file
func NewOCFWriterAppender(existingFile io.Reader, output io.Writer) (*OCFWriter, error) {
if existingFile == nil {
return nil, fmt.Errorf("cannot create OCFWriter: 'existingFile' can't be <nil>")
}
if output == nil {
return nil, fmt.Errorf("cannot create OCFWriter: 'output' can't be <nil>")
}

var err error

ocf := &OCFWriter{iow: output}
if ocf.header, err = readOCFHeader(existingFile); err != nil {
return nil, fmt.Errorf("cannot create OCFWriter: %s", err)
}

return ocf, nil
}

// quickScanToTail advances the stream reader to the tail end of the
// file. Rather than reading each encoded block, optionally decompressing it,
// and then decoding it, this method reads the block count, ignoring it, then
Expand Down