Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SequentialDataBase as a better SimpleDatabase #129

Open
wants to merge 5 commits into
base: 1.12
Choose a base branch
from

Conversation

ZZZank
Copy link

@ZZZank ZZZank commented Oct 23, 2024

This PR is made for resolving this issue:

img

but unlike PR128, who made a stupid and not-working LongSet, this PR replaced BitSet with IntOpenHashSet for id usage lookup, with a lowerBound for skipping ids that are certainly used when generating new id, it works like this:

  • when generating new id through nextID, it will return the first id not in ids and in range [lowerBound, Integer.MAX_VALUE), if found, lowerBound will be set to id+1, and the id will be added to ids
  • when removing id (removeID()), lowerBound can be set to the removed id because it might be the smallest unused id now. But note that this will not happen when removed id is smaller than lowerBound

@jchung01
Copy link

Isn't it better to just have QuestLine and QuestLineDatabase also use randomly-generated IDs as GTNH does? i.e. have them both extend RandomIndexDatabase instead of SimpleDatabase. There is no underlying idMap necessary for generating and tracking random IDs, which should resolve the shown issue due to questlines.

@ZZZank
Copy link
Author

ZZZank commented Oct 23, 2024

Isn't it better to just have QuestLine and QuestLineDatabase also use randomly-generated IDs as GTNH does?

yes it will be a better solution, but I think this should be in another PR, since this PR only focuses on improving SimpleDaraBase

@ZZZank ZZZank changed the title Better id handling in SimpleDatabase Add SequentialDataBase as a better SimpleDatabase Oct 27, 2024
@ZZZank
Copy link
Author

ZZZank commented Oct 27, 2024

since #130 provides a better fix for questline entries, this PR only focuses on providing a better SimpleDatabase now ¯\(ツ)

I added a new database implementation SequentialDataBase, specialized in handling sequantial and dense ids. The SimpleDatabase is now just an "empty" subclass for SequentialDataBase, kept here for backward compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants