Author: gsingers
Date: Wed May 27 12:34:09 2009
New Revision: 779144
URL: http://svn.apache.org/viewvc?rev=779144&view=rev
Log:
SOLR-1188: Minor efficiency improvement in TermVectorComponent
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/java/org/apache/solr/handler/component/TermVectorComponent.java
lucene/solr/trunk/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
Modified: lucene/solr/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=779144&r1=779143&r2=779144&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Wed May 27 12:34:09 2009
@@ -269,10 +269,6 @@
12. SOLR-1165: Use Lucene Filters and pass them down to the Lucene
search methods to filter earlier and improve performance. (yonik)
-13. SOLR-1111: Use per-segment sorting to share fieldcache elements
- across unchanged segments. This saves memory and reduces
- commit times for incremental updates to the index. (yonik)
-
Bug Fixes
----------------------
Modified:
lucene/solr/trunk/src/java/org/apache/solr/handler/component/TermVectorComponent.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/component/TermVectorComponent.java?rev=779144&r1=779143&r2=779144&view=diff
==============================================================================
---
lucene/solr/trunk/src/java/org/apache/solr/handler/component/TermVectorComponent.java
(original)
+++
lucene/solr/trunk/src/java/org/apache/solr/handler/component/TermVectorComponent.java
Wed May 27 12:34:09 2009
@@ -193,6 +193,16 @@
private NamedList fieldNL;
private Term currentTerm;
+ /**
+ *
+ * @param fields
+ * @param reader
+ * @param termFreq
+ * @param positions true if the TVM should try to get position info from
the Term Vector, assuming it is present
+ * @param offsets true if the TVM should try to get offset info from the
Term Vector, assuming it is present
+ * @param docFreq
+ * @param tfIdf
+ */
public TVMapper(String[] fields, IndexReader reader, boolean termFreq,
boolean positions, boolean offsets, boolean docFreq, boolean tfIdf) {
this.reader = reader;
@@ -268,6 +278,16 @@
fieldNL = null;
}
}
+
+ @Override
+ public boolean isIgnoringPositions() {
+ return this.positions == false; // if we are not interested in
positions, then return true telling Lucene to skip loading them
+ }
+
+ @Override
+ public boolean isIgnoringOffsets() {
+ return this.offsets == false; // if we are not interested in offsets,
then return true telling Lucene to skip loading them
+ }
}
public void prepare(ResponseBuilder rb) throws IOException {
Modified:
lucene/solr/trunk/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java?rev=779144&r1=779143&r2=779144&view=diff
==============================================================================
---
lucene/solr/trunk/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
(original)
+++
lucene/solr/trunk/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
Wed May 27 12:34:09 2009
@@ -93,7 +93,11 @@
NamedList titl = (NamedList) field.get("titl");
assertTrue("titl is null and it shouldn't be", titl != null);
assertTrue(titl.get("tf") + " does not equal: " + 2, ((Integer)
titl.get("tf")) == 2);
-
+ //there should not be any positions or offsets
+ NamedList positions = (NamedList) titl.get("positions");
+ assertTrue("positions is not null and it should be", positions == null);
+ NamedList offsets = (NamedList) titl.get("offsets");
+ assertTrue("offsets is not null and it should be", offsets == null);
String uniqueKeyFieldName = (String) termVectors.getVal(1);
assertTrue("uniqueKeyFieldName is null and it shouldn't be",
uniqueKeyFieldName != null);
assertTrue(uniqueKeyFieldName + " is not equal to " + "id",
uniqueKeyFieldName.equals("id") == true);
@@ -126,6 +130,24 @@
NamedList doc = (NamedList) termVectors.getVal(0);
assertTrue("doc is null and it shouldn't be", doc != null);
assertTrue(doc.size() + " does not equal: " + 2, doc.size() == 2);
+ NamedList offtv = (NamedList) doc.get("test_posofftv");
+ assertTrue("offtv is null and it shouldn't be", offtv != null);
+ assertTrue("offtv Size: " + offtv.size() + " is not: " + 2, offtv.size()
== 2);
+ NamedList another = (NamedList) offtv.get("anoth");
+ NamedList offsets = (NamedList) another.get("offsets");
+ assertTrue("offsets is null and it shouldn't be", offsets != null);
+ assertTrue("offsets Size: " + offsets.size() + " is not greater than: " +
0, offsets.size() > 0);
+ NamedList pos = (NamedList) another.get("positions");
+ assertTrue("pos is null and it shouldn't be", pos != null);
+ assertTrue("pos Size: " + pos.size() + " is not greater than: " + 0,
pos.size() > 0);
+ Integer df = (Integer) another.get("df");
+ assertTrue("df is null and it shouldn't be", df != null);
+ assertTrue(df + " does not equal: " + 2, df == 2);
+ Double tfIdf = (Double) another.get("tf-idf");
+ assertTrue("tfIdf is null and it shouldn't be", tfIdf != null);
+ assertTrue(tfIdf + " does not equal: " + 0.5, tfIdf == 0.5);
+
+
}