@Override public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { List<MCollection> result = new ArrayList<>(100); try (CloseableIterator<MFile> iter = getFileIterator()) { while (iter.hasNext()) { MCollection part = new CollectionSingleFile(iter.next(), logger); result.add( part); lastModified = Math.max(lastModified, part.getLastModified()); } } return result; }
@Override public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { List<MCollection> result = new ArrayList<>(100); try (CloseableIterator<MFile> iter = getFileIterator()) { while (iter.hasNext()) { MCollection part = new CollectionSingleFile(iter.next(), logger); if (!wasRemoved(part)) result.add(part); lastModified = Math.max(lastModified, part.getLastModified()); } } return result; }
@Override public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { if (forceCollection == null) forceCollection = CollectionUpdateType.test; DirectoryBuilder builder = new DirectoryBuilder(topCollection, topDir, null); builder.constructChildren(indexReader, forceCollection); List<MCollection> result = new ArrayList<>(); for (DirectoryBuilder child : builder.getChildren()) { try { MCollection dc = DirectoryBuilder.factory(config, child.getDir(), indexReader, logger); result.add(dc); lastModified = Math.max(lastModified, dc.getLastModified()); } catch (IOException ioe) { logger.warn("DirectoryBuilder on "+child.getDir()+" failed: skipping", ioe); } } return result; }
public Partition(MCollection dcm) { FeatureCollectionConfig config = (FeatureCollectionConfig) dcm.getAuxInfo(FeatureCollectionConfig.AUX_CONFIG); if (config == null) logger.warn("Partition missing FeatureCollectionConfig {}", dcm); this.dcm = dcm; this.name = dcm.getCollectionName(); this.lastModified = dcm.getLastModified(); this.directory = StringUtil2.replace(dcm.getRoot(), '\\', "/"); this.partitionDate = dcm.getPartitionDate(); String indexFilename = StringUtil2.replace(dcm.getIndexFilename(GribCdmIndex.NCX_SUFFIX), '\\', "/"); if (partitionDate == null) { partitionDate = getDateExtractor().getCalendarDateFromPath(indexFilename); // LOOK dicey } // now remove the directory if (indexFilename.startsWith(directory)) { indexFilename = indexFilename.substring(directory.length()); if (indexFilename.startsWith("/")) indexFilename = indexFilename.substring(1); } filename = indexFilename; }
@Override public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { if (forceCollection == null) forceCollection = CollectionUpdateType.test; DirectoryBuilder builder = new DirectoryBuilder(topCollection, collectionDir, null, suffix); builder.constructChildren(indexReader, forceCollection); List<MCollection> result = new ArrayList<>(); for (DirectoryBuilder child : builder.getChildren()) { MCollection dc = null; try { dc = DirectoryBuilder.factory(config, child.getDir(), false, indexReader, suffix, logger); // DirectoryPartitions or DirectoryCollections if (!wasRemoved( dc)) result.add(dc); lastModified = Math.max(lastModified, dc.getLastModified()); } catch (Throwable ioe) { logger.warn("DirectoryBuilder on "+child.getDir()+" failed: skipping", ioe); if (dc != null) dc.close(); } } // sort collection by name Collections.sort(result, new Comparator<MCollection>() { public int compare(MCollection o1, MCollection o2) { return o1.getCollectionName().compareTo(o2.getCollectionName()); } }); return result; }