Discussion:
[SR-Users] Creating array out of hashtable
aft
2014-09-08 08:50:57 UTC
Permalink
[1]Is it possible to iterate a htable without using "keys" like an array?


[2] Is it possible to search for "keys" using regxp?
--
-Cheers
-Arif
Daniel-Constantin Mierla
2014-09-08 09:38:39 UTC
Permalink
Hello,
Post by aft
[1]Is it possible to iterate a htable without using "keys" like an array?
there is no possibility to iterate the hash table from configuration
file. The structure is stored in memory, with locks per slots, to be
optimized for parallel processing.

For a consistent iteration, the lock has to be at hash table level,
which will impact the performances a lot.

An alternative would be to add iteration still using the locks on slots,
but that means new items can be added/removed/updated in other slots
while walking on a slot. So it is not like taking a snapshot of hash
table content at a specific time.

Also, maybe you can provide more details about what you need to achieve,
there could be other options to try.
Post by aft
[2] Is it possible to search for "keys" using regxp?
It is possible to count items by regular expression matching on key or
value, see:

-
http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#shtcn_htable_exp

As well as deleting items:

-
http://kamailio.org/docs/modules/stable/modules/htable.html#htable.f.sht_rm_name_re

Cheers,
Daniel
aft
2014-09-09 08:20:29 UTC
Permalink
Thanks for the reply. It was very helpful.

On Mon, Sep 8, 2014 at 3:38 PM, Daniel-Constantin Mierla
Post by Daniel-Constantin Mierla
Hello,
Post by aft
[1]Is it possible to iterate a htable without using "keys" like an array?
there is no possibility to iterate the hash table from configuration file.
The structure is stored in memory, with locks per slots, to be optimized for
parallel processing.
For a consistent iteration, the lock has to be at hash table level, which
will impact the performances a lot.
An alternative would be to add iteration still using the locks on slots, but
that means new items can be added/removed/updated in other slots while
walking on a slot. So it is not like taking a snapshot of hash table content
at a specific time.
Also, maybe you can provide more details about what you need to achieve,
there could be other options to try.
Post by aft
[2] Is it possible to search for "keys" using regxp?
It is possible to count items by regular expression matching on key or
-
http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#shtcn_htable_exp
-
http://kamailio.org/docs/modules/stable/modules/htable.html#htable.f.sht_rm_name_re
Cheers,
Daniel
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
-Cheers
-Arif
Continue reading on narkive:
Loading...