partition.putAuxInfo(FeatureCollectionConfig.AUX_CONFIG, config); if (specp.getFilter() != null) partition.setStreamFilter(new StreamFilter(specp.getFilter(), specp.getFilterOnName()));
/** * Update all the gbx indices in one directory, and the ncx index for that directory * * @param config FeatureCollectionConfig * @param dirPath directory path * @return true if collection was rewritten, exception on failure * @throws IOException */ static private boolean updateLeafCollection(boolean isGrib1, FeatureCollectionConfig config, CollectionUpdateType updateType, boolean isTop, Logger logger, Path dirPath) throws IOException { if (config.ptype == FeatureCollectionConfig.PartitionType.file) { return updateFilePartition(isGrib1, config, updateType, isTop, logger, dirPath); } else { Formatter errlog = new Formatter(); CollectionSpecParser specp = config.getCollectionSpecParser(errlog); try (DirectoryCollection dcm = new DirectoryCollection(config.collectionName, dirPath, isTop, config.olderThan, logger)) { dcm.putAuxInfo(FeatureCollectionConfig.AUX_CONFIG, config); if (specp.getFilter() != null) dcm.setStreamFilter(new StreamFilter(specp.getFilter(), specp.getFilterOnName())); boolean changed = updateGribCollection(isGrib1, dcm, updateType, FeatureCollectionConfig.PartitionType.directory, logger, errlog); if (debug) System.out.printf(" GribCdmIndex.updateDirectoryPartition was updated=%s on %s%n", changed, dirPath); return changed; } } }
@Test public void testStreamFilterInDirPartition() throws IOException { // this dataset 0-6 hour forecasts x 124 runtimes (4x31) // there are 2 groups, likely miscoded, the smaller group are 0 hour, duplicates, possibly miscoded FeatureCollectionConfig config = new FeatureCollectionConfig("cfrsAnalysis_46", "test/testCfrsAnalysisOnly", FeatureCollectionType.GRIB2, TestDir.cdmUnitTestDir + "gribCollections/cfsr/.*grb2", null, null, null, "directory", null); Formatter errlog = new Formatter(); CollectionSpecParser specp = new CollectionSpecParser(config.spec, errlog); Path rootPath = Paths.get(specp.getRootDir()); try (DirectoryCollection dcm = new DirectoryCollection(config.collectionName, rootPath, true, config.olderThan, logger)) { dcm.putAuxInfo(FeatureCollectionConfig.AUX_CONFIG, config); if (specp.getFilter() != null) dcm.setStreamFilter(new StreamFilter(specp.getFilter(), specp.getFilterOnName())); int count = 0; for (MFile mfile : dcm.getFilesSorted()) { System.out.printf("%s%n", mfile); assert mfile.getName().equals("pwat.gdas.199612.grb2"); count++; } assert count == 1; } }