-
Notifications
You must be signed in to change notification settings - Fork 7
Description
It's been bothering me for a while that RunlistStream always requires a fully resolved runlist to function. Sometimes resolving a full runlist is expensive and slow, and you don't always need the entire runlist (e.g. you're only reading a small portion or randomly seeking through a large file).
RunlistStream (or a new class, LookupStream? TBD) should allow subclasses to define something like a _lookup(self, offset, length) -> Iterator[tuple[int, int]] method that will resolve run lookup on-demand. For example, in dissect.extfs or dissect.btrfs, this could be used to query the extent BTree to lookup the proper extent/run and return the (physical offset, size) tuple for that. Making it a generator will allow for lazy evaluation too, especially useful in continuous reads. However, if a seek happens (outside the cache boundary) then the generator should be reset/another lookup should be done.
For dissect.btrfs, this would also resolve fox-it/dissect.btrfs#10.