zanmato1984 commented on code in PR #40237:
URL: https://github.com/apache/arrow/pull/40237#discussion_r1576588469


##########
cpp/src/arrow/scalar.h:
##########
@@ -245,41 +250,51 @@ struct ARROW_EXPORT DoubleScalar : public 
NumericScalar<DoubleType> {
   using NumericScalar<DoubleType>::NumericScalar;
 };
 
-struct ARROW_EXPORT BaseBinaryScalar
-    : public internal::PrimitiveScalarBase,
-      private internal::ArraySpanFillFromScalarScratchSpace {
-  using internal::PrimitiveScalarBase::PrimitiveScalarBase;
+struct ARROW_EXPORT BaseBinaryScalar : public internal::PrimitiveScalarBase {
   using ValueType = std::shared_ptr<Buffer>;
 
-  std::shared_ptr<Buffer> value;
+  // The value is not supposed to be modified after construction, because 
subclasses have
+  // a scratch space whose content need to be kept consistent with the value. 
It is also
+  // the user of this class's responsibility to ensure that the buffer is not 
written to
+  // accidentally.
+  const std::shared_ptr<Buffer> value = NULLPTR;

Review Comment:
   No, the `Buffer` in `const std::shared_ptr<Buffer>` is non-const, meaning 
one can mutate the content of the pointing buffer. But as the comment says
   > It is also the user of this class's responsibility to ensure that the 
buffer is not written to accidentally.
   
   I'm sort of following the style as what `BufferSpan` is doing:
   
https://github.com/apache/arrow/blob/d2f140dd7540420aad7685e035f887b0cc9baf91/cpp/src/arrow/array/data.h#L375-L377
   



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