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

Function strBuildJSON

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

Source from the content-addressed store, hash-verified

2711}
2712
2713String strBuildJSON(RandomGenerator & rg, const int jdepth, const int jwidth)
2714{
2715 String ret = "{";
2716
2717 if (jdepth && jwidth && rg.nextSmallNumber() < 9)
2718 {
2719 std::uniform_int_distribution<int> childd(0, jwidth);
2720 const int nchildren = childd(rg.generator);
2721
2722 for (int i = 0; i < nchildren; i++)
2723 {
2724 std::uniform_int_distribution<int> jopt(1, 3);
2725
2726 if (i != 0)
2727 {
2728 ret += ",";
2729 }
2730 ret += "\"";
2731 ret += rg.nextJSONCol();
2732 ret += "\":";
2733 switch (jopt(rg.generator))
2734 {
2735 case 1:
2736 /// Object
2737 ret += strBuildJSON(rg, jdepth - 1, jwidth);
2738 break;
2739 case 2:
2740 /// Array
2741 ret += strBuildJSONArray(rg, jdepth - 1, jwidth);
2742 break;
2743 case 3:
2744 /// Others
2745 ret += strBuildJSONElement(rg);
2746 break;
2747 default: UNREACHABLE();
2748 }
2749 }
2750 }
2751 ret += "}";
2752 return ret;
2753}
2754
2755String StatementGenerator::strAppendAnyValue(RandomGenerator & rg, const bool allow_cast, SQLType * tp)
2756{

Callers 4

appendRandomRawValueMethod · 0.85
strBuildJSONArrayFunction · 0.85

Calls 4

strBuildJSONArrayFunction · 0.85
strBuildJSONElementFunction · 0.85
nextSmallNumberMethod · 0.80
nextJSONColMethod · 0.80

Tested by

no test coverage detected