Ticket #559 (closed discussion: fixed)

Opened 5 months ago

Last modified 3 months ago

Filters

Reported by: ciaranm Owned by: ciaranm
Priority: Sometime Milestone: Misc features
Component: core/paludis Version: scm
Keywords: Cc:
Blocked By: Blocking:
Distribution: Gentoo

Description

Filters can improve the performance of Query and replace qo_order_by_version etc. Instead of doing Query(...) & Query(...) & Query(...), one would do Query(...) & Query(...) | Filter(...) | Filter(...).

Filters would operate on an existing Query result set and remove or reorder results, rather than operating on an Environment and then being intersectioned with other queries.

Typical example: query::Matches(blah) & query::NotMasked(), qo_best_version_only requires metadata for every ID that matches. But if we do query::Matches(blah) | filter::BestVersionOnly() | filter::ExcludeMasked() it only needs metadata for the selected ID.

Change History

Changed 3 months ago by ciaranm

  • distribution set to Gentoo

We probably need three things. First, generators:

Generator:
    repositories(env) -> RepositorySet
    categories(RepositorySet) -> CategoryNameSet
    packages(RepositorySet, CategoryNameSet) -> QualifiedPackageNameSet
    ids(RepositorySet, QualifiedPackageNameSet) -> PackageIDSet

Generators include All, Matches, Package, Repository and Category. Two generators can be union-combined using operator&, which creates a new Generator.

Second, filters:

Filter:
    repositories(RepositorySet) -> RepositorySet
    categories(RepositorySet, CategoryNameSet) -> CategoryNameSet
    packages(RepositorySet, QualifiedPackageNameSet) -> QualifiedPackageNameSet
    ids(RepositorySet, PackageIDSet) -> PackageIDSet

Filters include SupportsAction<>, NotMasked, InstalledAtRoot.

Combining generators and filters is done using operator|. There's a bit of magic, to make filters optional and to allow filter chaining: we have an implicit Generator to FilteredGenerator conversion in Generator, and FilteredGenerator operator| (const FilteredGenerator &, const Filter &).

Third, selectors (bad name?). Splitting selectors from filters allows us to have "best version only, and not masked" not load metadata for lower versions once it's found a result.

Selector:
    ids(FilteredGenerator unless we make it a ctor param) -> PackageIDSequence

Selectors include BestVersionOnly, InWhateverOrder, BestVersionInEachSlot, OrderedByVersion, GroupedBySlot and RequireExactlyOne.

Syntactically, we could either do:

    env[generator::Blah() | filter::Blah(),  BestVersionOnly()]

or to avoid overloading operator, which is icky and doesn't work in bindings:

    env[BestVersionOnly(generator::Blah() | filter::Blah())]

where env[...] is a shortcut for env->package_database()->query(...).

Changed 3 months ago by ciaranm

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.