#include "test_data.hpp" #include #include namespace weaseldb::test_data { // Sample JSON strings of varying complexity for benchmarking and testing const std::string SIMPLE_JSON = R"({ "request_id": "simple-test", "leader_id": "leader123", "read_version": 12345 })"; const std::string MEDIUM_JSON = R"({ "request_id": "medium-test", "leader_id": "leader456", "read_version": 98765, "preconditions": [ { "type": "point_read", "version": 98764, "key": "dGVzdEtleQ==" }, { "type": "range_read", "version": 98763, "begin": "cmFuZ2VTdGFydA==", "end": "cmFuZ2VFbmQ=" } ], "operations": [ { "type": "write", "key": "d3JpdGVLZXk=", "value": "d3JpdGVWYWx1ZQ==" }, { "type": "delete", "key": "ZGVsZXRlS2V5" } ] })"; const std::string COMPLEX_JSON = R"({ "request_id": "complex-batch-operation-12345", "leader_id": "leader789abcdef", "read_version": 999999999, "preconditions": [ { "type": "point_read", "version": 999999998, "key": "cHJlY29uZGl0aW9uS2V5MQ==" }, { "type": "range_read", "version": 999999997, "begin": "cmFuZ2VQcmVjb25kaXRpb25CZWdpbg==", "end": "cmFuZ2VQcmVjb25kaXRpb25FbmQ=" }, { "type": "point_read", "version": 999999996, "key": "YW5vdGhlclByZWNvbmRpdGlvbktleQ==" } ], "operations": [ { "type": "write", "key": "b3BlcmF0aW9uS2V5MQ==", "value": "bGFyZ2VPcGVyYXRpb25WYWx1ZVdpdGhMb3RzT2ZEYXRhSGVyZQ==" }, { "type": "write", "key": "b3BlcmF0aW9uS2V5Mg==", "value": "YW5vdGhlckxhcmdlVmFsdWVXaXRoRXZlbk1vcmVEYXRh" }, { "type": "delete", "key": "ZGVsZXRlT3BlcmF0aW9uS2V5" }, { "type": "range_delete", "begin": "cmFuZ2VEZWxldGVTdGFydA==", "end": "cmFuZ2VEZWxldGVFbmQ=" }, { "type": "write", "key": "ZmluYWxPcGVyYXRpb25LZXk=", "value": "ZmluYWxPcGVyYXRpb25WYWx1ZVdpdGhMb25nZXJEYXRhRm9yVGVzdGluZw==" } ] })"; // Helper function to encode a string as base64 std::string encode_base64(const std::string &input) { if (input.empty()) { return ""; } size_t max_output_size = simdutf::base64_length_from_binary(input.size()); std::vector output(max_output_size); size_t written = simdutf::binary_to_base64( input.data(), input.size(), output.data(), simdutf::base64_default); return std::string(output.data(), written); } // Generate a large JSON with many operations for stress testing std::string generate_large_json(int num_operations) { std::string json = R"({ "request_id": "large-batch-)" + std::to_string(num_operations) + R"(", "leader_id": "stress-test-leader", "read_version": 1000000, "operations": [)"; for (int i = 0; i < num_operations; ++i) { if (i > 0) json += ","; std::string key = "key" + std::to_string(i); std::string value = "value" + std::to_string(i); std::string key_b64 = encode_base64(key); std::string value_b64 = encode_base64(value); json += R"( { "type": "write", "key": ")" + key_b64 + R"(", "value": ")" + value_b64 + R"(" })"; } json += R"( ] })"; return json; } } // namespace weaseldb::test_data