lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r680361 - in /lucene/java/trunk/src/java/org/apache/lucene/search: BooleanQuery.java MultiPhraseQuery.java PhraseQuery.java
Date Mon, 28 Jul 2008 13:58:40 GMT
Author: yonik
Date: Mon Jul 28 06:58:39 2008
New Revision: 680361

URL: http://svn.apache.org/viewvc?rev=680361&view=rev
Log:
LUCENE-1346: replace Vector with ArrayList in Queries

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java?rev=680361&r1=680360&r2=680361&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java Mon Jul 28 06:58:39
2008
@@ -177,7 +177,7 @@
 
   private class BooleanWeight implements Weight {
     protected Similarity similarity;
-    protected Vector weights = new Vector();
+    protected ArrayList weights = new ArrayList();
 
     public BooleanWeight(Searcher searcher)
       throws IOException {
@@ -195,7 +195,7 @@
       float sum = 0.0f;
       for (int i = 0 ; i < weights.size(); i++) {
         BooleanClause c = (BooleanClause)clauses.get(i);
-        Weight w = (Weight)weights.elementAt(i);
+        Weight w = (Weight)weights.get(i);
         // call sumOfSquaredWeights for all clauses in case of side effects
         float s = w.sumOfSquaredWeights();         // sum sub weights
         if (!c.isProhibited())
@@ -212,7 +212,7 @@
     public void normalize(float norm) {
       norm *= getBoost();                         // incorporate boost
       for (int i = 0 ; i < weights.size(); i++) {
-        Weight w = (Weight)weights.elementAt(i);
+        Weight w = (Weight)weights.get(i);
         // normalize all clauses, (even if prohibited in case of side affects)
         w.normalize(norm);
       }
@@ -228,7 +228,7 @@
 
       for (int i = 0 ; i < weights.size(); i++) {
         BooleanClause c = (BooleanClause)clauses.get(i);
-        Weight w = (Weight)weights.elementAt(i);
+        Weight w = (Weight)weights.get(i);
         Scorer subScorer = w.scorer(reader);
         if (subScorer != null)
           result.add(subScorer, c.isRequired(), c.isProhibited());
@@ -252,7 +252,7 @@
       int shouldMatchCount = 0;
       for (int i = 0 ; i < weights.size(); i++) {
         BooleanClause c = (BooleanClause)clauses.get(i);
-        Weight w = (Weight)weights.elementAt(i);
+        Weight w = (Weight)weights.get(i);
         Explanation e = w.explain(reader, doc);
         if (!c.isProhibited()) maxCoord++;
         if (e.isMatch()) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=680361&r1=680360&r2=680361&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java Mon Jul 28 06:58:39
2008
@@ -41,7 +41,7 @@
 public class MultiPhraseQuery extends Query {
   private String field;
   private ArrayList termArrays = new ArrayList();
-  private Vector positions = new Vector();
+  private ArrayList positions = new ArrayList();
 
   private int slop = 0;
 
@@ -68,7 +68,7 @@
   public void add(Term[] terms) {
     int position = 0;
     if (positions.size() > 0)
-      position = ((Integer) positions.lastElement()).intValue() + 1;
+      position = ((Integer) positions.get(positions.size()-1)).intValue() + 1;
 
     add(terms, position);
   }
@@ -93,7 +93,7 @@
     }
 
     termArrays.add(terms);
-    positions.addElement(new Integer(position));
+    positions.add(new Integer(position));
   }
 
   /**
@@ -110,7 +110,7 @@
   public int[] getPositions() {
     int[] result = new int[positions.size()];
     for (int i = 0; i < positions.size(); i++)
-      result[i] = ((Integer) positions.elementAt(i)).intValue();
+      result[i] = ((Integer) positions.get(i)).intValue();
     return result;
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java?rev=680361&r1=680360&r2=680361&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java Mon Jul 28 06:58:39
2008
@@ -20,6 +20,7 @@
 import java.io.IOException;
 import java.util.Set;
 import java.util.Vector;
+import java.util.ArrayList;
 
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermPositions;
@@ -33,8 +34,8 @@
  */
 public class PhraseQuery extends Query {
   private String field;
-  private Vector terms = new Vector();
-  private Vector positions = new Vector();
+  private ArrayList terms = new ArrayList(4);
+  private ArrayList positions = new ArrayList(4);
   private int slop = 0;
 
   /** Constructs an empty phrase query. */
@@ -65,7 +66,7 @@
   public void add(Term term) {
     int position = 0;
     if(positions.size() > 0)
-        position = ((Integer) positions.lastElement()).intValue() + 1;
+        position = ((Integer) positions.get(positions.size()-1)).intValue() + 1;
 
     add(term, position);
   }
@@ -85,8 +86,8 @@
       else if (term.field() != field)
           throw new IllegalArgumentException("All phrase terms must be in the same field:
" + term);
 
-      terms.addElement(term);
-      positions.addElement(new Integer(position));
+      terms.add(term);
+      positions.add(new Integer(position));
   }
 
   /** Returns the set of terms in this phrase. */
@@ -100,7 +101,7 @@
   public int[] getPositions() {
       int[] result = new int[positions.size()];
       for(int i = 0; i < positions.size(); i++)
-          result[i] = ((Integer) positions.elementAt(i)).intValue();
+          result[i] = ((Integer) positions.get(i)).intValue();
       return result;
   }
 
@@ -140,7 +141,7 @@
 
       TermPositions[] tps = new TermPositions[terms.size()];
       for (int i = 0; i < terms.size(); i++) {
-        TermPositions p = reader.termPositions((Term)terms.elementAt(i));
+        TermPositions p = reader.termPositions((Term)terms.get(i));
         if (p == null)
           return null;
         tps[i] = p;
@@ -171,7 +172,7 @@
           query.append(" ");
         }
 
-        Term term = (Term)terms.elementAt(i);
+        Term term = (Term)terms.get(i);
 
         docFreqs.append(term.text());
         docFreqs.append("=");
@@ -237,7 +238,7 @@
 
   protected Weight createWeight(Searcher searcher) throws IOException {
     if (terms.size() == 1) {			  // optimize one-term case
-      Term term = (Term)terms.elementAt(0);
+      Term term = (Term)terms.get(0);
       Query termQuery = new TermQuery(term);
       termQuery.setBoost(getBoost());
       return termQuery.createWeight(searcher);
@@ -262,7 +263,7 @@
 
     buffer.append("\"");
     for (int i = 0; i < terms.size(); i++) {
-      buffer.append(((Term)terms.elementAt(i)).text());
+      buffer.append(((Term)terms.get(i)).text());
       if (i != terms.size()-1)
   buffer.append(" ");
     }



Mime
View raw message