adriangb commented on code in PR #10917:
URL: https://github.com/apache/arrow-rs/pull/10917#discussion_r3890012606


##########
parquet/examples/chunk_probe_writer.rs:
##########
@@ -0,0 +1,530 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! An adaptive Parquet writer that measures encodings instead of guessing 
them.
+//!
+//! The writer's default encoding choices are made ahead of time from the 
schema
+//! and a handful of size limits. They cannot know whether a particular 
column's
+//! actual values compress better as a dictionary, as deltas, or as plain
+//! values. This example shows how a caller can find out by measurement, using
+//! [`ArrowRowGroupWriterFactory::create_column_writer`], which builds a writer
+//! for one leaf column of one row group at properties of the caller's 
choosing.
+//!
+//! For each row group, and for each column that has not yet made up its mind,
+//! the writer encodes a short probe prefix of that column once per candidate
+//! set of writer properties, through throwaway single-column writers. Closing
+//! one yields a `ColumnCloseResult` whose metadata carries the compressed size
+//! that candidate actually achieved. The smallest wins, the probe chunks are
+//! discarded, and the row group is then written for real through one ordinary
+//! column writer per column at that column's current choice.
+//!
+//! The cost model is deliberately simple. A column that is still deciding
+//! encodes its probe prefix K + 1 times: K throwaway passes plus the real one.
+//! The prefix is one data page worth of rows rather than a whole row group, so
+//! the extra work is bounded by the page size and not by the data. A column
+//! that has settled costs nothing extra at all: no probe writer is built for
+//! it, so no page store is allocated for it either. That is what addressing 
one
+//! column at a time buys over building every column writer at once.

Review Comment:
   Can we clarify how this interacts w/ dictionary pages, and in general how 
this adaptive writer handles "is the dictionary encoding earning it's keep"? 
How does it measure "is this dictionary worth it"? Does it fall back to avoid 
dictionary pages being larger than memory (there can only be 1)?



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

Reply via email to