Changeset 2315


Ignore:
Timestamp:
02/22/07 15:46:53 (13 years ago)
Author:
curtis
Message:

Make FileStitcher.getUsedFiles smarter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r2291 r2315  
    554554  public String[] getUsedFiles(String id) throws FormatException, IOException { 
    555555    if (!id.equals(currentId)) initFile(id); 
    556     if (usedFiles == null) { 
    557       String[][] used = new String[files.length][]; 
    558       int total = files.length; 
    559       for (int i=0; i<files.length; i++) { 
    560         used[i] = reader.getUsedFiles(files[i]); 
    561         total += used[i].length; 
    562       } 
    563       usedFiles = new String[total]; 
    564       for (int i=0, off=0; i<used.length; i++) { 
    565         System.arraycopy(used[i], 0, usedFiles, off, used[i].length);  
    566         off += used[i].length; 
    567       } 
    568     } 
    569     return usedFiles; 
     556 
     557    // returning the files list directly here is fast, since we do not 
     558    // have to call initFile on each constituent file; but we can only do so 
     559    // when each constituent file does not itself have multiple used files 
     560 
     561    if (reader.getUsedFiles(files[0]).length > 1) { 
     562      // each constituent file has multiple used files; we must build the list 
     563      // this could happen with, e.g., a stitched collection of ICS/IDS pairs 
     564      // we have no datasets structured this way, so this logic is untested 
     565      if (usedFiles == null) { 
     566        String[][] used = new String[files.length][]; 
     567        int total = files.length; 
     568        for (int i=0; i<files.length; i++) { 
     569          used[i] = readers[i].getUsedFiles(files[i]); 
     570          total += used[i].length; 
     571        } 
     572        usedFiles = new String[total]; 
     573        for (int i=0, off=0; i<used.length; i++) { 
     574          System.arraycopy(used[i], 0, usedFiles, off, used[i].length);  
     575          off += used[i].length; 
     576        } 
     577      } 
     578      return usedFiles; 
     579    } 
     580    // assume every constituent file has no other used files 
     581    // this logic could fail if the first constituent has no extra used files, 
     582    // but later constituents do; in practice, this scenario seems unlikely 
     583    return files; 
    570584  } 
    571585 
Note: See TracChangeset for help on using the changeset viewer.