Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does. Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, sr-users-request@lists.sip-router.orgwrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88=AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com
Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?
Hello,
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does.
for hash tables in config, the alternative is using htable module. Then the selection is done on exact match, no prefix matching. mtree is suitable for storing keys that are composed from a limited set of characters (like numbers, 0-9 digits only), otherwise becomes too memory consuming. For keys that are composed from any character and need exact match, hash table structures are more suitable, no matter if it is via htable module or something else like redis.
Cheers, Daniel
Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, <sr-users-request@lists.sip-router.org mailto:sr-users-request@lists.sip-router.org> wrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org <mailto:sr-users-request@lists.sip-router.org> You can reach the person managing the list at sr-users-owner@lists.sip-router.org <mailto:sr-users-owner@lists.sip-router.org> When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..." Today's Topics: 1. how to match exact string value in mtree (Uri Shacked) ---------------------------------------------------------------------- Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked <ushacked@gmail.com <mailto:ushacked@gmail.com>> Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" <sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org>> Message-ID: <CAMMbDhTFNXAE-K88=AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com <mailto:AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com>> Content-Type: text/plain; charset="iso-8859-1" Hi, I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this: modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)") The thing is, that i tried all: if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0")) and lets say i have the both prefix in the nts mtree: 09555 09555333 And the prefix i search for is $avp(DID)=09555444 I allwasy get the 09555 because it is the longest match. I need exact match..... how do i do that?
thanks, i use the mtree module for about 5 million records.... does htable able to handle it as well?
On Fri, Feb 17, 2012 at 10:18 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does.
for hash tables in config, the alternative is using htable module. Then the selection is done on exact match, no prefix matching. mtree is suitable for storing keys that are composed from a limited set of characters (like numbers, 0-9 digits only), otherwise becomes too memory consuming. For keys that are composed from any character and need exact match, hash table structures are more suitable, no matter if it is via htable module or something else like redis.
Cheers, Daniel
Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, sr-users-request@lists.sip-router.orgwrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88= AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?
hi,
what do you think about the Dialplan module? it can probably do the trick as well...
cheers,
On Fri, Feb 17, 2012 at 10:18 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does.
for hash tables in config, the alternative is using htable module. Then the selection is done on exact match, no prefix matching. mtree is suitable for storing keys that are composed from a limited set of characters (like numbers, 0-9 digits only), otherwise becomes too memory consuming. For keys that are composed from any character and need exact match, hash table structures are more suitable, no matter if it is via htable module or something else like redis.
Cheers, Daniel
Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, sr-users-request@lists.sip-router.orgwrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88= AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?
Hi
Maybe I didn't understand your scenario, but I don't see how to do it with the dialplan module. Let's say you have two entries in your dialplan table: 09555333 (this should go first) 09555* If your string is 09555444 you will still get the second entry....
Regards
Javi
On Fri, Feb 17, 2012 at 3:11 PM, Uri Shacked ushacked@gmail.com wrote:
hi,
what do you think about the Dialplan module? it can probably do the trick as well...
cheers,
On Fri, Feb 17, 2012 at 10:18 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does.
for hash tables in config, the alternative is using htable module. Then the selection is done on exact match, no prefix matching. mtree is suitable for storing keys that are composed from a limited set of characters (like numbers, 0-9 digits only), otherwise becomes too memory consuming. For keys that are composed from any character and need exact match, hash table structures are more suitable, no matter if it is via htable module or something else like redis.
Cheers, Daniel
Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, sr-users-request@lists.sip-router.orgwrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88= AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?
i think that if i set the match_op in the dialplan table to 0, it will only find the exact match...
On Fri, Feb 17, 2012 at 4:22 PM, Javier Gallart jgallartm@gmail.com wrote:
Hi
Maybe I didn't understand your scenario, but I don't see how to do it with the dialplan module. Let's say you have two entries in your dialplan table: 09555333 (this should go first) 09555* If your string is 09555444 you will still get the second entry....
Regards
Javi
On Fri, Feb 17, 2012 at 3:11 PM, Uri Shacked ushacked@gmail.com wrote:
hi,
what do you think about the Dialplan module? it can probably do the trick as well...
cheers,
On Fri, Feb 17, 2012 at 10:18 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does.
for hash tables in config, the alternative is using htable module. Then the selection is done on exact match, no prefix matching. mtree is suitable for storing keys that are composed from a limited set of characters (like numbers, 0-9 digits only), otherwise becomes too memory consuming. For keys that are composed from any character and need exact match, hash table structures are more suitable, no matter if it is via htable module or something else like redis.
Cheers, Daniel
Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, <sr-users-request@lists.sip-router.org
wrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88= AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?
Hello Javier,
one question about redis, can it do longest prefix matching or all prefixes match?
Cheers, Daniel
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does. Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, <sr-users-request@lists.sip-router.org mailto:sr-users-request@lists.sip-router.org> wrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org <mailto:sr-users-request@lists.sip-router.org> You can reach the person managing the list at sr-users-owner@lists.sip-router.org <mailto:sr-users-owner@lists.sip-router.org> When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..." Today's Topics: 1. how to match exact string value in mtree (Uri Shacked) ---------------------------------------------------------------------- Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked <ushacked@gmail.com <mailto:ushacked@gmail.com>> Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" <sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org>> Message-ID: <CAMMbDhTFNXAE-K88=AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com <mailto:AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com>> Content-Type: text/plain; charset="iso-8859-1" Hi, I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this: modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)") The thing is, that i tried all: if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0")) and lets say i have the both prefix in the nts mtree: 09555 09555333 And the prefix i search for is $avp(DID)=09555444 I allwasy get the 09555 because it is the longest match. I need exact match..... how do i do that?
Hi Daniel,
no, in order to find the best match we do a manual trick using the s.prefixes transformation (I think you suggested that). We start with the full number and stop when we find a non-null value. This kamailio is serving many thousands of calls per hour, and the response time is pretty much the same as when we used the mtree module. For us , using redis has the advantage of being able to load the tree data faster than when we used postgres without the need to perform a mtree reload.
Regards
Javi
On Fri, Feb 17, 2012 at 10:25 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello Javier,
one question about redis, can it do longest prefix matching or all prefixes match?
Cheers, Daniel
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis module more suited for that type of task. Instead of a tree you have a hash like this: tname tprefix tvalue. If you do a hget nts $avp(DID) and you get a not null value you have found your exact match. It works very well for me and the time it takes for that "query" is barely noticeable. Of course redis does not address items like persistence, etc the same way a rdbms does. Hope it helps.
Regards
Javi
On Thu, Feb 16, 2012 at 12:00 PM, sr-users-request@lists.sip-router.orgwrote:
Send sr-users mailing list submissions to sr-users@lists.sip-router.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users or, via email, send a message with subject or body 'help' to sr-users-request@lists.sip-router.org
You can reach the person managing the list at sr-users-owner@lists.sip-router.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of sr-users digest..."
Today's Topics:
- how to match exact string value in mtree (Uri Shacked)
Message: 1 Date: Thu, 16 Feb 2012 12:54:50 +0200 From: Uri Shacked ushacked@gmail.com Subject: [SR-Users] how to match exact string value in mtree To: "SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List" sr-users@lists.sip-router.org Message-ID: <CAMMbDhTFNXAE-K88= AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some of them starts with 0 or characters like D for example. so, the mtree param is like this:
modparam("mtree", "db_url", CFGDB) modparam("mtree", "mtree", "name=nts;dbtable=service_numbers_view;type=0;") modpmodparam("mtree", "char_list", "0123456789*+#YMDabcdefgh") modparam("mtree", "pv_value", "$avp(mtval)") modparam("mtree", "pv_values", "$avp(mtvals)")
The thing is, that i tried all:
if(!mt_match("nts", "$avp(DID)","1")) if(!mt_match("nts", "$avp(DID)","2")) if(!mt_match("nts", "$avp(DID)","0"))
and lets say i have the both prefix in the nts mtree: 09555 09555333
And the prefix i search for is $avp(DID)=09555444
I allwasy get the 09555 because it is the longest match. I need exact match.....
how do i do that?