You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/17 22:39:38 UTC
svn commit: r1158897 -
/uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java
Author: joern
Date: Wed Aug 17 20:39:38 2011
New Revision: 1158897
URL: http://svn.apache.org/viewvc?rev=1158897&view=rev
Log:
UIMA-2215 The create flag for the IndexWriter is now configurable via the properties file.
Modified:
uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java
Modified: uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java
URL: http://svn.apache.org/viewvc/uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java?rev=1158897&r1=1158896&r2=1158897&view=diff
==============================================================================
--- uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java (original)
+++ uima/addons/trunk/Lucas/src/main/java/org/apache/uima/lucas/indexer/IndexWriterProviderImpl.java Wed Aug 17 20:39:38 2011
@@ -42,8 +42,9 @@ public class IndexWriterProviderImpl imp
public static final String USE_COMPOUND_FILE_FORMAT_PROPERTY = "useCompoundFileFormat";
public static final String RAMBUFFER_SIZE_PROPERTY = "RAMBufferSize";
public static final String INDEX_PATH_PROPERTY = "indexPath";
+ public static final String CREATE_INDEX_PROPERTY = "createIndex";
public static final String MAX_FIELD_LENGTH_PROPERTY = "maxFieldLength";
- private static final String UNIQUE_INDEX_PROPERTY = "uniqueIndex";
+ public static final String UNIQUE_INDEX_PROPERTY = "uniqueIndex";
private static Set<Integer> randomNumbers = new HashSet<Integer>();
@@ -61,7 +62,10 @@ public class IndexWriterProviderImpl imp
indexPath = createUniqueIndexPath(indexPath);
MaxFieldLength maxFieldLength = getMaxFieldLengthOrDefault(properties);
- createIndexWriter(indexPath, maxFieldLength);
+
+ boolean createIndex = getCreateIndexOrDefault(properties);
+
+ createIndexWriter(indexPath, maxFieldLength, createIndex);
Double ramBufferSize = getRAMBufferSizeOrDefault(properties);
Boolean useCompoundFileFormat = getUseCompoundFormatOrDefault(properties);
@@ -138,9 +142,20 @@ public class IndexWriterProviderImpl imp
}
}
- private void createIndexWriter(String indexPath, MaxFieldLength maxFieldLength) throws ResourceInitializationException {
+ private boolean getCreateIndexOrDefault(Properties properties) {
+ String createIndexAsString = properties.getProperty(CREATE_INDEX_PROPERTY);
+ if (createIndexAsString != null) {
+ return Boolean.getBoolean(createIndexAsString);
+ }
+ else {
+ // Thats the default before this property was introduced
+ return true;
+ }
+ }
+
+ private void createIndexWriter(String indexPath, MaxFieldLength maxFieldLength, boolean create) throws ResourceInitializationException {
try {
- indexWriter = new IndexWriter(indexPath, new StandardAnalyzer(), true, maxFieldLength);
+ indexWriter = new IndexWriter(indexPath, new StandardAnalyzer(), create, maxFieldLength);
} catch (CorruptIndexException e) {
throw new ResourceInitializationException(e);
} catch (LockObtainFailedException e) {