Merge branch 'bug6279' into eclipse-main

This commit is contained in:
Axel Uhl
2026-08-31 23:41:49 +02:00
5 changed files with 24 additions and 21 deletions
@@ -37,4 +37,5 @@ public interface Candidate extends Comparable<CandidateImpl>, Timed {
int compareTo(Candidate other);
long getTimePointAsMillis();
}
@@ -479,7 +479,7 @@ public class MarkPassingCalculator {
newCompetitorFixes.get(competitorAndFixesFinderConsidersAffected.getKey()),
competitorFixesThatReplacedExistingOnes
.get(competitorAndFixesFinderConsidersAffected.getKey()));
tasks.add((race.getTrackedRegatta().cpuMeterCallable(new Callable<Void>() {
tasks.add(race.getTrackedRegatta().cpuMeterCallable(new Callable<Void>() {
@Override
public Void call() throws Exception {
runnable.run();
@@ -496,7 +496,7 @@ public class MarkPassingCalculator {
+ competitorAndFixesFinderConsidersAffected.getKey() + " with "
+ competitorAndFixesFinderConsidersAffected.getValue().size() + " fixes";
}
}, CPUMeteringType.MARK_PASSINGS.name())));
}, CPUMeteringType.MARK_PASSINGS.name()));
}
ThreadPoolUtil.INSTANCE.invokeAllAndLogExceptions(executor, Level.INFO,
"Error during mark passing calculation: %s", tasks);
@@ -39,7 +39,6 @@ import com.sap.sse.common.Distance;
import com.sap.sse.common.Duration;
import com.sap.sse.common.Speed;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Timed;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.impl.KnotSpeedImpl;
@@ -231,8 +230,6 @@ public class CandidateChooserImpl implements CandidateChooser {
*
*/
private class StartAndEndAwareTimeBasedCandidateComparator implements Comparator<Candidate> {
private final Comparator<Timed> timedComparator = TimedComparator.INSTANCE;
@Override
public int compare(Candidate o1, Candidate o2) {
int result;
@@ -243,7 +240,7 @@ public class CandidateChooserImpl implements CandidateChooser {
} else if (o1 == end || o2 == start) {
result = 1;
} else {
result = timedComparator.compare(o1, o2);
result = (int) (o1.getTimePointAsMillis() - o2.getTimePointAsMillis());
if (result == 0) {
result = Integer.compare(o1.getOneBasedIndexOfWaypoint(), o2.getOneBasedIndexOfWaypoint());
if (result == 0) {
@@ -5,18 +5,30 @@ import java.util.Comparator;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.markpassingcalculation.Candidate;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.AbstractTimePoint;
public class CandidateImpl implements Candidate {
private static final long serialVersionUID = -4626280455738918911L;
private final Waypoint w;
private final TimePoint p;
private final boolean timePointAsMillisIsNull;
private final long timePointAsMillis;
private final double probability;
private final Integer oneBasedIndexOfWaypoint;
private final Comparator<TimePoint> nullSafeTimePointComparator;
public class CandidateTimePoint extends AbstractTimePoint implements TimePoint {
private static final long serialVersionUID = 8156956989028606884L;
@Override
public long asMillis() {
return timePointAsMillis;
}
}
public CandidateImpl(int oneBasedIndexOfWaypoint, TimePoint p, double probability, Waypoint w) {
this.w = w;
this.p = p;
this.timePointAsMillisIsNull = p == null;
this.timePointAsMillis = p == null ? 0 : p.asMillis();
this.probability = probability;
this.oneBasedIndexOfWaypoint = oneBasedIndexOfWaypoint;
this.nullSafeTimePointComparator = Comparator.nullsLast(Comparator.naturalOrder());
@@ -29,7 +41,12 @@ public class CandidateImpl implements Candidate {
@Override
public TimePoint getTimePoint() {
return p;
return timePointAsMillisIsNull ? null : new CandidateTimePoint();
}
@Override
public long getTimePointAsMillis() {
return timePointAsMillisIsNull ? -1 : timePointAsMillis;
}
@Override
@@ -173,13 +173,6 @@ public class JumpyTrackSmootheningTest {
@Test
public void testMarkPassingCalculatorForAdjusted() throws Exception {
// final java.util.logging.FileHandler fileHandler =
// new java.util.logging.FileHandler(
// System.getProperty("user.home") + "/Desktop/jumpy-markpassing.log",
// false);
// fileHandler.setFormatter(new java.util.logging.SimpleFormatter());
// java.util.logging.Logger.getLogger("").addHandler(fileHandler);
try {
final DynamicGPSFixTrack<Competitor, GPSFixMoving> track = readTrack("GallagherZelenka.gpx.gz");
final Duration durationForAdjustedTrack;
final Duration durationForOriginalTrack;
@@ -208,11 +201,6 @@ public class JumpyTrackSmootheningTest {
assertTrue(durationForAdjustedTrack.times(2).compareTo(durationForOriginalTrack) < 0,
"Expected duration for mark passing analysis on adjusted track to be at least two times less than for original track: "+
durationForAdjustedTrack+" vs. "+durationForOriginalTrack);
} finally {
// java.util.logging.Logger.getLogger("").removeHandler(fileHandler);
// fileHandler.close();
}
}
private DynamicGPSFixTrack<Competitor, GPSFixMoving> readTrack(String filename) throws Exception {