Changeset 7474


Ignore:
Timestamp:
Apr 12, 2018, 10:33:31 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2114: Improve progress reporting in Annotation importer plug-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.12-stable/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r7204 r7474  
    643643  private int numRemoved;
    644644  private ProgressReporter progress;
     645  // Percentages will be adjusted based on number of annotations
     646  private int progressParser = 50; // Progress percentage for file-parsing
     647  private int progressDatabase = 48; // Progress percentage for database update
    645648 
    646649  @Override
     
    761764      ++i;
    762765    }
     766   
     767    // Recalculate progress parts so that the file parsing is between 10-50% depedning on number of annotations
     768    int dbPart = (1 + mappers.size() % 20);
     769    progressParser = Math.max(100 / (1+dbPart), 10);
     770    progressDatabase = 98 - progressParser;
     771   
    763772    batcher = new AnnotationBatcher(dc, itemType);
    764773    batcher.addAnnotationTypes(mappers.values());
     
    948957        for (Set<NewAnnotations> n : itemCache.values())
    949958        {
    950           if (progress != null && current % 100 == 0)
    951           {
    952             progress.display(50 + (48 * current) / total, "Saving to database (" + current + " of  " + total + " items done)...");
     959          // progressParser should be between 10-50 and is a good interval for progress reporting
     960          if (progress != null && current % progressParser == 0)
     961          {
     962            progress.display(progressParser + (progressDatabase * current) / total, "Saving to database (" + current + " of  " + total + " items done)...");
    953963          }
    954964          current++;
     
    9961006  /**
    9971007    Overriding default implementation since we want file parsing to
    998     only use 50% and the remaining 50% for storing to the database.
     1008    only use 'progressParser'% and the remaining 'progressDatabase'%
     1009    for storing to the database.
    9991010   */
    10001011  @Override
    10011012  protected int getProgress(FlatFileParser ffp)
    10021013  {
    1003     return super.getProgress(ffp) * 50 / 100;
     1014    if (ffp.getParsedDataLines() == 0) return 0;
     1015    return super.getProgress(ffp) * progressParser / 100;
    10041016  }
    10051017  // -------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.