Issue #1328 Fixed time matching error for 4-panel products where No Data Available on some of the panes
Amend: Changed time cache object to have single setter for setting fields, changed map to identity map Change-Id: I598e9033187b794631d1dbfc78bb018084ec95cf Former-commit-id:0cda5a49ee
[formerlydbc9141454
] [formerly8fc766ab05
] [formerly0cda5a49ee
[formerlydbc9141454
] [formerly8fc766ab05
] [formerly424c6e0b1b
[formerly8fc766ab05
[formerly 9a5766f8a6bd61734b2f9e44aaabbef835d1d676]]]] Former-commit-id:424c6e0b1b
Former-commit-id:d05d9c1904
[formerly9a978a9156
] [formerly 598a914c099b0e3e8613a8f807aaaa1c214ae6c0 [formerly4cb9cc5632
]] Former-commit-id: 68e92f951b16bc8ffce114577a92cd77f5d11e74 [formerly87ad71d28d
] Former-commit-id:057dc3019a
This commit is contained in:
parent
611cceb4d3
commit
b183944982
2 changed files with 69 additions and 68 deletions
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -84,6 +85,44 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(D2DTimeMatcher.class);
|
.getHandler(D2DTimeMatcher.class);
|
||||||
|
|
||||||
|
private static class TimeCache {
|
||||||
|
/**
|
||||||
|
* The last set of times that the resource with these properties was
|
||||||
|
* matched against. As long as we are matching against these same times
|
||||||
|
* then lastFrameTimes is valid.
|
||||||
|
*/
|
||||||
|
private DataTime[] lastBaseTimes;
|
||||||
|
|
||||||
|
/** The result of the last time matching. */
|
||||||
|
private DataTime[] lastFrameTimes;
|
||||||
|
|
||||||
|
/** The number of frames time matched against */
|
||||||
|
private int lastFrameCount;
|
||||||
|
|
||||||
|
public DataTime[] getLastBaseTimes() {
|
||||||
|
return lastBaseTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTime[] getLastFrameTimes() {
|
||||||
|
return lastFrameTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastFrameCount() {
|
||||||
|
return lastFrameCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimes(DataTime[] baseTimes, DataTime[] frameTimes) {
|
||||||
|
setTimes(baseTimes, frameTimes, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimes(DataTime[] baseTimes, DataTime[] frameTimes,
|
||||||
|
int frameCount) {
|
||||||
|
this.lastBaseTimes = baseTimes;
|
||||||
|
this.lastFrameTimes = frameTimes;
|
||||||
|
this.lastFrameCount = frameCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected transient AbstractVizResource<?, ?> timeMatchBasis;
|
protected transient AbstractVizResource<?, ?> timeMatchBasis;
|
||||||
|
|
||||||
private IDisposeListener timeMatchBasisDisposeListener = new IDisposeListener() {
|
private IDisposeListener timeMatchBasisDisposeListener = new IDisposeListener() {
|
||||||
|
@ -121,6 +160,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
|
|
||||||
private AbstractTimeMatchingConfigurationFactory configFactory;
|
private AbstractTimeMatchingConfigurationFactory configFactory;
|
||||||
|
|
||||||
|
private Map<AbstractVizResource<?, ?>, TimeCache> timeCacheMap = new IdentityHashMap<AbstractVizResource<?, ?>, D2DTimeMatcher.TimeCache>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -136,10 +177,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redoTimeMatching(AbstractVizResource<?, ?> resource) {
|
public void redoTimeMatching(AbstractVizResource<?, ?> resource) {
|
||||||
TimeMatchingConfiguration config = getConfiguration(resource
|
TimeCache cache = timeCacheMap.get(resource);
|
||||||
.getLoadProperties());
|
if (cache != null) {
|
||||||
config.setLastBaseTimes(null);
|
cache.setTimes(null, null);
|
||||||
config.setLastFrameTimes(null);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -149,7 +190,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
|
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (timeMatchBasis != null) {
|
if (timeMatchBasis != null) {
|
||||||
IDescriptor tmDescriptor = timeMatchBasis.getDescriptor();
|
IDescriptor tmDescriptor = timeMatchBasis.getDescriptor();
|
||||||
|
@ -311,9 +351,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
if (rsc != timeMatchBasis) {
|
if (rsc != timeMatchBasis) {
|
||||||
TimeMatchingConfiguration config = getConfiguration(rsc
|
TimeMatchingConfiguration config = getConfiguration(rsc
|
||||||
.getLoadProperties());
|
.getLoadProperties());
|
||||||
|
TimeCache timeCache = getTimeCache(rsc);
|
||||||
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo);
|
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo);
|
||||||
if (Arrays.equals(timeSteps, config.getLastBaseTimes())) {
|
if (Arrays.equals(timeSteps, timeCache.getLastBaseTimes())) {
|
||||||
framesInfo.getTimeMap().put(rsc, config.getLastFrameTimes());
|
framesInfo.getTimeMap().put(rsc, timeCache.getLastFrameTimes());
|
||||||
} else {
|
} else {
|
||||||
config = config.clone();
|
config = config.clone();
|
||||||
if (config.getDataTimes() == null
|
if (config.getDataTimes() == null
|
||||||
|
@ -325,10 +366,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
config.getDataTimes(), config.getClock(), timeSteps,
|
config.getDataTimes(), config.getClock(), timeSteps,
|
||||||
config.getLoadMode(), config.getForecast(),
|
config.getLoadMode(), config.getForecast(),
|
||||||
config.getDelta(), config.getTolerance());
|
config.getDelta(), config.getTolerance());
|
||||||
getConfiguration(rsc.getLoadProperties()).setLastBaseTimes(
|
timeCache.setTimes(timeSteps, overlayDates);
|
||||||
timeSteps);
|
|
||||||
getConfiguration(rsc.getLoadProperties()).setLastFrameTimes(
|
|
||||||
overlayDates);
|
|
||||||
framesInfo.getTimeMap().put(rsc, overlayDates);
|
framesInfo.getTimeMap().put(rsc, overlayDates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,15 +442,12 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
private DataTime[] findBasisTimes(ResourceList resourceList,
|
private DataTime[] findBasisTimes(ResourceList resourceList,
|
||||||
int numberOfFrames) throws VizException {
|
int numberOfFrames) throws VizException {
|
||||||
if (timeMatchBasis != null) {
|
if (timeMatchBasis != null) {
|
||||||
TimeMatchingConfiguration config = getConfiguration(timeMatchBasis
|
TimeCache timeCache = getTimeCache(timeMatchBasis);
|
||||||
.getLoadProperties());
|
DataTime[] times = timeCache.getLastFrameTimes();
|
||||||
DataTime[] times = config.getLastFrameTimes();
|
if (times == null || timeCache.getLastBaseTimes() != null
|
||||||
if (times == null || config.getLastBaseTimes() != null
|
|| timeCache.getLastFrameCount() != numberOfFrames) {
|
||||||
|| config.getLastFrameCount() != numberOfFrames) {
|
|
||||||
times = makeEmptyLoadList(numberOfFrames, timeMatchBasis);
|
times = makeEmptyLoadList(numberOfFrames, timeMatchBasis);
|
||||||
config.setLastFrameTimes(times);
|
timeCache.setTimes(null, times, numberOfFrames);
|
||||||
config.setLastBaseTimes(null);
|
|
||||||
config.setLastFrameCount(numberOfFrames);
|
|
||||||
}
|
}
|
||||||
if (times != null) {
|
if (times != null) {
|
||||||
return times;
|
return times;
|
||||||
|
@ -443,9 +478,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DataTime[] times = makeEmptyLoadList(numberOfFrames, rsc);
|
DataTime[] times = makeEmptyLoadList(numberOfFrames, rsc);
|
||||||
getConfiguration(rsc.getLoadProperties()).setLastFrameTimes(
|
|
||||||
times);
|
|
||||||
if (times != null) {
|
if (times != null) {
|
||||||
|
getTimeCache(rsc).setTimes(null, times, numberOfFrames);
|
||||||
return times;
|
return times;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +575,15 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new TimeMatchingConfiguration();
|
return new TimeMatchingConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeCache getTimeCache(AbstractVizResource<?, ?> resource) {
|
||||||
|
TimeCache cache = timeCacheMap.get(resource);
|
||||||
|
if (cache == null) {
|
||||||
|
cache = new TimeCache();
|
||||||
|
timeCacheMap.put(resource, cache);
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -692,6 +734,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
timeMatchBasis = null;
|
timeMatchBasis = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
timeCacheMap.remove(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -742,7 +785,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
config.getDataTimes(), config.getClock(),
|
config.getDataTimes(), config.getClock(),
|
||||||
descriptor.getNumberOfFrames(), config.getLoadMode(),
|
descriptor.getNumberOfFrames(), config.getLoadMode(),
|
||||||
config.getForecast(), config.getDelta());
|
config.getForecast(), config.getDelta());
|
||||||
getConfiguration(loadProps).setLastFrameTimes(dataTimesToLoad);
|
|
||||||
} else {
|
} else {
|
||||||
config = configFactory.getOverlayConfiguration(loadProps, this,
|
config = configFactory.getOverlayConfiguration(loadProps, this,
|
||||||
availableTimes, descriptor);
|
availableTimes, descriptor);
|
||||||
|
@ -764,9 +806,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
config.getForecast(), config.getDelta(),
|
config.getForecast(), config.getDelta(),
|
||||||
config.getTolerance());
|
config.getTolerance());
|
||||||
|
|
||||||
getConfiguration(loadProps).setLastBaseTimes(existingDataTimes);
|
|
||||||
getConfiguration(loadProps).setLastFrameTimes(dataTimesToLoad);
|
|
||||||
|
|
||||||
if (timeMatchBasis.getDescriptor() != null
|
if (timeMatchBasis.getDescriptor() != null
|
||||||
&& timeMatchBasis.getDescriptor() != descriptor) {
|
&& timeMatchBasis.getDescriptor() != descriptor) {
|
||||||
// Still use my times, but the index from the time match basis
|
// Still use my times, but the index from the time match basis
|
||||||
|
@ -789,23 +828,20 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
|
||||||
*/
|
*/
|
||||||
public void changeTimeMatchBasis(AbstractVizResource<?, ?> resource) {
|
public void changeTimeMatchBasis(AbstractVizResource<?, ?> resource) {
|
||||||
if (timeMatchBasis != resource) {
|
if (timeMatchBasis != resource) {
|
||||||
|
TimeMatchingConfiguration config = getConfiguration(resource
|
||||||
|
.getLoadProperties());
|
||||||
|
TimeCache timeCache = getTimeCache(resource);
|
||||||
if (timeMatchBasis != null) {
|
if (timeMatchBasis != null) {
|
||||||
TimeMatchingConfiguration config = getConfiguration(timeMatchBasis
|
|
||||||
.getLoadProperties());
|
|
||||||
config.setTimeMatchBasis(false);
|
config.setTimeMatchBasis(false);
|
||||||
config.setLastBaseTimes(null);
|
timeCache.setTimes(null, null);
|
||||||
config.setLastFrameTimes(null);
|
|
||||||
timeMatchBasis
|
timeMatchBasis
|
||||||
.unregisterListener(timeMatchBasisDisposeListener);
|
.unregisterListener(timeMatchBasisDisposeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeMatchBasis = resource;
|
timeMatchBasis = resource;
|
||||||
if (timeMatchBasis != null) {
|
if (timeMatchBasis != null) {
|
||||||
TimeMatchingConfiguration config = getConfiguration(timeMatchBasis
|
|
||||||
.getLoadProperties());
|
|
||||||
config.setTimeMatchBasis(true);
|
config.setTimeMatchBasis(true);
|
||||||
config.setLastBaseTimes(null);
|
timeCache.setTimes(null, null);
|
||||||
config.setLastFrameTimes(null);
|
|
||||||
timeMatchBasis.registerListener(timeMatchBasisDisposeListener);
|
timeMatchBasis.registerListener(timeMatchBasisDisposeListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,17 +59,6 @@ public class TimeMatchingConfiguration {
|
||||||
|
|
||||||
private boolean timeMatchBasis = false;
|
private boolean timeMatchBasis = false;
|
||||||
|
|
||||||
// The last set of times that the resource with these properties was matched
|
|
||||||
// against. As long as we are matching against these same times then
|
|
||||||
// lastFrameTimes is valid.
|
|
||||||
private DataTime[] lastBaseTimes;
|
|
||||||
|
|
||||||
// The result of the last time matching.
|
|
||||||
private DataTime[] lastFrameTimes;
|
|
||||||
|
|
||||||
// The number of frames time matched against
|
|
||||||
private int lastFrameCount;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -217,28 +206,4 @@ public class TimeMatchingConfiguration {
|
||||||
this.cancel = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTime[] getLastBaseTimes() {
|
|
||||||
return lastBaseTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastBaseTimes(DataTime[] lastBaseTimes) {
|
|
||||||
this.lastBaseTimes = lastBaseTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTime[] getLastFrameTimes() {
|
|
||||||
return lastFrameTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastFrameTimes(DataTime[] lastFrameTimes) {
|
|
||||||
this.lastFrameTimes = lastFrameTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastFrameCount(int lastFrameCount) {
|
|
||||||
this.lastFrameCount = lastFrameCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastFrameCount() {
|
|
||||||
return lastFrameCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue