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

Commit 527da88

Browse files
author
Nikita Glukhov
committed
Remove inline struct JsonValueStats.booleans
1 parent 4a6a004 commit 527da88

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/backend/utils/adt/jsonb_typanalyze.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ typedef struct JsonScalarStats
119119
* XXX This seems rather complicated and needs simplification. We're not
120120
* really using all the various JsonScalarStats bits, there's a lot of
121121
* duplication (e.g. each JsonScalarStats contains it's own array, which
122-
* has a copy of data from the one in "jsons"). Some of it is defined as
123-
* a typedef, but booleans have inline struct.
122+
* has a copy of data from the one in "jsons").
124123
*/
125124
typedef struct JsonValueStats
126125
{
@@ -134,14 +133,9 @@ typedef struct JsonValueStats
134133
JsonScalarStats lens; /* stats of object/array lengths */
135134
JsonScalarStats arrlens; /* stats of array lengths */
136135

137-
/* stats for booleans */
138-
struct
139-
{
140-
int ntrue;
141-
int nfalse;
142-
} booleans;
143-
144136
int nnulls; /* number of JSON null values */
137+
int ntrue; /* number of JSON true values */
138+
int nfalse; /* number of JSON false values */
145139
int nobjects; /* number of JSON objects */
146140
int narrays; /* number of JSON arrays */
147141
int nstrings; /* number of JSON strings */
@@ -358,9 +352,9 @@ jsonAnalyzeJsonValue(JsonAnalyzeContext *ctx, JsonValueStats *vstats,
358352

359353
case jbvBool:
360354
if (jv->val.boolean)
361-
vstats->booleans.ntrue++;
355+
vstats->ntrue++;
362356
else
363-
vstats->booleans.nfalse++;
357+
vstats->nfalse++;
364358
break;
365359

366360
case jbvString:
@@ -792,8 +786,7 @@ jsonAnalyzeBuildPathStats(JsonPathAnlStats *pstats)
792786
vstats->jsons.values.count);
793787

794788
pushJsonbKeyValueFloat(&ps, &val, "freq_boolean",
795-
freq * (vstats->booleans.nfalse +
796-
vstats->booleans.ntrue) /
789+
freq * (vstats->nfalse + vstats->ntrue) /
797790
vstats->jsons.values.count);
798791

799792
pushJsonbKeyValueFloat(&ps, &val, "freq_string",

0 commit comments

Comments
 (0)