Search Unity

GetKeyArray but for NativeMultiHashMap?

Discussion in 'Entity Component System' started by Mr-Mechanical, Feb 10, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I've noticed NativeHashMap has a GetKeyArray function but NativeMultiHashMap does not. Any thoughts?

    Thanks. Advice is always appreciated.
     
    Tony_Max likes this.
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I had a look at why this was the case when they first implemented it to see if I could add it myself and I think it's a technical issue. While I didn't spend that long at the problem I couldn't think of an efficient way of implementing it with how the hash maps are designed. They'll probably come up with something at some point though.
     
    Mr-Mechanical likes this.
  3. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I'm taking a look at IJobNativeMultiHashMapMergedSharedKeyIndices, but it in my use case I'd like to compare each value with every other value in the same key (2 nested loops). Though, I am not sure this is possible with IJobNativeMultiHashMapMergedSharedKeyIndices since you can only visit each value once with ExecuteFirst and ExecuteNext. I'll have to think about this.
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    I never really looked into IJobNativeMultiHashMapMergedSharedKeyIndices.

    What exactly does it do?

    I had a similar usecase and just unrolled it via an ijob. I would love to just be able to reinterprete the values per key as native arrays, without any copying
     
    Mr-Mechanical likes this.
  5. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I like the idea of a special job type that does exactly as you describe. Currently, we only have
    IJobNativeMultiHashMapVisitKeyValue, which access every value but also has to access the same key multiple times to accomplish this.
    Here's a link to IJobNativeMultiHashMapMergedSharedKeyIndices explanation from Mike Acton's GDC. It's a job type that seems to be mostly specialized towards the Boid sample.