Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 70da77c

Browse files
author
Nikita Glukhov
committed
Rename functions for JSON paths collection
1 parent 3d71035 commit 70da77c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/backend/utils/adt/jsonb_typanalyze.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,11 @@ jsonAnalyzeJsonValue(JsonAnalyzeContext *ctx, JsonValueStats *vstats,
420420
}
421421

422422
/*
423-
* jsonAnalyzeJson
424-
* Parse the JSON document and build/update stats.
425-
*
426-
* XXX The name seems a bit weird, with the two json bits.
423+
* jsonAnalyzeCollectPaths
424+
* Parse the JSON document and collect all paths and their values.
427425
*/
428426
static void
429-
jsonAnalyzeJson(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
427+
jsonAnalyzeCollectPaths(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
430428
{
431429
JsonbValue jv;
432430
JsonbIterator *it;
@@ -513,12 +511,12 @@ jsonAnalyzeJson(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
513511
}
514512

515513
/*
516-
* jsonAnalyzeJsonSubpath
517-
* ???
514+
* jsonAnalyzeCollectSubpath
515+
* Recursively extract trailing part of a path and collect its values.
518516
*/
519517
static void
520-
jsonAnalyzeJsonSubpath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
521-
JsonbValue *jbv, int n)
518+
jsonAnalyzeCollectSubpath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
519+
JsonbValue *jbv, int n)
522520
{
523521
JsonbValue scalar;
524522
int i;
@@ -549,7 +547,7 @@ jsonAnalyzeJsonSubpath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
549547
while ((r = JsonbIteratorNext(&it, &elem, true)) != WJB_DONE)
550548
{
551549
if (r == WJB_ELEM)
552-
jsonAnalyzeJsonSubpath(ctx, pstats, &elem, i + 1);
550+
jsonAnalyzeCollectSubpath(ctx, pstats, &elem, i + 1);
553551
}
554552

555553
return;
@@ -579,11 +577,11 @@ jsonAnalyzeJsonSubpath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
579577
}
580578

581579
/*
582-
* jsonAnalyzeJsonPath
583-
* ???
580+
* jsonAnalyzeCollectPath
581+
* Extract a single path from JSON documents and collect its values.
584582
*/
585583
static void
586-
jsonAnalyzeJsonPath(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
584+
jsonAnalyzeCollectPath(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
587585
{
588586
JsonPathAnlStats *pstats = (JsonPathAnlStats *) param;
589587
JsonbValue jbvtmp;
@@ -603,7 +601,7 @@ jsonAnalyzeJsonPath(JsonAnalyzeContext *ctx, Jsonb *jb, void *param)
603601
pstats->entries[i] = path;
604602
}
605603

606-
jsonAnalyzeJsonSubpath(ctx, pstats, jbv, 0);
604+
jsonAnalyzeCollectSubpath(ctx, pstats, jbv, 0);
607605
}
608606

609607
static Datum
@@ -1219,7 +1217,7 @@ compute_json_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
12191217
if (false)
12201218
{
12211219
/* Collect all values of all paths */
1222-
jsonAnalyzePass(&ctx, jsonAnalyzeJson, (void *)(intptr_t) true);
1220+
jsonAnalyzePass(&ctx, jsonAnalyzeCollectPaths, (void *)(intptr_t) true);
12231221
jsonAnalyzePaths(&ctx);
12241222
}
12251223
else
@@ -1249,7 +1247,7 @@ compute_json_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
12491247
*/
12501248

12511249
/* Collect all paths first and sort them */
1252-
jsonAnalyzePass(&ctx, jsonAnalyzeJson, (void *)(intptr_t) false);
1250+
jsonAnalyzePass(&ctx, jsonAnalyzeCollectPaths, (void *)(intptr_t) false);
12531251
jsonAnalyzeSortPaths(&ctx);
12541252

12551253
MemoryContextReset(tmpcxt);
@@ -1261,7 +1259,7 @@ compute_json_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
12611259
elog(DEBUG1, "analyzing json path (%d/%d) %s",
12621260
i + 1, ctx.npaths, path->pathstr);
12631261

1264-
jsonAnalyzePass(&ctx, jsonAnalyzeJsonPath, path);
1262+
jsonAnalyzePass(&ctx, jsonAnalyzeCollectPath, path);
12651263
jsonAnalyzePath(&ctx, path);
12661264

12671265
MemoryContextReset(tmpcxt);

0 commit comments

Comments
 (0)