Closed busslina closed 10 months ago
Do you get the DuplicateKeyException
with the default keys or with the custom keys?
Using an int key would not work, as the keys are used to compute the path, so any Key, will need to have a toString()
override.
If its an issue with the default implementation, then rather then using the UniqueKey, I can update it to use a UUID instead.
You can test your code by using one the of UUID, let me if it resolves the issue for you.
I looked into this issue, and apparently, if the child count is more than 10,000, then the duplicate keys started to appear at a rate of 0.3-0.4%. I have replaced the UniqueKey
with Uuid
for generating the keys, and now the issue has been resolved.
There are no duplicate keys even at 100,000 children.
Yeah, it was happening when opening large directories multiple times. The best solution would be with no limit. Why you don't give a try to GlobalKey
?
I read somewhere that is not real guaranty of uniqueness with uuid
Uuids are guaranteed to be unique within a system. As we are only concerned with uniqueness within the local system that is generating the Uuids, so they will be unique. Theoretically, there is no limit to how many Uuids can be generated, however I have only tested upto 100,000 entries.
Relevant ancillary documentation: [1][2] Identifier uniqueness considerations: This document specifies three algorithms to generate UUIDs: the first leverages the unique values of 802 MAC addresses to guarantee uniqueness, the second uses pseudo-random number generators, and the third uses cryptographic hashing and application-provided text strings. As a result, the UUIDs generated according to the mechanisms here will be unique from all other UUIDs that have been or will be assigned.
I got this error (https://github.com/embraceitmobile/animated_tree_view/blob/3e7ec1e132a54a07d5ae9e711cce98cc3721bdc5/lib/node/node.dart#L54) when I have a Node with a lot of children.
In my case it happens (sometimes) when I open this tree location (/bin/), where there are a lot of children.
I bypass this error by providing a String key to every node.
I suggest that maybe you can provide an int instead of String (2^64 unique keys is enough).
Also I tried to use int keys like this:
'$keyIndex++'
, but I got same error: (0 key is yet used, 1 key is yet used, ...).