Module: sip-router Branch: master Commit: 427e4c0f5f8dd8665a5484e724154921a2b896b5 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=427e4c0f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Oct 1 16:51:56 2010 +0200
mtree: option to ignore duplicates
- when testing with lot of data generated randomnly (usage and performance profiling) there might be duplicates that can be ignored
---
modules/mtree/README | 19 +++++++++++++++++-- modules/mtree/doc/mtree_admin.xml | 20 ++++++++++++++++++++ modules/mtree/mtree.c | 3 +++ modules/mtree/mtree_mod.c | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/modules/mtree/README b/modules/mtree/README index 7aaa4fd..6391512 100644 --- a/modules/mtree/README +++ b/modules/mtree/README @@ -35,6 +35,7 @@ Daniel-Constantin Mierla 3.8. char_list (string) 3.9. pv_value (string) 3.10. mt_tree_type (integer) + 3.11. mt_ignore_duplicates (integer)
4. Exported Functions
@@ -58,7 +59,8 @@ Daniel-Constantin Mierla 1.8. Set char_list parameter 1.9. Set pv_value parameter 1.10. Set mt_tree_type parameter - 1.11. mt_match usage + 1.11. Set mt_ignore_duplicates parameter + 1.12. mt_match usage
Chapter 1. Admin Guide
@@ -82,6 +84,7 @@ Chapter 1. Admin Guide 3.8. char_list (string) 3.9. pv_value (string) 3.10. mt_tree_type (integer) + 3.11. mt_ignore_duplicates (integer)
4. Exported Functions
@@ -126,6 +129,7 @@ Chapter 1. Admin Guide 3.8. char_list (string) 3.9. pv_value (string) 3.10. mt_tree_type (integer) + 3.11. mt_ignore_duplicates (integer)
3.1. db_url (string)
@@ -239,6 +243,17 @@ modparam("mtree", "pv_value", "$var(mtval)") modparam("mtree", "mt_tree_type", 1) ...
+3.11. mt_ignore_duplicates (integer) + + Ignore duplicated prefixes when loading data. + + Default value is 0. + + Example 1.11. Set mt_ignore_duplicates parameter +... +modparam("mtree", "mt_ignore_duplicates", 1) +... + 4. Exported Functions
4.1. mt_match(mtree, pv, mode) @@ -248,7 +263,7 @@ modparam("mtree", "mt_tree_type", 1) Match 'pv' value against mtree. mode is reserved for further use, now set any integer or PV.
- Example 1.11. mt_match usage + Example 1.12. mt_match usage ... mt_match("mytree", "$rU", "0"); ... diff --git a/modules/mtree/doc/mtree_admin.xml b/modules/mtree/doc/mtree_admin.xml index 64e4c00..fd471a1 100644 --- a/modules/mtree/doc/mtree_admin.xml +++ b/modules/mtree/doc/mtree_admin.xml @@ -255,6 +255,26 @@ modparam("mtree", "mt_tree_type", 1) </example> </section>
+ <section> + <title><varname>mt_ignore_duplicates</varname> (integer)</title> + <para> + Ignore duplicated prefixes when loading data. + </para> + <para> + <emphasis> + Default value is 0. + </emphasis> + </para> + <example> + <title>Set <varname>mt_ignore_duplicates</varname> parameter</title> + <programlisting format="linespecific"> +... +modparam("mtree", "mt_ignore_duplicates", 1) +... +</programlisting> + </example> + </section> + </section> <section> diff --git a/modules/mtree/mtree.c b/modules/mtree/mtree.c index 84a798d..3678040 100644 --- a/modules/mtree/mtree.c +++ b/modules/mtree/mtree.c @@ -43,6 +43,7 @@ extern pv_spec_t pv_value; extern pv_spec_t pv_dstid; extern pv_spec_t pv_weight; extern int _mt_tree_type; +extern int _mt_ignore_duplicates;
/** structures containing prefix-value pairs */ static m_tree_t **_ptree = NULL; @@ -207,6 +208,8 @@ int mt_add_to_tree(m_tree_t *pt, str *sp, str *sv) sp->len, sp->s, sv->len, sv->s, itn0[_mt_char_table[(unsigned int)sp->s[l]]].tvalue.len, itn0[_mt_char_table[(unsigned int)sp->s[l]]].tvalue.s); + if(_mt_ignore_duplicates!=0) + return 1; return -1; }
diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c index e89987a..aeb98ad 100644 --- a/modules/mtree/mtree_mod.c +++ b/modules/mtree/mtree_mod.c @@ -90,6 +90,7 @@ pv_spec_t pv_dstid; pv_spec_t pv_weight; pv_spec_t pv_count; int _mt_tree_type = MT_TREE_SVAL; +int _mt_ignore_duplicates = 0;
/* lock, ref counter and flag used for reloading the date */ static gen_lock_t *mt_lock = 0; @@ -136,6 +137,7 @@ static param_export_t params[]={ {"pv_weight", STR_PARAM, &weight_param.s}, {"pv_count", STR_PARAM, &count_param.s}, {"mt_tree_type", INT_PARAM, &_mt_tree_type}, + {"mt_ignore_duplicates", INT_PARAM, &_mt_ignore_duplicates}, {0, 0, 0} };