mapleFU commented on code in PR #55449:
URL: https://github.com/apache/arrow/pull/55449#discussion_r4708934784


##########
cpp/src/parquet/encoder.cc:
##########
@@ -1913,11 +1934,12 @@ std::unique_ptr<Encoder> MakeEncoder(Type::type 
type_num, Encoding::type encodin
             "and FIXED_LEN_BYTE_ARRAY");
     }
   } else if (encoding == Encoding::ALP) {
+    const auto& alp_options = options.Get<AlpOptions>(encoding);

Review Comment:
   Should we validate it here since it's a public API ( just DCHECK might also 
ok for me, I don't know)



##########
cpp/src/arrow/util/alp/alp_compression.cc:
##########
@@ -524,16 +525,25 @@ template <typename TargetType>
 void AlpCompression<T>::PatchExceptions(
     std::span<const T> exceptions,
     std::span<const AlpFormatConstants::PositionType> exception_positions,
-    std::span<TargetType> outputs) {
+    const bool positions_strictly_increasing, std::span<TargetType> outputs) {
   ARROW_DCHECK_EQ(exceptions.size(), exception_positions.size());
-  // `ivdep` assumes the positions are distinct. The encoder writes them in
-  // order, and loading a page rejects positions that do not increase.
-  int64_t exception_idx = 0;
-  ARROW_ALP_UNROLL_AND_ASSUME_INDEPENDENT
-  for (const AlpFormatConstants::PositionType exception_position : 
exception_positions) {
-    ARROW_DCHECK_LT(exception_position, outputs.size());
-    outputs[exception_position] = static_cast<T>(exceptions[exception_idx]);
-    exception_idx++;
+  const size_t num_exceptions = exception_positions.size();
+  const auto patch_exception = [&](size_t i) {
+    const auto position = exception_positions[i];
+    ARROW_DCHECK_LT(position, outputs.size());
+    outputs[position] = static_cast<T>(exceptions[i]);
+  };
+  if (positions_strictly_increasing) {
+    // The encoder emits strictly increasing positions. Use the vectorized
+    // fast path for that common case.

Review Comment:
   I suggest we can remove this 🤔



##########
cpp/src/parquet/properties.cc:
##########
@@ -106,6 +124,10 @@ void 
WriterProperties::Builder::CopyColumnSpecificProperties(
     if (col_props.bloom_filter_options().has_value()) {
       this->enable_bloom_filter(col_path, 
col_props.bloom_filter_options().value());
     }
+
+    if (!col_props.encoding_options().options.empty()) {
+      this->encoding_options(col_path, col_props.encoding_options());

Review Comment:
   Here didn't copying from default? Or should we just not keeping the default?



##########
cpp/src/parquet/properties.cc:
##########
@@ -61,6 +61,24 @@ std::shared_ptr<ArrowWriterProperties> 
default_arrow_writer_properties() {
   return default_writer_properties;
 }
 
+void ColumnProperties::set_encoding_options(const EncodingOptions& options) {
+  options.Validate();
+  encoding_options_ = options;
+}
+
+WriterProperties::Builder* WriterProperties::Builder::encoding_options(
+    const EncodingOptions& options) {
+  default_column_properties_.set_encoding_options(options);

Review Comment:
   why do we set default options here, bf doesn't have default options in this 
scenerio, I'm not sure about what's the pro of it.



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