AcceleratedArrays.jl
AcceleratedArrays.jl copied to clipboard
Add option for HashIndex & UniqueHashIndex to hash lazily
This is useful to me, and could be useful to others. I often have UniqueHashIndexes that never get indexed into into (either the indexing is more often happening on another dimension, or the indexing is a nice to have for interactive sessions). This could also give us cheap views of HashIndex AcceleratedArrays - just take a view of the parent array and construct a lazy HashIndex from it.
Only downside is that there now has to be a small check every time the dictionary is accessed. This is acceptable to me, though it could maybe prevent certain optimisations in very loopy indexing code (the dictionary access might not get hoisted out of the loop)? If it's a big deal, we could make these lazy variants separate types.
In terms of the code - tossed up whether to have a Bool
field or a Union{D,Nothing}
dictionary. The latter is nicer but seemed a little fiddlier.
Hmm - this is very interesting! Can you elaborate when this is useful? I tended to assumed people would attach indices precisely where they are needed (and nowhere else) kind of like when a DBA carefully optimizes their database indices.