Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patricia foreach with prefix #22

Open
aji opened this issue Jan 2, 2014 · 0 comments
Open

patricia foreach with prefix #22

aji opened this issue Jan 2, 2014 · 0 comments

Comments

@aji
Copy link
Contributor

aji commented Jan 2, 2014

The ability to iterate over the values in a patricia whose keys begin with a certain prefix is a very valuable feature, especially if the number of elements with that prefix is much smaller than the number of elements in the patricia as a whole. The structure of a patricia lends itself nicely to this sort of operation.

ircd-micro was recently ported to libmowgli. As part of this port, all uses of micro's trie were replaced with mowgli patricias. micro's trie had the above feature, and it was used when iterating over the users on a particular server. This could be done by iterating over users_by_uid with the server's SID as the prefix. After the port, this was accomplished by iterating over users_by_uid and performing strncmp, which is slightly slower (but not slow enough to be a big deal at this point, really).

Another practical application of such a feature would be Atheme metadata. Object metadata in Atheme is often namespaced with colons, such as "private:userhost" or "private:closer". Being able to iterate over only pairs starting with "private:" or "private:userhost:" would be a useful capability. It wouldn't be much of a speedup, but would result in clearer code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant