From c3a04ebf521134c3aeb2d0b85e87ba9ad5b4f0dc Mon Sep 17 00:00:00 2001 From: "oleg.smirnov" Date: Fri, 22 Mar 2019 11:37:21 +0300 Subject: [PATCH 1/2] Ability to read header from separate reader has been added --- ocf_writer.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ocf_writer.go b/ocf_writer.go index 820af5c..c9f3876 100644 --- a/ocf_writer.go +++ b/ocf_writer.go @@ -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 ") + } + if output == nil { + return nil, fmt.Errorf("cannot create OCFWriter: 'output' can't be ") + } + + 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 From 2ce02a80db4de22ef1ab28a87ffe20a540201a84 Mon Sep 17 00:00:00 2001 From: "oleg.smirnov" Date: Thu, 16 Jan 2020 12:52:06 +0300 Subject: [PATCH 2/2] Change module name to be able use fork with go modules --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a934ef9..b4c9e81 100644 --- a/go.mod +++ b/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