-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Indexes
Equivalent of a SQL column index. A new feature which enables the user to add an index to a component, which would - in theory - speed up querying entities with the index.
I am thinking of something in the lines of:
entityManager.createIndex('comp1')
entityManager.createIndex('comp2')
entityManager.getEntititesByComponents('comp1', 'comp2') // sped up, because of indexesThoughts on a possible implementation
- create per-component indexes (a list of entity ids)
const indexes = {
'comp1': [ 1, 3, 6, 14, ],
'comp2': [ 3, 6, 7, 14, 18, ],
'comp3': [ 6, 14, 25, ],
'comp4': null,
}- When fetching entities, look for indexes and use them to invalidate entitites (todo: find a fitting algorithm with a low time complexity)
Caveat
It's not unlikely that the additional overhead of indexes would negate any possible wins, in which case a cache-based system would be preferable, (see #79)