-
Notifications
You must be signed in to change notification settings - Fork 21
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
Flekschas/faster beddb #135
base: develop
Are you sure you want to change the base?
Conversation
Genome wide this can lead to 20x faster queries but it increases the file size by a factor of 2.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The speedup looks phenomenal. I think the space might be able to be reduced. See the inline comments. And how about some tests?
tile_id = "{}.{}".format(curr_zoom, curr_tile) | ||
|
||
tile_counts[tile_id] += 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you put the tile_inserts.append()
call from below here and save yourself a while loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works. The reason why is the following:
tile_counts
only counts the first time an interval is inserted but not the subsequent times. Hence, this while
loop is only called once, while the one below is called in higher zoom levels as well.
Here's a short example: say we set the max number of intervals per tile to 2. The first interval will be inserted at tile 0.0 and its counter will increase. However, we want to make sure that the most important tile is always shown in tile with a higher zoom level so we will insert tile-id<>interval-id pairs for higher zoom levels as well. However, we will not increase the counter for those tiles as otherwise we would never see more details as we zoom in in some cases. Does this somehow make sense? :)
This replicates the existing behavior of the beddb format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for the responses!
Description
What was changed in this pull request?
I implemented a tile-based indexing strategy for beddb which can speed up queries by up to 20x at the expense of increasing the file size by a factor of ~2.5x
To avoid adding the burden of having to handle another format to the end-user I decided to mark this indexing using an appended
t
to the version number. I.e., version3
is the normal version while3t
is the tile-index versionTo create a tile-indexed beddb file use
clodius aggregate bedfile
with--tile-index
.Why is it necessary?
The range-based rtree indexing is getting slow with >5mio intervals (i.e.,
0.5
s for a query) while the tile-based index remains fast with ~0.025
s.Checklist
black .