mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 09:41:00 +00:00
pass cache to more rank calculations, starting from computeDTO
This commit is contained in:
1 parent
cc5d6e5c74
commit
96fb38555f
4 files changed
+14
-3
No files matched your search
+1
-1
@@ -1681,7 +1681,7 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
if (legRanks != null) {
|
||||
result.rank = legRanks.get(trackedLeg.getCompetitor());
|
||||
} else {
|
||||
result.rank = trackedLeg.getRank(timePoint);
|
||||
result.rank = trackedLeg.getRank(timePoint, cache);
|
||||
}
|
||||
result.started = trackedLeg.hasStartedLeg(timePoint);
|
||||
Speed velocityMadeGood;
|
||||
|
||||
+6
@@ -128,6 +128,12 @@ public interface TrackedLegOfCompetitor extends Serializable {
|
||||
*/
|
||||
int getRank(TimePoint timePoint);
|
||||
|
||||
/**
|
||||
* Same as {@link #getRank(TimePoint)} with the additional option to provide a cache
|
||||
* that can help avoid redundant calculations of wind and leg data.
|
||||
*/
|
||||
int getRank(TimePoint timePoint, WindLegTypeAndLegBearingCache cache);
|
||||
|
||||
/**
|
||||
* Computes the gap in seconds to the leader / winner of this leg. Returns <code>null</code> in case this leg's
|
||||
* competitor hasn't started the leg yet.
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class TrackedLegImpl implements TrackedLeg, RaceChangeListener {
|
||||
return getCompetitorTracksOrderedByRank(timePoint, new NoCachingWindLegTypeAndLegBearingCache());
|
||||
}
|
||||
|
||||
private List<TrackedLegOfCompetitor> getCompetitorTracksOrderedByRank(TimePoint timePoint, WindLegTypeAndLegBearingCache cache) {
|
||||
List<TrackedLegOfCompetitor> getCompetitorTracksOrderedByRank(TimePoint timePoint, WindLegTypeAndLegBearingCache cache) {
|
||||
List<TrackedLegOfCompetitor> rankedCompetitorList;
|
||||
synchronized (competitorTracksOrderedByRank) {
|
||||
rankedCompetitorList = competitorTracksOrderedByRank.get(timePoint);
|
||||
|
||||
+6
-1
@@ -276,9 +276,14 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
*/
|
||||
@Override
|
||||
public int getRank(TimePoint timePoint) {
|
||||
return getRank(timePoint, new NoCachingWindLegTypeAndLegBearingCache());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRank(TimePoint timePoint, WindLegTypeAndLegBearingCache cache) {
|
||||
int result = 0;
|
||||
if (hasStartedLeg(timePoint)) {
|
||||
List<TrackedLegOfCompetitor> competitorTracksByRank = getTrackedLeg().getCompetitorTracksOrderedByRank(timePoint);
|
||||
List<TrackedLegOfCompetitor> competitorTracksByRank = getTrackedLeg().getCompetitorTracksOrderedByRank(timePoint, cache);
|
||||
result = competitorTracksByRank.indexOf(this)+1;
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user