Package ucar.nc2.internal.ncml
Class Aggregation
- java.lang.Object
-
- ucar.nc2.internal.ncml.Aggregation
-
- All Implemented Interfaces:
AggregationIF
- Direct Known Subclasses:
AggregationNew
public abstract class Aggregation extends Object implements AggregationIF
Superclass for NcML Aggregation Builder. An Aggregation acts as a ProxyReader for VariableDS. That, is it must implement:public Array read(Variable mainv); public Array read(Variable mainv, Section section);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAggregation.Typeprotected static classAggregation.TypicalDataset
-
Field Summary
Fields Modifier and Type Field Description protected booleancacheDirtyprotected MFileCollectionManagerdatasetManagerprotected List<ucar.nc2.internal.ncml.AggDataset>datasetsprotected StringdateFormatMarkprotected DateFormatterdateFormatterprotected static booleandebugprotected static booleandebugConvertprotected static booleandebugDateParseprotected static booleandebugOpenFileprotected static booleandebugProxyprotected static booleandebugReadprotected static booleandebugSyncDetailprotected StringdimNameprotected static DiskCache2diskCache2protected static Executorexecutorprotected List<ucar.nc2.internal.ncml.AggDataset>explicitDatasetsprotected booleanisDateprotected static org.slf4j.Loggerloggerprotected NetcdfDataset.BuilderncDatasetprotected ObjectspiObjectprotected Aggregation.Typetypeprotected static Aggregation.TypicalDatasettypicalDatasetMode
-
Constructor Summary
Constructors Modifier Constructor Description protectedAggregation(NetcdfDataset.Builder ncd, String dimName, Aggregation.Type type, String recheckS)Create an Aggregation for the given NetcdfDataset.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddCollection(String spec, String olderThan)voidaddDataset(ucar.nc2.internal.ncml.AggDataset nested)voidaddDatasetScan(org.jdom2.Element crawlableDatasetElement, String dirName, String suffix, String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan)Add a dataset scanvoidaddExplicitDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, FileFactory reader)Add a nested dataset, specified by an explicit netcdf element.voidbuild(CancelTask cancelTask)protected abstract voidbuildNetcdfDataset(CancelTask cancelTask)Call this to build the dataset objects in the NetcdfDatasetvoidclose()List<ucar.nc2.internal.ncml.AggDataset>getDatasets()voidgetDetailInfo(Formatter f)StringgetDimensionName()Get dimension name to join onStringgetFileTypeDescription()StringgetFileTypeId()longgetLastModified()protected StringgetLocation()Aggregation.TypegetType()Get type of aggregationprotected ucar.nc2.internal.ncml.AggDatasetgetTypicalDataset()Open one of the nested datasets as a template for the aggregation dataset.protected ucar.nc2.internal.ncml.AggDatasetmakeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, FileFactory reader)Dataset factory, so subclasses can overrideprotected ucar.nc2.internal.ncml.AggDatasetmakeDataset(MFile dset)protected voidmakeDatasets(CancelTask cancelTask)Make the list of Datasets, from explicit and scans.protected voidpersistRead()read info from the persistent XML file, if it exists; overridden in AggregationExistingvoidpersistWrite()Allow information to be made persistent.static voidsetExecutor(Executor exec)voidsetModifications(org.jdom2.Element ncmlMods)static voidsetPersistenceCache(DiskCache2 dc)static voidsetTypicalDatasetMode(String mode)booleansyncExtend()Check to see if its time to rescan directory, and if so, rescan and extend dataset if needed.
-
-
-
Field Detail
-
typicalDatasetMode
protected static Aggregation.TypicalDataset typicalDatasetMode
-
logger
protected static org.slf4j.Logger logger
-
diskCache2
protected static DiskCache2 diskCache2
-
executor
protected static Executor executor
-
debug
protected static boolean debug
-
debugOpenFile
protected static boolean debugOpenFile
-
debugSyncDetail
protected static boolean debugSyncDetail
-
debugProxy
protected static boolean debugProxy
-
debugRead
protected static boolean debugRead
-
debugDateParse
protected static boolean debugDateParse
-
debugConvert
protected static boolean debugConvert
-
ncDataset
protected NetcdfDataset.Builder ncDataset
-
type
protected Aggregation.Type type
-
spiObject
protected Object spiObject
-
explicitDatasets
protected List<ucar.nc2.internal.ncml.AggDataset> explicitDatasets
-
datasets
protected List<ucar.nc2.internal.ncml.AggDataset> datasets
-
datasetManager
protected MFileCollectionManager datasetManager
-
cacheDirty
protected boolean cacheDirty
-
dimName
protected String dimName
-
dateFormatMark
protected String dateFormatMark
-
isDate
protected boolean isDate
-
dateFormatter
protected DateFormatter dateFormatter
-
-
Constructor Detail
-
Aggregation
protected Aggregation(NetcdfDataset.Builder ncd, String dimName, Aggregation.Type type, String recheckS)
Create an Aggregation for the given NetcdfDataset. The following addXXXX methods are called, then build(), before the object is ready for use.- Parameters:
ncd- Aggregation belongs to this NetcdfDatasetdimName- the aggregation dimension nametype- the Aggregation.TyperecheckS- how often to check if files have changes
-
-
Method Detail
-
setPersistenceCache
public static void setPersistenceCache(DiskCache2 dc)
-
setExecutor
public static void setExecutor(Executor exec)
-
setTypicalDatasetMode
public static void setTypicalDatasetMode(String mode)
-
addExplicitDataset
public void addExplicitDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, FileFactory reader)
Add a nested dataset, specified by an explicit netcdf element. enhance is handled by the reader, so its always false here.- Parameters:
cacheName- a unique name to use for cachinglocation- attribute "location" on the netcdf elementid- attribute "id" on the netcdf elementncoordS- attribute "ncoords" on the netcdf elementcoordValueS- attribute "coordValue" on the netcdf elementsectionSpec- attribute "section" on the netcdf elementreader- factory for reading this netcdf dataset
-
addDataset
public void addDataset(ucar.nc2.internal.ncml.AggDataset nested)
-
addDatasetScan
public void addDatasetScan(org.jdom2.Element crawlableDatasetElement, String dirName, String suffix, String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan)Add a dataset scan- Parameters:
crawlableDatasetElement- defines a CrawlableDataset, or nulldirName- scan this directorysuffix- filter on this suffix (may be null)regexpPatternString- include if full name matches this regular expression (may be null)dateFormatMark- create dates from the filename (may be null)enhanceMode- how should files be enhancedsubdirs- equals "false" if should not descend into subdirectoriesolderThan- files must be older than this time (now - lastModified >= olderThan); must be a time unit, may ne bull
-
setModifications
public void setModifications(org.jdom2.Element ncmlMods)
-
getType
public Aggregation.Type getType()
Get type of aggregation- Returns:
- type of aggregation
-
getDimensionName
public String getDimensionName()
Get dimension name to join on- Returns:
- dimension name or null if type union/tiled
-
getLocation
protected String getLocation()
-
close
public void close() throws IOException- Specified by:
closein interfaceAggregationIF- Throws:
IOException
-
syncExtend
public boolean syncExtend() throws IOExceptionCheck to see if its time to rescan directory, and if so, rescan and extend dataset if needed. Note that this just calls sync(), so structural metadata may be modified (!!)- Specified by:
syncExtendin interfaceAggregationIF- Returns:
- true if directory was rescanned and dataset may have been updated
- Throws:
IOException- on io error
-
getLastModified
public long getLastModified()
- Specified by:
getLastModifiedin interfaceAggregationIF
-
getFileTypeId
public String getFileTypeId()
- Specified by:
getFileTypeIdin interfaceAggregationIF
-
getFileTypeDescription
public String getFileTypeDescription()
- Specified by:
getFileTypeDescriptionin interfaceAggregationIF
-
buildNetcdfDataset
protected abstract void buildNetcdfDataset(CancelTask cancelTask) throws IOException
Call this to build the dataset objects in the NetcdfDataset- Parameters:
cancelTask- maybe cancel- Throws:
IOException- on read error
-
persistWrite
public void persistWrite() throws IOExceptionAllow information to be made persistent. Overridden in AggregationExisting- Specified by:
persistWritein interfaceAggregationIF- Throws:
IOException- on error
-
persistRead
protected void persistRead()
read info from the persistent XML file, if it exists; overridden in AggregationExisting
-
getDetailInfo
public void getDetailInfo(Formatter f)
- Specified by:
getDetailInfoin interfaceAggregationIF
-
build
public void build(CancelTask cancelTask) throws IOException
- Throws:
IOException
-
getDatasets
public List<ucar.nc2.internal.ncml.AggDataset> getDatasets()
-
makeDatasets
protected void makeDatasets(CancelTask cancelTask) throws IOException
Make the list of Datasets, from explicit and scans.- Parameters:
cancelTask- user can cancel- Throws:
IOException- on i/o error
-
getTypicalDataset
protected ucar.nc2.internal.ncml.AggDataset getTypicalDataset() throws IOExceptionOpen one of the nested datasets as a template for the aggregation dataset.- Returns:
- a typical Dataset
- Throws:
IOException- if there are no datasets
-
makeDataset
protected ucar.nc2.internal.ncml.AggDataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, FileFactory reader)
Dataset factory, so subclasses can override- Parameters:
cacheName- a unique name to use for cachinglocation- attribute "location" on the netcdf elementid- attribute "id" on the netcdf elementncoordS- attribute "ncoords" on the netcdf elementcoordValueS- attribute "coordValue" on the netcdf elementsectionSpec- attribute "sectionSpec" on the netcdf elementenhance- open dataset in enhance mode NOT USEDreader- factory for reading this netcdf dataset- Returns:
- a Dataset
-
makeDataset
protected ucar.nc2.internal.ncml.AggDataset makeDataset(MFile dset)
-
-