azecevic000 commented on code in PR #12483:
URL: https://github.com/apache/arrow-rs/pull/12483#discussion_r4721284228


##########
parquet/src/util/interner.rs:
##########
@@ -40,11 +40,23 @@ impl<S: Storage> Interner<S> {
     pub fn new(storage: S) -> Self {
         Self {
             state: Default::default(),
-            dedup: HashTable::with_capacity(DEFAULT_DEDUP_CAPACITY),
+            // Start empty: a column that gets no value never needs the table. 
The
+            // dictionary encoder reserves the full table before its first 
value
+            // (`reserve_if_empty`), as growing from empty is slower.
+            dedup: HashTable::new(),
             storage,
         }
     }
 
+    /// Reserves `DEFAULT_DEDUP_CAPACITY` entries if the table has none yet.
+    pub(crate) fn reserve_if_empty(&mut self) {

Review Comment:
   This is pushing the responsibility of maintaining a desirable state of the 
object to the caller, which is not ideal. Making `dedup: Option<HashTable>` is 
probably a better alternative. The other reasonable (and arguably better) 
alternative is to push Option even further upstream, where the notion of 
laziness has clearer semantics (e.g.  `Option<Interner>` in `DictEncoder`).



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