lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r687014 - in /lucene/java/trunk: ./ contrib/analyzers/src/java/org/apache/lucene/analysis/query/ contrib/memory/src/java/org/apache/lucene/index/memory/ contrib/miscellaneous/src/java/org/apache/lucene/index/ contrib/miscellaneous/src/java/...
Date Tue, 19 Aug 2008 10:40:42 GMT
Author: mikemccand
Date: Tue Aug 19 03:40:39 2008
New Revision: 687014

URL: http://svn.apache.org/viewvc?rev=687014&view=rev
Log:
LUCENE-1334: add Term(String fieldName) constructor that sets term text to empty string

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/analyzers/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
    lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
    lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
    lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
    lucene/java/trunk/src/java/org/apache/lucene/index/ParallelReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/Term.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Aug 19 03:40:39 2008
@@ -105,6 +105,9 @@
     the provided byte[] result to getBinaryValue.  (Eks Dev via Mike
     McCandless)
 
+16. LUCENE-1334: Add new constructor for Term: Term(String fieldName)
+    which defaults term text to "".  (DM Smith via Mike McCandless)
+
 Bug fixes
     
  1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimize a single 

Modified: lucene/java/trunk/contrib/analyzers/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
(original)
+++ lucene/java/trunk/contrib/analyzers/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
Tue Aug 19 03:40:39 2008
@@ -138,7 +138,7 @@
   public int addStopWords(IndexReader reader, String fieldName, int maxDocFreq) throws IOException
{
     HashSet stopWords = new HashSet();
     String internedFieldName = fieldName.intern();
-    TermEnum te = reader.terms(new Term(fieldName, ""));
+    TermEnum te = reader.terms(new Term(fieldName));
     Term term = te.term();
     while (term != null) {
       if (term.field() != internedFieldName) {

Modified: lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
(original)
+++ lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
Tue Aug 19 03:40:39 2008
@@ -704,7 +704,7 @@
   ///////////////////////////////////////////////////////////////////////////////
   // Nested classes:
   ///////////////////////////////////////////////////////////////////////////////
-  private static final Term MATCH_ALL_TERM = new Term("", "");
+  private static final Term MATCH_ALL_TERM = new Term("");
     
   /**
    * Search support for Lucene framework integration; implements all methods
@@ -821,7 +821,7 @@
           Term template = info.template;
           if (template == null) { // not yet cached?
             String fieldName = (String) sortedFields[pos].getKey();
-            template = new Term(fieldName, "");
+            template = new Term(fieldName);
             info.template = template;
           }
           

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
(original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
Tue Aug 19 03:40:39 2008
@@ -118,7 +118,7 @@
       if (sim == null)
         fakeNorms = SegmentReader.createFakeNorms(reader.maxDoc());
       try {
-        termEnum = reader.terms(new Term(field,""));
+        termEnum = reader.terms(new Term(field));
         try {
           termDocs = reader.termDocs();
           do {

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
(original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
Tue Aug 19 03:40:39 2008
@@ -114,7 +114,7 @@
       reader = IndexReader.open(dir);
       termCounts = new int[reader.maxDoc()];
       try {
-        termEnum = reader.terms(new Term(field,""));
+        termEnum = reader.terms(new Term(field));
         try {
           termDocs = reader.termDocs();
           do {

Modified: lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
(original)
+++ lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
Tue Aug 19 03:40:39 2008
@@ -83,7 +83,7 @@
 	{
 		
     OpenBitSet bits=new OpenBitSet(reader.maxDoc()); //assume all are INvalid
-		Term startTerm=new Term(fieldName,"");
+		Term startTerm=new Term(fieldName);
 		TermEnum te = reader.terms(startTerm);
 		if(te!=null)
 		{
@@ -123,7 +123,7 @@
 		
     OpenBitSet bits=new OpenBitSet(reader.maxDoc());
 		bits.set(0,reader.maxDoc()); //assume all are valid
-		Term startTerm=new Term(fieldName,"");
+		Term startTerm=new Term(fieldName);
 		TermEnum te = reader.terms(startTerm);
 		if(te!=null)
 		{

Modified: lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
(original)
+++ lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
Tue Aug 19 03:40:39 2008
@@ -106,7 +106,7 @@
         TokenStream ts=analyzer.tokenStream(f.fieldName,new StringReader(f.queryString));
         Token token=ts.next();
         int corpusNumDocs=reader.numDocs();
-        Term internSavingTemplateTerm =new Term(f.fieldName,""); //optimization to avoid
constructing new Term() objects
+        Term internSavingTemplateTerm =new Term(f.fieldName); //optimization to avoid constructing
new Term() objects
         HashSet processedTerms=new HashSet();
         while(token!=null)
         {            

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
Tue Aug 19 03:40:39 2008
@@ -57,7 +57,7 @@
 
     LuceneIterator() {
       try {
-        termEnum = reader.terms(new Term(field, ""));
+        termEnum = reader.terms(new Term(field));
       } catch (IOException e) {
         throw new RuntimeException(e);
       }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/ParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/ParallelReader.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/ParallelReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/ParallelReader.java Tue Aug 19 03:40:39
2008
@@ -486,7 +486,7 @@
       }
       while (fieldIterator.hasNext()) {
         field = (String) fieldIterator.next();
-        termEnum = ((IndexReader)fieldToReader.get(field)).terms(new Term(field, ""));
+        termEnum = ((IndexReader)fieldToReader.get(field)).terms(new Term(field));
         Term term = termEnum.term();
         if (term!=null && term.field()==field)
           return true;

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/Term.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/Term.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/Term.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/Term.java Tue Aug 19 03:40:39 2008
@@ -35,6 +35,17 @@
   public Term(String fld, String txt) {
     this(fld, txt, true);
   }
+
+  /** Constructs a Term with the given field and empty text.
+   * This serves two purposes: 1) reuse of a Term with the same field.
+   * 2) pattern for a query.
+   * 
+   * @param fld
+   */
+  public Term(String fld) {
+    this(fld, "", true);
+  }
+
   Term(String fld, String txt, boolean intern) {
     field = intern ? fld.intern() : fld;	  // field names are interned
     text = txt;					  // unless already known to be

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java Tue Aug
19 03:40:39 2008
@@ -45,7 +45,7 @@
       LongParser parser = (LongParser) entry.custom;
       final long[] retArray = new long[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term(field, ""));
+      TermEnum termEnum = reader.terms (new Term(field));
       try {
         do {
           Term term = termEnum.term();
@@ -85,7 +85,7 @@
       DoubleParser parser = (DoubleParser) entry.custom;
       final double[] retArray = new double[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -115,7 +115,7 @@
     protected Object createValue(IndexReader reader, Object fieldKey)
         throws IOException {
       String field = ((String)fieldKey).intern();
-      TermEnum enumerator = reader.terms (new Term (field, ""));
+      TermEnum enumerator = reader.terms (new Term (field));
       try {
         Term term = enumerator.term();
         if (term == null) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java Tue Aug 19 03:40:39
2008
@@ -176,7 +176,7 @@
       ByteParser parser = (ByteParser) entry.custom;
       final byte[] retArray = new byte[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -215,7 +215,7 @@
       ShortParser parser = (ShortParser) entry.custom;
       final short[] retArray = new short[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -254,7 +254,7 @@
       IntParser parser = (IntParser) entry.custom;
       final int[] retArray = new int[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -295,7 +295,7 @@
       FloatParser parser = (FloatParser) entry.custom;
       final float[] retArray = new float[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -327,7 +327,7 @@
       String field = ((String) fieldKey).intern();
       final String[] retArray = new String[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();
@@ -360,7 +360,7 @@
       final int[] retArray = new int[reader.maxDoc()];
       String[] mterms = new String[reader.maxDoc()+1];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       int t = 0;  // current term number
 
       // an entry for documents that have no terms in this field
@@ -431,7 +431,7 @@
     protected Object createValue(IndexReader reader, Object fieldKey)
         throws IOException {
       String field = ((String)fieldKey).intern();
-      TermEnum enumerator = reader.terms (new Term (field, ""));
+      TermEnum enumerator = reader.terms (new Term (field));
       try {
         Term term = enumerator.term();
         if (term == null) {
@@ -488,7 +488,7 @@
       SortComparator comparator = (SortComparator) entry.custom;
       final Comparable[] retArray = new Comparable[reader.maxDoc()];
       TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
+      TermEnum termEnum = reader.terms (new Term (field));
       try {
         do {
           Term term = termEnum.term();

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java Tue Aug 19 03:40:39
2008
@@ -102,7 +102,7 @@
         TermEnum enumerator =
             (null != lowerTerm
              ? reader.terms(new Term(fieldName, lowerTerm))
-             : reader.terms(new Term(fieldName,"")));
+             : reader.terms(new Term(fieldName)));
         
         try {
             
@@ -164,7 +164,7 @@
         TermEnum enumerator =
             (null != lowerTerm
              ? reader.terms(new Term(fieldName, lowerTerm))
-             : reader.terms(new Term(fieldName,"")));
+             : reader.terms(new Term(fieldName)));
         
         try {
             

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java?rev=687014&r1=687013&r2=687014&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java Tue Aug 19 03:40:39
2008
@@ -69,7 +69,7 @@
             this.lowerTerm = lowerTerm;
         }
         else {
-            this.lowerTerm = new Term(upperTerm.field(), "");
+            this.lowerTerm = new Term(upperTerm.field());
         }
 
         this.upperTerm = upperTerm;



Mime
View raw message