zeroshade commented on code in PR #1689:
URL: https://github.com/apache/arrow-go/pull/1689#discussion_r4721755918
##########
parquet/writer_properties.go:
##########
@@ -391,6 +391,20 @@ func WithMaxStatsSize(maxStatsSize int64) WriterProperty {
}
}
+// WithColumnChunkBoundsObserver observes the min and max in Parquet statistics
Review Comment:
`WriterProperties` are often built once and shared across concurrent
`NewFileWriter` calls, so calls from different writers can interleave. Please
document that the observer must be goroutine-safe when props are shared. Also,
"observes the min and max in Parquet statistics encoding as each column chunk
closes" reads awkwardly; suggest "is called with each column chunk's min and
max, in Parquet statistics encoding, before the statistics size limit is
applied."
##########
parquet/file/column_writer.go:
##########
@@ -785,6 +785,9 @@ func (w *columnWriter) Close() (err error) {
return err
}
+ if observe := w.props.ColumnChunkBoundsObserver(); observe !=
nil && w.rowsWritten > 0 && chunkStats.HasMin && chunkStats.HasMax {
Review Comment:
The callback gets no row group ordinal, so callers have to count calls to
work out which row group a bound belongs to. The column writer already has the
ordinal (the page writer is given `rgOrdinal` for encryption); please pass it
along with the column ordinal.
##########
parquet/writer_properties.go:
##########
@@ -391,6 +391,20 @@ func WithMaxStatsSize(maxStatsSize int64) WriterProperty {
}
}
+// WithColumnChunkBoundsObserver observes the min and max in Parquet statistics
+// encoding as each column chunk closes, before the statistics size limit is
+// applied. Chunks without min/max statistics do not call the observer.
+//
+// The arguments are read-only and must be copied if needed after the callback
+// returns. The observer runs synchronously and does not alter the file's
+// statistics. Use the observed bounds only if writing the file succeeds.
+// Pass nil to disable the observer.
+func WithColumnChunkBoundsObserver(observe func(path ColumnPath, min, max
[]byte)) WriterProperty {
Review Comment:
Once released, a bare `func(ColumnPath, []byte, []byte)` can't change
without a break. Consider a struct argument so fields can be added later, e.g.:
```go
type ColumnChunkBounds struct {
Path ColumnPath
RowGroup int
Column int
Min, Max []byte // statistics encoding; read-only
}
```
`Min`/`Max` are raw statistics bytes, so callers also need the physical type
and sort order to read them (`chunkStats.Signed` is only set after the callback
runs). Either include those in the struct or say in the docs that callers must
get them from the schema.
##########
parquet/file/file_writer_test.go:
##########
@@ -986,6 +986,58 @@ func (t *PageIndexRoundTripSuite) TestDropLargeStats() {
})
}
+func TestColumnChunkBoundsObserver(t *testing.T) {
Review Comment:
Nit: this sits between two `PageIndexRoundTripSuite` methods; please move it
after the suite or next to the other top-level tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]