question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AsMultiMap with selector

See original GitHub issue

It looks to me like AsMultiMap uses some component as a key to reference entities. Is there some way that I can specify a key selector instead of using an entire component?

For example, lets say I have some component:

struct TransformComponent {
  Vector3 Position;
  Quaternion Rotation;
  Entity Parent;
}

If I wanted to get the parent of some component, that’s easy to do by following Parent. But if I wanted to find all children of an entity, how could I construct a query to efficiently perform that lookup? Is this even a viable approach?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Dorakucommented, Jan 17, 2022

You can provide AsMultiMap with a IEqualityComparer to change what the multimap use for equality. You can also make your component implements IEquatable<T> to change the default equality comparer used by the multimap. With both solution you can only take into account the Entity Parent and the multimap would effectively give you all children for a given entity.

0reactions
Dorakucommented, Jan 25, 2022

Hum I guess it should be possible but we would need a new type EntityMap<TComponent, TKey> with a Func<TComponent, TKey> selector like in your example (the key should still be part of a component obviously). It would be cool to also allow the key to be produced from multiple components. I will try to play around with this idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

View.AsMultimap (Apache Beam 2.11.0)
@Internal public static class View.AsMultimap<K,V> extends PTransform<PCollection<KV<K,V>>,PCollectionView<java.util.Map<K,java.lang.Iterable<V>>>>.
Read more >
View.AsMultimap (Apache Beam 2.29.0)
@Internal public static class View.AsMultimap<K,V> extends PTransform<PCollection<KV<K,V>>,PCollectionView<java.util.Map<K,java.lang.Iterable<V>>>>.
Read more >
org.apache.beam.sdk.transforms.View.asMultimap java ...
AsMultimap transform that takes a PCollection as input and produces a PCollectionView mapping each window to its contents as a Map for use...
Read more >
Issues · Doraku/DefaultEcs
Entity Component System framework aiming for syntax and usage simplicity with maximum performance for game development. - Issues · Doraku/DefaultEcs.
Read more >
Index (core 2.35.0 API) - javadoc.io
asMultimap () - Static method in class org.apache.beam.sdk.transforms.View. Returns a View. ... Parser for textual field-access selector.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found