halirutan
07/29/2018, 12:39 AM.
in Java/Kotlin and the last part is the name and the first part is the namespace (it's called context). Namespaces can be nested like in Java too, so there might be symbol thats in ``My`name`space`symbol``.
A simple datastructure for this is to have a hashset with entries fullSymbolNames -> symbolInformation
but I have some operations that need to be blazingly fast because they are called very often
1. Does symbol Plot
exist in the namespace ``System` ``? This can easily be done by prepending the namespace to the symbol-name and simply check if the keys contain such an entry
2. In which namespaces does the symbol FooBar
exists? Not really fast as I have to filter the whole list of values or process all keys.
3. What symbols are in the namespace PacletManager
? Again, I need to filter all values for this.
My current implementation in Java makes this possible by handling several different hashsets/lists but I wonder if anyone can think of a better data-structure to make the 3 operations fast. Note that once I loaded all the information about symbols, the data is read-only and I do not mutate any of it.karelpeeters
07/29/2018, 12:41 AMhalirutan
07/29/2018, 12:43 AMkarelpeeters
07/29/2018, 12:44 AMPacletManager
node.halirutan
07/29/2018, 12:44 AMkarelpeeters
07/29/2018, 12:44 AMkarelpeeters
07/29/2018, 12:44 AMkarelpeeters
07/29/2018, 12:51 AMhalirutan
07/29/2018, 12:52 AMSystem
will have leafs that are real symbols and it can contain another namespace as child.karelpeeters
07/29/2018, 12:57 AMsealed
classes?halirutan
07/29/2018, 1:00 AMhalirutan
07/29/2018, 1:01 AMhalirutan
07/29/2018, 1:02 AMsealed classes
.halirutan
07/29/2018, 1:02 AMkarelpeeters
07/29/2018, 1:04 AMclass Node(val children: Map<String, Node>, val symbols: Map<String, PropertyInfo>)
should do the trick.halirutan
07/29/2018, 1:08 AMsymbols
map would be very large for some nodes and then I'm back to a hashmap when searching for a specific name in a namespace. Maybe it's too much trouble to think about it, but I plan to rewrite it anyway so I thought I asked.karelpeeters
07/29/2018, 1:08 AMhalirutan
07/29/2018, 1:11 AMkarelpeeters
07/29/2018, 1:12 AMkarelpeeters
07/29/2018, 1:13 AMkarelpeeters
07/29/2018, 1:13 AMhalirutan
07/29/2018, 1:14 AMMap<String, Map<String, Property>>
where the first string is the namespace and the inner map is the list of symbols in that namespace.halirutan
07/29/2018, 1:15 AMhalirutan
07/29/2018, 1:17 AMcontainsKey
.