umrndem opened a new pull request, #1709: URL: https://github.com/apache/arrow-go/pull/1709
### Rationale for this change The CSV writer formats every column in a record before writing the first row, retaining record-sized string buffers. Fixes #78. ### What changes are included in this PR? Format default columns in 1,024-row chunks and reuse the string slices between chunks. Release each temporary array slice after conversion, including error and panic paths. Custom converters still receive complete columns, including empty columns. That path stays unchunked to preserve callback behavior and converters that reuse their result buffer. ### Are these changes tested? Added regressions for chunk boundaries, sliced arrays, nested values, nulls, quoting, string replacement, repeated writes, empty records, whole-column custom converters and cleanup after an unsupported-type panic. The CSV package tests passed with `assert,test`, race checking and `assert,test,noasm`. `go vet`, the configured staticcheck linter and formatting checks passed for the CSV package. Extended `BenchmarkWrite` with a one-million-row case using the same 16-column fixture. Local results on Linux/amd64, Go 1.26.6, `GOMAXPROCS=4`, with the benchmark applied to both versions: | Measurement | main | this PR | | --- | ---: | ---: | | 1,000 rows, median time/op | 714 us | 695 us | | 1,000,000 rows, median time/op | 681 ms | 610 ms | | 1,000,000 rows, allocated bytes/op | 480,493,192 | 227,453,592 | | 1,000,000 rows, allocations/op | 20,215,044 | 20,246,310 | | Large benchmark, peak process RSS | 1,006 MiB | 323 MiB | The small case uses five samples; the large case uses three samples of three writes each. Peak RSS comes from `/usr/bin/time -v` on the compiled large-benchmark test binaries and includes input construction. The 1,000-row case retains the same allocation counts and approximately 433 kB/op. ### Are there any user-facing changes? Large records use less temporary memory with the default converters. CSV formatting is preserved, and custom converters retain their whole-column behavior. AI helped with the implementation, checks and PR text. -- 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]
