Package ucar.nc2.grib.collection
Class GribCdmIndex
- java.lang.Object
-
- ucar.nc2.grib.collection.GribCdmIndex
-
- All Implemented Interfaces:
IndexReader
public class GribCdmIndex extends Object implements IndexReader
Utilities for creating GRIB CDM index (ncx) files, both collections and partitions. Can be used as a standalone program. TODO review - is this working?
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GribCdmIndex.GribCollectionType
-
Nested classes/interfaces inherited from interface thredds.inventory.partition.IndexReader
IndexReader.AddChildCallback
-
-
Field Summary
Fields Modifier and Type Field Description static FileCacheIF
gribCollectionCache
static String
NCX_SUFFIX
-
Constructor Summary
Constructors Constructor Description GribCdmIndex(org.slf4j.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
disableGribCollectionCache()
static File
getTopIndexFileFromConfig(FeatureCollectionConfig config)
static GribCdmIndex.GribCollectionType
getType(RandomAccessFile raf)
Find out what kind of index this isstatic void
initDefaultCollectionCache(int minElementsInMemory, int maxElementsInMemory, int period)
boolean
isPartition(Path indexFile)
Open an ncx file and find out what type it isstatic void
main(String[] args)
static boolean
makeIndex(FeatureCollectionConfig config, Formatter errlog, Path topPath)
static boolean
moveCdmIndex(String indexFilename, org.slf4j.Logger logger)
static GribCollectionImmutable
openCdmIndex(String indexFilename, FeatureCollectionConfig config, boolean useCache, org.slf4j.Logger logger)
static GribCollectionImmutable
openGribCollection(FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger)
Open GribCollection from config.static GribCollectionImmutable
openGribCollectionFromDataFile(boolean isGrib1, MFile mfile, CollectionUpdateType updateType, FeatureCollectionConfig config, Formatter errlog, org.slf4j.Logger logger)
static GribCollectionImmutable
openGribCollectionFromIndexFile(RandomAccessFile indexRaf, FeatureCollectionConfig config, org.slf4j.Logger logger)
Create a grib collection / partition collection from an existing ncx2 file.static GribCollectionImmutable
openGribCollectionFromRaf(RandomAccessFile raf, FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger)
static GribCollectionMutable
openMutableGCFromIndex(String indexFilename, FeatureCollectionConfig config, boolean dataOnly, boolean useCache, org.slf4j.Logger logger)
boolean
readChildren(Path indexFile, IndexReader.AddChildCallback callback)
Open a Partition ncx file and read children indexesboolean
readMFiles(Path indexFile, List<MFile> result)
Read the MFiles from a GribCollection index filestatic void
setGribCollectionCache(FileCacheIF cache)
static void
shutdown()
static boolean
updateGribCollection(boolean isGrib1, MCollection dcm, CollectionUpdateType updateType, FeatureCollectionConfig.PartitionType ptype, org.slf4j.Logger logger, Formatter errlog)
static boolean
updateGribCollection(FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger)
Update Grib Collection if neededstatic boolean
updateGribCollectionFromPCollection(boolean isGrib1, PartitionManager dcm, CollectionUpdateType updateType, Formatter errlog, org.slf4j.Logger logger)
-
-
-
Field Detail
-
NCX_SUFFIX
public static final String NCX_SUFFIX
- See Also:
- Constant Field Values
-
gribCollectionCache
public static FileCacheIF gribCollectionCache
-
-
Method Detail
-
initDefaultCollectionCache
public static void initDefaultCollectionCache(int minElementsInMemory, int maxElementsInMemory, int period)
-
disableGribCollectionCache
public static void disableGribCollectionCache()
-
setGribCollectionCache
public static void setGribCollectionCache(FileCacheIF cache)
-
shutdown
public static void shutdown()
-
getTopIndexFileFromConfig
public static File getTopIndexFileFromConfig(FeatureCollectionConfig config)
-
getType
public static GribCdmIndex.GribCollectionType getType(RandomAccessFile raf) throws IOException
Find out what kind of index this is- Parameters:
raf
- open RAF- Returns:
- GribCollectionType
- Throws:
IOException
- on read error
-
openCdmIndex
@Nullable public static GribCollectionImmutable openCdmIndex(String indexFilename, FeatureCollectionConfig config, boolean useCache, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
openMutableGCFromIndex
@Nullable public static GribCollectionMutable openMutableGCFromIndex(String indexFilename, FeatureCollectionConfig config, boolean dataOnly, boolean useCache, org.slf4j.Logger logger)
-
updateGribCollectionFromPCollection
public static boolean updateGribCollectionFromPCollection(boolean isGrib1, PartitionManager dcm, CollectionUpdateType updateType, Formatter errlog, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
updateGribCollection
public static boolean updateGribCollection(FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger) throws IOException
Update Grib Collection if needed- Returns:
- true if the collection was updated
- Throws:
IOException
-
updateGribCollection
public static boolean updateGribCollection(boolean isGrib1, MCollection dcm, CollectionUpdateType updateType, FeatureCollectionConfig.PartitionType ptype, org.slf4j.Logger logger, Formatter errlog) throws IOException
- Throws:
IOException
-
makeIndex
public static boolean makeIndex(FeatureCollectionConfig config, Formatter errlog, Path topPath) throws IOException
- Throws:
IOException
-
moveCdmIndex
public static boolean moveCdmIndex(String indexFilename, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
openGribCollection
public static GribCollectionImmutable openGribCollection(FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger) throws IOException
Open GribCollection from config. CollectionUpdater calls InvDatasetFc.update() calls InvDatasetFcGrib.updateCollection()- Throws:
IOException
-
openGribCollectionFromRaf
public static GribCollectionImmutable openGribCollectionFromRaf(RandomAccessFile raf, FeatureCollectionConfig config, CollectionUpdateType updateType, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
openGribCollectionFromDataFile
@Nullable public static GribCollectionImmutable openGribCollectionFromDataFile(boolean isGrib1, MFile mfile, CollectionUpdateType updateType, FeatureCollectionConfig config, Formatter errlog, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
openGribCollectionFromIndexFile
@Nullable public static GribCollectionImmutable openGribCollectionFromIndexFile(RandomAccessFile indexRaf, FeatureCollectionConfig config, org.slf4j.Logger logger) throws IOException
Create a grib collection / partition collection from an existing ncx2 file. PartionCollection.partition.getGribCollection().- Parameters:
indexRaf
- the ncx2 file already openconfig
- special configuration- Returns:
- the resulting GribCollection, or null on failure
- Throws:
IOException
- on io error
-
readChildren
public boolean readChildren(Path indexFile, IndexReader.AddChildCallback callback) throws IOException
Description copied from interface:IndexReader
Open a Partition ncx file and read children indexes- Specified by:
readChildren
in interfaceIndexReader
- Parameters:
indexFile
- the Partition ncx index file to opencallback
- for each child index, call this back- Returns:
- true if indexFile is a partition collection
- Throws:
IOException
- on bad things
-
isPartition
public boolean isPartition(Path indexFile) throws IOException
Description copied from interface:IndexReader
Open an ncx file and find out what type it is- Specified by:
isPartition
in interfaceIndexReader
- Parameters:
indexFile
- the ncx index file to open- Returns:
- true if its a partition type index
- Throws:
IOException
- on bad
-
readMFiles
public boolean readMFiles(Path indexFile, List<MFile> result) throws IOException
Description copied from interface:IndexReader
Read the MFiles from a GribCollection index file- Specified by:
readMFiles
in interfaceIndexReader
- Parameters:
indexFile
- the Partition ncx index file to openresult
- put results in this list- Returns:
- true if indexFile is a GribCollection collection, and read ok
- Throws:
IOException
-
-