lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mharw...@apache.org
Subject svn commit: r389886 - in /lucene/java/trunk/src/java/org/apache/lucene/search/spans: SpanFirstQuery.java SpanNearQuery.java SpanNotQuery.java SpanOrQuery.java SpanQuery.java SpanTermQuery.java SpanWeight.java
Date Wed, 29 Mar 2006 20:50:49 GMT
Author: mharwood
Date: Wed Mar 29 12:50:47 2006
New Revision: 389886

URL: http://svn.apache.org/viewcvs?rev=389886&view=rev
Log:
Deprecated superfluous abstract getTerms method introduced in SpanQuery.java, added implementations
of Query's existing extractTerms method and switched SpanWeight to use extractTerms instead.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java Wed Mar
29 12:50:47 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
@@ -44,6 +45,10 @@
 
   public String getField() { return match.getField(); }
 
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see #extractTerms(Set)
+   */
   public Collection getTerms() { return match.getTerms(); }
 
   public String toString(String field) {
@@ -56,6 +61,10 @@
     buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
+  
+  public void extractTerms(Set terms) {
+	    match.extractTerms(terms);
+  }  
 
   public Spans getSpans(final IndexReader reader) throws IOException {
     return new Spans() {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java Wed Mar 29
12:50:47 2006
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.Set;
 
 
 import org.apache.lucene.index.IndexReader;
@@ -72,7 +73,11 @@
   public boolean isInOrder() { return inOrder; }
 
   public String getField() { return field; }
-
+  
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see #extractTerms(Set)
+   */
   public Collection getTerms() {
     Collection terms = new ArrayList();
     Iterator i = clauses.iterator();
@@ -82,6 +87,15 @@
     }
     return terms;
   }
+  
+  public void extractTerms(Set terms) {
+	    Iterator i = clauses.iterator();
+	    while (i.hasNext()) {
+	      SpanQuery clause = (SpanQuery)i.next();
+	      clause.extractTerms(terms);
+	    }
+  }  
+  
 
   public String toString(String field) {
     StringBuffer buffer = new StringBuffer();

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java Wed Mar 29
12:50:47 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
@@ -47,7 +48,13 @@
 
   public String getField() { return include.getField(); }
 
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see #extractTerms(Set)
+   */
   public Collection getTerms() { return include.getTerms(); }
+  
+  public void extractTerms(Set terms) { include.extractTerms(terms); }
 
   public String toString(String field) {
     StringBuffer buffer = new StringBuffer();

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Wed Mar 29
12:50:47 2006
@@ -22,6 +22,7 @@
 import java.util.Collection;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.PriorityQueue;
@@ -56,6 +57,10 @@
 
   public String getField() { return field; }
 
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see #extractTerms(Set)
+   */
   public Collection getTerms() {
     Collection terms = new ArrayList();
     Iterator i = clauses.iterator();
@@ -65,6 +70,15 @@
     }
     return terms;
   }
+  
+  public void extractTerms(Set terms) {
+	    Iterator i = clauses.iterator();
+	    while (i.hasNext()) {
+	      SpanQuery clause = (SpanQuery)i.next();
+	      clause.extractTerms(terms);
+	    }
+  }
+  
 
   public Query rewrite(IndexReader reader) throws IOException {
     SpanOrQuery clone = null;

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java Wed Mar 29 12:50:47
2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
@@ -34,7 +35,10 @@
   /** Returns the name of the field matched by this query.*/
   public abstract String getField();
 
-  /** Returns a collection of all terms matched by this query.*/
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see Query#extractTerms(Set)
+   */
   public abstract Collection getTerms();
 
   protected Weight createWeight(Searcher searcher) throws IOException {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Wed Mar 29
12:50:47 2006
@@ -20,6 +20,7 @@
 
 import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -37,11 +38,18 @@
   public Term getTerm() { return term; }
 
   public String getField() { return term.field(); }
-
+  
+  /** Returns a collection of all terms matched by this query.
+   * @deprecated use extractTerms instead
+   * @see #extractTerms(Set)
+   */
   public Collection getTerms() {
     Collection terms = new ArrayList();
     terms.add(term);
     return terms;
+  }
+  public void extractTerms(Set terms) {
+	  terms.add(term);
   }
 
   public String toString(String field) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=389886&r1=389885&r2=389886&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java Wed Mar 29 12:50:47
2006
@@ -18,8 +18,9 @@
 
 import java.io.IOException;
 
+import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Collection;
+import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -38,14 +39,15 @@
   private float queryNorm;
   private float queryWeight;
 
-  private Collection terms;
+  private Set terms;
   private SpanQuery query;
 
   public SpanWeight(SpanQuery query, Searcher searcher)
     throws IOException {
     this.similarity = query.getSimilarity(searcher);
     this.query = query;
-    this.terms = query.getTerms();
+    terms=new HashSet();
+    query.extractTerms(terms);
 
     idf = this.query.getSimilarity(searcher).idf(terms, searcher);
   }



Mime
View raw message