You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/19 23:45:37 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #14415: ARROW-17966: [C++] Adjust to new format for Substrait optional arguments

westonpace commented on code in PR #14415:
URL: https://github.com/apache/arrow/pull/14415#discussion_r1000021551


##########
cpp/src/arrow/engine/substrait/extension_set.cc:
##########
@@ -156,15 +156,33 @@ Result<compute::Expression> SubstraitCall::GetValueArg(uint32_t index) const {
   return value_arg_it->second;
 }
 
-bool SubstraitCall::HasValueArg(uint32_t index) const {
+bool SubstraitCall::HasValueArg(int index) const {
   return value_args_.find(index) != value_args_.end();
 }
 
-void SubstraitCall::SetValueArg(uint32_t index, compute::Expression value_arg) {
+void SubstraitCall::SetValueArg(int index, compute::Expression value_arg) {
   size_ = std::max(size_, index + 1);
   value_args_[index] = std::move(value_arg);
 }
 
+std::optional<std::vector<std::string> const*> SubstraitCall::GetOption(
+    std::string_view option_name) const {
+  auto opt = options_.find(std::string(option_name));
+  if (opt == options_.end()) {
+    return std::nullopt;
+  }
+  return &opt->second;
+}
+
+void SubstraitCall::SetOption(std::string_view option_name,
+                              const std::vector<std::string_view>& option_preferences) {
+  std::vector<std::string> prefs_copy;
+  std::transform(option_preferences.begin(), option_preferences.end(),
+                 std::back_inserter(prefs_copy),
+                 [](std::string_view pref) { return std::string(pref); });
+  options_[std::string(option_name)] = prefs_copy;

Review Comment:
   Ah, true, could have done a `std::move` on `prefs_copy`.  I agree this is more readable though.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org