What's the best way to store multi-dimensional data within an htable? For example, storing an avp stack:
$avp(foo) = "first"; $avp(foo) = "second";
$sht(bar=>foo) = $avp(foo);
The result of which is that only $avp(foo[0]) is stored in the htable:
kamcmd htable.dump bar { entry: 2 size: 1 slot: { { name: bar value: second type: str } } }
The htable documentation shows support for lists, but it doesn't make clear if this is really usable outside of loading from a database, and looks like it's short hand for managing/creating linked lists. The other option would be to simply serialize the data before storing it in the htable - which is fine, I just want to be sure I'm not overlooking a more convenient method.
Regards, Kaufman
Hello,
just to add one possible option, there is a small module "matrix" that provides a data structure that might be handy in this case.
https://www.kamailio.org/docs/modules/devel/modules/matrix.html
Of course it can be also done by serializing the data in a htable or similar.
Cheers,
Henning
From: Ben Kaufman bkaufman@bcmone.com Sent: Sonntag, 17. September 2023 17:39 To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] Multi-dimensional data in htable
What's the best way to store multi-dimensional data within an htable? For example, storing an avp stack:
$avp(foo) = "first"; $avp(foo) = "second";
$sht(bar=>foo) = $avp(foo); The result of which is that only $avp(foo[0]) is stored in the htable:
kamcmd htable.dump bar { entry: 2 size: 1 slot: { { name: bar value: second type: str } } }
The htable documentation shows support for lists, but it doesn't make clear if this is really usable outside of loading from a database, and looks like it's short hand for managing/creating linked lists. The other option would be to simply serialize the data before storing it in the htable - which is fine, I just want to be sure I'm not overlooking a more convenient method.
Regards, Kaufman
Why not just use a hash and separate fields by ; ? You can then just join or split as you set or get?
On Fri, 22 Sep 2023 at 08:20, Ben Kaufman via sr-users < sr-users@lists.kamailio.org> wrote:
Thank you. I’ll look into that!
Kaufman __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
I have extensively invented this kind of serialisation scheme over the years, and it's just very tedious. Turn-key nonscalar support would be a lot easier.
On Sep 22, 2023, at 12:16 PM, David Villasmil via sr-users sr-users@lists.kamailio.org wrote:
Why not just use a hash and separate fields by ; ? You can then just join or split as you set or get?
On Fri, 22 Sep 2023 at 08:20, Ben Kaufman via sr-users sr-users@lists.kamailio.org wrote: Thank you. I’ll look into that! Kaufman __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
I was just checking to make sure that there wasn't an easy and obvious solution I was overlooking.
Depending on the depth of the data I can use xavp_implode() or jansson. The structures I'm working with should be predictable enough to do this. I think the "solution to simplify serialization" long term is probably using KEMI, whereby the more robust scripting languages have better functionality for that sort of thing.
-----Original Message----- From: Alex Balashov via sr-users sr-users@lists.kamailio.org Sent: Friday, September 22, 2023 12:18 PM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Alex Balashov abalashov@evaristesys.com Subject: [SR-Users] Re: Multi-dimensional data in htable
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
I have extensively invented this kind of serialisation scheme over the years, and it's just very tedious. Turn-key nonscalar support would be a lot easier.
On Sep 22, 2023, at 12:16 PM, David Villasmil via sr-users sr-users@lists.kamailio.org wrote:
Why not just use a hash and separate fields by ; ? You can then just join or split as you set or get?
On Fri, 22 Sep 2023 at 08:20, Ben Kaufman via sr-users sr-users@lists.kamailio.org wrote: Thank you. I'll look into that! Kaufman __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
-- Alex Balashov Principal Consultant Evariste Systems LLC Web: https://evaristesys.com/ Tel: +1-706-510-6800
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: