| 2106 | template <typename ParquetType> |
| 2107 | template <typename ArrowType> |
| 2108 | Status TypedColumnWriterImpl<ParquetType>::WriteArrowSerialize( |
| 2109 | const int16_t* def_levels, const int16_t* rep_levels, int64_t num_levels, |
| 2110 | const ::arrow::Array& array, ArrowWriteContext* ctx, bool maybe_parent_nulls) { |
| 2111 | using ArrayType = typename ::arrow::TypeTraits<ArrowType>::ArrayType; |
| 2112 | using ParquetCType = typename ParquetType::c_type; |
| 2113 | |
| 2114 | ParquetCType* buffer = nullptr; |
| 2115 | PARQUET_THROW_NOT_OK(ctx->GetScratchData<ParquetCType>(array.length(), &buffer)); |
| 2116 | |
| 2117 | SerializeFunctor<ParquetType, ArrowType> functor; |
| 2118 | // The value buffer could be empty if all values are nulls. |
| 2119 | // The output buffer will then remain uninitialized, but that's ok since |
| 2120 | // null value slots are not written in Parquet. |
| 2121 | if (array.null_count() != array.length()) { |
| 2122 | RETURN_NOT_OK(functor.Serialize(checked_cast<const ArrayType&>(array), ctx, buffer)); |
| 2123 | } |
| 2124 | bool no_nulls = |
| 2125 | this->descr()->schema_node()->is_required() || (array.null_count() == 0); |
| 2126 | if (!maybe_parent_nulls && no_nulls) { |
| 2127 | PARQUET_CATCH_NOT_OK(WriteBatchInternal(num_levels, def_levels, rep_levels, buffer)); |
| 2128 | } else { |
| 2129 | PARQUET_CATCH_NOT_OK(WriteBatchSpacedInternal(num_levels, def_levels, rep_levels, |
| 2130 | array.null_bitmap_data(), |
| 2131 | array.offset(), buffer)); |
| 2132 | } |
| 2133 | return Status::OK(); |
| 2134 | } |
| 2135 | |
| 2136 | #define WRITE_SERIALIZE_CASE(ArrowEnum) \ |
| 2137 | case ::arrow::Type::ArrowEnum: { \ |