hn.today

Writing Parquet files using Haskell

datahaskell.org3 points0 comments
Screenshot of Writing Parquet files using Haskell

A Parquet writer has been implemented for DataHaskell/Dataframe that lets you write parquet files with a simple writeParquet call or tune behavior via writeParquetWithOptions. The implementation targets efficient storage and queryability by exposing options like pageSize, rowGroupSize, batchRows, subBatchRows, compressionCodec, writer strategy, and maxRowsPerFile. It treats page and row-group sizes as best-effort targets and enforces that row groups and pages contain integer multiples of batchRows and subBatchRows respectively, which simplifies bookkeeping and improves throughput. The design emphasizes projection/predicate pushdown and IO-friendly layouts while providing sensible defaults.

Technically, it is an effectful fold over a dataframe that threads a ParquetWriterState containing output handle, per-column ColumnChunkState (buffers, encoder, stats), and page state. Values are encoded by an Encoder abstraction (encodeValue and finishValues), written into per-column page buffers, assembled into a reusable scratchBuffer with page metadata and definition levels, then flushed into column chunk buffers and files. Memory uses pinned MutableByteArray wrapped in MemoryBuffer to allow Ptr operations; growth allocates new pinned arrays rather than in-place grow. Current limitations: only Snappy and uncompressed compression, plain encoding, definition levels up to 1, and single-threaded execution; future work targets more codecs/encodings and selective parallelism.

Read on datahaskell.org0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.