Jump to content

In what order are LinksetData keys stored?


jak Scribe
 Share

You are about to reply to a thread that has been inactive for 345 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I know this question should have a simple answer: such as "Alphabetical Order"

I am storing Textures, including the attributes for Rotations and Animations, in LSD:

Example LSD Keys stored in this order:: (The ║ is my seperator)

Static║00_girl

Static║00_stars

Static║00_universe

Static║99_number 7

Static║99_number 9

llLinksetDataWrite( groupname+SEPERATOR+texturename, texturename );

Later I do this:

Pictures = llLinksetDataFindKeys( "^"+groupname, 0,0 );

llOwnerSay(llList2CSV(Pictures));  I get this:

Static║99_number 9, Static║99_number 7, Static║00_universe, Static║00_stars, Static║00_girl

It seems to be returning the keys are being given out in the reverse order to the way they were stored?

Any reason why?

 

 

 

Link to comment
Share on other sites

Quote from the Wiki:

Quote

The llLinksetDataFindKeys function returns a list of up to count keys from the datastore that match pattern, starting at the one indicated by start. If count is less than 1, then all keys between start and the end which match pattern are returned. If count minus start exceeds the number of matching keys, the returned list will be shorter than count, down to a zero-length list if start equals or exceeds the number of matching keys.

I noticed you are using "0" for Count.  I use "-1" and they come back for me in the normal sorting order.

Perhaps try using "-1" for count.  

The quote above is a bit um.."opaque" but, could passing "0,0" cause the list to come back in reverse order?

To be honest, I have done a LOT of LSD programming now. However, I only use "0, -1" for the last 2 parameters on llLinksetDataFindKeys().

Link to comment
Share on other sites

Reading your Answer suddenly sounded so logical, and I always use -1 in most functions needing a start and end, so I tried it as I was shaking my head at myself. 🤪

 

But...  Pictures = llLinksetDataFindKeys( "^"+groupname, 0, -1 ); brought trhe same result as the 0,0 example.

I went back and read the LinksetData wiki, but it is not very clearly described:

"If count is less than 1, then all keys between start and the end are returned"

Sadly there is no mention about the order.

I have solved it using

Pictures = llListSort( llLinksetDataFindKeys( "^"+groupname, 0,0 ), 1, TRUE);

but am still curious about it.

 

Thank You 🙂

 

Link to comment
Share on other sites

dunno, i seem to be seeing alphabetical?

tried this....

default
{
    state_entry()
    {  llLinksetDataReset( );
       llLinksetDataWrite("test-1", "See you 1 the other side!");
       llLinksetDataWrite("test-2", "See you 2 the other side!");
       llLinksetDataWrite("test-3", "See you 3 the other side!");
       llLinksetDataWrite("alpha test-4", "See you 4 the other side!");
       
       llLinksetDataWrite("a Static║00_girl", " ");     
       llLinksetDataWrite("b Static║00_stars", " ");
       llLinksetDataWrite("c Static║00_universe", " ");
       llLinksetDataWrite("d Static║99_number", "7");
       llLinksetDataWrite("e Static║99_number", "9");      
    }
    touch_start(integer total_number)
    {  list keys  = llLinksetDataListKeys( 0, -1 );
       string tmp = llDumpList2String( keys,"\n");
       llOwnerSay(" list\n" + tmp);
    }
}

and got this ...

[16:45] Object:  list


a Static║00_girl
alpha test-4
b Static║00_stars
c Static║00_universe
d Static║99_number
e Static║99_number
test-1
test-2
test-3

Link to comment
Share on other sites

Of the LinksetData functions, ListKeys will sort the list returned, but FindKeys will not.

This is specifically mentioned in the llLinksetDataFindKeys wiki page on the caveats section:

Quote
  • Unlike llLinksetDataListKeys, the order of the returned list is neither usefully sorted nor predictable.
    • The order of keys returned is the same through successive calls, even if pattern has changed. However, when a new key-value pair is added, it is added essentially randomly in the order.
    • Writing the same sequence of key-value pairs after successive calls to llLinksetDataReset or in different linksets occasionally results in the same ordering. However, this behavior is by no means guaranteed and should not be relied upon.

You can see this by running the following code, comment/uncomment the function you wish to see in action.

default
{
    state_entry()
    {
        llLinksetDataReset( );
        llLinksetDataWrite("Static║00_girl", " ");     
        llLinksetDataWrite("Static║00_stars", " ");
        llLinksetDataWrite("Static║00_universe", " ");
        llLinksetDataWrite("Static║99_number 7", " ");
        llLinksetDataWrite("Static║99_number 9", " "); 
        
        //list Pictures = llLinksetDataFindKeys( "^Static", 0,-1 );
        list Pictures = llLinksetDataListKeys(0,-1);
        llOwnerSay(llList2CSV(Pictures));
    }
}

//FindKeys returns: Static║99_number 7, Static║00_universe, Static║00_stars, Static║99_number 9, Static║00_girl
//ListKeys returns: Static║00_girl, Static║00_stars, Static║00_universe, Static║99_number 7, Static║99_number 9

 

This sort discrepancy may be changed in the future, if BUG-232895 is implemented.

  • Thanks 1
Link to comment
Share on other sites

Ahah! I am not using FindKeys() to actually display the result the same way as you, so I was completely wrong. Sorry!

I must be only using ListKeys() to "display" a result.

I forgot that I am only FindKeys() for certain processing - not for "all" processing.  I am mostly using it only to "delete" a range of keys for now.

Sorry about that, but it gives me a nice heads-up for when I start to use if more soon!

Edited to add: Boy, giving a wrong answer when you think you know what you're talking about, sure makes one feel like a dope! LOL!

Edited by Love Zhaoying
  • Like 1
