Package thredds.inventory.partition
Class DirectoryPartition
- java.lang.Object
-
- thredds.inventory.CollectionAbstract
-
- thredds.inventory.partition.DirectoryPartition
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,MCollection
,PartitionManager
public class DirectoryPartition extends CollectionAbstract implements PartitionManager
A Partition that uses directories to do the partitioning. Intended for very large collections - does not scan more than one directory at a time. The partitions may be DirectoryPartitions or DirectoryCollections, figured out by DirectoryBuilder.factory()- Since:
- 11/9/13
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class thredds.inventory.CollectionAbstract
CollectionAbstract.DateSorter, CollectionAbstract.MyStreamFilter
-
-
Field Summary
-
Fields inherited from class thredds.inventory.CollectionAbstract
auxInfo, CATALOG, collectionName, dateExtractor, DIR, FILE, GLOB, lastModified, LIST, logger, protoChoice, root, sfilter, startCollection
-
-
Constructor Summary
Constructors Constructor Description DirectoryPartition(FeatureCollectionConfig config, Path collectionDir, boolean isTop, IndexReader indexReader, String suffix, org.slf4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close and release any resources.CloseableIterator<MFile>
getFileIterator()
Get the current collection of MFile, no guaranteed order.Iterable<MFile>
getFilesSorted()
Get the current collection of MFile.String
getIndexFilename(String suffix)
String
getRoot()
Get common root directory of all MFiles in the collection - may be nullIterable<MCollection>
makePartitions(CollectionUpdateType forceCollection)
void
removePartition(MCollection partition)
-
Methods inherited from class thredds.inventory.CollectionAbstract
cleanName, extractDate, getAuxInfo, getCollectionName, getFilenames, getLastModified, getLatestFile, getPartitionDate, getProtoIndex, hasDateExtractor, makeFileListSorted, open, parseOlderThanString, putAuxInfo, setDateExtractor, setRoot, setStreamFilter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface thredds.inventory.MCollection
extractDate, getAuxInfo, getCollectionName, getFilenames, getLastModified, getLatestFile, getPartitionDate, getProtoIndex, hasDateExtractor, putAuxInfo
-
-
-
-
Constructor Detail
-
DirectoryPartition
public DirectoryPartition(FeatureCollectionConfig config, Path collectionDir, boolean isTop, IndexReader indexReader, String suffix, org.slf4j.Logger logger)
-
-
Method Detail
-
getIndexFilename
public String getIndexFilename(String suffix)
- Specified by:
getIndexFilename
in interfaceMCollection
- Overrides:
getIndexFilename
in classCollectionAbstract
-
makePartitions
public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException
- Specified by:
makePartitions
in interfacePartitionManager
- Throws:
IOException
-
getRoot
public String getRoot()
Description copied from interface:MCollection
Get common root directory of all MFiles in the collection - may be null- Specified by:
getRoot
in interfaceMCollection
- Overrides:
getRoot
in classCollectionAbstract
- Returns:
- root directory name, or null.
-
getFilesSorted
public Iterable<MFile> getFilesSorted()
Description copied from interface:MCollection
Get the current collection of MFile. if hasDateExtractor() == true, these will be sorted by Date, otherwise by path.- Specified by:
getFilesSorted
in interfaceMCollection
- Returns:
- current collection of MFile as an Iterable.
-
getFileIterator
public CloseableIterator<MFile> getFileIterator()
Description copied from interface:MCollection
Get the current collection of MFile, no guaranteed order. May be faster than getFilesSorted() for large collections, use when order is not important.try (CloseableIterator
iter = getFileIterator()) { while (iter.hasNext()) { MFile file = iter.next(); } } - Specified by:
getFileIterator
in interfaceMCollection
- Returns:
- current collection of MFile as an CloseableIterator.
-
close
public void close()
Description copied from interface:MCollection
Close and release any resources. Do not make further calls on this object.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceMCollection
-
removePartition
public void removePartition(MCollection partition)
- Specified by:
removePartition
in interfacePartitionManager
-
-