From a7a90e75b7d49474f8fecb13bc3cff525c9f5d0d Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Thu, 8 Dec 2022 17:41:22 -0500 Subject: [PATCH] change Writer.flush parameter to bool --- zio/arrowio/writer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zio/arrowio/writer.go b/zio/arrowio/writer.go index dcf4241439..f734962167 100644 --- a/zio/arrowio/writer.go +++ b/zio/arrowio/writer.go @@ -47,7 +47,7 @@ func NewWriter(w io.WriteCloser) *Writer { func (w *Writer) Close() error { var err error if w.writer != nil { - err = w.flush(1) + err = w.flush(true) w.builder.Release() if err2 := w.writer.Close(); err == nil { err = err2 @@ -88,11 +88,11 @@ func (w *Writer) Write(val *zed.Value) error { } w.buildArrowValue(builder, recType.Columns[i].Type, b) } - return w.flush(recordBatchSize) + return w.flush(false) } -func (w *Writer) flush(min int) error { - if w.builder.Field(0).Len() < min { +func (w *Writer) flush(partialBatch bool) error { + if n := w.builder.Field(0).Len(); n >= recordBatchSize || partialBatch && n > 0 { return nil } rec := w.builder.NewRecord()