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