diff options
author | Pascal Rapicault | 2009-03-08 04:40:42 +0000 |
---|---|---|
committer | Pascal Rapicault | 2009-03-08 04:40:42 +0000 |
commit | 76caf76879b2358944ae81f617bd7ed1721bce35 (patch) | |
tree | b329f30422839752c51f36fe8d29d0933a845953 /bundles | |
parent | 8cddb2cb8e99cac8105bbf7a1b78d53a37e82feb (diff) | |
download | rt.equinox.p2-76caf76879b2358944ae81f617bd7ed1721bce35.tar.gz rt.equinox.p2-76caf76879b2358944ae81f617bd7ed1721bce35.tar.xz rt.equinox.p2-76caf76879b2358944ae81f617bd7ed1721bce35.zip |
Bug 267518 - Update the optimization function to take into account the patchesv20090308-0011
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java index 46b714e5b..74fa0c7a2 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java @@ -225,24 +225,27 @@ public class Projector { maxWeight = maxWeight.multiply(POWER); BigInteger optionalWeight = maxWeight.negate(); - BigInteger patchWeight = maxWeight.multiply(POWER).multiply(POWER).negate(); - if (patches != null) { - IRequiredCapability[] reqs = metaIu.getRequiredCapabilities(); - for (int j = 0; j < reqs.length; j++) { - if (!reqs[j].isOptional()) - continue; - Collector matches = picker.query(new CapabilityQuery(reqs[j]), new Collector(), null); - for (Iterator iterator = matches.iterator(); iterator.hasNext();) { - IInstallableUnit match = (IInstallableUnit) iterator.next(); - if (match instanceof IInstallableUnitPatch) - weightedObjects.add(WeightedObject.newWO(match, patchWeight)); - else - weightedObjects.add(WeightedObject.newWO(match, optionalWeight)); - } + long countOptional = 1; + List requestedPatches = new ArrayList(); + IRequiredCapability[] reqs = metaIu.getRequiredCapabilities(); + for (int j = 0; j < reqs.length; j++) { + if (!reqs[j].isOptional()) + continue; + Collector matches = picker.query(new CapabilityQuery(reqs[j]), new Collector(), null); + for (Iterator iterator = matches.iterator(); iterator.hasNext();) { + IInstallableUnit match = (IInstallableUnit) iterator.next(); + if (match instanceof IInstallableUnitPatch) { + requestedPatches.add(match); + countOptional = countOptional + 1; + } else + weightedObjects.add(WeightedObject.newWO(match, optionalWeight)); } - } + BigInteger patchWeight = maxWeight.multiply(POWER).multiply(BigInteger.valueOf(countOptional)).negate(); + for (Iterator iterator = requestedPatches.iterator(); iterator.hasNext();) { + weightedObjects.add(WeightedObject.newWO(iterator.next(), patchWeight)); + } if (!weightedObjects.isEmpty()) { createObjectiveFunction(weightedObjects); } |