Smityz commented on a change in pull request #842:
URL: https://github.com/apache/incubator-pegasus/pull/842#discussion_r756559550
##########
File path: src/test/function_test/utils.h
##########
@@ -30,3 +33,50 @@
}
\
}
\
} while (0)
+
+inline std::string generate_random_str(uint32_t str_len = 20)
+{
+ static const std::string chars("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "1234567890");
+ std::string result;
+ for (int i = 0; i < str_len; i++) {
+ result += chars[dsn::rand::next_u32(chars.size())];
+ }
+ return result;
+}
+
+inline std::string
+generate_hash_key_with_hotkey(bool is_hotkey, int probability = 100, uint32_t
str_len = 20)
+{
+ if (is_hotkey && (dsn::rand::next_u32(100) < probability)) {
+ return "ThisisahotkeyThisisahotkey";
+ }
+ return generate_random_str(str_len);
+}
+
+inline std::vector<std::string> generate_str_vector_by_random(uint32_t
single_str_len,
+ uint32_t arr_len,
+ bool
random_value_size = false)
+{
+ std::vector<std::string> result;
+ result.reserve(arr_len);
+ for (int i = 0; i < arr_len; i++) {
+ result.emplace_back(generate_random_str(
+ random_value_size ? dsn::rand::next_u32(single_str_len) :
single_str_len));
+ }
+ return result;
+}
+
+inline std::map<std::string, std::string>
+generate_sortkey_value_map(const std::vector<std::string> sortkeys,
+ const std::vector<std::string> values)
+{
+ std::map<std::string, std::string> result;
+ dassert(sortkeys.size() == values.size(), "sortkeys.size() !=
values.size()");
Review comment:
It's util, not a test
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]