v.21.6New Feature

Added dictGetChildren and dictGetDescendants Functions with Performance Improvements

Added functions dictGetChildren(dictionary, key), dictGetDescendants(dictionary, key, level). Function dictGetChildren return all children as an array if indexes. It is a inverse transformation for dictGetHierarchy. Function dictGetDescendants return all descendants as if dictGetChildren was applied level times recursively. Zero level value is equivalent to infinity. Improved performance of dictGetHierarchy, dictIsIn functions. Closes #14656. #22096 (Maksim Kita).
Introduced new dictionary functions dictGetChildren(dictionary, key) and dictGetDescendants(dictionary, key, level) to retrieve child and descendant keys from hierarchical dictionaries. Additionally, improved performance of existing functions dictGetHierarchy and dictIsIn.

Why it matters

These new functions solve the problem of efficiently querying dictionary hierarchies by enabling users to get all direct children or all descendants (up to a specified recursion level) of a given key. This provides an inverse operation to dictGetHierarchy, enhancing flexibility and usability of dictionaries in hierarchical data scenarios.

How to use it

Use dictGetChildren(dictionary, key) to get an array of all direct children indexes for the specified key. Use dictGetDescendants(dictionary, key, level) to retrieve descendants recursively up to the given level (where zero means unlimited recursion). These functions can be called directly in SQL queries. The improved dictGetHierarchy and dictIsIn functions continue to work as before but with better performance.