Talk:LlLinksetDataListKeys
In which order are the key/value pairs stored?
Usually, KVP implementations, even those allowing some form of key transversal, never guarantee a specific 'order', just that all keys will be retrieved; two successive runs of the key transversal may or may not return the same keys in the same order, merely because there might have been automatic garbage collection or other optimisation techniques running in the background which might have reordered the keys.
These LSL functions, however, seem to presume that the KVP store has an implicit order — or else, speaking of the 'first' element in the store would not make sense. It would be just 'a' element, not 'the first'.
This is just important for those applications which might just retrieve a batch at a time (or even just one KVP!) for processing — and will need to know if they can rely on these LSL function calls to guarantee that with each successive llLinksetDataListKeys call, a different key will be retrieved, possibly in the same order, until the 'last' key is retrieved. This implies that abstract concepts such as 'first', 'next', 'previous', 'first' and 'last' element in the KVP store are not arbitrary, but that subsequently, such calls will correctly retrieve all the key/value pairs in the order they are internally stored.
I haven't toyed & tinkered enough to answer myself, so I'm wondering if anyone has made some more testing on this specific issue...
— Gwyneth Llewelyn (talk) 13:47, 11 December 2022 (PST)
- In my testing, llLinksetDataListKeys returns keys in alphabetical order, whereas llLinksetDataFindKeys with the regex "^.*$" (should return all pairs) does not. But either way, it seems that when the datastore has not been modified, the ordering will always stay the same. When a key is added, it seems to be added randomly into the order as shown using llLinksetDataFindKeys. Removing keys does not re-order anything. Modifying values also does not seem to change the order. But when writing the same sequence of pairs on a newly-reset datastore, it sometimes comes out with the same ordering, sometimes not, when read using llLinksetDataFindKeys. So there is definitely some strange hashing going on in the backend. - Nelson Jenkins (talk) 21:27, 14 January 2023 (PST)