Thanks Ignasi, Andrew.

I've opened a pull request for this at [1]. Pretty straightforward and hopefully others will find it useful too!

--A

[1]  https://github.com/jclouds/jclouds/pull/166



On 02/10/2013 06:05, Ignasi wrote:
The TemplateBuilder currently allows you to customize the filters you
want to apply to the templates, but does not allow to customize the
"reduce" operation to get the template that is best, so I think this
would be a nice addition.
Personally, I like the idea of exposing a method in the builder to
provide a custom Ordering, to keep things simple and respect the
custom behavior.

On 2 October 2013 14:59, Alex Heneveld <[email protected]> wrote:
Hey Andrew


I'd like to tie in to jclouds's TemplateBuilder so that I can use its
filtering capabilities but then use custom logic to determine which of
the matching images is "best" (for my custom value of best).

Rather than adding ordering semantics, how about allowing you to add a
"filterBy(...)" or similar predicate that would be applied to each
image that matches the template? Or do you need the *whole list* of
matching images in order to be able to make your decision..?

There is already `TemplateBuilder.imageMatches(Predicate)`. However I think
we do need to whole list in order to decide which is best, i.e. what is the
latest version of Ubuntu or CentOS.

I'm thinking allowing to set an `imageSorter(Ordering)`. This fits with how
the Impl currently works (it already uses an Ordering, you just can't change
it; and it stays in line with the naming convention of `Sorter` as in
`Ordering hardwareSorter()`.)

Note that this doesn't change runtime from $O(N)$ to $O(N \log N)$ (or
worse)
(if that is your concern Andrew, I had to convince myself!) because we
aren't
sorting the whole list, we are just finding the max.

Best
Alex


Reply via email to