Page 1 of 1

Using Dynamic Dictionaries

Posted: Wed Dec 10, 2014 11:26 pm
by M45HY
Hi guys,

I'm trying to use Dynamic Dictionaries and I have never used them previously so I was doing some research on them including looking at the JADE Manual (https://secure.jadeworld.com/downloads/ ... ng.String)).

According to the JADE Manual, it states that Dynamic Dictionaries do not allow persistence, nor do they offer a facility to sort objects not entirely based on a comparison of embedded attribute values; for example, the ability for you to provide your own sort compare routine is not supported. I was slightly confused here; I noticed that the addMemberKey() function requires a property value and two boolean values for sort descending and case insensitive. If the sort descending is false, does that mean that when records are added to the DynaDictionary, they will go in Ascending order or do I have key in true for descending order and then iterate backwards?

Thanks

Omash

Re: Using Dynamic Dictionaries

Posted: Thu Dec 11, 2014 2:47 am
by ghosttie
If you use addExternalKey you can sort the items by something that isn't an embedded attribute, but you're correct that you can't provide your own sort routine.

Sort descending just sets whether the items are sorted in ascending or descending key order: if you added items with keys 2, 1 and 3 and sort descending was false they'd be sorted as 1, 2, 3 whereas if sort descending was true they'd be 3, 2, 1.

Re: Using Dynamic Dictionaries

Posted: Thu Dec 11, 2014 7:34 am
by BeeJay
Hi guys,

I'm trying to use Dynamic Dictionaries and I have never used them previously so I was doing some research on them including looking at the JADE Manual (https://secure.jadeworld.com/downloads/ ... ng.String)).
Are you actually using another language to access your Jade database? If not, and you're writing Jade method logic, then you may find the standard Jade Help more useful:

https://www.jadeworld.com/docs/jade-701 ... _class.htm
According to the JADE Manual, it states that Dynamic Dictionaries do not allow persistence
In the original implementation of DynaDicts that was the case, but in later Jade releases you can now persist dynamic dictionaries. I'm not sure in exactly which Jade release this changed.
nor do they offer a facility to sort objects not entirely based on a comparison of embedded attribute values; for example, the ability for you to provide your own sort compare routine is not supported. I was slightly confused here;
This simply means you can't write your own 'compare' routine and supply it for the DynaDict to use to decide where in the dictionary that entry should be placed.
I noticed that the addMemberKey() function requires a property value and two boolean values for sort descending and case insensitive. If the sort descending is false, does that mean that when records are added to the DynaDictionary, they will go in Ascending order or do I have key in true for descending order and then iterate backwards?
As ghosttie already said, if you don't set the 'descending' parameter to true then the DynaDict will sort in ascending order.
If you use addExternalKey you can sort the items by something that isn't an embedded attribute, but you're correct that you can't provide your own sort routine.
While not directly a sort routine as such, because you choose the 'key value' when coding the DynaDict::putAtKey logic, for a DynaDict created using DynaDict::addExternalKey, you can simulate your own sort routine within the confines of the standard DynaDict sorting algorithms. :)

Cheers,
BeeJay.

Re: Using Dynamic Dictionaries

Posted: Fri Dec 12, 2014 10:53 pm
by M45HY
Thanks Guys,

This helped a lot; I believe I'm on the verge of cracking it, thanks.

Cheers,
Omash