lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1442886 - in /lucene/dev/branches/branch_4x: ./ dev-tools/ lucene/ lucene/analysis/ lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ lucene/analysis/uima/src/java/org/...
Date Wed, 06 Feb 2013 10:12:14 GMT
Author: tommaso
Date: Wed Feb  6 10:12:13 2013
New Revision: 1442886

URL: http://svn.apache.org/viewvc?rev=1442886&view=rev
Log:
LUCENE-4756 - merged to branch_4x

Added:
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/AEProviderFactoryTest.java
      - copied unchanged from r1442876, lucene/dev/trunk/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/AEProviderFactoryTest.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/BUILD.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/MIGRATE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/README.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/SYSTEM_REQUIREMENTS.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java
  (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/BaseUIMATokenizer.java
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.java
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizer.java
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ae/AEProviderFactory.java
    lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/OverridingParamsAEProviderTest.java
    lucene/dev/branches/branch_4x/lucene/backwards/   (props changed)
    lucene/dev/branches/branch_4x/lucene/benchmark/   (props changed)
    lucene/dev/branches/branch_4x/lucene/build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/codecs/   (props changed)
    lucene/dev/branches/branch_4x/lucene/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.cfs.zip
  (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.nocfs.zip
  (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.cfs.zip
  (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.nocfs.zip
  (props changed)
    lucene/dev/branches/branch_4x/lucene/demo/   (props changed)
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/grouping/   (props changed)
    lucene/dev/branches/branch_4x/lucene/highlighter/   (props changed)
    lucene/dev/branches/branch_4x/lucene/ivy-settings.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/join/   (props changed)
    lucene/dev/branches/branch_4x/lucene/licenses/   (props changed)
    lucene/dev/branches/branch_4x/lucene/memory/   (props changed)
    lucene/dev/branches/branch_4x/lucene/misc/   (props changed)
    lucene/dev/branches/branch_4x/lucene/module-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/queries/   (props changed)
    lucene/dev/branches/branch_4x/lucene/queryparser/   (props changed)
    lucene/dev/branches/branch_4x/lucene/sandbox/   (props changed)
    lucene/dev/branches/branch_4x/lucene/site/   (props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/   (props changed)
    lucene/dev/branches/branch_4x/lucene/suggest/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/README.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/SYSTEM_REQUIREMENTS.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/cloud-dev/   (props changed)
    lucene/dev/branches/branch_4x/solr/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/contrib/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/example/   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/scripts/   (props changed)
    lucene/dev/branches/branch_4x/solr/site/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/testlogging.properties   (props changed)
    lucene/dev/branches/branch_4x/solr/webapp/   (props changed)

Modified: lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/BaseUIMATokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/BaseUIMATokenizer.java?rev=1442886&r1=1442885&r2=1442886&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/BaseUIMATokenizer.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/BaseUIMATokenizer.java
Wed Feb  6 10:12:13 2013
@@ -28,7 +28,6 @@ import org.apache.uima.resource.Resource
 
 import java.io.IOException;
 import java.io.Reader;
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -38,17 +37,17 @@ import java.util.Map;
 public abstract class BaseUIMATokenizer extends Tokenizer {
 
   protected FSIterator<AnnotationFS> iterator;
-  protected final AnalysisEngine ae;
-  protected final CAS cas;
+
+  private final String descriptorPath;
+  private final Map<String, Object> configurationParameters;
+
+  protected AnalysisEngine ae;
+  protected CAS cas;
 
   protected BaseUIMATokenizer(Reader reader, String descriptorPath, Map<String, Object>
configurationParameters) {
     super(reader);
-    try {
-      ae = AEProviderFactory.getInstance().getAEProvider(null, descriptorPath, configurationParameters).getAE();
-      cas = ae.newCAS();
-    } catch (ResourceInitializationException e) {
-      throw new RuntimeException(e);
-    }
+    this.descriptorPath = descriptorPath;
+    this.configurationParameters = configurationParameters;
   }
 
   /**
@@ -58,8 +57,15 @@ public abstract class BaseUIMATokenizer 
    *
    * @throws IOException If there is a low-level I/O error.
    */
-  protected void analyzeInput() throws AnalysisEngineProcessException, IOException {
-    cas.reset();
+  protected void analyzeInput() throws ResourceInitializationException, AnalysisEngineProcessException,
IOException {
+    if (ae == null) {
+      ae = AEProviderFactory.getInstance().getAEProvider(null, descriptorPath, configurationParameters).getAE();
+    }
+    if (cas == null) {
+      cas = ae.newCAS();
+    } else {
+      cas.reset();
+    }
     cas.setDocumentText(toString(input));
     ae.process(cas);
   }
@@ -90,5 +96,18 @@ public abstract class BaseUIMATokenizer 
     iterator = null;
   }
 
+  @Override
+  public void close() throws IOException {
+    super.close();
 
+    // release resources and ease GC
+    if (ae != null) {
+      ae.destroy();
+      ae = null;
+    }
+    if (cas != null) {
+      cas.release();
+      cas = null;
+    }
+  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.java?rev=1442886&r1=1442885&r2=1442886&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.java
Wed Feb  6 10:12:13 2013
@@ -23,6 +23,7 @@ import org.apache.lucene.analysis.tokena
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.resource.ResourceInitializationException;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -54,6 +55,8 @@ public final class UIMAAnnotationsTokeni
       analyzeInput();
     } catch (AnalysisEngineProcessException e) {
       throw new IOException(e);
+    } catch (ResourceInitializationException e) {
+      throw new IOException(e);
     }
     finalOffset = correctOffset(cas.getDocumentText().length());
     Type tokenType = cas.getTypeSystem().getType(tokenTypeString);

Modified: lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizer.java?rev=1442886&r1=1442885&r2=1442886&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizer.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizer.java
Wed Feb  6 10:12:13 2013
@@ -26,6 +26,7 @@ import org.apache.uima.cas.CASException;
 import org.apache.uima.cas.FeaturePath;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.resource.ResourceInitializationException;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -66,6 +67,8 @@ public final class UIMATypeAwareAnnotati
       analyzeInput();
     } catch (AnalysisEngineProcessException e) {
       throw new IOException(e);
+    } catch (ResourceInitializationException e) {
+      throw new IOException(e);
     }
     featurePath = cas.createFeaturePath();
     try {

Modified: lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ae/AEProviderFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ae/AEProviderFactory.java?rev=1442886&r1=1442885&r2=1442886&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ae/AEProviderFactory.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/ae/AEProviderFactory.java
Wed Feb  6 10:12:13 2013
@@ -25,7 +25,7 @@ import java.util.Map;
  */
 public class AEProviderFactory {
 
-  private static AEProviderFactory instance;
+  private static final AEProviderFactory instance = new AEProviderFactory();
 
   private final Map<String, AEProvider> providerCache = new HashMap<String, AEProvider>();
 
@@ -34,15 +34,12 @@ public class AEProviderFactory {
   }
 
   public static AEProviderFactory getInstance() {
-    if (instance == null) {
-      instance = new AEProviderFactory();
-    }
     return instance;
   }
 
   /**
-   * @param keyPrefix a prefix of the key used to cache the AEProvider
-   * @param aePath the AnalysisEngine descriptor path
+   * @param keyPrefix         a prefix of the key used to cache the AEProvider
+   * @param aePath            the AnalysisEngine descriptor path
    * @param runtimeParameters map of runtime parameters to configure inside the AnalysisEngine
    * @return AEProvider
    */
@@ -69,7 +66,7 @@ public class AEProviderFactory {
   }
 
   /**
-   * @param aePath the AnalysisEngine descriptor path
+   * @param aePath            the AnalysisEngine descriptor path
    * @param runtimeParameters map of runtime parameters to configure inside the AnalysisEngine
    * @return AEProvider
    */

Modified: lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/OverridingParamsAEProviderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/OverridingParamsAEProviderTest.java?rev=1442886&r1=1442885&r2=1442886&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/OverridingParamsAEProviderTest.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/ae/OverridingParamsAEProviderTest.java
Wed Feb  6 10:12:13 2013
@@ -24,7 +24,9 @@ import org.junit.Test;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 /**
  * TestCase for {@link OverridingParamsAEProvider}
@@ -56,6 +58,8 @@ public class OverridingParamsAEProviderT
     AEProvider aeProvider = new OverridingParamsAEProvider("/uima/AggregateSentenceAE.xml",
runtimeParameters);
     AnalysisEngine analysisEngine = aeProvider.getAE();
     assertNotNull(analysisEngine);
-    assertEquals(analysisEngine.getConfigParameterValue("ngramsize"), 3);
+    Object parameterValue = analysisEngine.getConfigParameterValue("ngramsize");
+    assertNotNull(parameterValue);
+    assertEquals(Integer.valueOf(3), Integer.valueOf(parameterValue.toString()));
   }
 }



Mime
View raw message