MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / generateRandomJSONNode

Function generateRandomJSONNode

src/Storages/StorageFuzzJSON.cpp:312–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312std::shared_ptr<JSONNode>
313generateRandomJSONNode(const StorageFuzzJSON::Configuration & config, pcg64 & rnd, bool with_key, JSONValue::Type type)
314{
315 auto node = std::make_shared<JSONNode>();
316
317 if (with_key)
318 node->key = generateRandomKey(config.min_key_length, config.max_key_length, rnd);
319
320 auto & val = node->value;
321 switch (type)
322
323 {
324 case JSONValue::Type::Fixed: {
325 val.fixed = generateRandomFixedValue(config, rnd);
326 break;
327 }
328 case JSONValue::Type::Array: {
329 val.array = JSONNodeList{};
330 break;
331 }
332 case JSONValue::Type::Object: {
333 val.object = JSONNodeList{};
334 break;
335 }
336 }
337 return node;
338}
339
340template <size_t n>
341std::shared_ptr<JSONNode> generateRandomJSONNode(

Callers 1

Calls 3

generateRandomKeyFunction · 0.85
generateRandomFixedValueFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected