pitrou commented on code in PR #41330:
URL: https://github.com/apache/arrow/pull/41330#discussion_r1587792048
##########
cpp/src/gandiva/cache_test.cc:
##########
@@ -38,5 +42,77 @@ TEST(TestCache, TestGetPut) {
ASSERT_EQ(cache.GetObjectCode(TestCacheKey(2)), "world");
}
-TEST(TestCache, TestGetCacheCapacity) { ASSERT_EQ(GetCapacity(), 5000); }
+namespace {
+constexpr auto capacity_env_var = "GANDIVA_CACHE_SIZE";
+constexpr auto default_capacity = 5000;
+} // namespace
+
+TEST(TestCache, TestGetCacheCapacityDefault) {
+ ASSERT_EQ(GetCapacity(), default_capacity);
+}
+
+TEST(TestCache, TestGetCacheCapacityEnvVar) {
+ // Uncleared env var may have side-effect to subsequent tests. Use a
structure to help
+ // clearing the env var when leaving the scope.
+ struct ScopedEnvVar {
Review Comment:
Can use the existing `EnvVarGuard` from our testing utilities.
##########
cpp/src/gandiva/cache.h:
##########
@@ -25,6 +25,14 @@
namespace gandiva {
+namespace internal {
+// Only called once by GetCapacity().
+// Do the actual work of getting the capacity from env var.
+// Also makes the testing easier.
+GANDIVA_EXPORT
+int GetCapacityFromEnvVar();
+} // namespace internal
+
GANDIVA_EXPORT
int GetCapacity();
Review Comment:
Can this be called `GetCacheCapacity`? The current name is too imprecise.
--
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]