dbh_sweep(3)
π dbh_sweep(3) β the DBHashTables Programmers' Manual, bestie edition π
okay so this is a page from the DBHashTables Programmers' Manual, and it's about a whole lil squad of functions: dbh_sweep, dbh_fanout, dbh_foreach_sweep, dbh_foreach_fanout, dbh_exit_sweep and dbh_exit_fanout. they all do the same iconic thing β apply a function to all or part of the DBHashtable. let's get into it π¦
β¨ NAME β¨
dbh_sweep, dbh_fanout, dbh_foreach_sweep, dbh_foreach_fanout, dbh_exit_sweep, dbh_exit_fanout β apply a function to all or part of the DBHashtable π
π SYNOPSIS π
#include <dbh.h>
int dbh_foreach_sweep (DBHashTable *dbh, DBHashFunc operate);
int dbh_foreach_fanout (DBHashTable *dbh, DBHashFunc operate);
int dbh_sweep (DBHashTable *dbh, DBHashFunc operate, unsigned char
*key1, unsigned char *key2, unsigned char ignore_portion);
int dbh_fanout (DBHashTable *dbh, DBHashFunc operate, unsigned char
*key1, unsigned char *key2, unsigned char ignore_portion);
void dbh_exit_sweep (DBHashTable *dbh);
void dbh_exit_fanout (DBHashTable *dbh);
π DESCRIPTION π
so dbh_foreach_sweep applies the function operate to each member of the hash, following a sweep trajectory. and what is a sweep trajectory, you ask? it's traversing the DBHashTable in a vertical direction through all the branches. vertical. going down. slay. πΈ
dbh_foreach_fanout applies a function operate to each member of the hash too, but following a fanout trajectory. fanout is traversing the DBHashTable in a horizontal direction through all the records. so like, sideways. different vibe, same energy. β¨
dbh_sweep and dbh_fanout apply a function to subtree members of the hash β so not the whole thing, just a piece of it. dbh_sweep follows a sweep trajectory (vertically through branches) and dbh_fanout follows a fanout trajectory (horizontally through branches). iykyk π
okay now the arguments, because this is the part where you actually have to pay attention bestie:
key1β the key from which to start the sweep, orNULLif you don't care and want to start at the top. π«Ά but if you do decide to definekey1, make sure it is a top level node of a subtree. this is done withdbh_find.key2β the key which will trigger an exit condition, orNULLif you don't care and want to continue until the end of theDBHashTable.ignore_portionβ lets you define the ignored trailing bytes ofkey1, which will define the size of the subtree to be sweeped, or zero if you don't care and want to process all branches.
and in all of these functions, operate β which is void (*operate) (DBHashTable *dbh) β is the function to apply to each selected member of the DBHashTable. yes, a function pointer. yes, you're a real programmer now. π
dbh_exit_sweep and dbh_exit_fanout, when called within the operate function, will cause the exit of a currently running sweep or fanout. it's the "okay we're done here" button. π
β RETURN VALUE β
0 on error, 1 otherwise.
that's it. that's the whole thing. binary. iconic. π
π NOTES π
listen. listen. in order for sweep/fanout functions to be extremely fast, you should prepare the DBHashTable for the trajectory you intend to use with dbh_regen_sweep or dbh_regen_fanout first. do this and you get extremely efficient use of hardware and operating system caches. that's the whole point. no cap. π₯
bestie the performance difference is real, do the regen first, your caches will thank you π«Ά
π SEE ALSO π
dbh (0)dbh_regen_sweep (3)dbh_regen_fanout (3)dbh_find (3)dbh_settempdir (3)
πΈ Author πΈ
Edscott Wilson Garcia <edscott@xfce.org>
and that's the tea, bestie π this page is from the DBHashTables manual, DBH section, page dbh_sweep(3) β go forth and sweep, and remember: vertical for sweep, horizontal for fanout, and always regen first. mwah ππ§β¨
π¦ where this page comes from
- fedora 43: dbh-devel 1:5.0.16-24.fc43 Β· GPL-3.0-or-later
- fedora 43: dbh-devel 1:5.0.16-24.fc43 Β· GPL-3.0-or-later
- fedora 43: dbh-devel 1:5.0.22-1.fc43 Β· GPL-3.0-or-later
- fedora 43: dbh-devel 1:5.0.22-1.fc43 Β· GPL-3.0-or-later
- fedora 44: dbh-devel 1:5.0.22-3.fc44 Β· GPL-3.0-or-later
- fedora 44: dbh-devel 1:5.0.22-3.fc44 Β· GPL-3.0-or-later
- Copyright (c) 2010 Edscott Wilson Garcia (edscott@xfce.org)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms