ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1452959 - in /incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae: BaseLookupConsumerImpl.java ThreadedDictionaryLookupAnnotator.java UmlsToSnomedDbConsumerImpl.java
Date Tue, 05 Mar 2013 19:40:06 GMT
Author: seanfinan
Date: Tue Mar  5 19:40:06 2013
New Revision: 1452959

URL: http://svn.apache.org/r1452959
Log:
CTAKES-159 : Added some typing in BaseLookupConsumerImpl
Executor required .shutdown() in ThreadedDictionaryLookupAnnotator
Added close() to UmlsToSnomedDbConsumerImpl that closes the db connection

Modified:
    incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/BaseLookupConsumerImpl.java
    incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
    incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java

Modified: incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/BaseLookupConsumerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/BaseLookupConsumerImpl.java?rev=1452959&r1=1452958&r2=1452959&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/BaseLookupConsumerImpl.java
(original)
+++ incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/BaseLookupConsumerImpl.java
Tue Mar  5 19:40:06 2013
@@ -39,7 +39,7 @@ public abstract class BaseLookupConsumer
     * @return Iterator over Set objects. Each Set object is a collection of
     *         LookupHit objects with the same begin,end offsets.
     */
-   static protected Iterator organizeByOffset( final Iterator<LookupHit> lookupHitIterator
) {
+   static protected Iterator<Set<LookupHit>> organizeByOffset( final Iterator<LookupHit>
lookupHitIterator ) {
       final  Map<LookupHitKey, Set<LookupHit>> lookupHitMap = createLookupHitMap(
lookupHitIterator );
       return lookupHitMap.values().iterator();
    }

Modified: incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java?rev=1452959&r1=1452958&r2=1452959&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
(original)
+++ incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/ThreadedDictionaryLookupAnnotator.java
Tue Mar  5 19:40:06 2013
@@ -63,6 +63,23 @@ public class ThreadedDictionaryLookupAnn
    }
 
    /**
+    * Close db connections in UmlsToSnomedDbConsumerImpl
+    * @throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
+    */
+   public void collectionProcessComplete() throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
{
+      for ( Object value : _lookupSpecSet ) {
+         if ( value instanceof LookupSpec ) {
+            final LookupSpec ls = (LookupSpec)value;
+            final LookupConsumer lookupConsumer = ls.getLookupConsumer();
+            if ( lookupConsumer != null && lookupConsumer instanceof UmlsToSnomedDbConsumerImpl
) {
+               ((UmlsToSnomedDbConsumerImpl)lookupConsumer).close();
+            }
+         }
+      }
+      super.collectionProcessComplete();
+   }
+
+   /**
     * Reads configuration parameters.
     */
    private void configInit( final UimaContext uimaContext ) throws ResourceInitializationException
{
@@ -128,6 +145,11 @@ public class ThreadedDictionaryLookupAnn
          // thrown by future.get()
          throw new AnalysisEngineProcessException( exE );
       }
+      try {
+         fixedThreadService.shutdown();
+      } catch ( SecurityException sE ) {
+         _logger.debug( "Can ignore: " + sE.getMessage() );
+      }
    }
 
    private LookupDataStore getLookupData( final JCas jcas, final LookupSpec lookupSpec )
{
@@ -156,6 +178,8 @@ public class ThreadedDictionaryLookupAnn
             // throw new AnalysisEngineProcessException(e);
          }
       }
+      // TODO - last ditch memory reclamation, haven't tried yet  - spf
+//      NDC.remove();
       return new LookupDataStore( lookupSpec, allHits );
    }
 

Modified: incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java?rev=1452959&r1=1452958&r2=1452959&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java
(original)
+++ incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsToSnomedDbConsumerImpl.java
Tue Mar  5 19:40:06 2013
@@ -64,6 +64,16 @@ public class UmlsToSnomedDbConsumerImpl 
       this( uimaContext, properties, Integer.MAX_VALUE );
    }
 
+   public void close() {
+      try {
+         if ( _preparedStatement != null && !_preparedStatement.isClosed() ) {
+            _preparedStatement.close();
+         }
+      } catch ( SQLException sqlE ) {
+         // Nothing necessary
+      }
+   }
+
    /**
     * Queries the given UMLS CUI against the DB. Re`turns a set of SNOMED codes.
     *



Mime
View raw message