pitrou commented on code in PR #24372:
URL: https://github.com/apache/arrow/pull/24372#discussion_r1067170412
##########
cpp/src/arrow/array/builder_base.h:
##########
@@ -36,6 +36,48 @@
namespace arrow {
+namespace internal {
+
+template <class Builder, class V>
+class ArrayBuilderExtraOps {
+ private:
+ inline Status AppendOptional(const std::optional<V>& value, bool
force_empty_value) {
+ auto* self = static_cast<Builder*>(this);
+ if (value.has_value()) {
+ return self->Append(*value);
+ }
+ return force_empty_value ? self->AppendEmptyValue() : self->AppendNull();
+ }
+
+ inline void UnsafeAppendOptional(const std::optional<V>& value,
+ bool force_empty_value) {
+ auto* self = static_cast<Builder*>(this);
+ if (value.has_value()) {
+ return self->UnsafeAppend(*value);
+ }
+ return force_empty_value ? self->UnsafeAppendEmptyValue() :
self->UnsafeAppendNull();
+ }
+
+ public:
+ Status AppendOrNull(const std::optional<V>& value) {
+ return AppendOptional(value, false);
+ }
+
+ Status AppendOrEmptyValue(const std::optional<V>& value) {
+ return AppendOptional(value, true);
+ }
Review Comment:
I don't think appending an empty value for an empty optional is an
interesting use case, what do you think @bkietz ?
--
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]