Changeset 6582


Ignore:
Timestamp:
Oct 29, 2014, 12:38:28 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1876: Delay preloading array design feature in raw data batcher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/core/net/sf/basedb/core/RawDataBatcher.java

    r6444 r6582  
    161161    @see FeatureIdentificationMethod
    162162  */
    163   private final Map<Object, FeatureData> preloaded;
     163  private Map<Object, FeatureData> preloaded;
    164164 
    165165  /**
     
    230230    }
    231231   
    232     // Preload features
    233     if (arrayDesign != null && arrayDesign.getHasFeatures() && rawBioAssay.getNumDbSpots() == 0)
    234     {
    235       org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "COUNT_FEATURES_FOR_ARRAYDESIGN");
    236       /*
    237         SELECT count(*)
    238         FROM FeatureData f
    239         WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
    240       */
    241       query.setInteger("arrayDesign", arrayDesign.getId());
    242       int numFeatures = HibernateUtil.loadData(Long.class, query).intValue();
    243       preloaded = new HashMap<Object, FeatureData>(numFeatures);
    244       query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "PRELOAD_FEATURES");
    245       /*
    246         SELECT f
    247         FROM FeatureData f
    248         JOIN FETCH f.arrayDesignBlock b
    249         LEFT JOIN FETCH f.reporter
    250         WHERE b.arrayDesign = :arrayDesign
    251       */
    252       query.setInteger("arrayDesign", arrayDesign.getId());
    253       ScrollIterator<FeatureData> si = null;
    254       try
    255       {
    256         si = QueryExecutor.loadIterator(FeatureData.class, query,
    257             dc.getStatelessSession(), dc.getSessionControl());
    258       }
    259       catch (InterruptedException ex)
    260       {
    261         throw new SignalException("Aborted by user", ex);
    262       }
    263       while (si.hasNext())
    264       {
    265         ThreadSignalHandler.checkInterrupted();
    266         FeatureData feature = si.next();
    267         Object featureId = fiMethod.getIdentifier(feature);
    268         if (preloaded.put(featureId, feature) != null)
    269         {
    270           throw new InvalidDataException("Can't identify features with " + fiMethod +
    271             ". Found duplicate feature: " + featureId);
    272         }
    273       }
    274       si.close();
    275     }
    276     else
    277     {
    278       this.preloaded = null;
    279     }
    280     this.usedFeatures = new HashSet<Object>(preloaded == null ? 100 : preloaded.size());
    281232    setDbControl(dc);
    282233  }
     
    529480    throws BaseException
    530481  {
     482    if (usedFeatures == null) preloadFeatures();
    531483    if (externalReporterId != null) externalReporterId = externalReporterId.trim();
    532484    if (preloaded == null)
     
    601553  }
    602554 
     555  private void preloadFeatures()
     556  {
     557    // Preload features
     558    if (arrayDesign != null && arrayDesign.getHasFeatures() && rawBioAssay.getNumDbSpots() == 0)
     559    {
     560      DbControl dc = getDbControl();
     561      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "COUNT_FEATURES_FOR_ARRAYDESIGN");
     562      /*
     563        SELECT count(*)
     564        FROM FeatureData f
     565        WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
     566      */
     567      query.setInteger("arrayDesign", arrayDesign.getId());
     568      int numFeatures = HibernateUtil.loadData(Long.class, query).intValue();
     569      preloaded = new HashMap<Object, FeatureData>(numFeatures);
     570      query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "PRELOAD_FEATURES");
     571      /*
     572        SELECT f
     573        FROM FeatureData f
     574        JOIN FETCH f.arrayDesignBlock b
     575        LEFT JOIN FETCH f.reporter
     576        WHERE b.arrayDesign = :arrayDesign
     577      */
     578      query.setInteger("arrayDesign", arrayDesign.getId());
     579      ScrollIterator<FeatureData> si = null;
     580      try
     581      {
     582        si = QueryExecutor.loadIterator(FeatureData.class, query,
     583            dc.getStatelessSession(), dc.getSessionControl());
     584      }
     585      catch (InterruptedException ex)
     586      {
     587        throw new SignalException("Aborted by user", ex);
     588      }
     589      while (si.hasNext())
     590      {
     591        ThreadSignalHandler.checkInterrupted();
     592        FeatureData feature = si.next();
     593        Object featureId = fiMethod.getIdentifier(feature);
     594        if (preloaded.put(featureId, feature) != null)
     595        {
     596          throw new InvalidDataException("Can't identify features with " + fiMethod +
     597            ". Found duplicate feature: " + featureId);
     598        }
     599      }
     600      si.close();
     601    }
     602    else
     603    {
     604      this.preloaded = null;
     605    }
     606    this.usedFeatures = new HashSet<Object>(preloaded == null ? 100 : preloaded.size());
     607  }
     608 
    603609  /**
    604610    Create a new raw data object. After you have set all
Note: See TracChangeset for help on using the changeset viewer.