@Nullable
  public static GribCollectionImmutable openCdmIndex(String indexFilename, FeatureCollectionConfig config, boolean useCache, Logger logger) throws IOException {
    """
	open GribCollectionImmutable from an existing index file. return null on failure
    """
    File indexFileInCache = useCache ? GribIndexCache.getExistingFileOrCache(indexFilename) : new File(indexFilename);
    if (indexFileInCache == null)
      return null;
    String indexFilenameInCache = indexFileInCache.getPath();
    String name = makeNameFromIndexFilename(indexFilename);
    GribCollectionImmutable result = null;

    try (RandomAccessFile raf = RandomAccessFile.acquire(indexFilenameInCache)) {
      GribCollectionType type = getType(raf);

      switch (type) {
        case GRIB2:
          result = Grib2CollectionBuilderFromIndex.readFromIndex(name, raf, config, logger);
          break;
        case Partition2:
          result = Grib2PartitionBuilderFromIndex.createTimePartitionFromIndex(name, raf, config, logger);
          break;
        case GRIB1:
          result = Grib1CollectionBuilderFromIndex.readFromIndex(name, raf, config, logger);
          break;
        case Partition1:
          result = Grib1PartitionBuilderFromIndex.createTimePartitionFromIndex(name, raf, config, logger);
          break;
        default:
          logger.warn("GribCdmIndex.openCdmIndex failed on {} type={}", indexFilenameInCache, type);
      }
    } catch (FileNotFoundException ioe) {
      throw ioe;

    } catch (Throwable t) {
      logger.warn("GribCdmIndex.openCdmIndex failed on " + indexFilenameInCache, t);
      RandomAccessFile.eject(indexFilenameInCache);
      if (!indexFileInCache.delete())
        logger.warn("failed to delete {}", indexFileInCache.getPath());
    }

    return result;
  }
@Nullable
  public static GribCollectionImmutable openCdmIndex(String indexFilename, FeatureCollectionConfig config, boolean useCache, Logger logger) throws IOException {
    File indexFileInCache = useCache ? GribIndexCache.getExistingFileOrCache(indexFilename) : new File(indexFilename);
    if (indexFileInCache == null)
      return null;
    String indexFilenameInCache = indexFileInCache.getPath();
    String name = makeNameFromIndexFilename(indexFilename);
    GribCollectionImmutable result = null;

    try (RandomAccessFile raf = RandomAccessFile.acquire(indexFilenameInCache)) {
      GribCollectionType type = getType(raf);

      switch (type) {
        case GRIB2:
          result = Grib2CollectionBuilderFromIndex.readFromIndex(name, raf, config, logger);
          break;
        case Partition2:
          result = Grib2PartitionBuilderFromIndex.createTimePartitionFromIndex(name, raf, config, logger);
          break;
        case GRIB1:
          result = Grib1CollectionBuilderFromIndex.readFromIndex(name, raf, config, logger);
          break;
        case Partition1:
          result = Grib1PartitionBuilderFromIndex.createTimePartitionFromIndex(name, raf, config, logger);
          break;
        default:
          logger.warn("GribCdmIndex.openCdmIndex failed on {} type={}", indexFilenameInCache, type);
      }
    } catch (FileNotFoundException ioe) {
      throw ioe;

    } catch (Throwable t) {
      logger.warn("GribCdmIndex.openCdmIndex failed on " + indexFilenameInCache, t);
      RandomAccessFile.eject(indexFilenameInCache);
      if (!indexFileInCache.delete())
        logger.warn("failed to delete {}", indexFileInCache.getPath());
    }

    return result;
  }
@ Nullable public static GribCollectionImmutable openCdmIndex ( String indexFilename , FeatureCollectionConfig config , boolean useCache , Logger logger ) throws IOException { File indexFileInCache = useCache ? GribIndexCache . getExistingFileOrCache ( indexFilename ) : new File ( indexFilename ) ; if ( indexFileInCache == null ) return null ; String indexFilenameInCache = indexFileInCache . getPath ( ) ; String name = makeNameFromIndexFilename ( indexFilename ) ; GribCollectionImmutable result = null ; try ( RandomAccessFile raf = RandomAccessFile . acquire ( indexFilenameInCache ) ) { GribCollectionType type = getType ( raf ) ; switch ( type ) { case GRIB2 : result = Grib2CollectionBuilderFromIndex . readFromIndex ( name , raf , config , logger ) ; break ; case Partition2 : result = Grib2PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , raf , config , logger ) ; break ; case GRIB1 : result = Grib1CollectionBuilderFromIndex . readFromIndex ( name , raf , config , logger ) ; break ; case Partition1 : result = Grib1PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , raf , config , logger ) ; break ; default : logger . warn ( "GribCdmIndex.openCdmIndex failed on {} type={}" , indexFilenameInCache , type ) ; } } catch ( FileNotFoundException ioe ) { throw ioe ; } catch ( Throwable t ) { logger . warn ( "GribCdmIndex.openCdmIndex failed on " + indexFilenameInCache , t ) ; RandomAccessFile . eject ( indexFilenameInCache ) ; if ( ! indexFileInCache . delete ( ) ) logger . warn ( "failed to delete {}" , indexFileInCache . getPath ( ) ) ; } return result ; }
open GribCollectionImmutable from an existing index file. return null on failure
open GribCollectionImmutable from an existing index file . return null on failure