Revision: 17255
http://sourceforge.net/p/gate/code/17255
Author: valyt
Date: 2014-01-29 15:29:10 +0000 (Wed, 29 Jan 2014)
Log Message:
-----------
Direct indexes don't use the IndexReaderPool any more.
Modified Paths:
--------------
mimir/branches/5.0/mimir-core/src/gate/mimir/index/AtomicIndex.java
mimir/branches/5.0/mimir-core/src/gate/mimir/index/mg4j/zipcollection/DocumentCollection.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/QueryEngine.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/query/TermQuery.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AnnotationTermsQuery.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentTermsQuery.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsAndTermsQuery.java
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsOrTermsQuery.java
Modified: mimir/branches/5.0/mimir-core/src/gate/mimir/index/AtomicIndex.java
===================================================================
--- mimir/branches/5.0/mimir-core/src/gate/mimir/index/AtomicIndex.java
2014-01-29 13:16:11 UTC (rev 17254)
+++ mimir/branches/5.0/mimir-core/src/gate/mimir/index/AtomicIndex.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -1762,15 +1762,6 @@
public Index getDirectIndex() {
return directIndex;
}
-
- /**
- * Creates and returns an {@link IndexReader} for this index.
- * @return
- * @throws IOException
- */
- public IndexReader getIndexReader() throws IOException {
- return getIndex().getReader();
- }
/**
* Gets the term string for a given direct term ID. The term ID must have
been
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/index/mg4j/zipcollection/DocumentCollection.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/index/mg4j/zipcollection/DocumentCollection.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/index/mg4j/zipcollection/DocumentCollection.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -504,7 +504,7 @@
*/
public void close() throws IOException {
// close the writer
- collectionFileWriter.close();
+ if(collectionFileWriter != null) collectionFileWriter.close();
// close the reader
closed = true;
if(collectionFiles != null){
Modified: mimir/branches/5.0/mimir-core/src/gate/mimir/search/QueryEngine.java
===================================================================
--- mimir/branches/5.0/mimir-core/src/gate/mimir/search/QueryEngine.java
2014-01-29 13:16:11 UTC (rev 17254)
+++ mimir/branches/5.0/mimir-core/src/gate/mimir/search/QueryEngine.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -99,12 +99,6 @@
}
/**
- * Array containing the direct indexes (if enabled) for the Mímir composite
- * index.
- */
- protected IndexReaderPool[] directIndexReaderPools;
-
- /**
* The maximum size of an index that can be loaded in memory (by default 64
* MB).
*/
@@ -294,19 +288,6 @@
}
/**
- * Returns the set of direct indexes (if enabled) in the Mimir composite
- * index. The array contains first the token indexes (in the same order as
- * listed in the index configuration), followed by the mentions indexes
- * (in the same order as listed in the index configuration). In other words,
- * this array is parallel to the one returned by {@link #getIndexes()}.
- *
- * @return an array of {@link Index} objects.
- */
- public IndexReaderPool[] getDirectIndexes() {
- return directIndexReaderPools;
- }
-
- /**
* Returns the index that stores the data for a particular feature of token
* annotations.
*
@@ -316,27 +297,6 @@
public AtomicTokenIndex getTokenIndex(String featureName) {
return index.getTokenIndex(featureName);
}
-
- /**
- * Returns the <strong>direct</strong> index that stores the data for a
- * particular feature of token annotations.
- *
- * NB: direct indexes are used to search for term IDs given
- * a document ID. For standard searches (getting documents given search
terms)
- * use the default (inverted) index returned by:
- * {@link #getTokenIndex(String)}.
- *
- * @param featureName
- * @return
- */
- public IndexReaderPool getTokenDirectIndex(String featureName) {
- for(int i = 0; i < indexConfig.getTokenIndexers().length; i++) {
-
if(indexConfig.getTokenIndexers()[i].getFeatureName().equals(featureName)) {
- return directIndexReaderPools[i];
- }
- }
- return null;
- }
/**
* Returns the index that stores the data for a particular semantic
annotation
@@ -348,30 +308,6 @@
public AtomicAnnotationIndex getAnnotationIndex(String annotationType) {
return index.getAnnotationIndex(annotationType);
}
-
- /**
- * Returns the <strong>direct</strong> index that stores the data for a
- * particular semantic annotation type.
- *
- * NB: direct indexes are used to search for term IDs given
- * a document ID. For standard searches (getting documents given search
terms)
- * use the default (inverted) index returned by:
- * {@link #getAnnotationIndex(String)}.
- *
- * @param annotationType
- * @return
- */
- public IndexReaderPool getAnnotationDirectIndex(String annotationType) {
- for(int i = 0; i < indexConfig.getSemanticIndexers().length; i++) {
- for(String aType :
- indexConfig.getSemanticIndexers()[i].getAnnotationTypes()) {
- if(aType.equals(annotationType)) {
- return directIndexReaderPools[indexConfig.getTokenIndexers().length
+ i];
- }
- }
- }
- return null;
- }
public SemanticAnnotationHelper getAnnotationHelper(String annotationType) {
for(int i = 0; i < indexConfig.getSemanticIndexers().length; i++) {
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/query/TermQuery.java
===================================================================
--- mimir/branches/5.0/mimir-core/src/gate/mimir/search/query/TermQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++ mimir/branches/5.0/mimir-core/src/gate/mimir/search/query/TermQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -117,7 +117,7 @@
if(atomicIndex == null) throw new IllegalArgumentException(
"No index provided for field " + node.getIndexName() + "!");
- indexReader = atomicIndex.getIndexReader();
+ indexReader = atomicIndex.getIndex().getReader();
// if we have the term ID, use that
if(query.termId != DocumentIterator.END_OF_LIST) {
this.indexIterator = indexReader.documents(query.termId);
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -60,14 +60,9 @@
protected final IndexType indexType;
/**
- * The direct index used for executing the query. This value is non-null only
- * if a direct index was configured as part of the Mímir index being
searched.
+ * The atomic index used for executing the query. This includes both the
+ * inverted and the direct index (if configured).
*/
- protected transient IndexReaderPool directIndexPool;
-
- /**
- * The indirect index used for executing the query.
- */
protected transient AtomicIndex atomicIndex;
/**
@@ -209,19 +204,17 @@
this.engine = engine;
switch(indexType){
case ANNOTATIONS:
- directIndexPool = engine.getAnnotationDirectIndex(indexName);
atomicIndex = engine.getAnnotationIndex(indexName);
annotationHelper = engine.getAnnotationHelper(indexName);
break;
case TOKENS:
- directIndexPool = engine.getTokenDirectIndex(indexName);
atomicIndex = engine.getTokenIndex(indexName);
break;
default:
throw new IllegalArgumentException("Invalid index type: " +
indexType.toString());
}
- if(directIndexPool == null) { throw new IllegalArgumentException(
+ if(!atomicIndex.hasDirectIndex()) { throw new IllegalArgumentException(
"This type of query requires a " +
"direct index, but one was not found for (" +
indexType.toString().toLowerCase() + ") sub-index \"" + indexName +
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AnnotationTermsQuery.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AnnotationTermsQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/AnnotationTermsQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -98,7 +98,7 @@
counts = new int[mentions.size()];
atomicAnnIndex = engine.getAnnotationIndex(
annotationQuery.getAnnotationType());
- annotationIndexReader = atomicAnnIndex.getIndexReader();
+ annotationIndexReader = atomicAnnIndex.getIndex().getReader();
}
int[] lengths = new int[mentions.size()];
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentTermsQuery.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentTermsQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentTermsQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -15,6 +15,7 @@
package gate.mimir.search.terms;
import gate.mimir.SemanticAnnotationHelper;
+import gate.mimir.index.AtomicIndex;
import gate.mimir.index.mg4j.MimirDirectIndexBuilder;
import gate.mimir.search.QueryEngine;
import gate.mimir.search.QueryEngine.IndexType;
@@ -73,13 +74,7 @@
@Override
public TermsResultSet execute(QueryEngine engine) throws IOException {
prepare(engine);
- IndexReader indexReader = null;
- try {
- indexReader = directIndexPool.borrowReader();
- return buildResultSet(indexReader.documents(MimirDirectIndexBuilder
- .longToTerm(documentIds[0])));
- } finally {
- if(indexReader != null) directIndexPool.returnReader(indexReader);
- }
+ return buildResultSet(atomicIndex.getDirectIndex().documents
+ (AtomicIndex.longToTerm(documentIds[0])));
}
}
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsAndTermsQuery.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsAndTermsQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsAndTermsQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -15,6 +15,7 @@
package gate.mimir.search.terms;
import gate.mimir.SemanticAnnotationHelper;
+import gate.mimir.index.AtomicIndex;
import gate.mimir.index.mg4j.MimirDirectIndexBuilder;
import gate.mimir.search.QueryEngine;
import gate.mimir.search.QueryEngine.IndexType;
@@ -73,19 +74,11 @@
@Override
public TermsResultSet execute(QueryEngine engine) throws IOException {
prepare(engine);
- IndexReader[] indexReaders = new IndexReader[documentIds.length];
- try {
- IndexIterator[] iterators = new IndexIterator[documentIds.length];
- for(int i = 0; i < documentIds.length; i++) {
- indexReaders[i] = directIndexPool.borrowReader();
- iterators[i] = indexReaders[i].documents(
- MimirDirectIndexBuilder.longToTerm(documentIds[i]));
- }
- return buildResultSet(AndDocumentIterator.getInstance(iterators));
- } finally {
- for(IndexReader reader : indexReaders) {
- directIndexPool.returnReader(reader);
- }
+ IndexIterator[] iterators = new IndexIterator[documentIds.length];
+ for(int i = 0; i < documentIds.length; i++) {
+ iterators[i] = atomicIndex.getDirectIndex().documents(
+ AtomicIndex.longToTerm(documentIds[i]));
}
+ return buildResultSet(AndDocumentIterator.getInstance(iterators));
}
}
Modified:
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsOrTermsQuery.java
===================================================================
---
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsOrTermsQuery.java
2014-01-29 13:16:11 UTC (rev 17254)
+++
mimir/branches/5.0/mimir-core/src/gate/mimir/search/terms/DocumentsOrTermsQuery.java
2014-01-29 15:29:10 UTC (rev 17255)
@@ -15,6 +15,7 @@
package gate.mimir.search.terms;
import gate.mimir.SemanticAnnotationHelper;
+import gate.mimir.index.AtomicIndex;
import gate.mimir.index.mg4j.MimirDirectIndexBuilder;
import gate.mimir.search.QueryEngine;
import gate.mimir.search.QueryEngine.IndexType;
@@ -76,19 +77,11 @@
@Override
public TermsResultSet execute(QueryEngine engine) throws IOException {
prepare(engine);
- IndexReader[] indexReaders = new IndexReader[documentIds.length];
- try {
- IndexIterator[] iterators = new IndexIterator[documentIds.length];
- for(int i = 0; i < documentIds.length; i++) {
- indexReaders[i] = directIndexPool.borrowReader();
- iterators[i] = indexReaders[i].documents(
- MimirDirectIndexBuilder.longToTerm(documentIds[i]));
- }
- return buildResultSet(OrDocumentIterator.getInstance(iterators));
- } finally {
- for(IndexReader reader : indexReaders) {
- directIndexPool.returnReader(reader);
- }
+ IndexIterator[] iterators = new IndexIterator[documentIds.length];
+ for(int i = 0; i < documentIds.length; i++) {
+ iterators[i] = atomicIndex.getDirectIndex().documents(
+ AtomicIndex.longToTerm(documentIds[i]));
}
+ return buildResultSet(OrDocumentIterator.getInstance(iterators));
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs