emkornfield commented on code in PR #39677:
URL: https://github.com/apache/arrow/pull/39677#discussion_r1458184838


##########
cpp/src/parquet/column_writer.cc:
##########
@@ -323,6 +323,19 @@ class SerializedPageWriter : public PageWriter {
 
     PARQUET_THROW_NOT_OK(sink_->Write(output_data_buffer, output_data_len));
 
+    // Add the dictionary page to the offsets
+    if (offset_index_builder_ != nullptr) {
+      const int64_t compressed_size = output_data_len + header_size;
+      if (compressed_size > std::numeric_limits<int32_t>::max()) {
+        throw ParquetException("Compressed dictionary page size overflows to 
INT32_MAX.");
+      }
+
+      /// start_pos is a relative offset in the buffered mode. It should be
+      /// adjusted via OffsetIndexBuilder::Finish() after BufferedPageWriter
+      /// has flushed all data pages.
+      offset_index_builder_->AddPage(start_pos, 
static_cast<int32_t>(compressed_size), -1);
+    }

Review Comment:
   We should clarify the spec, but I believe dictionary pages were intended to 
be retrieved via column metadata (which would be in the footer).  I think it 
would have been mentioned if it is, and I think the spec always assumes the 
footer is parsed, and for page indexes there is a copy of the metadata there.  
The OffsetIndex is meant to directly parallel the ColumnIndex which only keep 
stats for data pages.
   
   > The dictionary page, is in fact, a type of data page. So including it 
should be backwards compatible since readers should recognize its type in the 
list of pages provided by an OffsetIndex.
   
   In the sense that everything is "data" that is correct.  But in parquet 
dictionaries are 
[modeled](https://github.com/apache/parquet-format/blob/master/src/main/thrift/parquet.thrift#L603)
 as a separate concept.   The actual type of page is not stored in either 
index, it is therefore not really possible to make this a compatible change 
because old readers would likely error out here.  [Parquet-mr does not touch 
the index when writing a dictionary 
page](https://github.com/apache/parquet-mr/blob/master/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java#L1042)
 either it does for [data 
pages](https://github.com/apache/parquet-mr/blob/master/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java#L781).



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