mikegoatly / lifti

A lightweight full text indexer for .NET
MIT License
184 stars 9 forks source link

Split IdPool and ItemStore #88

Closed mikegoatly closed 11 months ago

mikegoatly commented 11 months ago

At the moment IdPool : ItemStore. I think the intent was to make it easier to add an item and allow it to generate its own id as that happened. This has actually made it harder to do the item scoring work as I need to add in additional metadata for an item, and IdPool would need to become aware of item types as well (probably via some method overloads). This is really messy and I have a feeling splitting this code up will make it more maintainable.

IdPool - single responsibility for shared internal ids. (Possibly removing the need for it to be generic?) ItemStore - responsible for managing item metadata

  1. Clean up IdPool
  2. Migrate logic to ItemStore
  3. Change index add actions:
    1. Get the next id from the pool
    2. Add the item to the item store, with the returned id
  4. Change index remove actions:
    1. Remove the item from the item store
    2. Return the item's internal id to the pool

A good lesson in preferring composition over inheritance.

mikegoatly commented 11 months ago

Done as part of item score boosting for v6