From: Toon Claes Date: Wed, 15 Jul 2026 05:27:08 GMT Subject: Re: [PATCH v3 8/9] odb: introduce object filters to `odb_for_each_object()` Message-ID: <874ii0n7pv.fsf@emacs.iotcl.com> In-Reply-To: <20260713-pks-odb-for-each-object-filter-v3-8-b3c65c641073@pks.im> Patrick Steinhardt writes: > The function `for_each_bitmapped_object()` can be used to iterate > through all objects covered by a bitmap. The benefit of this function is > that it allows the caller to efficiently handle some object filters. For > example, this can be used to filter out objects of a specific type with > some simple bitmap operations. But callers are currently required to > manually wire up the use of bitmaps though, and to do so they have to > reach into internals of a given object database source. > > Introduce a new `struct odb_for_each_object_options::filter` field so > that the interface becomes generic. When set, then a backend may > optionally use the filter to skip some objects that it would have > otherwise yielded. > > Note that the respective backends are free to ignore this field if they > cannot meaningfully optimize for a given filter, and consequently > callers need to verify whether they actually want the returned objects. > While annoying, we cannot easily lift this restriction anyway as the > object filter infrastructure supports some filters that cannot be > answered by the object database alone. > > An alternative might be to limit the filters to only those that _can_ be > answered by backends. But ultimately, the filters that can be answered > efficiently by the "packed" backend are completely disjunct from those > that can be answered by the "loose" backend, and consequently the set of > filters supported by all backends would be empty. Furthermore, it would > require us to make assumptions about capabilities of future backends, > which may be able to efficiently handle more filters than current ones. > So in the end, this alternative would only limit us artificially. > > Implement the logic for the "packed" source. Note that we use the new > function `prepare_source_bitmap_git()` to open the bitmap: as the Also here: `prepare_bitmap_git_for_source()` > backend operates on a single object source, we must only use bitmaps > that belong to that specific source. Otherwise we might yield objects > that are not part of the source at all, and with multiple sources we > would enumerate the same bitmap once per source. -- Cheers, Toon