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

Function strBuildJSONArray

src/Client/BuzzHouse/Generator/SQLTypes.cpp:2566–2616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2564}
2565
2566String strBuildJSONArray(RandomGenerator & rg, const int jdepth, const int jwidth)
2567{
2568 std::uniform_int_distribution<int> jopt(1, 4);
2569 int nelems = 0;
2570 int next_width = 0;
2571
2572 if (jwidth)
2573 {
2574 std::uniform_int_distribution<int> alen(0, jwidth);
2575 nelems = alen(rg.generator);
2576 }
2577 String ret = "[";
2578 next_width = nelems;
2579 for (int j = 0; j < nelems; j++)
2580 {
2581 if (j != 0)
2582 {
2583 ret += ",";
2584 }
2585 if (jdepth)
2586 {
2587 switch (jopt(rg.generator))
2588 {
2589 case 1:
2590 /// Object
2591 ret += strBuildJSON(rg, jdepth - 1, next_width);
2592 break;
2593 case 2:
2594 /// Array
2595 ret += strBuildJSONArray(rg, jdepth - 1, next_width);
2596 break;
2597 case 3:
2598 /// Others
2599 ret += strBuildJSONElement(rg);
2600 break;
2601 case 4:
2602 /// Homogeneous array
2603 ret += homogeneousJSONArray(rg);
2604 break;
2605 default: UNREACHABLE();
2606 }
2607 }
2608 else
2609 {
2610 ret += strBuildJSONElement(rg);
2611 }
2612 next_width--;
2613 }
2614 ret += "]";
2615 return ret;
2616}
2617
2618String strBuildJSONElement(RandomGenerator & rg)
2619{

Callers 1

strBuildJSONFunction · 0.85

Calls 3

strBuildJSONFunction · 0.85
strBuildJSONElementFunction · 0.85
homogeneousJSONArrayFunction · 0.85

Tested by

no test coverage detected