Link to comment
Share on other sites

3 hours ago, Fenix Eldritch said:

This sort discrepancy may be changed in the future, if BUG-232895 is implemented.

ATM, this is implemented on Blue Steel regions running server version 2023-02-02.578100.

LSDFindKeys() will now sort alphanumerically before index input handling, just like LSDListKeys.

LL allegedly will slow roll this code, so it will hopefully be grid-wide by March 7th.

Link to comment
Share on other sites

  • 1 month later...
On 2/16/2023 at 12:15 AM, Lucia Nightfire said:
On 2/15/2023 at 8:23 PM, Fenix Eldritch said:

This sort discrepancy may be changed in the future, if BUG-232895 is implemented.

ATM, this is implemented on Blue Steel regions running server version 2023-02-02.578100.

LSDFindKeys() will now sort alphanumerically before index input handling, just like LSDListKeys.

LL allegedly will slow roll this code, so it will hopefully be grid-wide by March 7th.

Checking back, do we know if the sorting ever got sorted out with llLinksetDataFindKeys()?

The Wiki still says, "Unlike llLinksetDataListKeys, the order of the returned list is neither usefully sorted nor predictable.".

Link to comment
Share on other sites

For what I noticed actually after testing, the alphanumerical sorting for llLinsetDataFindKeys is a little bit weird.  The index sort in priority the "+" and "-" respectively, then the numbers from 0 to 9, then special character except plus and minus, and as last A to Z.

After write these keys name in LSD in random order, the command FindKeys return:

0 = +123Av
1 = -123Av
2 = 123Av
3 = 123Az
4 = ?Av
5 = Av

Edited by Avalon Criss
content correction
Link to comment
Share on other sites

5 hours ago, Love Zhaoying said:

Checking back, do we know if the sorting ever got sorted out with llLinksetDataFindKeys()?

The Wiki still says, "Unlike llLinksetDataListKeys, the order of the returned list is neither usefully sorted nor predictable.".

Pushed to some of the RC channels last Wednesday (5, April), server version "2023-03-24.579022".  As I understand it with this server version, the FindKeys function will now sort alpha-numerically before returning the find results.

Correction, I misread the deploy plans.  579022 looks to be pushed to all channels, and there is a special to some RC channels

but yes, using the sample script, output is

Quote

[12:30] Object: Static║00_girl, Static║00_stars, Static║00_universe, Static║99_number 7, Static║99_number 9

 

Edited by Anna Salyx
  • Thanks 1
Link to comment
Share on other sites

48 minutes ago, Anna Salyx said:

Pushed to some of the RC channels last Wednesday (5, April), server version "2023-03-24.579022".  As I understand it with this server version, the FindKeys function will now sort alpha-numerically before returning the find results.

Correction, I misread the deploy plans.  579022 looks to be pushed to all channels, and there is a special to some RC channels

but yes, using the sample script, output is

 

Thanks, I saw a post about the increase to 128k but missed this one. Meanwhile, I realized that I should change my approach so still don't need it..yet!

My use-case was to be "XX,100", "XX,200" etc. but due to other issues I'll be using "XX,0", "XX,1" and storing the "100" and "200" as data elements.  Much simpler. 

Edited by Love Zhaoying
Link to comment
Share on other sites

I'm also intrested in clarify this. I tried many characters for testing the actual sorting:

default
{
    state_entry()
    {
        llLinksetDataReset( );
        llLinksetDataWrite("Z Static", " ");     
        llLinksetDataWrite("A Static", " ");
        llLinksetDataWrite("a Static", " ");
        llLinksetDataWrite("1 Static", " ");
        llLinksetDataWrite("9 Static", " ");
        llLinksetDataWrite("8 Static", " ");
        llLinksetDataWrite("% Static", " ");
        llLinksetDataWrite("/ Static", " ");     
        llLinksetDataWrite("- Static", " ");
        llLinksetDataWrite("* Static", " ");
        llLinksetDataWrite("< Static", " ");
        llLinksetDataWrite("? Static", " ");
        llLinksetDataWrite("_ Static", " ");
        llLinksetDataWrite("+ Static", " ");
        llLinksetDataWrite(". Static", " ");
        llLinksetDataWrite(", Static", " ");
        llLinksetDataWrite("§ Static", " ");
        llLinksetDataWrite("& Static", " ");
        llLinksetDataWrite("$ Static", " ");
        llLinksetDataWrite("€ Static", " ");
        llLinksetDataWrite("= Static", " ");
        llLinksetDataWrite("# Static", " ");
        
        list Pictures = llLinksetDataFindKeys("Static", 0,-1 );
//        list Pictures = llLinksetDataListKeys(0,-1);

        llOwnerSay(llList2CSV(Pictures));
    }
}

The output for llLinksetDataFindKeys is:

# Static, $ Static, % Static, & Static, * Static, + Static, , Static, - Static, . Static, / Static, 1 Static, 8 Static, 9 Static, < Static, = Static, ? Static, A Static, Z Static, _ Static, a Static, § Static, € Static

which is actually the same for _ListKeys.

Also I thought the priority over number was only for math symbols, but it seems some others special characters have same prevalence. Anyone know what is the difference from characters of the group sorted at the beginning compared to others sorted at the ending?

Link to comment
Share on other sites

19 minutes ago, Avalon Criss said:

Also I thought the priority over number was only for math symbols, but it seems some others special characters have same prevalence. Anyone know what is the difference from characters of the group sorted at the beginning compared to others sorted at the ending?

Alphabetical sorting usually follows ASCII order (and a similar order for UTF extended characters), which is what you see in your output. The same applies to inventory sorting, for example.

As to why someone back in the day decided that should be the other of those characters... 🤷

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
You are about to reply to a thread that has been inactive for 345 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...