/** * Cache a variable (for efficiency). * Useful for Variables that are used a lot, and not too large, like coordinate variables. * * @param varName name of variable to cache. must exist. * @param dtype datatype of variable */ void addCacheVariable(String varName, DataType dtype) { if (findCacheVariable(varName) != null) return; // no duplicates cacheList.add(new CacheVar(varName, dtype)); }
Array data = pv.getData(dod.getId()); if (data != null) { out.print(" <cache varName='" + pv.varName + "' >");
pv.putData(id, data); } catch (Exception e) { logger.warn("Error reading cached data ",e);
Array data = pv.getData(dod.getId()); if (data != null) { out.print(" <cache varName='" + pv.varName + "' >");
pv.putData(id, data); countCacheUse++;
Array data = pv.getData(dod.getId()); if (data != null) { out.print(" <cache varName='" + pv.varName + "' >");
pv.putData(id, data); } catch (Exception e) { logger.warn("Error reading cached data ",e);
CacheVar pv = (CacheVar) spObj; try { Array cacheArray = pv.read(mainv.getShapeAsSection(), cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
if (spObj != null && spObj instanceof CacheVar) { CacheVar pv = (CacheVar) spObj; Array cacheArray = pv.read(section, cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
CacheVar pv = (CacheVar) spObj; try { Array cacheArray = pv.read(mainv.getShapeAsSection(), cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
if (spObj != null && spObj instanceof CacheVar) { CacheVar pv = (CacheVar) spObj; Array cacheArray = pv.read(section, cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
if (spObj != null && spObj instanceof CacheVar) { CacheVar pv = (CacheVar) spObj; Array cacheArray = pv.read(section, cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
CacheVar pv = (CacheVar) spObj; try { Array cacheArray = pv.read(mainv.getShapeAsSection(), cancelTask); return MAMath.convert(cacheArray, dtype); // // cache may keep data as different type
Array varData = read(dod); if (varData == null) throw new IOException("cant read "+dod);
Array varData = read(dod);
Array varData = read(dod); if (varData == null) throw new IOException("cant read "+dod);
protected void rebuildDataset() throws IOException { buildCoords(null); // reset dimension length Dimension aggDim = ncDataset.findDimension(dimName); // LOOK use group aggDim.setLength(getTotalCoords()); // reset coordinate var VariableDS joinAggCoord = (VariableDS) ncDataset.getRootGroup().findVariable(dimName); joinAggCoord.setDimensions(dimName); // reset its dimension joinAggCoord.invalidateCache(); // get rid of any cached data, since its now wrong // reset agg variables for (Variable aggVar : aggVars) { //aggVar.setDimensions(dimName); // reset its dimension aggVar.resetDimensions(); // reset its dimensions aggVar.invalidateCache(); // get rid of any cached data, since its now wrong } // reset the typical dataset, where non-agg variables live Dataset typicalDataset = getTypicalDataset(); for (Variable var : ncDataset.getRootGroup().getVariables()) { VariableDS varDS = (VariableDS) var; if (aggVars.contains(varDS) || dimName.equals(var.getShortName())) continue; DatasetProxyReader proxy = new DatasetProxyReader(typicalDataset); var.setProxyReader(proxy); } // reset cacheVars for (CacheVar cv : cacheList) { cv.reset(); } }
protected void rebuildDataset() throws IOException { buildCoords(null); // reset dimension length Dimension aggDim = ncDataset.findDimension(dimName); // LOOK use group aggDim.setLength(getTotalCoords()); // reset coordinate var VariableDS joinAggCoord = (VariableDS) ncDataset.getRootGroup().findVariable(dimName); joinAggCoord.setDimensions(dimName); // reset its dimension joinAggCoord.invalidateCache(); // get rid of any cached data, since its now wrong // reset agg variables for (Variable aggVar : aggVars) { //aggVar.setDimensions(dimName); // reset its dimension aggVar.resetDimensions(); // reset its dimensions aggVar.invalidateCache(); // get rid of any cached data, since its now wrong } // reset the typical dataset, where non-agg variables live Dataset typicalDataset = getTypicalDataset(); for (Variable var : ncDataset.getRootGroup().getVariables()) { VariableDS varDS = (VariableDS) var; if (aggVars.contains(varDS) || dimName.equals(var.getShortName())) continue; DatasetProxyReader proxy = new DatasetProxyReader(typicalDataset); var.setProxyReader(proxy); } // reset cacheVars for (CacheVar cv : cacheList) { cv.reset(); } }
protected Array read(DatasetOuterDimension dset, NetcdfFile ncfile) throws IOException { Array data = readCached(dset); if (data != null) return data; return super.read(dset, ncfile); }