lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r829454 [3/8] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/ contrib/analyzers/common/src/java/org/apache/l...
Date Sat, 24 Oct 2009 21:23:37 GMT
Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java Sat Oct 24 21:23:15 2009
@@ -65,7 +65,7 @@
   protected int numToHighlight = Integer.MAX_VALUE;
   protected boolean mergeContiguous;
   protected int maxFrags = 2;
-  protected Set paramFields = Collections.EMPTY_SET;
+  protected Set<String> paramFields = Collections.emptySet();
   protected Highlighter highlighter;
   protected int maxDocCharsToAnalyze;
 
@@ -104,8 +104,8 @@
     };
   }
 
-  protected Collection/*<String>*/ getFieldsToHighlight(Document document) {
-    Collection result = super.getFieldsToHighlight(document);
+  protected Collection<String> getFieldsToHighlight(Document document) {
+    Collection<String> result = super.getFieldsToHighlight(document);
     //if stored is false, then result will be empty, in which case just get all the param fields
     if (paramFields.isEmpty() == false && result.isEmpty() == false) {
       result.retainAll(paramFields);
@@ -127,7 +127,7 @@
       } else if (splits[i].startsWith("mergeContiguous[") == true){
         mergeContiguous = Boolean.valueOf(splits[i].substring("mergeContiguous[".length(),splits[i].length() - 1)).booleanValue();
       } else if (splits[i].startsWith("fields[") == true){
-        paramFields = new HashSet();
+        paramFields = new HashSet<String>();
         String fieldNames = splits[i].substring("fields[".length(), splits[i].length() - 1);
         String [] fieldSplits = fieldNames.split(";");
         for (int j = 0; j < fieldSplits.length; j++) {

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java Sat Oct 24 21:23:15 2009
@@ -58,12 +58,12 @@
 
   public void setParams(String params) {
     this.params = params; // cannot just call super.setParams(), b/c it's params differ.
-    Set fieldsToLoad = new HashSet();
+    Set<String> fieldsToLoad = new HashSet<String>();
     for (StringTokenizer tokenizer = new StringTokenizer(params, ","); tokenizer.hasMoreTokens();) {
       String s = tokenizer.nextToken();
       fieldsToLoad.add(s);
     }
-    fieldSelector = new SetBasedFieldSelector(fieldsToLoad, Collections.EMPTY_SET);
+    fieldSelector = new SetBasedFieldSelector(fieldsToLoad, Collections.<String> emptySet());
   }
 
 

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java Sat Oct 24 21:23:15 2009
@@ -59,7 +59,7 @@
   protected int numToHighlight = Integer.MAX_VALUE;
   protected int maxFrags = 2;
   protected int fragSize = 100;
-  protected Set paramFields = Collections.EMPTY_SET;
+  protected Set<String> paramFields = Collections.emptySet();
   protected FastVectorHighlighter highlighter;
 
   public SearchTravRetVectorHighlightTask(PerfRunData runData) {
@@ -101,8 +101,8 @@
     };
   }
 
-  protected Collection/*<String>*/ getFieldsToHighlight(Document document) {
-    Collection result = super.getFieldsToHighlight(document);
+  protected Collection<String> getFieldsToHighlight(Document document) {
+    Collection<String> result = super.getFieldsToHighlight(document);
     //if stored is false, then result will be empty, in which case just get all the param fields
     if (paramFields.isEmpty() == false && result.isEmpty() == false) {
       result.retainAll(paramFields);
@@ -124,7 +124,7 @@
       } else if (splits[i].startsWith("fragSize[") == true){
         fragSize = (int)Float.parseFloat(splits[i].substring("fragSize[".length(),splits[i].length() - 1));
       } else if (splits[i].startsWith("fields[") == true){
-        paramFields = new HashSet();
+        paramFields = new HashSet<String>();
         String fieldNames = splits[i].substring("fields[".length(), splits[i].length() - 1);
         String [] fieldSplits = fieldNames.split(";");
         for (int j = 0; j < fieldSplits.length; j++) {

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java Sat Oct 24 21:23:15 2009
@@ -18,7 +18,6 @@
  */
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.text.NumberFormat;
 
 import org.apache.lucene.benchmark.byTask.PerfRunData;
@@ -29,7 +28,7 @@
  */
 public class TaskSequence extends PerfTask {
   public static int REPEAT_EXHAUST = -2; 
-  private ArrayList tasks;
+  private ArrayList<PerfTask> tasks;
   private int repetitions = 1;
   private boolean parallel;
   private TaskSequence parent;
@@ -54,7 +53,7 @@
     setSequenceName();
     this.parent = parent;
     this.parallel = parallel;
-    tasks = new ArrayList();
+    tasks = new ArrayList<PerfTask>();
   }
 
   public void close() throws Exception {
@@ -70,7 +69,7 @@
       final int numTasks = tasks.size();
       tasksArray = new PerfTask[numTasks];
       for(int k=0;k<numTasks;k++) {
-        tasksArray[k] = (PerfTask) tasks.get(k);
+        tasksArray[k] = tasks.get(k);
         anyExhaustibleTasks |= tasksArray[k] instanceof ResetInputsTask;
         anyExhaustibleTasks |= tasksArray[k] instanceof TaskSequence;
       }
@@ -279,8 +278,7 @@
     StringBuffer sb = new StringBuffer(super.toString());
     sb.append(parallel ? " [" : " {");
     sb.append(NEW_LINE);
-    for (Iterator it = tasks.iterator(); it.hasNext();) {
-      PerfTask task = (PerfTask) it.next();
+    for (final PerfTask task : tasks) {
       sb.append(task.toString());
       sb.append(NEW_LINE);
     }
@@ -304,8 +302,7 @@
    */
   public void setNoChildReport() {
     letChildReport  = false;
-    for (Iterator it = tasks.iterator(); it.hasNext();) {
-      PerfTask task = (PerfTask) it.next();
+    for (final PerfTask task : tasks) {
       if (task instanceof TaskSequence) {
         ((TaskSequence)task).setNoChildReport();
   }
@@ -352,7 +349,7 @@
   /**
    * @return Returns the tasks.
    */
-  public ArrayList getTasks() {
+  public ArrayList<PerfTask> getTasks() {
     return tasks;
   }
 
@@ -361,9 +358,9 @@
    */
   protected Object clone() throws CloneNotSupportedException {
     TaskSequence res = (TaskSequence) super.clone();
-    res.tasks = new ArrayList();
+    res.tasks = new ArrayList<PerfTask>();
     for (int i = 0; i < tasks.size(); i++) {
-      res.tasks.add(((PerfTask)tasks.get(i)).clone());
+      res.tasks.add((PerfTask)tasks.get(i).clone());
     }
     return res;
   }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java Sat Oct 24 21:23:15 2009
@@ -213,9 +213,9 @@
     
     // remove redundant top level enclosing sequences
     while (sequence.isCollapsable() && sequence.getRepetitions()==1 && sequence.getRate()==0) {
-      ArrayList t = sequence.getTasks();
+      ArrayList<PerfTask> t = sequence.getTasks();
       if (t!=null && t.size()==1) {
-        PerfTask p = (PerfTask) t.get(0);
+        PerfTask p = t.get(0);
         if (p instanceof TaskSequence) {
           sequence = (TaskSequence) p;
           continue;
@@ -252,20 +252,19 @@
    * Expert: for test purposes, return all tasks participating in this algorithm.
    * @return all tasks participating in this algorithm.
    */
-  public ArrayList extractTasks() {
-    ArrayList res = new ArrayList();
+  public ArrayList<PerfTask> extractTasks() {
+    ArrayList<PerfTask> res = new ArrayList<PerfTask>();
     extractTasks(res, sequence);
     return res;
   }
-  private void extractTasks (ArrayList extrct, TaskSequence seq) {
+  private void extractTasks (ArrayList<PerfTask> extrct, TaskSequence seq) {
     if (seq==null) 
       return;
     extrct.add(seq);
-    ArrayList t = sequence.getTasks();
+    ArrayList<PerfTask> t = sequence.getTasks();
     if (t==null) 
       return;
-    for (int i = 0; i < t.size(); i++) {
-      PerfTask p = (PerfTask) t.get(0);
+    for (final PerfTask p : t) {
       if (p instanceof TaskSequence) {
         extractTasks(extrct, (TaskSequence)p);
       } else {

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java Sat Oct 24 21:23:15 2009
@@ -26,6 +26,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
 
@@ -50,7 +51,7 @@
   private int roundNumber = 0;
   private Properties props;
   private HashMap valByRound = new HashMap();
-  private HashMap colForValByRound = new HashMap();
+  private HashMap<String,String> colForValByRound = new HashMap<String,String>();
   private String algorithmText;
 
   /**
@@ -60,7 +61,7 @@
    */
   public Config (Reader algReader) throws IOException {
     // read alg file to array of lines
-    ArrayList lines = new ArrayList();
+    ArrayList<String> lines = new ArrayList<String>();
     BufferedReader r = new BufferedReader(algReader);
     int lastConfigLine=0;
     for (String line = r.readLine(); line!=null; line=r.readLine()) {
@@ -112,10 +113,9 @@
 
   private void printProps() {
     System.out.println("------------> config properties:");
-    List propKeys = new ArrayList(props.keySet());
+    List<String> propKeys = new ArrayList(props.keySet());
     Collections.sort(propKeys);
-    for (Iterator it = propKeys.iterator(); it.hasNext();) {
-      String propName = (String) it.next();
+    for (final String propName : propKeys) {
       System.out.println(propName + " = " + props.getProperty(propName));
     }
     System.out.println("-------------------------------");
@@ -283,7 +283,7 @@
       return new int [] { Integer.parseInt(s) };
     }
     
-    ArrayList a = new ArrayList();
+    ArrayList<Integer> a = new ArrayList<Integer>();
     StringTokenizer st = new StringTokenizer(s,":");
     while (st.hasMoreTokens()) {
       String t = st.nextToken();
@@ -291,7 +291,7 @@
     }
     int res[] = new int[a.size()]; 
     for (int i=0; i<a.size(); i++) {
-      res[i] = ((Integer) a.get(i)).intValue();
+      res[i] = a.get(i).intValue();
     }
     return res;
   }
@@ -302,7 +302,7 @@
       return new double [] { Double.parseDouble(s) };
     }
     
-    ArrayList a = new ArrayList();
+    ArrayList<Double> a = new ArrayList<Double>();
     StringTokenizer st = new StringTokenizer(s,":");
     while (st.hasMoreTokens()) {
       String t = st.nextToken();
@@ -310,7 +310,7 @@
     }
     double res[] = new double[a.size()]; 
     for (int i=0; i<a.size(); i++) {
-      res[i] = ((Double) a.get(i)).doubleValue();
+      res[i] = a.get(i).doubleValue();
     }
     return res;
   }
@@ -321,7 +321,7 @@
       return new boolean [] { Boolean.valueOf(s).booleanValue() };
     }
     
-    ArrayList a = new ArrayList();
+    ArrayList<Boolean> a = new ArrayList<Boolean>();
     StringTokenizer st = new StringTokenizer(s,":");
     while (st.hasMoreTokens()) {
       String t = st.nextToken();
@@ -329,7 +329,7 @@
     }
     boolean res[] = new boolean[a.size()]; 
     for (int i=0; i<a.size(); i++) {
-      res[i] = ((Boolean) a.get(i)).booleanValue();
+      res[i] = a.get(i).booleanValue();
     }
     return res;
   }
@@ -342,9 +342,8 @@
       return "";
     }
     StringBuffer sb = new StringBuffer(); 
-    for (Iterator it = colForValByRound.keySet().iterator(); it.hasNext();) {
-      String name = (String) it.next();
-      String colName = (String) colForValByRound.get(name);
+    for (final String name : colForValByRound.keySet()) {
+      String colName = colForValByRound.get(name);
       sb.append(" ").append(colName);
     }
     return sb.toString();
@@ -358,9 +357,8 @@
       return "";
     }
     StringBuffer sb = new StringBuffer(); 
-    for (Iterator it = colForValByRound.keySet().iterator(); it.hasNext();) {
-      String name = (String) it.next();
-      String colName = (String) colForValByRound.get(name);
+    for (final String name  : colForValByRound.keySet()) {
+      String colName = colForValByRound.get(name);
       String template = " "+colName;
       if (roundNum<0) {
         // just append blanks

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityQuery.java Sat Oct 24 21:23:15 2009
@@ -34,14 +34,14 @@
  */
 public class QualityQuery implements Comparable {
   private String queryID;
-  private Map nameValPairs;
+  private Map<String,String> nameValPairs;
 
   /**
    * Create a QualityQuery with given ID and name-value pairs.
    * @param queryID ID of this quality query.
    * @param nameValPairs the contents of this quality query.
    */
-  public QualityQuery(String queryID, Map nameValPairs) {
+  public QualityQuery(String queryID, Map<String,String> nameValPairs) {
     this.queryID = queryID;
     this.nameValPairs = nameValPairs;
   }
@@ -50,7 +50,7 @@
    * Return all the names of name-value-pairs in this QualityQuery.
    */
   public String[] getNames() {
-    return (String[]) nameValPairs.keySet().toArray(new String[0]);
+    return nameValPairs.keySet().toArray(new String[0]);
   }
 
   /**
@@ -58,7 +58,7 @@
    * @param name the name whose value should be returned. 
    */
   public String getValue(String name) {
-    return (String) nameValPairs.get(name);
+    return nameValPairs.get(name);
   }
 
   /**

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityStats.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityStats.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityStats.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/QualityStats.java Sat Oct 24 21:23:15 2009
@@ -58,7 +58,7 @@
     }
   }
   
-  private ArrayList recallPoints;
+  private ArrayList<RecallPoint> recallPoints;
   
   /**
    * Construct a QualityStats object with anticipated maximal number of relevant hits. 
@@ -67,7 +67,7 @@
   public QualityStats(double maxGoodPoints, long searchTime) {
     this.maxGoodPoints = maxGoodPoints;
     this.searchTime = searchTime;
-    this.recallPoints = new ArrayList();
+    this.recallPoints = new ArrayList<RecallPoint>();
     pAt = new double[MAX_POINTS+1]; // pAt[0] unused. 
   }
 
@@ -265,7 +265,7 @@
    * Returns the recallPoints.
    */
   public RecallPoint [] getRecallPoints() {
-    return (RecallPoint[]) recallPoints.toArray(new RecallPoint[0]);
+    return recallPoints.toArray(new RecallPoint[0]);
   }
 
   /**

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/Trec1MQReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/Trec1MQReader.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/Trec1MQReader.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/Trec1MQReader.java Sat Oct 24 21:23:15 2009
@@ -55,7 +55,7 @@
    * @throws IOException if cannot read the queries.
    */
   public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
-    ArrayList res = new ArrayList();
+    ArrayList<QualityQuery> res = new ArrayList<QualityQuery>();
     String line;
     try {
       while (null!=(line=reader.readLine())) {
@@ -69,7 +69,7 @@
         // qtext
         String qtext = line.substring(k+1).trim();
         // we got a topic!
-        HashMap fields = new HashMap();
+        HashMap<String,String> fields = new HashMap<String,String>();
         fields.put(name,qtext);
         //System.out.println("id: "+id+" qtext: "+qtext+"  line: "+line);
         QualityQuery topic = new QualityQuery(id,fields);
@@ -79,7 +79,7 @@
       reader.close();
     }
     // sort result array (by ID) 
-    QualityQuery qq[] = (QualityQuery[]) res.toArray(new QualityQuery[0]);
+    QualityQuery qq[] = res.toArray(new QualityQuery[0]);
     Arrays.sort(qq);
     return qq;
   }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java Sat Oct 24 21:23:15 2009
@@ -21,7 +21,6 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.StringTokenizer;
 
 import org.apache.lucene.benchmark.quality.Judge;
@@ -32,7 +31,7 @@
  */
 public class TrecJudge implements Judge {
 
-  HashMap judgements;
+  HashMap<String,QRelJudgement> judgements;
   
   /**
    * Constructor from a reader.
@@ -50,7 +49,7 @@
    * @throws IOException 
    */
   public TrecJudge (BufferedReader reader) throws IOException {
-    judgements = new HashMap();
+    judgements = new HashMap<String,QRelJudgement>();
     QRelJudgement curr = null;
     String zero = "0";
     String line;
@@ -69,7 +68,7 @@
         assert !st.hasMoreTokens() : "wrong format: "+line+"  next: "+st.nextToken();
         if (relevant) { // only keep relevant docs
           if (curr==null || !curr.queryID.equals(queryID)) {
-            curr = (QRelJudgement)judgements.get(queryID);
+            curr = judgements.get(queryID);
             if (curr==null) {
               curr = new QRelJudgement(queryID);
               judgements.put(queryID,curr);
@@ -85,18 +84,18 @@
   
   // inherit javadocs
   public boolean isRelevant(String docName, QualityQuery query) {
-    QRelJudgement qrj = (QRelJudgement) judgements.get(query.getQueryID());
+    QRelJudgement qrj = judgements.get(query.getQueryID());
     return qrj!=null && qrj.isRelevant(docName);
   }
 
   /** single Judgement of a trec quality query */
   private static class QRelJudgement {
     private String queryID;
-    private HashMap relevantDocs;
+    private HashMap<String,String> relevantDocs;
     
     QRelJudgement(String queryID) {
       this.queryID = queryID;
-      relevantDocs = new HashMap();
+      relevantDocs = new HashMap<String,String>();
     }
     
     public void addRelevandDoc(String docName) {
@@ -114,8 +113,8 @@
 
   // inherit javadocs
   public boolean validateData(QualityQuery[] qq, PrintWriter logger) {
-    HashMap missingQueries = (HashMap) judgements.clone();
-    ArrayList missingJudgements = new ArrayList();
+    HashMap<String,QRelJudgement> missingQueries = (HashMap<String, QRelJudgement>) judgements.clone();
+    ArrayList<String> missingJudgements = new ArrayList<String>();
     for (int i=0; i<qq.length; i++) {
       String id = qq[i].getQueryID();
       if (missingQueries.containsKey(id)) {
@@ -130,7 +129,7 @@
       if (logger!=null) {
         logger.println("WARNING: "+missingJudgements.size()+" queries have no judgments! - ");
         for (int i=0; i<missingJudgements.size(); i++) {
-          logger.println("   "+(String)missingJudgements.get(i));
+          logger.println("   "+ missingJudgements.get(i));
         }
       }
     }
@@ -138,8 +137,7 @@
       isValid = false;
       if (logger!=null) {
         logger.println("WARNING: "+missingQueries.size()+" judgments match no query! - ");
-        for (Iterator it = missingQueries.keySet().iterator(); it.hasNext();) {
-          String id = (String) it.next();
+        for (final String id : missingQueries.keySet()) {
           logger.println("   "+id);
         }
       }
@@ -149,7 +147,7 @@
 
   // inherit javadocs
   public int maxRecall(QualityQuery query) {
-    QRelJudgement qrj = (QRelJudgement) judgements.get(query.getQueryID());
+    QRelJudgement qrj = judgements.get(query.getQueryID());
     if (qrj!=null) {
       return qrj.maxRecall();
     }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java Sat Oct 24 21:23:15 2009
@@ -62,11 +62,11 @@
    * @throws IOException if cannot read the queries.
    */
   public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
-    ArrayList res = new ArrayList();
+    ArrayList<QualityQuery> res = new ArrayList<QualityQuery>();
     StringBuffer sb;
     try {
       while (null!=(sb=read(reader,"<top>",null,false,false))) {
-        HashMap fields = new HashMap();
+        HashMap<String,String> fields = new HashMap<String,String>();
         // id
         sb = read(reader,"<num>",null,true,false);
         int k = sb.indexOf(":");
@@ -91,7 +91,7 @@
       reader.close();
     }
     // sort result array (by ID) 
-    QualityQuery qq[] = (QualityQuery[]) res.toArray(new QualityQuery[0]);
+    QualityQuery qq[] = res.toArray(new QualityQuery[0]);
     Arrays.sort(qq);
     return qq;
   }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java Sat Oct 24 21:23:15 2009
@@ -111,7 +111,7 @@
     String res[] = new String[pq.size()];
     int i = 0;
     while (pq.size()>0) {
-      TermDf tdf = (TermDf) pq.pop(); 
+      TermDf tdf = pq.pop(); 
       res[i++] = tdf.word;
       System.out.println(i+".   word:  "+tdf.df+"   "+tdf.word);
     }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java Sat Oct 24 21:23:15 2009
@@ -22,6 +22,7 @@
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
 
 /**
  * Simplistic quality query parser. A Lucene query is created by passing 
@@ -31,7 +32,7 @@
 
   private String qqName;
   private String indexField;
-  ThreadLocal queryParser = new ThreadLocal();
+  ThreadLocal<QueryParser> queryParser = new ThreadLocal<QueryParser>();
 
   /**
    * Constructor of a simple qq parser.
@@ -47,9 +48,9 @@
    * @see org.apache.lucene.benchmark.quality.QualityQueryParser#parse(org.apache.lucene.benchmark.quality.QualityQuery)
    */
   public Query parse(QualityQuery qq) throws ParseException {
-    QueryParser qp = (QueryParser) queryParser.get();
+    QueryParser qp = queryParser.get();
     if (qp==null) {
-      qp = new QueryParser(indexField, new StandardAnalyzer());
+      qp = new QueryParser(Version.LUCENE_CURRENT, indexField, new StandardAnalyzer(Version.LUCENE_CURRENT));
       queryParser.set(qp);
     }
     return qp.parse(qq.getValue(qqName));

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/QueryData.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/QueryData.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/QueryData.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/QueryData.java Sat Oct 24 21:23:15 2009
@@ -47,7 +47,7 @@
    * @return The QueryData
    */
   public static QueryData[] getAll(Query[] queries) {
-    Vector vqd = new Vector();
+    Vector<QueryData> vqd = new Vector<QueryData>();
     for (int i = 0; i < queries.length; i++) {
       for (int r = 1; r >= 0; r--) {
         for (int w = 1; w >= 0; w--) {
@@ -63,7 +63,7 @@
         }
       }
     }
-    return (QueryData[])vqd.toArray(new QueryData[0]);
+    return vqd.toArray(new QueryData[0]);
   }
 
   /** Short legend for interpreting toString() output. */

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestData.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestData.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestData.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestData.java Sat Oct 24 21:23:15 2009
@@ -19,7 +19,7 @@
 import java.io.File;
 import java.text.NumberFormat;
 import java.util.ArrayList;
-import java.util.Collection;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -53,7 +53,7 @@
     /**
      * List of results for each test run with these parameters.
      */
-    private Vector runData = new Vector();
+    private Vector<TestRunData> runData = new Vector<TestRunData>();
     private int maxBufferedDocs, mergeFactor;
     /**
      * Directory containing source files.
@@ -132,7 +132,7 @@
         {
             return "# [NO RUN DATA]";
         }
-        HashMap resByTask = new HashMap(); 
+        HashMap<String,LDCounter> resByTask = new HashMap<String,LDCounter>(); 
         StringBuffer sb = new StringBuffer();
         String lineSep = System.getProperty("line.separator");
         sb.append("warm = Warm Index Reader").append(lineSep).append("srch = Search Index").append(lineSep).append("trav = Traverse Hits list, optionally retrieving document").append(lineSep).append(lineSep);
@@ -140,20 +140,17 @@
           sb.append(COLS[i]);
         }
         sb.append("\n");
-        LinkedHashMap mapMem = new LinkedHashMap();
-        LinkedHashMap mapSpeed = new LinkedHashMap();
+        LinkedHashMap<String,TestData.LCounter[]> mapMem = new LinkedHashMap<String,TestData.LCounter[]>();
+        LinkedHashMap<String,DCounter> mapSpeed = new LinkedHashMap<String,DCounter>();
         for (int i = 0; i < runData.size(); i++)
         {
-            TestRunData trd = (TestRunData) runData.get(i);
-            Collection labels = trd.getLabels();
-            Iterator it = labels.iterator();
-            while (it.hasNext())
+            TestRunData trd = runData.get(i);
+            for (final String label : trd.getLabels()) 
             {
-                String label = (String) it.next();
                 MemUsage mem = trd.getMemUsage(label);
                 if (mem != null)
                 {
-                    TestData.LCounter[] tm = (TestData.LCounter[]) mapMem.get(label);
+                    TestData.LCounter[] tm = mapMem.get(label);
                     if (tm == null)
                     {
                         tm = new TestData.LCounter[2];
@@ -169,7 +166,7 @@
                 TimeData td = trd.getTotals(label);
                 if (td != null)
                 {
-                    TestData.DCounter dc = (TestData.DCounter) mapSpeed.get(label);
+                    TestData.DCounter dc = mapSpeed.get(label);
                     if (dc == null)
                     {
                         dc = new TestData.DCounter();
@@ -182,12 +179,12 @@
                 }
             }
         }
-        LinkedHashMap res = new LinkedHashMap();
-        Iterator it = mapSpeed.keySet().iterator();
+        LinkedHashMap<String,String> res = new LinkedHashMap<String,String>();
+        Iterator<String> it = mapSpeed.keySet().iterator();
         while (it.hasNext())
         {
-            String label = (String) it.next();
-            TestData.DCounter dc = (TestData.DCounter) mapSpeed.get(label);
+            String label = it.next();
+            TestData.DCounter dc = mapSpeed.get(label);
             res.put(label, 
                 format(dc.count, RUNCNT) + 
                 format(dc.recordCount / dc.count, RECCNT) +
@@ -197,7 +194,7 @@
             
             // also sum by task
             String task = label.substring(label.lastIndexOf("-")+1);
-            LDCounter ldc = (LDCounter) resByTask.get(task);
+            LDCounter ldc = resByTask.get(task);
             if (ldc==null) {
               ldc = new LDCounter();
               resByTask.put(task,ldc);
@@ -209,9 +206,9 @@
         it = mapMem.keySet().iterator();
         while (it.hasNext())
         {
-            String label = (String) it.next();
-            TestData.LCounter[] lc = (TestData.LCounter[]) mapMem.get(label);
-            String speed = (String) res.get(label);
+            String label = it.next();
+            TestData.LCounter[] lc =  mapMem.get(label);
+            String speed = res.get(label);
             boolean makeSpeed = false;
             if (speed == null)
             {
@@ -227,7 +224,7 @@
             
             // also sum by task
             String task = label.substring(label.lastIndexOf("-")+1);
-            LDCounter ldc = (LDCounter) resByTask.get(task);
+            LDCounter ldc = resByTask.get(task);
             if (ldc==null) {
               ldc = new LDCounter();
               resByTask.put(task,ldc);
@@ -244,7 +241,7 @@
         it = res.keySet().iterator();
         while (it.hasNext())
         {
-            String label = (String) it.next();
+            String label = it.next();
             sb.append(format(prefix, ID));
             sb.append(format(label, OP));
             sb.append(res.get(label)).append("\n");
@@ -258,8 +255,8 @@
         it = resByTask.keySet().iterator();
         while (it.hasNext())
         {
-            String task = (String) it.next();
-            LDCounter ldc = (LDCounter) resByTask.get(task);
+            String task = it.next();
+            LDCounter ldc = resByTask.get(task);
             sb.append(format("    ", ID));
             sb.append(format(task, OP));
             sb.append(format(ldc.Dcount, RUNCNT)); 
@@ -309,7 +306,7 @@
      */
     public static TestData[] getAll(File[] sources, Analyzer[] analyzers)
     {
-        List res = new ArrayList(50);
+        List<TestData> res = new ArrayList<TestData>(50);
         TestData ref = new TestData();
         for (int q = 0; q < analyzers.length; q++)
         {
@@ -332,7 +329,7 @@
                                 ref.optimize = Constants.BOOLEANS[p].booleanValue();
                                 try
                                 {
-                                    res.add(ref.clone());
+                                    res.add((TestData)ref.clone());
                                 }
                                 catch (Exception e)
                                 {
@@ -344,7 +341,7 @@
                 }
             }
         }
-        return (TestData[]) res.toArray(new TestData[0]);
+        return res.toArray(new TestData[0]);
     }
 
     /**
@@ -358,7 +355,7 @@
      */
     public static TestData[] getTestDataMinMaxMergeAndMaxBuffered(File[] sources, Analyzer[] analyzers)
     {
-        List res = new ArrayList(50);
+        List<TestData> res = new ArrayList<TestData>(50);
         TestData ref = new TestData();
         for (int q = 0; q < analyzers.length; q++)
         {
@@ -373,7 +370,7 @@
                 ref.optimize = true;
                 try
                 {
-                    res.add(ref.clone());
+                    res.add((TestData)ref.clone());
                 }
                 catch (Exception e)
                 {
@@ -388,7 +385,7 @@
                 ref.optimize = true;
                 try
                 {
-                    res.add(ref.clone());
+                    res.add((TestData)ref.clone());
                 }
                 catch (Exception e)
                 {
@@ -403,7 +400,7 @@
                 ref.optimize = true;
                 try
                 {
-                    res.add(ref.clone());
+                    res.add((TestData)ref.clone());
                 }
                 catch (Exception e)
                 {
@@ -418,7 +415,7 @@
                 ref.optimize = true;
                 try
                 {
-                    res.add(ref.clone());
+                    res.add((TestData)ref.clone());
                 }
                 catch (Exception e)
                 {
@@ -426,7 +423,7 @@
                 }
             }
         }
-        return (TestData[]) res.toArray(new TestData[0]);
+        return res.toArray(new TestData[0]);
     }
 
     protected Object clone()
@@ -553,12 +550,12 @@
         this.queries = queries;
     }
 
-    public Vector getRunData()
+    public Vector<TestRunData> getRunData()
     {
         return runData;
     }
 
-    public void setRunData(Vector runData)
+    public void setRunData(Vector<TestRunData> runData)
     {
         this.runData = runData;
     }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestRunData.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestRunData.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestRunData.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/stats/TestRunData.java Sat Oct 24 21:23:15 2009
@@ -33,7 +33,7 @@
   /** Start and end time of this test run. */
   private long start = 0L, end = 0L;
 
-  private LinkedHashMap data = new LinkedHashMap();
+  private LinkedHashMap<String,Vector<TimeData>> data = new LinkedHashMap<String,Vector<TimeData>>();
 
   public TestRunData() {}
 
@@ -41,7 +41,7 @@
     this.id = id;
   }
 
-    public LinkedHashMap getData()
+    public LinkedHashMap<String,Vector<TimeData>> getData()
     {
         return data;
     }
@@ -79,29 +79,29 @@
   /** Add a data point. */
   public void addData(TimeData td) {
     td.recordMemUsage();
-    Vector v = (Vector) data.get(td.name);
+    Vector<TimeData> v = data.get(td.name);
     if (v == null) {
-      v = new Vector();
+      v = new Vector<TimeData>();
       data.put(td.name, v);
     }
-    v.add(td.clone());
+    v.add((TimeData)td.clone());
   }
 
   /** Get a list of all available types of data points. */
-  public Collection getLabels() {
+  public Collection<String> getLabels() {
     return data.keySet();
   }
 
   /** Get total values from all data points of a given type. */
   public TimeData getTotals(String label) {
-    Vector v = (Vector) data.get(label);
+    Vector<TimeData> v = data.get(label);
       if (v == null)
       {
           return null;
       }
     TimeData res = new TimeData("TOTAL " + label);
     for (int i = 0; i < v.size(); i++) {
-      TimeData td = (TimeData) v.get(i);
+      TimeData td = v.get(i);
       res.count += td.count;
       res.elapsed += td.elapsed;
     }
@@ -111,12 +111,12 @@
   /** Get total values from all data points of all types.
    * @return a list of TimeData values for all types.
    */
-  public Vector getTotals() {
-    Collection labels = getLabels();
-    Vector v = new Vector();
-    Iterator it = labels.iterator();
+  public Vector<TimeData> getTotals() {
+    Collection<String> labels = getLabels();
+    Vector<TimeData> v = new Vector<TimeData>();
+    Iterator<String> it = labels.iterator();
     while (it.hasNext()) {
-      TimeData td = getTotals((String) it.next());
+      TimeData td = getTotals(it.next());
       v.add(td);
     }
     return v;
@@ -124,7 +124,7 @@
 
   /** Get memory usage stats for a given data type. */
   public MemUsage getMemUsage(String label) {
-    Vector v = (Vector) data.get(label);
+    Vector<TimeData> v = data.get(label);
       if (v == null)
       {
           return null;
@@ -134,7 +134,7 @@
     res.minTotal = Long.MAX_VALUE;
     long avgFree = 0L, avgTotal = 0L;
     for (int i = 0; i < v.size(); i++) {
-      TimeData td = (TimeData) v.get(i);
+      TimeData td = v.get(i);
         if (res.maxFree < td.freeMem)
         {
             res.maxFree = td.freeMem;
@@ -162,10 +162,7 @@
   /** Return a string representation. */
   public String toString() {
     StringBuffer sb = new StringBuffer();
-    Collection labels = getLabels();
-    Iterator it = labels.iterator();
-    while (it.hasNext()) {
-      String label = (String) it.next();
+    for (final String label : getLabels()) {
         sb.append(id).append("-").append(label).append(" ").append(getTotals(label).toString(false)).append(" ");
         sb.append(getMemUsage(label).toScaledString(1024 * 1024, "MB")).append("\n");
     }

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java (original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java Sat Oct 24 21:23:15 2009
@@ -20,12 +20,18 @@
 import java.io.IOException;
 import java.util.List;
 
+import org.apache.lucene.index.IndexCommit;
 import org.apache.lucene.index.IndexDeletionPolicy;
 
 public class NoDeletionPolicy implements IndexDeletionPolicy {
-  public void onCommit(List commits) throws IOException {    
+
+  public void onCommit(List<? extends IndexCommit> commits) throws IOException {
+    // TODO Auto-generated method stub
+    
   }
 
-  public void onInit(List commits) throws IOException {    
+  public void onInit(List<? extends IndexCommit> commits) throws IOException {
+    // TODO Auto-generated method stub
+    
   }
 }

Modified: lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/CollationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/CollationTestBase.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/CollationTestBase.java (original)
+++ lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/CollationTestBase.java Sat Oct 24 21:23:15 2009
@@ -40,6 +40,7 @@
 import org.apache.lucene.util.IndexableBinaryStringTools;
 import org.apache.lucene.queryParser.analyzing.AnalyzingQueryParser;
 import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.util.Version;
 
 import java.io.IOException;
 import java.nio.CharBuffer;
@@ -84,9 +85,9 @@
     writer.close();
     IndexSearcher is = new IndexSearcher(ramDir, true);
 
-    AnalyzingQueryParser aqp = new AnalyzingQueryParser("content", analyzer);
+    AnalyzingQueryParser aqp = new AnalyzingQueryParser(Version.LUCENE_CURRENT, "content", analyzer);
     aqp.setLowercaseExpandedTerms(false);
-
+    aqp.setUseOldRangeQuery(false);
     // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
     // orders the U+0698 character before the U+0633 character, so the single
     // index Term below should NOT be returned by a TermRangeQuery
@@ -95,7 +96,7 @@
       
     // Test ConstantScoreRangeQuery
     Query q = aqp.parse("[ \u062F TO \u0698 ]");
-    aqp.setUseOldRangeQuery(false);
+
     ScoreDoc[] result
       = is.search(q, null, 1000).scoreDocs;
     assertEquals("The index Term should not be included.", 0, result.length);
@@ -103,7 +104,7 @@
     result = is.search(aqp.parse("[ \u0633 TO \u0638 ]"), null, 1000).scoreDocs;
     assertEquals("The index Term should be included.", 1, result.length);
 
-    // Test TermRangeQuery
+    // Test Old TermRangeQuery
     aqp.setUseOldRangeQuery(true);
     result = is.search(aqp.parse("[ \u062F TO \u0698 ]"), null, 1000).scoreDocs;
     assertEquals("The index Term should not be included.", 0, result.length);

Modified: lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java (original)
+++ lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java Sat Oct 24 21:23:15 2009
@@ -38,6 +38,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
 
 /**
  * <code>FieldTermStack</code> is a stack that keeps query terms in the specified field
@@ -50,7 +51,7 @@
   
   public static void main( String[] args ) throws Exception {
     Analyzer analyzer = new WhitespaceAnalyzer();
-    QueryParser parser = new QueryParser( "f", analyzer );
+    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,  "f", analyzer );
     Query query = parser.parse( "a x:b" );
     FieldQuery fieldQuery = new FieldQuery( query, true, false );
     

Modified: lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java (original)
+++ lucene/java/branches/flex_1458/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java Sat Oct 24 21:23:15 2009
@@ -45,6 +45,7 @@
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
 
 public abstract class AbstractTestCase extends TestCase {
 
@@ -78,8 +79,8 @@
   protected void setUp() throws Exception {
     analyzerW = new WhitespaceAnalyzer();
     analyzerB = new BigramAnalyzer();
-    paW = new QueryParser( F, analyzerW );
-    paB = new QueryParser( F, analyzerB );
+    paW = new QueryParser(Version.LUCENE_CURRENT,  F, analyzerW );
+    paB = new QueryParser(Version.LUCENE_CURRENT,  F, analyzerB );
     dir = new RAMDirectory();
   }
   

Modified: lucene/java/branches/flex_1458/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java (original)
+++ lucene/java/branches/flex_1458/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java Sat Oct 24 21:23:15 2009
@@ -95,13 +95,32 @@
         }
       }
     } else if (query instanceof PhraseQuery) {
-      Term[] phraseQueryTerms = ((PhraseQuery) query).getTerms();
+      PhraseQuery phraseQuery = ((PhraseQuery) query);
+      Term[] phraseQueryTerms = phraseQuery.getTerms();
       SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.length];
       for (int i = 0; i < phraseQueryTerms.length; i++) {
         clauses[i] = new SpanTermQuery(phraseQueryTerms[i]);
       }
+      int slop = phraseQuery.getSlop();
+      int[] positions = phraseQuery.getPositions();
+      // add largest position increment to slop
+      if (positions.length > 0) {
+        int lastPos = positions[0];
+        int largestInc = 0;
+        int sz = positions.length;
+        for (int i = 1; i < sz; i++) {
+          int pos = positions[i];
+          int inc = pos - lastPos;
+          if (inc > largestInc) {
+            largestInc = inc;
+          }
+          lastPos = pos;
+        }
+        if(largestInc > 1) {
+          slop += largestInc;
+        }
+      }
 
-      int slop = ((PhraseQuery) query).getSlop();
       boolean inorder = false;
 
       if (slop == 0) {

Modified: lucene/java/branches/flex_1458/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (original)
+++ lucene/java/branches/flex_1458/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java Sat Oct 24 21:23:15 2009
@@ -83,13 +83,16 @@
  *
  */
 public class HighlighterTest extends BaseTokenStreamTestCase implements Formatter {
+  // TODO: change to CURRENT, does not work because posIncr:
+  static final Version TEST_VERSION = Version.LUCENE_CURRENT;
+
   private IndexReader reader;
   static final String FIELD_NAME = "contents";
   private Query query;
   RAMDirectory ramDir;
   public IndexSearcher searcher = null;
   int numHighlights = 0;
-  Analyzer analyzer = new StandardAnalyzer();
+  final Analyzer analyzer = new StandardAnalyzer(TEST_VERSION);
   TopDocs hits;
 
   String[] texts = {
@@ -97,7 +100,7 @@
       "This piece of text refers to Kennedy at the beginning then has a longer piece of text that is very long in the middle and finally ends with another reference to Kennedy",
       "JFK has been shot", "John Kennedy has been shot",
       "This text has a typo in referring to Keneddy",
-      "wordx wordy wordz wordx wordy wordx worda wordb wordy wordc", "y z x y z a b" };
+      "wordx wordy wordz wordx wordy wordx worda wordb wordy wordc", "y z x y z a b", "lets is a the lets is a the lets is a the lets" };
 
   /**
    * Constructor for HighlightExtractorTest.
@@ -110,7 +113,7 @@
 
   public void testQueryScorerHits() throws Exception {
     Analyzer analyzer = new SimpleAnalyzer();
-    QueryParser qp = new QueryParser(FIELD_NAME, analyzer);
+    QueryParser qp = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
     query = qp.parse("\"very long\"");
     searcher = new IndexSearcher(ramDir, true);
     TopDocs hits = searcher.search(query, 10);
@@ -140,7 +143,7 @@
 
     String s1 = "I call our world Flatland, not because we call it so,";
 
-    QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer(Version.LUCENE_CURRENT));
+    QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
 
     // Verify that a query against the default field results in text being
     // highlighted
@@ -172,7 +175,7 @@
    */
   private static String highlightField(Query query, String fieldName, String text)
       throws IOException, InvalidTokenOffsetsException {
-    TokenStream tokenStream = new StandardAnalyzer(Version.LUCENE_CURRENT).tokenStream(fieldName, new StringReader(text));
+    TokenStream tokenStream = new StandardAnalyzer(TEST_VERSION).tokenStream(fieldName, new StringReader(text));
     // Assuming "<B>", "</B>" used to highlight
     SimpleHTMLFormatter formatter = new SimpleHTMLFormatter();
     QueryScorer scorer = new QueryScorer(query, fieldName, FIELD_NAME);
@@ -218,7 +221,7 @@
     String q = "(" + f1c + ph1 + " OR " + f2c + ph1 + ") AND (" + f1c + ph2
         + " OR " + f2c + ph2 + ")";
     Analyzer analyzer = new WhitespaceAnalyzer();
-    QueryParser qp = new QueryParser(f1, analyzer);
+    QueryParser qp = new QueryParser(TEST_VERSION, f1, analyzer);
     Query query = qp.parse(q);
 
     QueryScorer scorer = new QueryScorer(query, f1);
@@ -253,6 +256,51 @@
 
     assertTrue("Failed to find correct number of highlights " + numHighlights + " found",
         numHighlights == 3);
+    
+    numHighlights = 0;
+    doSearching("\"This piece of text refers to Kennedy\"");
+
+    maxNumFragmentsRequired = 2;
+
+    scorer = new QueryScorer(query, FIELD_NAME);
+    highlighter = new Highlighter(this, scorer);
+    
+    for (int i = 0; i < hits.totalHits; i++) {
+      String text = searcher.doc(hits.scoreDocs[i].doc).get(FIELD_NAME);
+      TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new StringReader(text));
+
+      highlighter.setTextFragmenter(new SimpleFragmenter(40));
+
+      String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,
+          "...");
+      System.out.println("\t" + result);
+    }
+
+    assertTrue("Failed to find correct number of highlights " + numHighlights + " found",
+        numHighlights == 4);
+    
+    numHighlights = 0;
+    doSearching("\"lets is a the lets is a the lets is a the lets\"");
+
+    maxNumFragmentsRequired = 2;
+
+    scorer = new QueryScorer(query, FIELD_NAME);
+    highlighter = new Highlighter(this, scorer);
+    
+    for (int i = 0; i < hits.totalHits; i++) {
+      String text = searcher.doc(hits.scoreDocs[i].doc).get(FIELD_NAME);
+      TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new StringReader(text));
+
+      highlighter.setTextFragmenter(new SimpleFragmenter(40));
+
+      String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,
+          "...");
+      System.out.println("\t" + result);
+    }
+
+    assertTrue("Failed to find correct number of highlights " + numHighlights + " found",
+        numHighlights == 4);
+    
   }
 
   public void testSimpleQueryScorerPhraseHighlighting2() throws Exception {
@@ -542,8 +590,8 @@
         // Need to explicitly set the QueryParser property to use TermRangeQuery
         // rather
         // than RangeFilters
-        QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
-        parser.setUseOldRangeQuery(true);
+        QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
+        parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
         query = parser.parse(queryString);
         doSearching(query);
 
@@ -693,7 +741,7 @@
         hg.setTextFragmenter(new NullFragmenter());
 
         String match = null;
-        match = hg.getBestFragment(new StandardAnalyzer(), "data", "help me [54-65]");
+        match = hg.getBestFragment(analyzer, "data", "help me [54-65]");
         assertEquals("<B>help</B> me [54-65]", match);
 
       }
@@ -882,7 +930,7 @@
         String srchkey = "football";
 
         String s = "football-soccer in the euro 2004 footie competition";
-        QueryParser parser = new QueryParser("bookid", analyzer);
+        QueryParser parser = new QueryParser(TEST_VERSION, "bookid", analyzer);
         Query query = parser.parse(srchkey);
 
         TokenStream tokenStream = analyzer.tokenStream(null, new StringReader(s));
@@ -1004,13 +1052,13 @@
           sb.append(stopWords.iterator().next());
         }
         SimpleHTMLFormatter fm = new SimpleHTMLFormatter();
-        Highlighter hg = getHighlighter(query, "data", new StandardAnalyzer(stopWords).tokenStream(
+        Highlighter hg = getHighlighter(query, "data", new StandardAnalyzer(TEST_VERSION, stopWords).tokenStream(
             "data", new StringReader(sb.toString())), fm);// new Highlighter(fm,
         // new
         // QueryTermScorer(query));
         hg.setTextFragmenter(new NullFragmenter());
         hg.setMaxDocBytesToAnalyze(100);
-        match = hg.getBestFragment(new StandardAnalyzer(stopWords), "data", sb.toString());
+        match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "data", sb.toString());
         assertTrue("Matched text should be no more than 100 chars in length ", match.length() < hg
             .getMaxDocBytesToAnalyze());
 
@@ -1021,7 +1069,7 @@
         // + whitespace)
         sb.append(" ");
         sb.append(goodWord);
-        match = hg.getBestFragment(new StandardAnalyzer(stopWords), "data", sb.toString());
+        match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "data", sb.toString());
         assertTrue("Matched text should be no more than 100 chars in length ", match.length() < hg
             .getMaxDocBytesToAnalyze());
       }
@@ -1041,11 +1089,11 @@
 
         String text = "this is a text with searchterm in it";
         SimpleHTMLFormatter fm = new SimpleHTMLFormatter();
-        Highlighter hg = getHighlighter(query, "text", new StandardAnalyzer(
+        Highlighter hg = getHighlighter(query, "text", new StandardAnalyzer(TEST_VERSION, 
             stopWords).tokenStream("text", new StringReader(text)), fm);
         hg.setTextFragmenter(new NullFragmenter());
         hg.setMaxDocCharsToAnalyze(36);
-        String match = hg.getBestFragment(new StandardAnalyzer(stopWords), "text", text);
+        String match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "text", text);
         assertTrue(
             "Matched text should contain remainder of text after highlighted query ",
             match.endsWith("in it"));
@@ -1061,9 +1109,9 @@
         numHighlights = 0;
         // test to show how rewritten query can still be used
         searcher = new IndexSearcher(ramDir, true);
-        Analyzer analyzer = new StandardAnalyzer();
+        Analyzer analyzer = new StandardAnalyzer(TEST_VERSION);
 
-        QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
+        QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
         Query query = parser.parse("JF? or Kenned*");
         System.out.println("Searching with primitive query");
         // forget to set this and...
@@ -1074,7 +1122,7 @@
         // highlighted text
         // QueryHighlightExtractor highlighter = new
         // QueryHighlightExtractor(this,
-        // query, new StandardAnalyzer());
+        // query, new StandardAnalyzer(TEST_VERSION));
 
         int maxNumFragmentsRequired = 3;
 
@@ -1173,7 +1221,7 @@
   public void testMultiSearcher() throws Exception {
     // setup index 1
     RAMDirectory ramDir1 = new RAMDirectory();
-    IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
     Document d = new Document();
     Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.ANALYZED);
     d.add(f);
@@ -1184,7 +1232,7 @@
 
     // setup index 2
     RAMDirectory ramDir2 = new RAMDirectory();
-    IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
     d = new Document();
     f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.ANALYZED);
     d.add(f);
@@ -1197,14 +1245,14 @@
     searchers[0] = new IndexSearcher(ramDir1, true);
     searchers[1] = new IndexSearcher(ramDir2, true);
     MultiSearcher multiSearcher = new MultiSearcher(searchers);
-    QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+    QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
     parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
     query = parser.parse("multi*");
     System.out.println("Searching for: " + query.toString(FIELD_NAME));
     // at this point the multisearcher calls combine(query[])
     hits = multiSearcher.search(query, null, 1000);
 
-    // query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer());
+    // query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
     Query expandedQueries[] = new Query[2];
     expandedQueries[0] = query.rewrite(reader1);
     expandedQueries[1] = query.rewrite(reader2);
@@ -1230,7 +1278,7 @@
 
       public void run() throws Exception {
         String docMainText = "fred is one of the people";
-        QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
+        QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
         Query query = parser.parse("fred category:people");
 
         // highlighting respects fieldnames used in query
@@ -1371,64 +1419,64 @@
         Highlighter highlighter;
         String result;
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("foo");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("foo");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("Hi-Speed10 <B>foo</B>", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("10");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("10");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("Hi-Speed<B>10</B> foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hi");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("<B>Hi</B>-Speed10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("speed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("speed");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("Hi-<B>Speed</B>10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hispeed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hispeed");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("<B>Hi-Speed</B>10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hi speed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi speed");
         highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2(), s, 3, "...");
         assertEquals("<B>Hi-Speed</B>10 foo", result);
 
         // ///////////////// same tests, just put the bigger overlapping token
         // first
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("foo");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("foo");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("Hi-Speed10 <B>foo</B>", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("10");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("10");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("Hi-Speed<B>10</B> foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hi");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("<B>Hi</B>-Speed10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("speed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("speed");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("Hi-<B>Speed</B>10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hispeed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hispeed");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("<B>Hi-Speed</B>10 foo", result);
 
-        query = new QueryParser("text", new WhitespaceAnalyzer()).parse("hi speed");
+        query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi speed");
         highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
         result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
         assertEquals("<B>Hi-Speed</B>10 foo", result);
@@ -1473,7 +1521,7 @@
   
   private void searchIndex() throws IOException, ParseException, InvalidTokenOffsetsException {
     String q = "t_text1:random";
-    QueryParser parser = new QueryParser( "t_text1", a );
+    QueryParser parser = new QueryParser(TEST_VERSION,  "t_text1", a );
     Query query = parser.parse( q );
     IndexSearcher searcher = new IndexSearcher( dir, true );
     // This scorer can return negative idf -> null fragment
@@ -1527,7 +1575,8 @@
   }
 
   public void doSearching(String queryString) throws Exception {
-    QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+    QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
+    parser.setEnablePositionIncrements(true);
     parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
     query = parser.parse(queryString);
     doSearching(query);
@@ -1564,7 +1613,7 @@
   protected void setUp() throws Exception {
     super.setUp();
     ramDir = new RAMDirectory();
-    IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
     for (int i = 0; i < texts.length; i++) {
       addDoc(writer, texts[i]);
     }

Modified: lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java (original)
+++ lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java Sat Oct 24 21:23:15 2009
@@ -63,7 +63,7 @@
     RAMDirectory dir = new RAMDirectory();
 
     // create dir data
-    IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
     for (int i = 0; i < 20; i++) {
       Document document = new Document();
       assembleDocument(document, i);
@@ -87,7 +87,7 @@
     InstantiatedIndex ii = new InstantiatedIndex();
 
     // create dir data
-    IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
     for (int i = 0; i < 500; i++) {
       Document document = new Document();
       assembleDocument(document, i);
@@ -96,7 +96,7 @@
     indexWriter.close();
 
     // test ii writer
-    InstantiatedIndexWriter instantiatedIndexWriter = ii.indexWriterFactory(new StandardAnalyzer(), true);
+    InstantiatedIndexWriter instantiatedIndexWriter = ii.indexWriterFactory(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true);
     for (int i = 0; i < 500; i++) {
       Document document = new Document();
       assembleDocument(document, i);

Modified: lucene/java/branches/flex_1458/contrib/lucli/src/java/lucli/LuceneMethods.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/lucli/src/java/lucli/LuceneMethods.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/lucli/src/java/lucli/LuceneMethods.java (original)
+++ lucene/java/branches/flex_1458/contrib/lucli/src/java/lucli/LuceneMethods.java Sat Oct 24 21:23:15 2009
@@ -61,6 +61,7 @@
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
 
 /**
  * Various methods that interact with Lucene and provide info about the 
@@ -84,18 +85,18 @@
   }
 
     private Analyzer createAnalyzer() {
-        if (analyzerClassFQN == null) return new StandardAnalyzer();
+        if (analyzerClassFQN == null) return new StandardAnalyzer(Version.LUCENE_CURRENT);
         try {
             Class aClass = Class.forName(analyzerClassFQN);
             Object obj = aClass.newInstance();
             if (!(obj instanceof Analyzer)) {
                 message("Given class is not an Analyzer: " + analyzerClassFQN);
-                return new StandardAnalyzer();
+                return new StandardAnalyzer(Version.LUCENE_CURRENT);
             }
             return (Analyzer)obj;
         } catch (Exception e) {
             message("Unable to use Analyzer " + analyzerClassFQN);
-            return new StandardAnalyzer();
+            return new StandardAnalyzer(Version.LUCENE_CURRENT);
         }
     }
 
@@ -198,7 +199,7 @@
     for (int ii = 0; ii < arraySize; ii++) {
       indexedArray[ii] = (String) indexedFields.get(ii);
     }
-    MultiFieldQueryParser parser = new MultiFieldQueryParser(indexedArray, analyzer);
+    MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, indexedArray, analyzer);
     query = parser.parse(queryString);
     System.out.println("Searching for: " + query.toString());
     return (query);
@@ -219,7 +220,7 @@
     for (int ii = 0; ii < arraySize; ii++) {
       fieldsArray[ii] = (String) fields.get(ii);
     }
-    MultiFieldQueryParser parser = new MultiFieldQueryParser(fieldsArray, analyzer);
+    MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fieldsArray, analyzer);
     query = parser.parse(queryString);
     System.out.println("Searching for: " + query.toString());
   }

Modified: lucene/java/branches/flex_1458/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java (original)
+++ lucene/java/branches/flex_1458/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java Sat Oct 24 21:23:15 2009
@@ -33,6 +33,7 @@
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.util.Version;
 
 /**
  * Efficient Lucene analyzer/tokenizer that preferably operates on a String rather than a
@@ -124,7 +125,7 @@
    * freely across threads without harm); global per class loader.
    */
   public static final PatternAnalyzer DEFAULT_ANALYZER = new PatternAnalyzer(
-    NON_WORD_PATTERN, true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
+    Version.LUCENE_CURRENT, NON_WORD_PATTERN, true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
     
   /**
    * A lower-casing word analyzer with <b>extended </b> English stop words
@@ -134,15 +135,18 @@
    * http://thomas.loc.gov/home/all.about.inquery.html
    */
   public static final PatternAnalyzer EXTENDED_ANALYZER = new PatternAnalyzer(
-    NON_WORD_PATTERN, true, EXTENDED_ENGLISH_STOP_WORDS);
+    Version.LUCENE_CURRENT, NON_WORD_PATTERN, true, EXTENDED_ENGLISH_STOP_WORDS);
     
   private final Pattern pattern;
   private final boolean toLowerCase;
   private final Set stopWords;
+
+  private final Version matchVersion;
   
   /**
    * Constructs a new instance with the given parameters.
    * 
+   * @param matchVersion If >= {@link Version#LUCENE_29}, StopFilter.enablePositionIncrement is set to true
    * @param pattern
    *            a regular expression delimiting tokens
    * @param toLowerCase
@@ -158,7 +162,7 @@
    *            or <a href="http://www.unine.ch/info/clef/">other stop words
    *            lists </a>.
    */
-  public PatternAnalyzer(Pattern pattern, boolean toLowerCase, Set stopWords) {
+  public PatternAnalyzer(Version matchVersion, Pattern pattern, boolean toLowerCase, Set stopWords) {
     if (pattern == null) 
       throw new IllegalArgumentException("pattern must not be null");
     
@@ -170,6 +174,7 @@
     this.pattern = pattern;
     this.toLowerCase = toLowerCase;
     this.stopWords = stopWords;
+    this.matchVersion = matchVersion;
   }
   
   /**
@@ -197,7 +202,7 @@
     }
     else {
       stream = new PatternTokenizer(text, pattern, toLowerCase);
-      if (stopWords != null) stream = new StopFilter(false, stream, stopWords);
+      if (stopWords != null) stream = new StopFilter(StopFilter.getEnablePositionIncrementsVersionDefault(matchVersion), stream, stopWords);
     }
     
     return stream;

Modified: lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java (original)
+++ lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java Sat Oct 24 21:23:15 2009
@@ -52,6 +52,7 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.util.Version;
 
 /**
 Verifies that Lucene MemoryIndex and RAMDirectory have the same behaviour,
@@ -276,8 +277,8 @@
     
     Analyzer[] analyzers = new Analyzer[] { 
         new SimpleAnalyzer(),
-        new StopAnalyzer(),
-        new StandardAnalyzer(),
+        new StopAnalyzer(Version.LUCENE_CURRENT),
+        new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
         PatternAnalyzer.DEFAULT_ANALYZER,
 //        new WhitespaceAnalyzer(),
 //        new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null),
@@ -479,7 +480,7 @@
   }
   
   private Query parseQuery(String expression) throws ParseException {
-    QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
+    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
 //    parser.setPhraseSlop(0);
     return parser.parse(expression);
   }

Modified: lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java (original)
+++ lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java Sat Oct 24 21:23:15 2009
@@ -24,6 +24,7 @@
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.StopAnalyzer;
 import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.util.Version;
 
 /**
  * Verifies the behavior of PatternAnalyzer.
@@ -36,13 +37,13 @@
    */
   public void testNonWordPattern() throws IOException {
     // Split on non-letter pattern, do not lowercase, no stopwords
-    PatternAnalyzer a = new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN,
+    PatternAnalyzer a = new PatternAnalyzer(Version.LUCENE_CURRENT, PatternAnalyzer.NON_WORD_PATTERN,
         false, null);
     check(a, "The quick brown Fox,the abcd1234 (56.78) dc.", new String[] {
         "The", "quick", "brown", "Fox", "the", "abcd", "dc" });
 
     // split on non-letter pattern, lowercase, english stopwords
-    PatternAnalyzer b = new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN,
+    PatternAnalyzer b = new PatternAnalyzer(Version.LUCENE_CURRENT, PatternAnalyzer.NON_WORD_PATTERN,
         true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
     check(b, "The quick brown Fox,the abcd1234 (56.78) dc.", new String[] {
         "quick", "brown", "fox", "abcd", "dc" });
@@ -54,13 +55,13 @@
    */
   public void testWhitespacePattern() throws IOException {
     // Split on whitespace patterns, do not lowercase, no stopwords
-    PatternAnalyzer a = new PatternAnalyzer(PatternAnalyzer.WHITESPACE_PATTERN,
+    PatternAnalyzer a = new PatternAnalyzer(Version.LUCENE_CURRENT, PatternAnalyzer.WHITESPACE_PATTERN,
         false, null);
     check(a, "The quick brown Fox,the abcd1234 (56.78) dc.", new String[] {
         "The", "quick", "brown", "Fox,the", "abcd1234", "(56.78)", "dc." });
 
     // Split on whitespace patterns, lowercase, english stopwords
-    PatternAnalyzer b = new PatternAnalyzer(PatternAnalyzer.WHITESPACE_PATTERN,
+    PatternAnalyzer b = new PatternAnalyzer(Version.LUCENE_CURRENT, PatternAnalyzer.WHITESPACE_PATTERN,
         true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
     check(b, "The quick brown Fox,the abcd1234 (56.78) dc.", new String[] {
         "quick", "brown", "fox,the", "abcd1234", "(56.78)", "dc." });
@@ -72,12 +73,12 @@
    */
   public void testCustomPattern() throws IOException {
     // Split on comma, do not lowercase, no stopwords
-    PatternAnalyzer a = new PatternAnalyzer(Pattern.compile(","), false, null);
+    PatternAnalyzer a = new PatternAnalyzer(Version.LUCENE_CURRENT, Pattern.compile(","), false, null);
     check(a, "Here,Are,some,Comma,separated,words,", new String[] { "Here",
         "Are", "some", "Comma", "separated", "words" });
 
     // split on comma, lowercase, english stopwords
-    PatternAnalyzer b = new PatternAnalyzer(Pattern.compile(","), true,
+    PatternAnalyzer b = new PatternAnalyzer(Version.LUCENE_CURRENT, Pattern.compile(","), true,
         StopAnalyzer.ENGLISH_STOP_WORDS_SET);
     check(b, "Here,Are,some,Comma,separated,words,", new String[] { "here",
         "some", "comma", "separated", "words" });
@@ -102,7 +103,7 @@
     document.append(largeWord2);
 
     // Split on whitespace patterns, do not lowercase, no stopwords
-    PatternAnalyzer a = new PatternAnalyzer(PatternAnalyzer.WHITESPACE_PATTERN,
+    PatternAnalyzer a = new PatternAnalyzer(Version.LUCENE_CURRENT, PatternAnalyzer.WHITESPACE_PATTERN,
         false, null);
     check(a, document.toString(), new String[] { new String(largeWord),
         new String(largeWord2) });

Modified: lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/TestSynonymTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/TestSynonymTokenFilter.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/TestSynonymTokenFilter.java (original)
+++ lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/TestSynonymTokenFilter.java Sat Oct 24 21:23:15 2009
@@ -45,6 +45,14 @@
         new int[] { 1, 1, 1, 1, 0, 0 });
   }
   
+  public void testSynonymsSingleQuote() throws Exception {
+    SynonymMap map = new SynonymMap(new FileInputStream(testFile));
+    /* all expansions */
+    Analyzer analyzer = new SynonymWhitespaceAnalyzer(map, Integer.MAX_VALUE);
+    assertAnalyzesTo(analyzer, "king",
+        new String[] { "king", "baron" });
+  }
+  
   public void testSynonymsLimitedAmount() throws Exception {
     SynonymMap map = new SynonymMap(new FileInputStream(testFile));
     /* limit to one synonym expansion */

Modified: lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/testSynonyms.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/testSynonyms.txt?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/testSynonyms.txt (original)
+++ lucene/java/branches/flex_1458/contrib/memory/src/test/org/apache/lucene/index/memory/testSynonyms.txt Sat Oct 24 21:23:15 2009
@@ -3,3 +3,7 @@
 s(100000001,3,'forest',n,1,0).
 s(100000002,1,'wolfish',n,1,0).
 s(100000002,2,'ravenous',n,1,0).
+s(100000003,1,'king',n,1,1).
+s(100000003,2,'baron',n,1,1).
+s(100000004,1,'king''sevil',n,1,1).
+s(100000004,2,'meany',n,1,1).

Modified: lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.java (original)
+++ lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.java Sat Oct 24 21:23:15 2009
@@ -28,6 +28,7 @@
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
 
 /**
  * Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys
@@ -49,8 +50,8 @@
    * @param field    the default field for query terms.
    * @param analyzer used to find terms in the query text.
    */
-  public AnalyzingQueryParser(String field, Analyzer analyzer) {
-    super(field, analyzer);
+  public AnalyzingQueryParser(Version matchVersion, String field, Analyzer analyzer) {
+    super(matchVersion, field, analyzer);
   }
 
   /**

Modified: lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/complexPhrase/ComplexPhraseQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/complexPhrase/ComplexPhraseQueryParser.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/complexPhrase/ComplexPhraseQueryParser.java (original)
+++ lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/complexPhrase/ComplexPhraseQueryParser.java Sat Oct 24 21:23:15 2009
@@ -38,6 +38,7 @@
 import org.apache.lucene.search.spans.SpanOrQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
+import org.apache.lucene.util.Version;
 
 /**
  * QueryParser which permits complex phrase query syntax eg "(john jon
@@ -67,8 +68,8 @@
 
   private ComplexPhraseQuery currentPhraseQuery = null;
 
-  public ComplexPhraseQueryParser(String f, Analyzer a) {
-    super(f, a);
+  public ComplexPhraseQueryParser(Version matchVersion, String f, Analyzer a) {
+    super(matchVersion, f, a);
   }
 
   protected Query getFieldQuery(String field, String queryText, int slop) {

Modified: lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java (original)
+++ lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java Sat Oct 24 21:23:15 2009
@@ -25,7 +25,6 @@
 import org.apache.lucene.search.TermRangeQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.util.Parameter;
 import org.apache.lucene.util.AttributeSource;
 
 /**
@@ -104,13 +103,7 @@
   int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
   Locale locale = Locale.getDefault();
 
-  static final class Operator extends Parameter {
-    private Operator(String name) {
-      super(name);
-    }
-    static final Operator OR = new Operator("OR");
-    static final Operator AND = new Operator("AND");
-  }
+  static enum Operator { OR, AND }
 
   /** Constructs a query parser.
    *  @param f  the default field for query terms.



Mime
View raw message