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 class
Aggregation.Type
protected static class
Aggregation.TypicalDataset
-
Field Summary
Fields Modifier and Type Field Description protected boolean
cacheDirty
protected MFileCollectionManager
datasetManager
protected List<ucar.nc2.internal.ncml.AggDataset>
datasets
protected String
dateFormatMark
protected DateFormatter
dateFormatter
protected static boolean
debug
protected static boolean
debugConvert
protected static boolean
debugDateParse
protected static boolean
debugOpenFile
protected static boolean
debugProxy
protected static boolean
debugRead
protected static boolean
debugSyncDetail
protected String
dimName
protected static DiskCache2
diskCache2
protected static Executor
executor
protected List<ucar.nc2.internal.ncml.AggDataset>
explicitDatasets
protected boolean
isDate
protected static org.slf4j.Logger
logger
protected NetcdfDataset.Builder
ncDataset
protected Object
spiObject
protected Aggregation.Type
type
protected static Aggregation.TypicalDataset
typicalDatasetMode
-
Constructor Summary
Constructors Modifier Constructor Description protected
Aggregation(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 void
addCollection(String spec, String olderThan)
void
addDataset(ucar.nc2.internal.ncml.AggDataset nested)
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 scanvoid
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.void
build(CancelTask cancelTask)
protected abstract void
buildNetcdfDataset(CancelTask cancelTask)
Call this to build the dataset objects in the NetcdfDatasetvoid
close()
List<ucar.nc2.internal.ncml.AggDataset>
getDatasets()
void
getDetailInfo(Formatter f)
String
getDimensionName()
Get dimension name to join onString
getFileTypeDescription()
String
getFileTypeId()
long
getLastModified()
protected String
getLocation()
Aggregation.Type
getType()
Get type of aggregationprotected ucar.nc2.internal.ncml.AggDataset
getTypicalDataset()
Open one of the nested datasets as a template for the aggregation dataset.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 overrideprotected ucar.nc2.internal.ncml.AggDataset
makeDataset(MFile dset)
protected void
makeDatasets(CancelTask cancelTask)
Make the list of Datasets, from explicit and scans.protected void
persistRead()
read info from the persistent XML file, if it exists; overridden in AggregationExistingvoid
persistWrite()
Allow information to be made persistent.static void
setExecutor(Executor exec)
void
setModifications(org.jdom2.Element ncmlMods)
static void
setPersistenceCache(DiskCache2 dc)
static void
setTypicalDatasetMode(String mode)
boolean
syncExtend()
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:
close
in interfaceAggregationIF
- Throws:
IOException
-
syncExtend
public boolean syncExtend() throws IOException
Check 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:
syncExtend
in interfaceAggregationIF
- Returns:
- true if directory was rescanned and dataset may have been updated
- Throws:
IOException
- on io error
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceAggregationIF
-
getFileTypeId
public String getFileTypeId()
- Specified by:
getFileTypeId
in interfaceAggregationIF
-
getFileTypeDescription
public String getFileTypeDescription()
- Specified by:
getFileTypeDescription
in 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 IOException
Allow information to be made persistent. Overridden in AggregationExisting- Specified by:
persistWrite
in 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:
getDetailInfo
in 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 IOException
Open 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)
-
-