You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "llama90 (via GitHub)" <gi...@apache.org> on 2023/10/11 17:00:24 UTC

Re: [I] [C++][Integration] Refactor json_internal.cc to use fewer `DCHECK`s [arrow]

llama90 commented on issue #38186:
URL: https://github.com/apache/arrow/issues/38186#issuecomment-1758115499

   Looking at the file you mentioned, the `UnboxValue` function is implemented as follows:
   
   ```cpp
   template <typename T>
   enable_if_physical_floating_point<T, typename T::c_type> UnboxValue(
       const rj::Value& val) {
     DCHECK(val.IsFloat());
     return static_cast<typename T::c_type>(val.GetDouble());
   }
   ```
   
   Are you considering modifying it to something like this:
   
   ```cpp
   template <typename T>
   enable_if_physical_floating_point<T, typename T::c_type> UnboxValue(
       const rj::Value& val) {
     ARROW_CHECK(val.IsDouble());
     return static_cast<typename T::c_type>(val.GetDouble());
   }
   ```
   
   to ensure that an error is returned during runtime when incorrect scenarios are encountered? Is this what you intend to address in this issue?
   
   ```diff
   template <typename T>
   enable_if_physical_floating_point<T, typename T::c_type> UnboxValue(
       const rj::Value& val) {
   -  DCHECK(val.IsFloat());
   +  ARROW_CHECK(val.IsDouble());
     return static_cast<typename T::c_type>(val.GetDouble());
   }
   ```


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