Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/schema_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
namespace valkey_search {

constexpr absl::string_view kMaxIndexesConfig{"max-indexes"};
constexpr uint32_t kMaxIndexes{10};
constexpr uint32_t kMaxIndexes{UINT32_MAX};

constexpr absl::string_view kIndexSchemaBackfillBatchSizeConfig(
"backfill-batch-size");
Expand All @@ -59,7 +59,7 @@ namespace options {
/// have.
static auto max_indexes =
vmsdk::config::NumberBuilder(kMaxIndexesConfig, // name
kMaxIndexes, // default size
10, // default size
1, // min size
kMaxIndexes) // max size
.WithValidationCallback(CHECK_RANGE(1, kMaxIndexes, kMaxIndexesConfig))
Expand Down
2 changes: 1 addition & 1 deletion vmsdk/src/module_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template <typename T>
static T OnGetConfig(const char *config_name, void *priv_data) {
auto entry = static_cast<ConfigBase<T> *>(priv_data);
CHECK(entry) << "null private data for Boolean configuration entry.";
return static_cast<int>(entry->GetValue());
return entry->GetValue();
}

template <typename T>
Expand Down
16 changes: 9 additions & 7 deletions vmsdk/src/module_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,15 @@ ConfigBuilder<std::string> StringBuilder(Args &&...args) {
return Builder<std::string>(std::forward<Args>(args)...);
}

#define CHECK_RANGE(MIN, MAX, CONFIG_NAME) \
[](const int value) { \
if (value < MIN || value > MAX) { \
return absl::OutOfRangeError(absl::StrFormat( \
"%s must be between %u and %u", CONFIG_NAME, MIN, MAX)); \
} \
return absl::OkStatus(); \
#define CHECK_RANGE(MIN, MAX, CONFIG_NAME) \
[](const auto &value) { \
using T = std::decay_t<decltype(value)>; \
if (value < static_cast<T>(MIN) || value > static_cast<T>(MAX)) { \
return absl::OutOfRangeError( \
absl::StrFormat("%s must be between %v and %v", CONFIG_NAME, \
static_cast<T>(MIN), static_cast<T>(MAX))); \
} \
return absl::OkStatus(); \
}

} // namespace config
Expand Down
Loading