You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/12/21 12:40:14 UTC

svn commit: r1721134 [4/48] - in /lucene/dev/branches/lucene6835: ./ dev-tools/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/libraries/ dev-tools/maven/ dev-tools/maven/lucene/analysis/morfologik/ dev-tools/scripts/ lucene/ lucene/analysis/ luc...

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/SimpleNaiveBayesClassifier.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/SimpleNaiveBayesClassifier.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/SimpleNaiveBayesClassifier.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/SimpleNaiveBayesClassifier.java Mon Dec 21 11:39:57 2015
@@ -85,8 +85,9 @@ public class SimpleNaiveBayesClassifier
    * @param analyzer       an {@link Analyzer} used to analyze unseen text
    * @param query          a {@link Query} to eventually filter the docs used for training the classifier, or {@code null}
    *                       if all the indexed docs should be used
-   * @param classFieldName the name of the field used as the output for the classifier
-   * @param textFieldNames the name of the fields used as the inputs for the classifier
+   * @param classFieldName the name of the field used as the output for the classifier NOTE: must not be havely analyzed
+   *                       as the returned class will be a token indexed for this field
+   * @param textFieldNames the name of the fields used as the inputs for the classifier, NO boosting supported per field
    */
   public SimpleNaiveBayesClassifier(LeafReader leafReader, Analyzer analyzer, Query query, String classFieldName, String... textFieldNames) {
     this.leafReader = leafReader;
@@ -102,16 +103,16 @@ public class SimpleNaiveBayesClassifier
    */
   @Override
   public ClassificationResult<BytesRef> assignClass(String inputDocument) throws IOException {
-    List<ClassificationResult<BytesRef>> doclist = assignClassNormalizedList(inputDocument);
-    ClassificationResult<BytesRef> retval = null;
+    List<ClassificationResult<BytesRef>> assignedClasses = assignClassNormalizedList(inputDocument);
+    ClassificationResult<BytesRef> assignedClass = null;
     double maxscore = -Double.MAX_VALUE;
-    for (ClassificationResult<BytesRef> element : doclist) {
-      if (element.getScore() > maxscore) {
-        retval = element;
-        maxscore = element.getScore();
+    for (ClassificationResult<BytesRef> c : assignedClasses) {
+      if (c.getScore() > maxscore) {
+        assignedClass = c;
+        maxscore = c.getScore();
       }
     }
-    return retval;
+    return assignedClass;
   }
 
   /**
@@ -119,9 +120,9 @@ public class SimpleNaiveBayesClassifier
    */
   @Override
   public List<ClassificationResult<BytesRef>> getClasses(String text) throws IOException {
-    List<ClassificationResult<BytesRef>> doclist = assignClassNormalizedList(text);
-    Collections.sort(doclist);
-    return doclist;
+    List<ClassificationResult<BytesRef>> assignedClasses = assignClassNormalizedList(text);
+    Collections.sort(assignedClasses);
+    return assignedClasses;
   }
 
   /**
@@ -129,9 +130,9 @@ public class SimpleNaiveBayesClassifier
    */
   @Override
   public List<ClassificationResult<BytesRef>> getClasses(String text, int max) throws IOException {
-    List<ClassificationResult<BytesRef>> doclist = assignClassNormalizedList(text);
-    Collections.sort(doclist);
-    return doclist.subList(0, max);
+    List<ClassificationResult<BytesRef>> assignedClasses = assignClassNormalizedList(text);
+    Collections.sort(assignedClasses);
+    return assignedClasses.subList(0, max);
   }
 
   /**
@@ -141,46 +142,23 @@ public class SimpleNaiveBayesClassifier
    * @throws IOException if assigning probabilities fails
    */
   protected List<ClassificationResult<BytesRef>> assignClassNormalizedList(String inputDocument) throws IOException {
-    List<ClassificationResult<BytesRef>> dataList = new ArrayList<>();
+    List<ClassificationResult<BytesRef>> assignedClasses = new ArrayList<>();
 
-    Terms terms = MultiFields.getTerms(leafReader, classFieldName);
-    TermsEnum termsEnum = terms.iterator();
+    Terms classes = MultiFields.getTerms(leafReader, classFieldName);
+    TermsEnum classesEnum = classes.iterator();
     BytesRef next;
-    String[] tokenizedDoc = tokenizeDoc(inputDocument);
+    String[] tokenizedText = tokenize(inputDocument);
     int docsWithClassSize = countDocsWithClass();
-    while ((next = termsEnum.next()) != null) {
+    while ((next = classesEnum.next()) != null) {
       if (next.length > 0) {
-        // We are passing the term to IndexSearcher so we need to make sure it will not change over time
-        next = BytesRef.deepCopyOf(next);
-        double clVal = calculateLogPrior(next, docsWithClassSize) + calculateLogLikelihood(tokenizedDoc, next, docsWithClassSize);
-        dataList.add(new ClassificationResult<>(next, clVal));
+        Term term = new Term(this.classFieldName, next);
+        double clVal = calculateLogPrior(term, docsWithClassSize) + calculateLogLikelihood(tokenizedText, term, docsWithClassSize);
+        assignedClasses.add(new ClassificationResult<>(term.bytes(), clVal));
       }
     }
 
     // normalization; the values transforms to a 0-1 range
-    ArrayList<ClassificationResult<BytesRef>> returnList = new ArrayList<>();
-    if (!dataList.isEmpty()) {
-      Collections.sort(dataList);
-      // this is a negative number closest to 0 = a
-      double smax = dataList.get(0).getScore();
-
-      double sumLog = 0;
-      // log(sum(exp(x_n-a)))
-      for (ClassificationResult<BytesRef> cr : dataList) {
-        // getScore-smax <=0 (both negative, smax is the smallest abs()
-        sumLog += Math.exp(cr.getScore() - smax);
-      }
-      // loga=a+log(sum(exp(x_n-a))) = log(sum(exp(x_n)))
-      double loga = smax;
-      loga += Math.log(sumLog);
-
-      // 1/sum*x = exp(log(x))*1/sum = exp(log(x)-log(sum))
-      for (ClassificationResult<BytesRef> cr : dataList) {
-        returnList.add(new ClassificationResult<>(cr.getAssignedClass(), Math.exp(cr.getScore() - loga)));
-      }
-    }
-
-    return returnList;
+    return normClassificationResults(assignedClasses);
   }
 
   /**
@@ -192,15 +170,15 @@ public class SimpleNaiveBayesClassifier
   protected int countDocsWithClass() throws IOException {
     int docCount = MultiFields.getTerms(this.leafReader, this.classFieldName).getDocCount();
     if (docCount == -1) { // in case codec doesn't support getDocCount
-      TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
+      TotalHitCountCollector classQueryCountCollector = new TotalHitCountCollector();
       BooleanQuery.Builder q = new BooleanQuery.Builder();
       q.add(new BooleanClause(new WildcardQuery(new Term(classFieldName, String.valueOf(WildcardQuery.WILDCARD_STRING))), BooleanClause.Occur.MUST));
       if (query != null) {
         q.add(query, BooleanClause.Occur.MUST);
       }
       indexSearcher.search(q.build(),
-              totalHitCountCollector);
-      docCount = totalHitCountCollector.getTotalHits();
+          classQueryCountCollector);
+      docCount = classQueryCountCollector.getTotalHits();
     }
     return docCount;
   }
@@ -208,14 +186,14 @@ public class SimpleNaiveBayesClassifier
   /**
    * tokenize a <code>String</code> on this classifier's text fields and analyzer
    *
-   * @param doc the <code>String</code> representing an input text (to be classified)
+   * @param text the <code>String</code> representing an input text (to be classified)
    * @return a <code>String</code> array of the resulting tokens
    * @throws IOException if tokenization fails
    */
-  protected String[] tokenizeDoc(String doc) throws IOException {
+  protected String[] tokenize(String text) throws IOException {
     Collection<String> result = new LinkedList<>();
     for (String textFieldName : textFieldNames) {
-      try (TokenStream tokenStream = analyzer.tokenStream(textFieldName, doc)) {
+      try (TokenStream tokenStream = analyzer.tokenStream(textFieldName, text)) {
         CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class);
         tokenStream.reset();
         while (tokenStream.incrementToken()) {
@@ -227,18 +205,18 @@ public class SimpleNaiveBayesClassifier
     return result.toArray(new String[result.size()]);
   }
 
-  private double calculateLogLikelihood(String[] tokenizedDoc, BytesRef c, int docsWithClassSize) throws IOException {
+  private double calculateLogLikelihood(String[] tokenizedText, Term term, int docsWithClass) throws IOException {
     // for each word
     double result = 0d;
-    for (String word : tokenizedDoc) {
+    for (String word : tokenizedText) {
       // search with text:word AND class:c
-      int hits = getWordFreqForClass(word, c);
+      int hits = getWordFreqForClass(word, term);
 
       // num : count the no of times the word appears in documents of class c (+1)
       double num = hits + 1; // +1 is added because of add 1 smoothing
 
       // den : for the whole dictionary, count the no of times a word appears in documents of class c (+|V|)
-      double den = getTextTermFreqForClass(c) + docsWithClassSize;
+      double den = getTextTermFreqForClass(term) + docsWithClass;
 
       // P(w|c) = num/den
       double wordProbability = num / den;
@@ -249,25 +227,39 @@ public class SimpleNaiveBayesClassifier
     return result;
   }
 
-  private double getTextTermFreqForClass(BytesRef c) throws IOException {
+  /**
+   * Returns the average number of unique terms times the number of docs belonging to the input class
+   * @param term the term representing the class
+   * @return the average number of unique terms
+   * @throws IOException if a low level I/O problem happens
+   */
+  private double getTextTermFreqForClass(Term term) throws IOException {
     double avgNumberOfUniqueTerms = 0;
     for (String textFieldName : textFieldNames) {
       Terms terms = MultiFields.getTerms(leafReader, textFieldName);
       long numPostings = terms.getSumDocFreq(); // number of term/doc pairs
       avgNumberOfUniqueTerms += numPostings / (double) terms.getDocCount(); // avg # of unique terms per doc
     }
-    int docsWithC = leafReader.docFreq(new Term(classFieldName, c));
+    int docsWithC = leafReader.docFreq(term);
     return avgNumberOfUniqueTerms * docsWithC; // avg # of unique terms in text fields per doc * # docs with c
   }
 
-  private int getWordFreqForClass(String word, BytesRef c) throws IOException {
+  /**
+   * Returns the number of documents of the input class ( from the whole index or from a subset)
+   * that contains the word ( in a specific field or in all the fields if no one selected)
+   * @param word the token produced by the analyzer
+   * @param term the term representing the class
+   * @return the number of documents of the input class
+   * @throws IOException if a low level I/O problem happens
+   */
+  private int getWordFreqForClass(String word, Term term) throws IOException {
     BooleanQuery.Builder booleanQuery = new BooleanQuery.Builder();
     BooleanQuery.Builder subQuery = new BooleanQuery.Builder();
     for (String textFieldName : textFieldNames) {
       subQuery.add(new BooleanClause(new TermQuery(new Term(textFieldName, word)), BooleanClause.Occur.SHOULD));
     }
     booleanQuery.add(new BooleanClause(subQuery.build(), BooleanClause.Occur.MUST));
-    booleanQuery.add(new BooleanClause(new TermQuery(new Term(classFieldName, c)), BooleanClause.Occur.MUST));
+    booleanQuery.add(new BooleanClause(new TermQuery(term), BooleanClause.Occur.MUST));
     if (query != null) {
       booleanQuery.add(query, BooleanClause.Occur.MUST);
     }
@@ -276,11 +268,43 @@ public class SimpleNaiveBayesClassifier
     return totalHitCountCollector.getTotalHits();
   }
 
-  private double calculateLogPrior(BytesRef currentClass, int docsWithClassSize) throws IOException {
-    return Math.log((double) docCount(currentClass)) - Math.log(docsWithClassSize);
+  private double calculateLogPrior(Term term, int docsWithClassSize) throws IOException {
+    return Math.log((double) docCount(term)) - Math.log(docsWithClassSize);
   }
 
-  private int docCount(BytesRef countedClass) throws IOException {
-    return leafReader.docFreq(new Term(classFieldName, countedClass));
+  private int docCount(Term term) throws IOException {
+    return leafReader.docFreq(term);
+  }
+
+  /**
+   * Normalize the classification results based on the max score available
+   * @param assignedClasses the list of assigned classes
+   * @return the normalized results
+   */
+  protected ArrayList<ClassificationResult<BytesRef>> normClassificationResults(List<ClassificationResult<BytesRef>> assignedClasses) {
+    // normalization; the values transforms to a 0-1 range
+    ArrayList<ClassificationResult<BytesRef>> returnList = new ArrayList<>();
+    if (!assignedClasses.isEmpty()) {
+      Collections.sort(assignedClasses);
+      // this is a negative number closest to 0 = a
+      double smax = assignedClasses.get(0).getScore();
+
+      double sumLog = 0;
+      // log(sum(exp(x_n-a)))
+      for (ClassificationResult<BytesRef> cr : assignedClasses) {
+        // getScore-smax <=0 (both negative, smax is the smallest abs()
+        sumLog += Math.exp(cr.getScore() - smax);
+      }
+      // loga=a+log(sum(exp(x_n-a))) = log(sum(exp(x_n)))
+      double loga = smax;
+      loga += Math.log(sumLog);
+
+      // 1/sum*x = exp(log(x))*1/sum = exp(log(x)-log(sum))
+      for (ClassificationResult<BytesRef> cr : assignedClasses) {
+        double scoreDiff = cr.getScore() - loga;
+        returnList.add(new ClassificationResult<>(cr.getAssignedClass(), Math.exp(scoreDiff)));
+      }
+    }
+    return returnList;
   }
 }

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/package-info.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/package-info.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/package-info.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/package-info.java Mon Dec 21 11:39:57 2015
@@ -16,8 +16,8 @@
  */
 
 /**
- * Uses already seen data (the indexed documents) to classify new documents.
- * <p>
+ * Uses already seen data (the indexed documents) to classify an input ( can be simple text or a structured document).
+ *
  * Currently contains a (simplistic) Naive Bayes classifier, a k-Nearest
  * Neighbor classifier and a Perceptron based classifier.
  */

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java Mon Dec 21 11:39:57 2015
@@ -18,6 +18,7 @@ package org.apache.lucene.classification
  */
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -31,11 +32,10 @@ import org.apache.lucene.classification.
 import org.apache.lucene.classification.Classifier;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.StoredDocument;
-import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermRangeQuery;
 import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.NamedThreadFactory;
 
@@ -69,14 +69,15 @@ public class ConfusionMatrixGenerator {
 
       Map<String, Map<String, Long>> counts = new HashMap<>();
       IndexSearcher indexSearcher = new IndexSearcher(reader);
-      TopDocs topDocs = indexSearcher.search(new WildcardQuery(new Term(classFieldName, "*")), Integer.MAX_VALUE);
+      TopDocs topDocs = indexSearcher.search(new TermRangeQuery(classFieldName, null, null, true, true), Integer.MAX_VALUE);
       double time = 0d;
 
       for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
         StoredDocument doc = reader.document(scoreDoc.doc);
-        String correctAnswer = doc.get(classFieldName);
+        String[] correctAnswers = doc.getValues(classFieldName);
 
-        if (correctAnswer != null && correctAnswer.length() > 0) {
+        if (correctAnswers != null && correctAnswers.length > 0) {
+          Arrays.sort(correctAnswers);
           ClassificationResult<T> result;
           String text = doc.get(textFieldName);
           if (text != null) {
@@ -92,6 +93,13 @@ public class ConfusionMatrixGenerator {
                 if (assignedClass != null) {
                   String classified = assignedClass instanceof BytesRef ? ((BytesRef) assignedClass).utf8ToString() : assignedClass.toString();
 
+                  String correctAnswer;
+                  if (Arrays.binarySearch(correctAnswers, classified) >= 0) {
+                    correctAnswer = classified;
+                  } else {
+                    correctAnswer = correctAnswers[0];
+                  }
+
                   Map<String, Long> stringLongMap = counts.get(correctAnswer);
                   if (stringLongMap != null) {
                     Long aLong = stringLongMap.get(classified);
@@ -105,6 +113,7 @@ public class ConfusionMatrixGenerator {
                     stringLongMap.put(classified, 1l);
                     counts.put(correctAnswer, stringLongMap);
                   }
+
                 }
               }
             } catch (TimeoutException timeoutException) {
@@ -131,6 +140,7 @@ public class ConfusionMatrixGenerator {
     private final Map<String, Map<String, Long>> linearizedMatrix;
     private final double avgClassificationTime;
     private final int numberOfEvaluatedDocs;
+    private double accuracy = -1d;
 
     private ConfusionMatrix(Map<String, Map<String, Long>> linearizedMatrix, double avgClassificationTime, int numberOfEvaluatedDocs) {
       this.linearizedMatrix = linearizedMatrix;
@@ -140,12 +150,102 @@ public class ConfusionMatrixGenerator {
 
     /**
      * get the linearized confusion matrix as a {@link Map}
-     * @return a {@link Map} whose keys are the correct answers and whose values are the actual answers' counts
+     *
+     * @return a {@link Map} whose keys are the correct classification answers and whose values are the actual answers'
+     * counts
      */
     public Map<String, Map<String, Long>> getLinearizedMatrix() {
       return Collections.unmodifiableMap(linearizedMatrix);
     }
 
+    /**
+     * calculate precision on the given class
+     *
+     * @param klass the class to calculate the precision for
+     * @return the precision for the given class
+     */
+    public double getPrecision(String klass) {
+      Map<String, Long> classifications = linearizedMatrix.get(klass);
+      double tp = 0;
+      double fp = 0;
+      if (classifications != null) {
+        for (Map.Entry<String, Long> entry : classifications.entrySet()) {
+          if (klass.equals(entry.getKey())) {
+            tp += entry.getValue();
+          }
+        }
+        for (Map<String, Long> values : linearizedMatrix.values()) {
+          if (values.containsKey(klass)) {
+            fp += values.get(klass);
+          }
+        }
+      }
+      return tp + fp > 0 ? tp / (tp + fp) : 0;
+    }
+
+    /**
+     * calculate recall on the given class
+     *
+     * @param klass the class to calculate the recall for
+     * @return the recall for the given class
+     */
+    public double getRecall(String klass) {
+      Map<String, Long> classifications = linearizedMatrix.get(klass);
+      double tp = 0;
+      double fn = 0;
+      if (classifications != null) {
+        for (Map.Entry<String, Long> entry : classifications.entrySet()) {
+          if (klass.equals(entry.getKey())) {
+            tp += entry.getValue();
+          } else {
+            fn += entry.getValue();
+          }
+        }
+      }
+      return tp + fn > 0 ? tp / (tp + fn) : 0;
+    }
+
+    /**
+     * get the F-1 measure of the given class
+     *
+     * @param klass the class to calculate the F-1 measure for
+     * @return the F-1 measure for the given class
+     */
+    public double getF1Measure(String klass) {
+      double recall = getRecall(klass);
+      double precision = getPrecision(klass);
+      return precision > 0 && recall > 0 ? 2 * precision * recall / (precision + recall) : 0;
+    }
+
+    /**
+     * Calculate accuracy on this confusion matrix using the formula:
+     * {@literal accuracy = correctly-classified / (correctly-classified + wrongly-classified)}
+     *
+     * @return the accuracy
+     */
+    public double getAccuracy() {
+      if (this.accuracy == -1) {
+        double cc = 0d;
+        double wc = 0d;
+        for (Map.Entry<String, Map<String, Long>> entry : linearizedMatrix.entrySet()) {
+          String correctAnswer = entry.getKey();
+          for (Map.Entry<String, Long> classifiedAnswers : entry.getValue().entrySet()) {
+            Long value = classifiedAnswers.getValue();
+            if (value != null) {
+              if (correctAnswer.equals(classifiedAnswers.getKey())) {
+                cc += value;
+              } else {
+                wc += value;
+              }
+            }
+          }
+
+        }
+        this.accuracy = cc / (cc + wc);
+      }
+      return this.accuracy;
+    }
+
     @Override
     public String toString() {
       return "ConfusionMatrix{" +
@@ -157,6 +257,7 @@ public class ConfusionMatrixGenerator {
 
     /**
      * get the average classification time in milliseconds
+     *
      * @return the avg classification time
      */
     public double getAvgClassificationTime() {
@@ -165,6 +266,7 @@ public class ConfusionMatrixGenerator {
 
     /**
      * get the no. of documents evaluated while generating this confusion matrix
+     *
      * @return the no. of documents evaluated
      */
     public int getNumberOfEvaluatedDocs() {

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java Mon Dec 21 11:39:57 2015
@@ -124,12 +124,18 @@ public class DatasetSplitter {
         }
         b++;
       }
-    } catch (Exception e) {
-      throw new IOException(e);
-    } finally {
+      // commit
       testWriter.commit();
       cvWriter.commit();
       trainingWriter.commit();
+
+      // merge
+      testWriter.forceMerge(3);
+      cvWriter.forceMerge(3);
+      trainingWriter.forceMerge(3);
+    } catch (Exception e) {
+      throw new IOException(e);
+    } finally {
       // close IWs
       testWriter.close();
       cvWriter.close();

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java Mon Dec 21 11:39:57 2015
@@ -79,7 +79,7 @@ public class BooleanPerceptronClassifier
     LeafReader leafReader = getRandomIndex(analyzer, 100);
     try {
       long trainStart = System.currentTimeMillis();
-      BooleanPerceptronClassifier classifier = new BooleanPerceptronClassifier(leafReader, analyzer, null, 1, 0d, booleanFieldName, textFieldName);
+      BooleanPerceptronClassifier classifier = new BooleanPerceptronClassifier(leafReader, analyzer, null, 1, null, booleanFieldName, textFieldName);
       long trainEnd = System.currentTimeMillis();
       long trainTime = trainEnd - trainStart;
       assertTrue("training took more than 10s: " + trainTime / 1000 + "s", trainTime < 10000);
@@ -93,6 +93,9 @@ public class BooleanPerceptronClassifier
       assertTrue("evaluation took more than 1m: " + evaluationTime / 1000 + "s", evaluationTime < 60000);
       double avgClassificationTime = confusionMatrix.getAvgClassificationTime();
       assertTrue(5000 > avgClassificationTime);
+      // accuracy check disabled until LUCENE-6853 is fixed
+//      double accuracy = confusionMatrix.getAccuracy();
+//      assertTrue(accuracy > 0d);
     } finally {
       leafReader.close();
     }

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java Mon Dec 21 11:39:57 2015
@@ -108,6 +108,8 @@ public class CachingNaiveBayesClassifier
       assertTrue("evaluation took more than 1m: " + evaluationTime / 1000 + "s", evaluationTime < 60000);
       double avgClassificationTime = confusionMatrix.getAvgClassificationTime();
       assertTrue(5000 > avgClassificationTime);
+      double accuracy = confusionMatrix.getAccuracy();
+      assertTrue(accuracy > 0d);
     } finally {
       leafReader.close();
     }

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java Mon Dec 21 11:39:57 2015
@@ -57,8 +57,8 @@ public abstract class ClassificationTest
   protected static final BytesRef TECHNOLOGY_RESULT = new BytesRef("technology");
 
   protected RandomIndexWriter indexWriter;
-  private Directory dir;
-  private FieldType ft;
+  protected Directory dir;
+  protected FieldType ft;
 
   protected String textFieldName;
   protected String categoryFieldName;

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java Mon Dec 21 11:39:57 2015
@@ -124,7 +124,7 @@ public class KNearestNeighborClassifierT
     try {
       long trainStart = System.currentTimeMillis();
       KNearestNeighborClassifier kNearestNeighborClassifier = new KNearestNeighborClassifier(leafReader, null,
-          analyzer, null, 1, 2, 2, categoryFieldName, textFieldName);
+          analyzer, null, 1, 1, 1, categoryFieldName, textFieldName);
       long trainEnd = System.currentTimeMillis();
       long trainTime = trainEnd - trainStart;
       assertTrue("training took more than 10s: " + trainTime / 1000 + "s", trainTime < 10000);
@@ -138,6 +138,8 @@ public class KNearestNeighborClassifierT
       assertTrue("evaluation took more than 2m: " + evaluationTime / 1000 + "s", evaluationTime < 120000);
       double avgClassificationTime = confusionMatrix.getAvgClassificationTime();
       assertTrue(5000 > avgClassificationTime);
+      double accuracy = confusionMatrix.getAccuracy();
+      assertTrue(accuracy > 0d);
     } finally {
       leafReader.close();
     }

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java Mon Dec 21 11:39:57 2015
@@ -109,6 +109,8 @@ public class SimpleNaiveBayesClassifierT
       assertTrue("evaluation took more than 2m: " + evaluationTime / 1000 + "s", evaluationTime < 120000);
       double avgClassificationTime = confusionMatrix.getAvgClassificationTime();
       assertTrue("avg classification time: " + avgClassificationTime, 5000 > avgClassificationTime);
+      double accuracy = confusionMatrix.getAccuracy();
+      assertTrue(accuracy > 0d);
     } finally {
       leafReader.close();
     }

Modified: lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java (original)
+++ lucene/dev/branches/lucene6835/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java Mon Dec 21 11:39:57 2015
@@ -84,6 +84,7 @@ public class ConfusionMatrixGeneratorTes
       assertNotNull(confusionMatrix.getLinearizedMatrix());
       assertEquals(7, confusionMatrix.getNumberOfEvaluatedDocs());
       assertTrue(confusionMatrix.getAvgClassificationTime() > 0d);
+      assertTrue(confusionMatrix.getAccuracy() > 0d);
     } finally {
       if (reader != null) {
         reader.close();
@@ -103,6 +104,7 @@ public class ConfusionMatrixGeneratorTes
       assertNotNull(confusionMatrix.getLinearizedMatrix());
       assertEquals(7, confusionMatrix.getNumberOfEvaluatedDocs());
       assertTrue(confusionMatrix.getAvgClassificationTime() > 0d);
+      assertTrue(confusionMatrix.getAccuracy() > 0d);
     } finally {
       if (reader != null) {
         reader.close();
@@ -122,6 +124,7 @@ public class ConfusionMatrixGeneratorTes
       assertNotNull(confusionMatrix.getLinearizedMatrix());
       assertEquals(7, confusionMatrix.getNumberOfEvaluatedDocs());
       assertTrue(confusionMatrix.getAvgClassificationTime() > 0d);
+      assertTrue(confusionMatrix.getAccuracy() > 0d);
     } finally {
       if (reader != null) {
         reader.close();
@@ -141,6 +144,13 @@ public class ConfusionMatrixGeneratorTes
       assertNotNull(confusionMatrix.getLinearizedMatrix());
       assertEquals(7, confusionMatrix.getNumberOfEvaluatedDocs());
       assertTrue(confusionMatrix.getAvgClassificationTime() >= 0d);
+      assertTrue(confusionMatrix.getAccuracy() > 0d);
+      assertTrue(confusionMatrix.getPrecision("true") > 0d);
+      assertTrue(confusionMatrix.getPrecision("false") > 0d);
+      assertTrue(confusionMatrix.getRecall("true") > 0d);
+      assertTrue(confusionMatrix.getRecall("false") > 0d);
+      assertTrue(confusionMatrix.getF1Measure("true") > 0d);
+      assertTrue(confusionMatrix.getF1Measure("false") > 0d);
     } finally {
       if (reader != null) {
         reader.close();

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java Mon Dec 21 11:39:57 2015
@@ -120,7 +120,7 @@ import org.apache.lucene.util.fst.Util;
  */
 
 public class FSTTermsWriter extends FieldsConsumer {
-  static final String TERMS_EXTENSION = "tmp";
+  static final String TERMS_EXTENSION = "tfp";
   static final String TERMS_CODEC_NAME = "FSTTerms";
   public static final int TERMS_VERSION_START = 2;
   public static final int TERMS_VERSION_CURRENT = TERMS_VERSION_START;

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java Mon Dec 21 11:39:57 2015
@@ -19,12 +19,13 @@ package org.apache.lucene.codecs.simplet
 
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.codecs.CompoundFormat;
+import org.apache.lucene.codecs.DimensionalFormat;
+import org.apache.lucene.codecs.DocValuesFormat;
 import org.apache.lucene.codecs.FieldInfosFormat;
 import org.apache.lucene.codecs.LiveDocsFormat;
+import org.apache.lucene.codecs.NormsFormat;
 import org.apache.lucene.codecs.PostingsFormat;
 import org.apache.lucene.codecs.SegmentInfoFormat;
-import org.apache.lucene.codecs.DocValuesFormat;
-import org.apache.lucene.codecs.NormsFormat;
 import org.apache.lucene.codecs.StoredFieldsFormat;
 import org.apache.lucene.codecs.TermVectorsFormat;
 
@@ -44,11 +45,12 @@ public final class SimpleTextCodec exten
   private final LiveDocsFormat liveDocs = new SimpleTextLiveDocsFormat();
   private final DocValuesFormat dvFormat = new SimpleTextDocValuesFormat();
   private final CompoundFormat compoundFormat = new SimpleTextCompoundFormat();
+  private final DimensionalFormat dimensionalFormat = new SimpleTextDimensionalFormat();
   
   public SimpleTextCodec() {
     super("SimpleText");
   }
-  
+
   @Override
   public PostingsFormat postingsFormat() {
     return postings;
@@ -93,4 +95,9 @@ public final class SimpleTextCodec exten
   public CompoundFormat compoundFormat() {
     return compoundFormat;
   }
+
+  @Override
+  public DimensionalFormat dimensionalFormat() {
+    return dimensionalFormat;
+  }
 }

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCompoundFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCompoundFormat.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCompoundFormat.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCompoundFormat.java Mon Dec 21 11:39:57 2015
@@ -214,7 +214,7 @@ public class SimpleTextCompoundFormat ex
   }
   
   // helper method to strip strip away 'prefix' from 'scratch' and return as String
-  private String stripPrefix(BytesRefBuilder scratch, BytesRef prefix) throws IOException {
+  private String stripPrefix(BytesRefBuilder scratch, BytesRef prefix) {
     return new String(scratch.bytes(), prefix.length, scratch.length() - prefix.length, StandardCharsets.UTF_8);
   }
   

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java Mon Dec 21 11:39:57 2015
@@ -24,7 +24,6 @@ import java.nio.charset.StandardCharsets
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.ParseException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -499,7 +498,7 @@ class SimpleTextDocValuesReader extends
   }
 
   /** Used only in ctor: */
-  private String stripPrefix(BytesRef prefix) throws IOException {
+  private String stripPrefix(BytesRef prefix) {
     return new String(scratch.bytes(), prefix.length, scratch.length() - prefix.length, StandardCharsets.UTF_8);
   }
 

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosFormat.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosFormat.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosFormat.java Mon Dec 21 11:39:57 2015
@@ -64,6 +64,8 @@ public class SimpleTextFieldInfosFormat
   static final BytesRef NUM_ATTS        =  new BytesRef("  attributes ");
   static final BytesRef ATT_KEY         =  new BytesRef("    key ");
   static final BytesRef ATT_VALUE       =  new BytesRef("    value ");
+  static final BytesRef DIM_COUNT       =  new BytesRef("  dimensional count ");
+  static final BytesRef DIM_NUM_BYTES   =  new BytesRef("  dimensional num bytes ");
   
   @Override
   public FieldInfos read(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, IOContext iocontext) throws IOException {
@@ -130,8 +132,17 @@ public class SimpleTextFieldInfosFormat
           atts.put(key, value);
         }
 
+        SimpleTextUtil.readLine(input, scratch);
+        assert StringHelper.startsWith(scratch.get(), DIM_COUNT);
+        int dimensionalCount = Integer.parseInt(readString(DIM_COUNT.length, scratch));
+
+        SimpleTextUtil.readLine(input, scratch);
+        assert StringHelper.startsWith(scratch.get(), DIM_NUM_BYTES);
+        int dimensionalNumBytes = Integer.parseInt(readString(DIM_NUM_BYTES.length, scratch));
+
         infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, 
-          omitNorms, storePayloads, indexOptions, docValuesType, dvGen, Collections.unmodifiableMap(atts));
+                                 omitNorms, storePayloads, indexOptions, docValuesType, dvGen, Collections.unmodifiableMap(atts),
+                                 dimensionalCount, dimensionalNumBytes);
       }
 
       SimpleTextUtil.checkFooter(input);
@@ -219,6 +230,14 @@ public class SimpleTextFieldInfosFormat
             SimpleTextUtil.writeNewline(out);
           }
         }
+
+        SimpleTextUtil.write(out, DIM_COUNT);
+        SimpleTextUtil.write(out, Integer.toString(fi.getDimensionCount()), scratch);
+        SimpleTextUtil.writeNewline(out);
+        
+        SimpleTextUtil.write(out, DIM_NUM_BYTES);
+        SimpleTextUtil.write(out, Integer.toString(fi.getDimensionNumBytes()), scratch);
+        SimpleTextUtil.writeNewline(out);
       }
       SimpleTextUtil.writeChecksum(out, scratch);
       success = true;

Modified: lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextUtil.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextUtil.java (original)
+++ lucene/dev/branches/lucene6835/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextUtil.java Mon Dec 21 11:39:57 2015
@@ -28,7 +28,6 @@ import org.apache.lucene.store.IndexOutp
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.StringHelper;
-import org.apache.lucene.util.UnicodeUtil;
 
 class SimpleTextUtil {
   public final static byte NEWLINE = 10;
@@ -77,15 +76,15 @@ class SimpleTextUtil {
     // same number of bytes
     // (BaseIndexFileFormatTestCase.testMergeStability cares):
     String checksum = String.format(Locale.ROOT, "%020d", out.getChecksum());
-    SimpleTextUtil.write(out, CHECKSUM);
-    SimpleTextUtil.write(out, checksum, scratch);
-    SimpleTextUtil.writeNewline(out);
+    write(out, CHECKSUM);
+    write(out, checksum, scratch);
+    writeNewline(out);
   }
   
   public static void checkFooter(ChecksumIndexInput input) throws IOException {
     BytesRefBuilder scratch = new BytesRefBuilder();
     String expectedChecksum = String.format(Locale.ROOT, "%020d", input.getChecksum());
-    SimpleTextUtil.readLine(input, scratch);
+    readLine(input, scratch);
     if (StringHelper.startsWith(scratch.get(), CHECKSUM) == false) {
       throw new CorruptIndexException("SimpleText failure: expected checksum line but got " + scratch.get().utf8ToString(), input);
     }
@@ -97,4 +96,21 @@ class SimpleTextUtil {
       throw new CorruptIndexException("Unexpected stuff at the end of file, please be careful with your text editor!", input);
     }
   }
+
+  /** Inverse of {@link BytesRef#toString}. */
+  public static BytesRef fromBytesRefString(String s) {
+    if (s.length() < 2) {
+      throw new IllegalArgumentException("string " + s + " was not created from BytesRef.toString?");
+    }
+    if (s.charAt(0) != '[' || s.charAt(s.length()-1) != ']') {
+      throw new IllegalArgumentException("string " + s + " was not created from BytesRef.toString?");
+    }
+    String[] parts = s.substring(1, s.length()-1).split(" ");
+    byte[] bytes = new byte[parts.length];
+    for(int i=0;i<parts.length;i++) {
+      bytes[i] = (byte) Integer.parseInt(parts[i], 16);
+    }
+
+    return new BytesRef(bytes);
+  }
 }

Modified: lucene/dev/branches/lucene6835/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/common-build.xml?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/common-build.xml (original)
+++ lucene/dev/branches/lucene6835/lucene/common-build.xml Mon Dec 21 11:39:57 2015
@@ -339,12 +339,16 @@
     We want to detect here only a limited set of versions and placed in normalized form in ${build.java.runtime},
     every other version is normalized to "unknown":
     - To define a target to be only run on a specific version, add <equals/> condition to one of the supplied versions.
-    - To explicitely exclude specific versions (and unknown ones), add a condition to disallow "unknown" and some versions like "1.9"!
+    - To explicitely exclude specific versions (and unknown ones), add a condition to disallow "unknown" and some versions like "1.9"/"9"!
+    - For Java 9, be sure to exclude both in custom checks: "9" and "1.9"
+    
+    TODO: Find a better solution in Ant without scripting to check supported Java versions!
    -->
   <condition property="build.java.runtime" value="${-cleaned.specification.version}" else="unknown">
     <or>
       <equals arg1="${-cleaned.specification.version}" arg2="1.8"/>
       <equals arg1="${-cleaned.specification.version}" arg2="1.9"/>
+      <equals arg1="${-cleaned.specification.version}" arg2="9"/>
     </or>
   </condition>
   

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java Mon Dec 21 11:39:57 2015
@@ -17,16 +17,15 @@ package org.apache.lucene.analysis;
  * limitations under the License.
  */
 
-import org.apache.lucene.store.AlreadyClosedException;
-import org.apache.lucene.util.CloseableThreadLocal;
-import org.apache.lucene.util.Version;
-
 import java.io.Closeable;
-import java.io.IOException;
 import java.io.Reader;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.lucene.store.AlreadyClosedException;
+import org.apache.lucene.util.CloseableThreadLocal;
+import org.apache.lucene.util.Version;
+
 /**
  * An Analyzer builds TokenStreams, which analyze text.  It thus represents a
  * policy for extracting index terms from text.
@@ -131,11 +130,10 @@ public abstract class Analyzer implement
    * @param reader the reader the streams source reads from
    * @return TokenStream for iterating the analyzed content of <code>reader</code>
    * @throws AlreadyClosedException if the Analyzer is closed.
-   * @throws IOException if an i/o error occurs.
    * @see #tokenStream(String, String)
    */
   public final TokenStream tokenStream(final String fieldName,
-                                       final Reader reader) throws IOException {
+                                       final Reader reader) {
     TokenStreamComponents components = reuseStrategy.getReusableComponents(this, fieldName);
     final Reader r = initReader(fieldName, reader);
     if (components == null) {
@@ -165,10 +163,9 @@ public abstract class Analyzer implement
    * @param text the String the streams source reads from
    * @return TokenStream for iterating the analyzed content of <code>reader</code>
    * @throws AlreadyClosedException if the Analyzer is closed.
-   * @throws IOException if an i/o error occurs (may rarely happen for strings).
    * @see #tokenStream(String, Reader)
    */
-  public final TokenStream tokenStream(final String fieldName, final String text) throws IOException {
+  public final TokenStream tokenStream(final String fieldName, final String text) {
     TokenStreamComponents components = reuseStrategy.getReusableComponents(this, fieldName);
     @SuppressWarnings("resource") final ReusableStringReader strReader = 
         (components == null || components.reusableStringReader == null) ?
@@ -313,10 +310,8 @@ public abstract class Analyzer implement
      * 
      * @param reader
      *          a reader to reset the source component
-     * @throws IOException
-     *           if the component's reset method throws an {@link IOException}
      */
-    protected void setReader(final Reader reader) throws IOException {
+    protected void setReader(final Reader reader) {
       source.setReader(reader);
     }
 

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java Mon Dec 21 11:39:57 2015
@@ -17,12 +17,12 @@ package org.apache.lucene.analysis;
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.io.Reader;
+
 import org.apache.lucene.util.AttributeFactory;
 import org.apache.lucene.util.AttributeSource;
 
-import java.io.Reader;
-import java.io.IOException;
-
 /** A Tokenizer is a TokenStream whose input is a Reader.
   <p>
   This is an abstract class; subclasses must override {@link #incrementToken()}
@@ -83,7 +83,7 @@ public abstract class Tokenizer extends
   /** Expert: Set a new reader on the Tokenizer.  Typically, an
    *  analyzer (in its tokenStream method) will use
    *  this to re-use a previously created tokenizer. */
-  public final void setReader(Reader input) throws IOException {
+  public final void setReader(Reader input) {
     if (input == null) {
       throw new NullPointerException("input must not be null");
     } else if (this.input != ILLEGAL_STATE_READER) {

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/Codec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/Codec.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/Codec.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/Codec.java Mon Dec 21 11:39:57 2015
@@ -18,8 +18,8 @@ package org.apache.lucene.codecs;
  */
 
 import java.util.Objects;
-import java.util.Set;
 import java.util.ServiceLoader; // javadocs
+import java.util.Set;
 
 import org.apache.lucene.index.IndexWriterConfig; // javadocs
 import org.apache.lucene.util.NamedSPILoader;
@@ -57,7 +57,7 @@ public abstract class Codec implements N
     }
     
     // TODO: should we use this, or maybe a system property is better?
-    static Codec defaultCodec = LOADER.lookup("Lucene53");
+    static Codec defaultCodec = LOADER.lookup("Lucene60");
   }
 
   private final String name;
@@ -107,6 +107,9 @@ public abstract class Codec implements N
   
   /** Encodes/decodes compound files */
   public abstract CompoundFormat compoundFormat();
+
+  /** Encodes/decodes dimensional index */
+  public abstract DimensionalFormat dimensionalFormat();
   
   /** looks up a codec by name */
   public static Codec forName(String name) {

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java Mon Dec 21 11:39:57 2015
@@ -135,9 +135,9 @@ public final class CodecUtil {
     out.writeBytes(id, 0, id.length);
     BytesRef suffixBytes = new BytesRef(suffix);
     if (suffixBytes.length != suffix.length() || suffixBytes.length >= 256) {
-      throw new IllegalArgumentException("codec must be simple ASCII, less than 256 characters in length [got " + suffix + "]");
+      throw new IllegalArgumentException("suffix must be simple ASCII, less than 256 characters in length [got " + suffix + "]");
     }
-    out.writeByte((byte)suffixBytes.length);
+    out.writeByte((byte) suffixBytes.length);
     out.writeBytes(suffixBytes.bytes, suffixBytes.offset, suffixBytes.length);
   }
 

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java Mon Dec 21 11:39:57 2015
@@ -103,4 +103,9 @@ public abstract class FilterCodec extend
   public CompoundFormat compoundFormat() {
     return delegate.compoundFormat();
   }
+
+  @Override
+  public DimensionalFormat dimensionalFormat() {
+    return delegate.dimensionalFormat();
+  }
 }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java Mon Dec 21 11:39:57 2015
@@ -304,7 +304,7 @@ public final class CompressingStoredFiel
   }
 
   /**
-   * Reads a long in a variable-length format.  Reads between one and
+   * Reads a long in a variable-length format.  Reads between one andCorePropLo
    * nine bytes. Small values typically take fewer bytes.
    */
   static long readTLong(DataInput in) throws IOException {
@@ -595,6 +595,9 @@ public final class CompressingStoredFiel
           readField(doc.in, visitor, fieldInfo, bits);
           break;
         case NO:
+          if (fieldIDX == doc.numStoredFields - 1) {// don't skipField on last field value; treat like STOP
+            return;
+          }
           skipField(doc.in, bits);
           break;
         case STOP:

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java Mon Dec 21 11:39:57 2015
@@ -152,7 +152,7 @@ public final class Lucene50FieldInfosFor
           lastAttributes = attributes;
           try {
             infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, 
-                                     indexOptions, docValuesType, dvGen, attributes);
+                                     indexOptions, docValuesType, dvGen, attributes, 0, 0);
             infos[i].checkConsistency();
           } catch (IllegalStateException e) {
             throw new CorruptIndexException("invalid fieldinfo for field: " + name + ", fieldNumber=" + fieldNumber, input, e);

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50StoredFieldsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50StoredFieldsFormat.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50StoredFieldsFormat.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50StoredFieldsFormat.java Mon Dec 21 11:39:57 2015
@@ -53,9 +53,9 @@ import org.apache.lucene.util.packed.Pac
  * These two options can be configured like this:
  * <pre class="prettyprint">
  *   // the default: for high performance
- *   indexWriterConfig.setCodec(new Lucene53Codec(Mode.BEST_SPEED));
+ *   indexWriterConfig.setCodec(new Lucene54Codec(Mode.BEST_SPEED));
  *   // instead for higher performance (but slower):
- *   // indexWriterConfig.setCodec(new Lucene53Codec(Mode.BEST_COMPRESSION));
+ *   // indexWriterConfig.setCodec(new Lucene54Codec(Mode.BEST_COMPRESSION));
  * </pre>
  * <p><b>File formats</b>
  * <p>Stored fields are represented by two files:

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene53/package-info.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene53/package-info.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene53/package-info.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/codecs/lucene53/package-info.java Mon Dec 21 11:39:57 2015
@@ -16,386 +16,8 @@
  */
 
 /**
- * Lucene 5.3 file format.
- * 
- * <h1>Apache Lucene - Index File Formats</h1>
- * <div>
- * <ul>
- * <li><a href="#Introduction">Introduction</a></li>
- * <li><a href="#Definitions">Definitions</a>
- *   <ul>
- *   <li><a href="#Inverted_Indexing">Inverted Indexing</a></li>
- *   <li><a href="#Types_of_Fields">Types of Fields</a></li>
- *   <li><a href="#Segments">Segments</a></li>
- *   <li><a href="#Document_Numbers">Document Numbers</a></li>
- *   </ul>
- * </li>
- * <li><a href="#Overview">Index Structure Overview</a></li>
- * <li><a href="#File_Naming">File Naming</a></li>
- * <li><a href="#file-names">Summary of File Extensions</a>
- *   <ul>
- *   <li><a href="#Lock_File">Lock File</a></li>
- *   <li><a href="#History">History</a></li>
- *   <li><a href="#Limitations">Limitations</a></li>
- *   </ul>
- * </li>
- * </ul>
- * </div>
- * <a name="Introduction"></a>
- * <h2>Introduction</h2>
- * <div>
- * <p>This document defines the index file formats used in this version of Lucene.
- * If you are using a different version of Lucene, please consult the copy of
- * <code>docs/</code> that was distributed with
- * the version you are using.</p>
- * <p>Apache Lucene is written in Java, but several efforts are underway to write
- * <a href="http://wiki.apache.org/lucene-java/LuceneImplementations">versions of
- * Lucene in other programming languages</a>. If these versions are to remain
- * compatible with Apache Lucene, then a language-independent definition of the
- * Lucene index format is required. This document thus attempts to provide a
- * complete and independent definition of the Apache Lucene file formats.</p>
- * <p>As Lucene evolves, this document should evolve. Versions of Lucene in
- * different programming languages should endeavor to agree on file formats, and
- * generate new versions of this document.</p>
- * </div>
- * <a name="Definitions"></a>
- * <h2>Definitions</h2>
- * <div>
- * <p>The fundamental concepts in Lucene are index, document, field and term.</p>
- * <p>An index contains a sequence of documents.</p>
- * <ul>
- * <li>A document is a sequence of fields.</li>
- * <li>A field is a named sequence of terms.</li>
- * <li>A term is a sequence of bytes.</li>
- * </ul>
- * <p>The same sequence of bytes in two different fields is considered a different 
- * term. Thus terms are represented as a pair: the string naming the field, and the
- * bytes within the field.</p>
- * <a name="Inverted_Indexing"></a>
- * <h3>Inverted Indexing</h3>
- * <p>The index stores statistics about terms in order to make term-based search
- * more efficient. Lucene's index falls into the family of indexes known as an
- * <i>inverted index.</i> This is because it can list, for a term, the documents
- * that contain it. This is the inverse of the natural relationship, in which
- * documents list terms.</p>
- * <a name="Types_of_Fields"></a>
- * <h3>Types of Fields</h3>
- * <p>In Lucene, fields may be <i>stored</i>, in which case their text is stored
- * in the index literally, in a non-inverted manner. Fields that are inverted are
- * called <i>indexed</i>. A field may be both stored and indexed.</p>
- * <p>The text of a field may be <i>tokenized</i> into terms to be indexed, or the
- * text of a field may be used literally as a term to be indexed. Most fields are
- * tokenized, but sometimes it is useful for certain identifier fields to be
- * indexed literally.</p>
- * <p>See the {@link org.apache.lucene.document.Field Field}
- * java docs for more information on Fields.</p>
- * <a name="Segments"></a>
- * <h3>Segments</h3>
- * <p>Lucene indexes may be composed of multiple sub-indexes, or <i>segments</i>.
- * Each segment is a fully independent index, which could be searched separately.
- * Indexes evolve by:</p>
- * <ol>
- * <li>Creating new segments for newly added documents.</li>
- * <li>Merging existing segments.</li>
- * </ol>
- * <p>Searches may involve multiple segments and/or multiple indexes, each index
- * potentially composed of a set of segments.</p>
- * <a name="Document_Numbers"></a>
- * <h3>Document Numbers</h3>
- * <p>Internally, Lucene refers to documents by an integer <i>document number</i>.
- * The first document added to an index is numbered zero, and each subsequent
- * document added gets a number one greater than the previous.</p>
- * <p>Note that a document's number may change, so caution should be taken when
- * storing these numbers outside of Lucene. In particular, numbers may change in
- * the following situations:</p>
- * <ul>
- * <li>
- * <p>The numbers stored in each segment are unique only within the segment, and
- * must be converted before they can be used in a larger context. The standard
- * technique is to allocate each segment a range of values, based on the range of
- * numbers used in that segment. To convert a document number from a segment to an
- * external value, the segment's <i>base</i> document number is added. To convert
- * an external value back to a segment-specific value, the segment is identified
- * by the range that the external value is in, and the segment's base value is
- * subtracted. For example two five document segments might be combined, so that
- * the first segment has a base value of zero, and the second of five. Document
- * three from the second segment would have an external value of eight.</p>
- * </li>
- * <li>
- * <p>When documents are deleted, gaps are created in the numbering. These are
- * eventually removed as the index evolves through merging. Deleted documents are
- * dropped when segments are merged. A freshly-merged segment thus has no gaps in
- * its numbering.</p>
- * </li>
- * </ul>
- * </div>
- * <a name="Overview"></a>
- * <h2>Index Structure Overview</h2>
- * <div>
- * <p>Each segment index maintains the following:</p>
- * <ul>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50SegmentInfoFormat Segment info}.
- *    This contains metadata about a segment, such as the number of documents,
- *    what files it uses, 
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50FieldInfosFormat Field names}. 
- *    This contains the set of field names used in the index.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat Stored Field values}. 
- * This contains, for each document, a list of attribute-value pairs, where the attributes 
- * are field names. These are used to store auxiliary information about the document, such as 
- * its title, url, or an identifier to access a database. The set of stored fields are what is 
- * returned for each hit when searching. This is keyed by document number.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Term dictionary}. 
- * A dictionary containing all of the terms used in all of the
- * indexed fields of all of the documents. The dictionary also contains the number
- * of documents which contain the term, and pointers to the term's frequency and
- * proximity data.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Term Frequency data}. 
- * For each term in the dictionary, the numbers of all the
- * documents that contain that term, and the frequency of the term in that
- * document, unless frequencies are omitted (IndexOptions.DOCS_ONLY)
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Term Proximity data}. 
- * For each term in the dictionary, the positions that the
- * term occurs in each document. Note that this will not exist if all fields in
- * all documents omit position data.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene53.Lucene53NormsFormat Normalization factors}. 
- * For each field in each document, a value is stored
- * that is multiplied into the score for hits on that field.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat Term Vectors}. 
- * For each field in each document, the term vector (sometimes
- * called document vector) may be stored. A term vector consists of term text and
- * term frequency. To add Term Vectors to your index see the 
- * {@link org.apache.lucene.document.Field Field} constructors
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50DocValuesFormat Per-document values}. 
- * Like stored values, these are also keyed by document
- * number, but are generally intended to be loaded into main memory for fast
- * access. Whereas stored values are generally intended for summary results from
- * searches, per-document values are useful for things like scoring factors.
- * </li>
- * <li>
- * {@link org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat Live documents}. 
- * An optional file indicating which documents are live.
- * </li>
- * </ul>
- * <p>Details on each of these are provided in their linked pages.</p>
- * </div>
- * <a name="File_Naming"></a>
- * <h2>File Naming</h2>
- * <div>
- * <p>All files belonging to a segment have the same name with varying extensions.
- * The extensions correspond to the different file formats described below. When
- * using the Compound File format (default in 1.4 and greater) these files (except
- * for the Segment info file, the Lock file, and Deleted documents file) are collapsed 
- * into a single .cfs file (see below for details)</p>
- * <p>Typically, all segments in an index are stored in a single directory,
- * although this is not required.</p>
- * <p>As of version 2.1 (lock-less commits), file names are never re-used.
- * That is, when any file is saved
- * to the Directory it is given a never before used filename. This is achieved
- * using a simple generations approach. For example, the first segments file is
- * segments_1, then segments_2, etc. The generation is a sequential long integer
- * represented in alpha-numeric (base 36) form.</p>
- * </div>
- * <a name="file-names"></a>
- * <h2>Summary of File Extensions</h2>
- * <div>
- * <p>The following table summarizes the names and extensions of the files in
- * Lucene:</p>
- * <table cellspacing="1" cellpadding="4" summary="lucene filenames by extension">
- * <tr>
- * <th>Name</th>
- * <th>Extension</th>
- * <th>Brief Description</th>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.index.SegmentInfos Segments File}</td>
- * <td>segments_N</td>
- * <td>Stores information about a commit point</td>
- * </tr>
- * <tr>
- * <td><a href="#Lock_File">Lock File</a></td>
- * <td>write.lock</td>
- * <td>The Write lock prevents multiple IndexWriters from writing to the same
- * file.</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50SegmentInfoFormat Segment Info}</td>
- * <td>.si</td>
- * <td>Stores metadata about a segment</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat Compound File}</td>
- * <td>.cfs, .cfe</td>
- * <td>An optional "virtual" file consisting of all the other index files for
- * systems that frequently run out of file handles.</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50FieldInfosFormat Fields}</td>
- * <td>.fnm</td>
- * <td>Stores information about the fields</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat Field Index}</td>
- * <td>.fdx</td>
- * <td>Contains pointers to field data</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat Field Data}</td>
- * <td>.fdt</td>
- * <td>The stored fields for documents</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Term Dictionary}</td>
- * <td>.tim</td>
- * <td>The term dictionary, stores term info</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Term Index}</td>
- * <td>.tip</td>
- * <td>The index into the Term Dictionary</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Frequencies}</td>
- * <td>.doc</td>
- * <td>Contains the list of docs which contain each term along with frequency</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Positions}</td>
- * <td>.pos</td>
- * <td>Stores position information about where a term occurs in the index</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat Payloads}</td>
- * <td>.pay</td>
- * <td>Stores additional per-position metadata information such as character offsets and user payloads</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene53.Lucene53NormsFormat Norms}</td>
- * <td>.nvd, .nvm</td>
- * <td>Encodes length and boost factors for docs and fields</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50DocValuesFormat Per-Document Values}</td>
- * <td>.dvd, .dvm</td>
- * <td>Encodes additional scoring factors or other per-document information.</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat Term Vector Index}</td>
- * <td>.tvx</td>
- * <td>Stores offset into the document data file</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat Term Vector Documents}</td>
- * <td>.tvd</td>
- * <td>Contains information about each document that has term vectors</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat Term Vector Fields}</td>
- * <td>.tvf</td>
- * <td>The field level info about term vectors</td>
- * </tr>
- * <tr>
- * <td>{@link org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat Live Documents}</td>
- * <td>.liv</td>
- * <td>Info about what files are live</td>
- * </tr>
- * </table>
- * </div>
- * <a name="Lock_File"></a>
- * <h2>Lock File</h2>
- * The write lock, which is stored in the index directory by default, is named
- * "write.lock". If the lock directory is different from the index directory then
- * the write lock will be named "XXXX-write.lock" where XXXX is a unique prefix
- * derived from the full path to the index directory. When this file is present, a
- * writer is currently modifying the index (adding or removing documents). This
- * lock file ensures that only one writer is modifying the index at a time.
- * <a name="History"></a>
- * <h2>History</h2>
- * <p>Compatibility notes are provided in this document, describing how file
- * formats have changed from prior versions:</p>
- * <ul>
- * <li>In version 2.1, the file format was changed to allow lock-less commits (ie,
- * no more commit lock). The change is fully backwards compatible: you can open a
- * pre-2.1 index for searching or adding/deleting of docs. When the new segments
- * file is saved (committed), it will be written in the new file format (meaning
- * no specific "upgrade" process is needed). But note that once a commit has
- * occurred, pre-2.1 Lucene will not be able to read the index.</li>
- * <li>In version 2.3, the file format was changed to allow segments to share a
- * single set of doc store (vectors &amp; stored fields) files. This allows for
- * faster indexing in certain cases. The change is fully backwards compatible (in
- * the same way as the lock-less commits change in 2.1).</li>
- * <li>In version 2.4, Strings are now written as true UTF-8 byte sequence, not
- * Java's modified UTF-8. See <a href="http://issues.apache.org/jira/browse/LUCENE-510">
- * LUCENE-510</a> for details.</li>
- * <li>In version 2.9, an optional opaque Map&lt;String,String&gt; CommitUserData
- * may be passed to IndexWriter's commit methods (and later retrieved), which is
- * recorded in the segments_N file. See <a href="http://issues.apache.org/jira/browse/LUCENE-1382">
- * LUCENE-1382</a> for details. Also,
- * diagnostics were added to each segment written recording details about why it
- * was written (due to flush, merge; which OS/JRE was used; etc.). See issue
- * <a href="http://issues.apache.org/jira/browse/LUCENE-1654">LUCENE-1654</a> for details.</li>
- * <li>In version 3.0, compressed fields are no longer written to the index (they
- * can still be read, but on merge the new segment will write them, uncompressed).
- * See issue <a href="http://issues.apache.org/jira/browse/LUCENE-1960">LUCENE-1960</a> 
- * for details.</li>
- * <li>In version 3.1, segments records the code version that created them. See
- * <a href="http://issues.apache.org/jira/browse/LUCENE-2720">LUCENE-2720</a> for details. 
- * Additionally segments track explicitly whether or not they have term vectors. 
- * See <a href="http://issues.apache.org/jira/browse/LUCENE-2811">LUCENE-2811</a> 
- * for details.</li>
- * <li>In version 3.2, numeric fields are written as natively to stored fields
- * file, previously they were stored in text format only.</li>
- * <li>In version 3.4, fields can omit position data while still indexing term
- * frequencies.</li>
- * <li>In version 4.0, the format of the inverted index became extensible via
- * the {@link org.apache.lucene.codecs.Codec Codec} api. Fast per-document storage
- * ({@code DocValues}) was introduced. Normalization factors need no longer be a 
- * single byte, they can be any {@link org.apache.lucene.index.NumericDocValues NumericDocValues}. 
- * Terms need not be unicode strings, they can be any byte sequence. Term offsets 
- * can optionally be indexed into the postings lists. Payloads can be stored in the 
- * term vectors.</li>
- * <li>In version 4.1, the format of the postings list changed to use either
- * of FOR compression or variable-byte encoding, depending upon the frequency
- * of the term. Terms appearing only once were changed to inline directly into
- * the term dictionary. Stored fields are compressed by default. </li>
- * <li>In version 4.2, term vectors are compressed by default. DocValues has 
- * a new multi-valued type (SortedSet), that can be used for faceting/grouping/joining
- * on multi-valued fields.</li>
- * <li>In version 4.5, DocValues were extended to explicitly represent missing values.</li>
- * <li>In version 4.6, FieldInfos were extended to support per-field DocValues generation, to 
- * allow updating NumericDocValues fields.</li>
- * <li>In version 4.8, checksum footers were added to the end of each index file 
- * for improved data integrity. Specifically, the last 8 bytes of every index file
- * contain the zlib-crc32 checksum of the file.</li>
- * <li>In version 4.9, DocValues has a new multi-valued numeric type (SortedNumeric)
- * that is suitable for faceting/sorting/analytics.
- * </li>
- * </ul>
- * <a name="Limitations"></a>
- * <h2>Limitations</h2>
- * <div>
- * <p>Lucene uses a Java <code>int</code> to refer to
- * document numbers, and the index file format uses an <code>Int32</code>
- * on-disk to store document numbers. This is a limitation
- * of both the index file format and the current implementation. Eventually these
- * should be replaced with either <code>UInt64</code> values, or
- * better yet, {@link org.apache.lucene.store.DataOutput#writeVInt VInt} values which have no limit.</p>
- * </div>
+ * Components from the Lucene 5.3 index format
+ * See {@link org.apache.lucene.codecs.lucene54} for an overview
+ * of the index format.
  */
 package org.apache.lucene.codecs.lucene53;

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/DateTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/DateTools.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/DateTools.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/DateTools.java Mon Dec 21 11:39:57 2015
@@ -17,11 +17,6 @@ package org.apache.lucene.document;
  * limitations under the License.
  */
 
-import org.apache.lucene.search.NumericRangeQuery; // for javadocs
-import org.apache.lucene.search.PrefixQuery;
-import org.apache.lucene.search.TermRangeQuery;
-import org.apache.lucene.util.NumericUtils;        // for javadocs
-
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -29,6 +24,10 @@ import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
 
+import org.apache.lucene.search.DimensionalRangeQuery;
+import org.apache.lucene.search.PrefixQuery;
+import org.apache.lucene.search.TermRangeQuery;
+
 /**
  * Provides support for converting dates to strings and vice-versa.
  * The strings are structured so that lexicographic sorting orders 
@@ -40,13 +39,12 @@ import java.util.TimeZone;
  * {@link TermRangeQuery} and {@link PrefixQuery} will require more memory and become slower.
  * 
  * <P>
- * Another approach is {@link NumericUtils}, which provides
- * a sortable binary representation (prefix encoded) of numeric values, which
- * date/time are.
+ * Another approach is {@link DimensionalLongField}, which indexes the
+ * values in sorted order.
  * For indexing a {@link Date} or {@link Calendar}, just get the unix timestamp as
  * <code>long</code> using {@link Date#getTime} or {@link Calendar#getTimeInMillis} and
- * index this as a numeric value with {@link LongField}
- * and use {@link NumericRangeQuery} to query it.
+ * index this as a numeric value with {@link DimensionalLongField}
+ * and use {@link DimensionalRangeQuery} to query it.
  */
 public class DateTools {
   

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Document.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Document.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Document.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Document.java Mon Dec 21 11:39:57 2015
@@ -229,8 +229,8 @@ public final class Document implements I
    * Returns an array of values of the field specified as the method parameter.
    * This method returns an empty array when there are no
    * matching fields.  It never returns null.
-   * For {@link IntField}, {@link LongField}, {@link
-   * FloatField} and {@link DoubleField} it returns the string value of the number. If you want
+   * For {@link LegacyIntField}, {@link LegacyLongField}, {@link
+   * LegacyFloatField} and {@link LegacyDoubleField} it returns the string value of the number. If you want
    * the actual numeric field instances back, use {@link #getFields}.
    * @param name the name of the field
    * @return a <code>String[]</code> of field values
@@ -256,8 +256,8 @@ public final class Document implements I
    * this document, or null.  If multiple fields exist with this name, this
    * method returns the first value added. If only binary fields with this name
    * exist, returns null.
-   * For {@link IntField}, {@link LongField}, {@link
-   * FloatField} and {@link DoubleField} it returns the string value of the number. If you want
+   * For {@link LegacyIntField}, {@link LegacyLongField}, {@link
+   * LegacyFloatField} and {@link LegacyDoubleField} it returns the string value of the number. If you want
    * the actual numeric field instance back, use {@link #getField}.
    */
   public final String get(String name) {
@@ -312,7 +312,7 @@ public final class Document implements I
     return new FilterIterator<StorableField, Field>(fields.iterator()) {
       @Override
       protected boolean predicateFunction(Field field) {
-        return field.type.stored() || field.type.docValuesType() != DocValuesType.NONE;
+        return field.type.stored() || field.type.docValuesType() != DocValuesType.NONE || field.type.dimensionCount() != 0;
       }
     };
   }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Field.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/java/org/apache/lucene/document/Field.java Mon Dec 21 11:39:57 2015
@@ -21,12 +21,11 @@ import java.io.IOException;
 import java.io.Reader;
 
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.NumericTokenStream;
+import org.apache.lucene.analysis.LegacyNumericTokenStream;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.BytesTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-import org.apache.lucene.document.FieldType.NumericType;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.IndexableFieldType;
@@ -36,8 +35,8 @@ import org.apache.lucene.util.BytesRef;
 /**
  * Expert: directly create a field for a document.  Most
  * users should use one of the sugar subclasses: {@link
- * IntField}, {@link LongField}, {@link FloatField}, {@link
- * DoubleField}, {@link BinaryDocValuesField}, {@link
+ * LegacyIntField}, {@link LegacyLongField}, {@link LegacyFloatField}, {@link
+ * LegacyDoubleField}, {@link BinaryDocValuesField}, {@link
  * NumericDocValuesField}, {@link SortedDocValuesField}, {@link
  * StringField}, {@link TextField}, {@link StoredField}.
  *
@@ -504,14 +503,14 @@ public class Field implements IndexableF
       return null;
     }
 
-    final NumericType numericType = fieldType().numericType();
+    final FieldType.LegacyNumericType numericType = fieldType().numericType();
     if (numericType != null) {
-      if (!(reuse instanceof NumericTokenStream && ((NumericTokenStream)reuse).getPrecisionStep() == type.numericPrecisionStep())) {
+      if (!(reuse instanceof LegacyNumericTokenStream && ((LegacyNumericTokenStream)reuse).getPrecisionStep() == type.numericPrecisionStep())) {
         // lazy init the TokenStream as it is heavy to instantiate
         // (attributes,...) if not needed (stored field loading)
-        reuse = new NumericTokenStream(type.numericPrecisionStep());
+        reuse = new LegacyNumericTokenStream(type.numericPrecisionStep());
       }
-      final NumericTokenStream nts = (NumericTokenStream) reuse;
+      final LegacyNumericTokenStream nts = (LegacyNumericTokenStream) reuse;
       // initialize value in TokenStream
       final Number val = (Number) fieldsData;
       switch (numericType) {