zanmato1984 commented on code in PR #41330:
URL: https://github.com/apache/arrow/pull/41330#discussion_r1574529527
##########
cpp/src/gandiva/cache.cc:
##########
@@ -23,23 +23,38 @@
namespace gandiva {
-static const size_t DEFAULT_CACHE_SIZE = 5000;
+static const int DEFAULT_CACHE_SIZE = 5000;
-int GetCapacity() {
- size_t capacity = DEFAULT_CACHE_SIZE;
- auto maybe_env_cache_size =
::arrow::internal::GetEnvVar("GANDIVA_CACHE_SIZE");
- if (maybe_env_cache_size.ok()) {
- const auto env_cache_size = *std::move(maybe_env_cache_size);
- if (!env_cache_size.empty()) {
- capacity = std::atol(env_cache_size.c_str());
- if (capacity <= 0) {
- ARROW_LOG(WARNING) << "Invalid cache size provided in
GANDIVA_CACHE_SIZE. "
- << "Using default cache size: " <<
DEFAULT_CACHE_SIZE;
- capacity = DEFAULT_CACHE_SIZE;
- }
- }
+namespace internal {
+int GetCapacityFromEnvVar() {
+ auto maybe_env_value = ::arrow::internal::GetEnvVar("GANDIVA_CACHE_SIZE");
+ if (!maybe_env_value.ok()) {
+ return DEFAULT_CACHE_SIZE;
+ }
+ const auto env_value = *std::move(maybe_env_value);
+ if (env_value.empty()) {
+ return DEFAULT_CACHE_SIZE;
+ }
+ int capacity = 0;
+ size_t length = 0;
+ bool exception = false;
+ try {
+ capacity = std::stoi(env_value.c_str(), &length);
Review Comment:
Replace `std::atol` with `std::stoi` to have better error handling.
--
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]