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:
austinried
2026-10-04 00:30:01 +00:00
parent 87dc4499ca
commit 729737895f
2 changed files with 46 additions and 1 deletions
@@ -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 {