Browse Source

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
Daniel-Constantin Mierla 15 years ago
parent
commit
427e4c0f5f
4 changed files with 42 additions and 2 deletions
  1. 17 2
      modules/mtree/README
  2. 20 0
      modules/mtree/doc/mtree_admin.xml
  3. 3 0
      modules/mtree/mtree.c
  4. 2 0
      modules/mtree/mtree_mod.c

+ 17 - 2
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");
 ...

+ 20 - 0
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>

+ 3 - 0
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;
 	}
 

+ 2 - 0
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}
 };