mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
address review: offset fallback for far backward album seeks; pin the playlist keyset
- The NULL-aware backward album predicate is not sargable, so a backward seek from a far cursor scans the whole album partition. Fall back to the offset query when the anchor is more than twice the offset away; near-cursor backward reads still use keyset. - Cover the playlist keyset path: a DAO test for `playlistSongsBefore` and a repository test scanning a playlist forward and backward. Both fail if the playlist order key stops driving the seek.
This commit is contained in:
@@ -764,6 +764,11 @@ class QueueRepository(
|
||||
): List<SongItem>? {
|
||||
if (!cursor.key.seekable(entry.kind)) return null
|
||||
val from = cursor.ordinal
|
||||
// A backward seek from a far cursor is not cheaper than the offset query: the album
|
||||
// predicate is not sargable (it has to include NULL disc/track), so it scans the partition
|
||||
// back to `offset` instead of using a range. Fall back when the anchor is more than twice
|
||||
// the offset away, matching the documented far-jump behaviour.
|
||||
if (from > offset && from - offset >= offset) return null
|
||||
return if (offset >= from) {
|
||||
rowsFrom(entry, cursor.key, offset - from, limit)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user