简体   繁体   中英

OptaPlanner: Difference between filtering during or after join

Is there any difference, semantically or performance wise, between

cf.forEach(Entity.class)
        .join(cf.forEach(Entity.class),
                Joiners.filtering(myBiPredicate)))
        ...

vs

cf.forEach(Entity.class)
        .join(cf.forEach(Entity.class))
        .filter(myBiPredicate)))
        ...

Also, are the Joiners executed in the order given? (Ie is it advised to, for example, put filters that prune a lot of pairs early in the argument list?)

To answer your first question - no, there is no practical difference between the two constraints. Joiners.filtering(...) exists so that you can apply a filter in ifExists(...) calls; when doing a normal join, you might as well just do a filter after the join.

To answer your second question, I wrote an entire blog post . Yes, it is better to prune early.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM