Skip to content

Commit 06b2dcc

Browse files
committed
Bug#25418534: JSON_EXTRACT USING WILDCARDS TAKES FOREVER
Patch #4: Move handling of auto-wrapping to the handling of array path legs, so that we don't pay the cost of checking if auto-wrapping should be performed for every path leg. Microbenchmarks (64-bit, Intel Core i7-4770 3.4 GHz, GCC 6.3): BM_JsonDomSearchEllipsis 22608 ns/iter [+12.5%] BM_JsonDomSearchEllipsis_OnlyOne 16169 ns/iter [ +9.8%] BM_JsonDomSearchKey 129 ns/iter [ -0.8%] BM_JsonBinarySearchEllipsis 230855 ns/iter [ +1.1%] BM_JsonBinarySearchEllipsis_OnlyOne 223140 ns/iter [ +1.3%] BM_JsonBinarySearchKey 86 ns/iter [ 0.0%] Change-Id: I2a233ee7b5a709a1388a370cb96126b17d59595b
1 parent e29bf52 commit 06b2dcc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

sql/json_dom.cc

+7-9
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ static bool find_child_doms(Json_dom *dom,
285285
enum_json_type dom_type= dom->json_type();
286286
enum_json_path_leg_type leg_type= path_leg->get_type();
287287

288-
// Handle auto-wrapping of non-arrays.
289-
if (auto_wrap && dom_type != enum_json_type::J_ARRAY &&
290-
path_leg->is_autowrap())
291-
{
292-
return add_if_missing(dom, duplicates, result);
293-
}
294-
295288
switch (leg_type)
296289
{
297290
case jpl_array_cell:
@@ -302,7 +295,9 @@ static bool find_child_doms(Json_dom *dom,
302295
return idx.within_bounds() &&
303296
add_if_missing((*array)[idx.position()], duplicates, result);
304297
}
305-
return false;
298+
// Handle auto-wrapping of non-arrays.
299+
return auto_wrap && path_leg->is_autowrap() &&
300+
add_if_missing(dom, duplicates, result);
306301
case jpl_array_range:
307302
case jpl_array_cell_wildcard:
308303
if (dom_type == enum_json_type::J_ARRAY)
@@ -316,8 +311,11 @@ static bool find_child_doms(Json_dom *dom,
316311
if (only_need_one)
317312
return false;
318313
}
314+
return false;
319315
}
320-
return false;
316+
// Handle auto-wrapping of non-arrays.
317+
return auto_wrap && path_leg->is_autowrap() &&
318+
add_if_missing(dom, duplicates, result);
321319
case jpl_ellipsis:
322320
{
323321
/*

0 commit comments

Comments
 (0)