You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/10/25 15:10:51 UTC

svn commit: r1402140 [7/17] - in /lucene/dev/branches/LUCENE-2878: ./ dev-tools/ dev-tools/eclipse/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/classification/ dev-tools/maven/ dev-tools/maven/lucene/classifica...

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java Thu Oct 25 13:10:25 2012
@@ -159,7 +159,7 @@ public abstract class FieldValueHitQueue
    *          priority first); cannot be <code>null</code> or empty
    * @param size
    *          The number of hits to retain. Must be greater than zero.
-   * @throws IOException
+   * @throws IOException if there is a low-level IO error
    */
   public static <T extends FieldValueHitQueue.Entry> FieldValueHitQueue<T> create(SortField[] fields, int size) throws IOException {
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java Thu Oct 25 13:10:25 2012
@@ -96,7 +96,7 @@ public class FuzzyTermsEnum extends Term
    * @param minSimilarity Minimum required similarity for terms from the reader. Pass an integer value
    *        representing edit distance. Passing a fraction is deprecated.
    * @param prefixLength Length of required common prefix. Default value is 0.
-   * @throws IOException
+   * @throws IOException if there is a low-level IO error
    */
   public FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, 
       final float minSimilarity, final int prefixLength, boolean transpositions) throws IOException {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java Thu Oct 25 13:10:25 2012
@@ -221,7 +221,8 @@ public class IndexSearcher {
    * this method can be used for efficient 'deep-paging' across potentially
    * large result sets.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs searchAfter(ScoreDoc after, Query query, int n) throws IOException {
     return search(createNormalizedWeight(query), after, n);
@@ -235,7 +236,8 @@ public class IndexSearcher {
    * this method can be used for efficient 'deep-paging' across potentially
    * large result sets.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n) throws IOException {
     return search(createNormalizedWeight(wrapFilter(query, filter)), after, n);
@@ -244,7 +246,8 @@ public class IndexSearcher {
   /** Finds the top <code>n</code>
    * hits for <code>query</code>.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs search(Query query, int n)
     throws IOException {
@@ -255,7 +258,8 @@ public class IndexSearcher {
   /** Finds the top <code>n</code>
    * hits for <code>query</code>, applying <code>filter</code> if non-null.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs search(Query query, Filter filter, int n)
     throws IOException {
@@ -270,7 +274,8 @@ public class IndexSearcher {
    * @param query to match documents
    * @param filter if non-null, used to permit documents to be collected.
    * @param results to receive hits
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public void search(Query query, Filter filter, Collector results)
     throws IOException {
@@ -278,11 +283,12 @@ public class IndexSearcher {
   }
 
   /** Lower-level search API.
-  *
-  * <p>{@link Collector#collect(int)} is called for every matching document.
-  *
-  * @throws BooleanQuery.TooManyClauses
-  */
+   *
+   * <p>{@link Collector#collect(int)} is called for every matching document.
+   *
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
+   */
   public void search(Query query, Collector results)
     throws IOException {
     search(leafContexts, createNormalizedWeight(query), results);
@@ -297,7 +303,8 @@ public class IndexSearcher {
    * {@link IndexSearcher#search(Query,Filter,int,Sort,boolean,boolean)} to
    * control scoring.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopFieldDocs search(Query query, Filter filter, int n,
                              Sort sort) throws IOException {
@@ -315,7 +322,8 @@ public class IndexSearcher {
    * <code>true</code> then the maximum score over all
    * collected hits will be computed.
    * 
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopFieldDocs search(Query query, Filter filter, int n,
                              Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException {
@@ -330,7 +338,8 @@ public class IndexSearcher {
    * this method can be used for efficient 'deep-paging' across potentially
    * large result sets.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n, Sort sort) throws IOException {
     if (after != null && !(after instanceof FieldDoc)) {
@@ -347,7 +356,7 @@ public class IndexSearcher {
    * @param n Return only the top n results
    * @param sort The {@link org.apache.lucene.search.Sort} object
    * @return The top docs, sorted according to the supplied {@link org.apache.lucene.search.Sort} instance
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public TopFieldDocs search(Query query, int n,
                              Sort sort) throws IOException {
@@ -362,7 +371,8 @@ public class IndexSearcher {
    * this method can be used for efficient 'deep-paging' across potentially
    * large result sets.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs searchAfter(ScoreDoc after, Query query, int n, Sort sort) throws IOException {
     if (after != null && !(after instanceof FieldDoc)) {
@@ -386,7 +396,8 @@ public class IndexSearcher {
    * <code>true</code> then the maximum score over all
    * collected hits will be computed.
    *
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n, Sort sort,
                              boolean doDocScores, boolean doMaxScore) throws IOException {
@@ -404,7 +415,8 @@ public class IndexSearcher {
    *
    * <p>Applications should usually call {@link IndexSearcher#search(Query,int)} or
    * {@link IndexSearcher#search(Query,Filter,int)} instead.
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   protected TopDocs search(Weight weight, ScoreDoc after, int nDocs) throws IOException {
     if (executor == null) {
@@ -441,7 +453,8 @@ public class IndexSearcher {
    *
    * <p>Applications should usually call {@link IndexSearcher#search(Query,int)} or
    * {@link IndexSearcher#search(Query,Filter,int)} instead.
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   protected TopDocs search(List<AtomicReaderContext> leaves, Weight weight, ScoreDoc after, int nDocs) throws IOException {
     // single thread
@@ -464,7 +477,8 @@ public class IndexSearcher {
    * <p>Applications should usually call {@link
    * IndexSearcher#search(Query,Filter,int,Sort)} instead.
    * 
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   protected TopFieldDocs search(Weight weight,
                                 final int nDocs, Sort sort,
@@ -560,7 +574,8 @@ public class IndexSearcher {
    *          to match documents
    * @param collector
    *          to receive hits
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   protected void search(List<AtomicReaderContext> leaves, Weight weight, Collector collector)
       throws IOException {
@@ -578,7 +593,8 @@ public class IndexSearcher {
   }
 
   /** Expert: called to re-write queries into primitive queries.
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   public Query rewrite(Query original) throws IOException {
     Query query = original;
@@ -610,7 +626,8 @@ public class IndexSearcher {
    * Computing an explanation is as expensive as executing the query over the
    * entire index.
    * <p>Applications should call {@link IndexSearcher#explain(Query, int)}.
-   * @throws BooleanQuery.TooManyClauses
+   * @throws BooleanQuery.TooManyClauses If a query would exceed 
+   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
    */
   protected Explanation explain(Weight weight, int doc) throws IOException {
     int n = ReaderUtil.subIndex(doc, leafContexts);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java Thu Oct 25 13:10:25 2012
@@ -76,8 +76,6 @@ public class MultiPhraseQuery extends Qu
    * Allows to specify the relative position of terms within the phrase.
    * 
    * @see PhraseQuery#add(Term, int)
-   * @param terms
-   * @param position
    */
   public void add(Term[] terms, int position) {
     if (termArrays.size() == 0)

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/NGramPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/NGramPhraseQuery.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/NGramPhraseQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/NGramPhraseQuery.java Thu Oct 25 13:10:25 2012
@@ -35,7 +35,7 @@ public class NGramPhraseQuery extends Ph
   
   /**
    * Constructor that takes gram size.
-   * @param n
+   * @param n n-gram size
    */
   public NGramPhraseQuery(int n){
     super();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java Thu Oct 25 13:10:25 2012
@@ -79,8 +79,6 @@ public class PhraseQuery extends Query {
    * This allows e.g. phrases with more than one term at the same position
    * or phrases with gaps (e.g. in connection with stopwords).
    * 
-   * @param term
-   * @param position
    */
   public void add(Term term, int position) {
     if (terms.size() == 0) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherLifetimeManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherLifetimeManager.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherLifetimeManager.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherLifetimeManager.java Thu Oct 25 13:10:25 2012
@@ -289,7 +289,7 @@ public class SearcherLifetimeManager imp
    *  should still call {@link #release} after they are
    *  done.
    *
-   *  <p><b>NOTE: you must ensure no other threads are
+   *  <p><b>NOTE</b>: you must ensure no other threads are
    *  calling {@link #record} while you call close();
    *  otherwise it's possible not all searcher references
    *  will be freed. */

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherManager.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherManager.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/SearcherManager.java Thu Oct 25 13:10:25 2012
@@ -79,7 +79,7 @@ public final class SearcherManager exten
    *          don't require the searcher to be warmed before going live or other
    *          custom behavior.
    * 
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public SearcherManager(IndexWriter writer, boolean applyAllDeletes, SearcherFactory searcherFactory) throws IOException {
     if (searcherFactory == null) {
@@ -96,7 +96,7 @@ public final class SearcherManager exten
    *        <code>null</code> if you don't require the searcher to be warmed
    *        before going live or other custom behavior.
    *        
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public SearcherManager(Directory dir, SearcherFactory searcherFactory) throws IOException {
     if (searcherFactory == null) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java Thu Oct 25 13:10:25 2012
@@ -96,7 +96,6 @@ public class TimeLimitingCollector exten
    * </pre>
    * </p>
    * @see #setBaseline() 
-   * @param clockTime
    */
   public void setBaseline(long clockTime) {
     t0 = clockTime;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java Thu Oct 25 13:10:25 2012
@@ -1060,7 +1060,7 @@ public abstract class TopFieldCollector 
    *          the given {@link Scorer} in {@link #setScorer(Scorer)}.
    * @return a {@link TopFieldCollector} instance which will sort the results by
    *         the sort criteria.
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public static TopFieldCollector create(Sort sort, int numHits,
       boolean fillFields, boolean trackDocScores, boolean trackMaxScore,
@@ -1105,7 +1105,7 @@ public abstract class TopFieldCollector 
    *          the given {@link Scorer} in {@link #setScorer(Scorer)}.
    * @return a {@link TopFieldCollector} instance which will sort the results by
    *         the sort criteria.
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public static TopFieldCollector create(Sort sort, int numHits, FieldDoc after,
       boolean fillFields, boolean trackDocScores, boolean trackMaxScore,

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Weight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Weight.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Weight.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Weight.java Thu Oct 25 13:10:25 2012
@@ -110,7 +110,7 @@ public abstract class Weight {
    *          Bits that represent the allowable docs to match (typically deleted docs
    *          but possibly filtering other documents)
    * @return a {@link Scorer} which scores documents in/out-of order.
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public abstract Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder,
       boolean topScorer, PostingFeatures flags, Bits acceptDocs) throws IOException;
@@ -144,7 +144,7 @@ public abstract class Weight {
     
     private PostingFeatures(int docFlags, int docsAndPositionsFlags, boolean isProximityFeature) {
       this.docsAndPositionsFlags = docsAndPositionsFlags;
-      this.docFlags = docsAndPositionsFlags;
+      this.docFlags = docFlags;
       this.isProximityFeature = isProximityFeature;
     }
     

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Thu Oct 25 13:10:25 2012
@@ -69,9 +69,9 @@ public class PayloadSpanUtil {
   /**
    * Query should be rewritten for wild/fuzzy support.
    * 
-   * @param query
+   * @param query rewritten query
    * @return payloads Collection
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public Collection<byte[]> getPayloadsForQuery(Query query) throws IOException {
     Collection<byte[]> payloads = new ArrayList<byte[]>();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java Thu Oct 25 13:10:25 2012
@@ -139,7 +139,7 @@ public class PayloadTermQuery extends Sp
       /**
        * 
        * @return {@link #getSpanScore()} * {@link #getPayloadScore()}
-       * @throws IOException
+       * @throws IOException if there is a low-level I/O error
        */
       @Override
       public float score() throws IOException {
@@ -154,7 +154,7 @@ public class PayloadTermQuery extends Sp
        * Should not be overridden without good cause!
        * 
        * @return the score for just the Span part w/o the payload
-       * @throws IOException
+       * @throws IOException if there is a low-level I/O error
        * 
        * @see #score()
        */

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalIterator.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalIterator.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalIterator.java Thu Oct 25 13:10:25 2012
@@ -79,7 +79,6 @@ public abstract class IntervalIterator {
   /**
    * Get any subiterators
    * @param inOrder true if the subiterators should be returned in order
-   * @return
    */
   public abstract IntervalIterator[] subs(boolean inOrder);
 
@@ -97,7 +96,6 @@ public abstract class IntervalIterator {
 
   /**
    * Get this iterator's {@link Scorer}
-   * @return
    */
   public Scorer getScorer() {
     return scorer;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java Thu Oct 25 13:10:25 2012
@@ -179,7 +179,7 @@ public abstract class Similarity {
    * @param weight collection information from {@link #computeWeight(float, CollectionStatistics, TermStatistics...)}
    * @param context segment of the inverted index to be scored.
    * @return ExactSimScorer for scoring documents across <code>context</code>
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public abstract ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException;
   
@@ -188,7 +188,7 @@ public abstract class Similarity {
    * @param weight collection information from {@link #computeWeight(float, CollectionStatistics, TermStatistics...)}
    * @param context segment of the inverted index to be scored.
    * @return SloppySimScorer for scoring documents across <code>context</code>
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public abstract SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException;
   

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java Thu Oct 25 13:10:25 2012
@@ -219,8 +219,6 @@ public class NearSpansOrdered extends Sp
   }
   
   /** Check whether two Spans in the same document are ordered.
-   * @param spans1 
-   * @param spans2 
    * @return true iff spans1 starts before spans2
    *              or the spans start at the same position,
    *              and spans1 ends before spans2.

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java Thu Oct 25 13:10:25 2012
@@ -241,7 +241,7 @@ public class NearSpansUnordered extends 
   /**
    * WARNING: The List is not necessarily in order of the the positions
    * @return Collection of <code>byte[]</code> payloads
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   @Override
   public Collection<byte[]> getPayload() throws IOException {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/Spans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/Spans.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/Spans.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/spans/Spans.java Thu Oct 25 13:10:25 2012
@@ -69,7 +69,7 @@ public abstract class Spans {
    * @lucene.experimental
    *
    * @return a List of byte arrays containing the data of this payload, otherwise null if isPayloadAvailable is false
-   * @throws java.io.IOException
+   * @throws IOException if there is a low-level I/O error
     */
   // TODO: Remove warning after API has been finalized
   public abstract Collection<byte[]> getPayload() throws IOException;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/BufferedIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/BufferedIndexOutput.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/BufferedIndexOutput.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/BufferedIndexOutput.java Thu Oct 25 13:10:25 2012
@@ -27,9 +27,6 @@ public abstract class BufferedIndexOutpu
   private long bufferStart = 0;           // position in file of buffer
   private int bufferPosition = 0;         // position in buffer
 
-  /** Writes a single byte.
-   * @see IndexInput#readByte()
-   */
   @Override
   public void writeByte(byte b) throws IOException {
     if (bufferPosition >= BUFFER_SIZE)
@@ -37,11 +34,6 @@ public abstract class BufferedIndexOutpu
     buffer[bufferPosition++] = b;
   }
 
-  /** Writes an array of bytes.
-   * @param b the bytes to write
-   * @param length the number of bytes to write
-   * @see IndexInput#readBytes(byte[],int,int)
-   */
   @Override
   public void writeBytes(byte[] b, int offset, int length) throws IOException {
     int bytesLeft = BUFFER_SIZE - bufferPosition;
@@ -82,7 +74,6 @@ public abstract class BufferedIndexOutpu
     }
   }
 
-  /** Forces any buffered output to be written. */
   @Override
   public void flush() throws IOException {
     flushBuffer(buffer, bufferPosition);
@@ -107,31 +98,16 @@ public abstract class BufferedIndexOutpu
    */
   protected abstract void flushBuffer(byte[] b, int offset, int len) throws IOException;
   
-  /** Closes this stream to further operations. */
   @Override
   public void close() throws IOException {
     flush();
   }
 
-  /** Returns the current position in this file, where the next write will
-   * occur.
-   * @see #seek(long)
-   */
   @Override
   public long getFilePointer() {
     return bufferStart + bufferPosition;
   }
 
-  /** Sets current position in this file, where the next write will occur.
-   * @see #getFilePointer()
-   */
-  @Override
-  public void seek(long pos) throws IOException {
-    flush();
-    bufferStart = pos;
-  }
-
-  /** The number of bytes in the file. */
   @Override
   public abstract long length() throws IOException;
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java Thu Oct 25 13:10:25 2012
@@ -22,7 +22,7 @@ import java.util.zip.CRC32;
 import java.util.zip.Checksum;
 
 /** Writes bytes through to a primary IndexOutput, computing
- *  checksum.  Note that you cannot use seek().
+ *  checksum.
  *
  * @lucene.internal
  */
@@ -66,11 +66,6 @@ public class ChecksumIndexOutput extends
     return main.getFilePointer();
   }
 
-  @Override
-  public void seek(long pos) {
-    throw new UnsupportedOperationException();    
-  }
-
   /** writes the checksum */
   public void finishCommit() throws IOException {
     main.writeLong(getChecksum());

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java Thu Oct 25 13:10:25 2012
@@ -215,14 +215,14 @@ public final class CompoundFileDirectory
   }
   
   /** Not implemented
-   * @throws UnsupportedOperationException */
+   * @throws UnsupportedOperationException always: not supported by CFS */
   @Override
   public void deleteFile(String name) {
     throw new UnsupportedOperationException();
   }
   
   /** Not implemented
-   * @throws UnsupportedOperationException */
+   * @throws UnsupportedOperationException always: not supported by CFS */
   public void renameFile(String from, String to) {
     throw new UnsupportedOperationException();
   }
@@ -253,7 +253,7 @@ public final class CompoundFileDirectory
   }
   
   /** Not implemented
-   * @throws UnsupportedOperationException */
+   * @throws UnsupportedOperationException always: not supported by CFS */
   @Override
   public Lock makeLock(String name) {
     throw new UnsupportedOperationException();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java Thu Oct 25 13:10:25 2012
@@ -129,6 +129,8 @@ final class CompoundFileWriter implement
     }
     IOException priorException = null;
     IndexOutput entryTableOut = null;
+    // TODO this code should clean up after itself
+    // (remove partial .cfs/.cfe)
     try {
       if (!pendingEntries.isEmpty() || outputTaken.get()) {
         throw new IllegalStateException("CFS has pending open files");
@@ -137,8 +139,6 @@ final class CompoundFileWriter implement
       // open the compound stream
       getOutput();
       assert dataOut != null;
-      long finalLength = dataOut.getFilePointer();
-      assert assertFileLength(finalLength, dataOut);
     } catch (IOException e) {
       priorException = e;
     } finally {
@@ -154,14 +154,6 @@ final class CompoundFileWriter implement
     }
   }
 
-  private static boolean assertFileLength(long expected, IndexOutput out)
-      throws IOException {
-    out.flush();
-    assert expected == out.length() : "expected: " + expected + " was "
-        + out.length();
-    return true;
-  }
-
   private final void ensureOpen() {
     if (closed) {
       throw new AlreadyClosedException("CFS Directory is already closed");
@@ -333,12 +325,6 @@ final class CompoundFileWriter implement
     }
 
     @Override
-    public void seek(long pos) throws IOException {
-      assert !closed;
-      delegate.seek(offset + pos);
-    }
-
-    @Override
     public long length() throws IOException {
       assert !closed;
       return delegate.length() - offset;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/Directory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/Directory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/Directory.java Thu Oct 25 13:10:25 2012
@@ -201,7 +201,18 @@ public abstract class Directory implemen
     } catch (IOException ioe) {
       priorException = ioe;
     } finally {
-      IOUtils.closeWhileHandlingException(priorException, os, is);
+      boolean success = false;
+      try {
+        IOUtils.closeWhileHandlingException(priorException, os, is);
+        success = true;
+      } finally {
+        if (!success) {
+          try {
+            to.deleteFile(dest);
+          } catch (Throwable t) {
+          }
+        }
+      }
     }
   }
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java Thu Oct 25 13:10:25 2012
@@ -135,7 +135,7 @@ public abstract class FSDirectory extend
    * @param path the path of the directory
    * @param lockFactory the lock factory to use, or null for the default
    * ({@link NativeFSLockFactory});
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   protected FSDirectory(File path, LockFactory lockFactory) throws IOException {
     // new ctors use always NativeFSLockFactory as default:
@@ -548,13 +548,6 @@ public abstract class FSDirectory extend
       }
     }
 
-    /** Random-access methods */
-    @Override
-    public void seek(long pos) throws IOException {
-      super.seek(pos);
-      file.seek(pos);
-    }
-
     @Override
     public long length() throws IOException {
       return file.length();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/IndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/IndexOutput.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/IndexOutput.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/IndexOutput.java Thu Oct 25 13:10:25 2012
@@ -39,14 +39,9 @@ public abstract class IndexOutput extend
 
   /** Returns the current position in this file, where the next write will
    * occur.
-   * @see #seek(long)
    */
   public abstract long getFilePointer();
 
-  /** Sets current position in this file, where the next write will occur.
-   * @see #getFilePointer()
-   */
-  public abstract void seek(long pos) throws IOException;
 
   /** The number of bytes in the file. */
   public abstract long length() throws IOException;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java Thu Oct 25 13:10:25 2012
@@ -90,7 +90,7 @@ public class MMapDirectory extends FSDir
    * @param path the path of the directory
    * @param lockFactory the lock factory to use, or null for the default
    * ({@link NativeFSLockFactory});
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public MMapDirectory(File path, LockFactory lockFactory) throws IOException {
     this(path, lockFactory, DEFAULT_MAX_BUFF);
@@ -99,7 +99,7 @@ public class MMapDirectory extends FSDir
   /** Create a new MMapDirectory for the named location and {@link NativeFSLockFactory}.
    *
    * @param path the path of the directory
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public MMapDirectory(File path) throws IOException {
     this(path, null);
@@ -123,7 +123,7 @@ public class MMapDirectory extends FSDir
    * be {@code 1 << 30}, as the address space is big enough.
    * <p>
    * <b>Please note:</b> The chunk size is always rounded down to a power of 2.
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public MMapDirectory(File path, LockFactory lockFactory, int maxChunkSize) throws IOException {
     super(path, lockFactory);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java Thu Oct 25 13:10:25 2012
@@ -58,7 +58,7 @@ public class NIOFSDirectory extends FSDi
    * @param path the path of the directory
    * @param lockFactory the lock factory to use, or null for the default
    * ({@link NativeFSLockFactory});
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public NIOFSDirectory(File path, LockFactory lockFactory) throws IOException {
     super(path, lockFactory);
@@ -67,7 +67,7 @@ public class NIOFSDirectory extends FSDi
   /** Create a new NIOFSDirectory for the named location and {@link NativeFSLockFactory}.
    *
    * @param path the path of the directory
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public NIOFSDirectory(File path) throws IOException {
     super(path, null);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java Thu Oct 25 13:10:25 2012
@@ -103,19 +103,6 @@ public class RAMOutputStream extends Ind
   }
 
   @Override
-  public void seek(long pos) throws IOException {
-    // set the file length in case we seek back
-    // and flush() has not been called yet
-    setFileLength();
-    if (pos < bufferStart || pos >= bufferStart + bufferLength) {
-      currentBufferIndex = (int) (pos / BUFFER_SIZE);
-      switchCurrentBuffer();
-    }
-
-    bufferPosition = (int) (pos % BUFFER_SIZE);
-  }
-
-  @Override
   public long length() {
     return file.length;
   }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java Thu Oct 25 13:10:25 2012
@@ -35,7 +35,7 @@ public class SimpleFSDirectory extends F
    * @param path the path of the directory
    * @param lockFactory the lock factory to use, or null for the default
    * ({@link NativeFSLockFactory});
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public SimpleFSDirectory(File path, LockFactory lockFactory) throws IOException {
     super(path, lockFactory);
@@ -44,7 +44,7 @@ public class SimpleFSDirectory extends F
   /** Create a new SimpleFSDirectory for the named location and {@link NativeFSLockFactory}.
    *
    * @param path the path of the directory
-   * @throws IOException
+   * @throws IOException if there is a low-level I/O error
    */
   public SimpleFSDirectory(File path) throws IOException {
     super(path, null);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRef.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRef.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRef.java Thu Oct 25 13:10:25 2012
@@ -262,7 +262,7 @@ public final class BytesRef implements C
     }    
   }
 
-  /** @deprecated */
+  /** @deprecated This comparator is only a transition mechanism */
   @Deprecated
   private final static Comparator<BytesRef> utf8SortedAsUTF16SortOrder = new UTF8SortedAsUTF16Comparator();
 
@@ -272,7 +272,7 @@ public final class BytesRef implements C
     return utf8SortedAsUTF16SortOrder;
   }
 
-  /** @deprecated */
+  /** @deprecated This comparator is only a transition mechanism */
   @Deprecated
   private static class UTF8SortedAsUTF16Comparator implements Comparator<BytesRef> {
     // Only singleton

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java Thu Oct 25 13:10:25 2012
@@ -34,7 +34,7 @@ public interface BytesRefIterator {
    * 
    * @return the next {@link BytesRef} in the iterator or <code>null</code> if
    *         the end of the iterator is reached.
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error.
    */
   public BytesRef next() throws IOException;
   

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CharsRef.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CharsRef.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CharsRef.java Thu Oct 25 13:10:25 2012
@@ -217,7 +217,7 @@ public final class CharsRef implements C
     return new CharsRef(chars, offset + start, offset + end);
   }
   
-  /** @deprecated */
+  /** @deprecated This comparator is only a transition mechanism */
   @Deprecated
   private final static Comparator<CharsRef> utf16SortedAsUTF8SortOrder = new UTF16SortedAsUTF8Comparator();
   
@@ -227,7 +227,7 @@ public final class CharsRef implements C
     return utf16SortedAsUTF8SortOrder;
   }
   
-  /** @deprecated */
+  /** @deprecated This comparator is only a transition mechanism */
   @Deprecated
   private static class UTF16SortedAsUTF8Comparator implements Comparator<CharsRef> {
     // Only singleton

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CommandLineUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CommandLineUtil.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CommandLineUtil.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/CommandLineUtil.java Thu Oct 25 13:10:25 2012
@@ -62,7 +62,7 @@ public final class CommandLineUtil {
    * Loads a specific Directory implementation 
    * @param clazzName The name of the Directory class to load
    * @return The Directory class loaded
-   * @throws ClassNotFoundException
+   * @throws ClassNotFoundException If the specified class cannot be found.
    */
   public static Class<? extends Directory> loadDirectoryClass(String clazzName) 
       throws ClassNotFoundException {
@@ -73,7 +73,7 @@ public final class CommandLineUtil {
    * Loads a specific FSDirectory implementation
    * @param clazzName The name of the FSDirectory class to load
    * @return The FSDirectory class loaded
-   * @throws ClassNotFoundException
+   * @throws ClassNotFoundException If the specified class cannot be found.
    */
   public static Class<? extends FSDirectory> loadFSDirectoryClass(String clazzName) 
       throws ClassNotFoundException {
@@ -97,10 +97,10 @@ public final class CommandLineUtil {
    * @param clazz The class of the object to be created
    * @param file The file to be used as parameter constructor
    * @return The new FSDirectory instance
-   * @throws NoSuchMethodException
-   * @throws InstantiationException
-   * @throws IllegalAccessException
-   * @throws InvocationTargetException
+   * @throws NoSuchMethodException If the Directory does not have a constructor that takes <code>File</code>.
+   * @throws InstantiationException If the class is abstract or an interface.
+   * @throws IllegalAccessException If the constructor does not have public visibility.
+   * @throws InvocationTargetException If the constructor throws an exception
    */
   public static FSDirectory newFSDirectory(Class<? extends FSDirectory> clazz, File file) 
       throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/IOUtils.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/IOUtils.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/IOUtils.java Thu Oct 25 13:10:25 2012
@@ -335,7 +335,7 @@ public final class IOUtils {
     for (String name : files) {
       try {
         dir.deleteFile(name);
-      } catch (IOException ignored) {
+      } catch (Throwable ignored) {
         // ignore
       }
     }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java Thu Oct 25 13:10:25 2012
@@ -81,9 +81,7 @@ public class OpenBitSet extends DocIdSet
   // Used only for assert:
   private long numBits;
 
-  /** Constructs an OpenBitSet large enough to hold numBits.
-   *
-   * @param numBits
+  /** Constructs an OpenBitSet large enough to hold <code>numBits</code>.
    */
   public OpenBitSet(long numBits) {
     this.numBits = numBits;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/Version.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/Version.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/Version.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/Version.java Thu Oct 25 13:10:25 2012
@@ -39,6 +39,13 @@ public enum Version { 
    */
   @Deprecated
   LUCENE_40,
+  
+  /**
+   * Match settings and bugs in Lucene's 4.1 release.
+   * @deprecated (5.0) Use latest
+   */
+  @Deprecated
+  LUCENE_41,
 
   /** Match settings and bugs in Lucene's 5.0 release. 
    *  <p>

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java Thu Oct 25 13:10:25 2012
@@ -133,22 +133,22 @@ public final class WeakIdentityMap<K,V> 
     
       @Override
       public boolean hasNext() {
-        return nextIsSet ? true : setNext();
+        return nextIsSet || setNext();
       }
       
       @Override @SuppressWarnings("unchecked")
       public K next() {
-        if (nextIsSet || setNext()) {
-          try {
-            assert nextIsSet;
-            return (K) next;
-          } finally {
-             // release strong reference and invalidate current value:
-            nextIsSet = false;
-            next = null;
-          }
+        if (!hasNext()) {
+          throw new NoSuchElementException();
+        }
+        assert nextIsSet;
+        try {
+          return (K) next;
+        } finally {
+           // release strong reference and invalidate current value:
+          nextIsSet = false;
+          next = null;
         }
-        throw new NoSuchElementException();
       }
       
       @Override
@@ -161,14 +161,15 @@ public final class WeakIdentityMap<K,V> 
         while (iterator.hasNext()) {
           next = iterator.next().get();
           if (next == null) {
-            // already garbage collected!
-            continue;
-          }
-          // unfold "null" special value
-          if (next == NULL) {
-            next = null;
+            // the key was already GCed, we can remove it from backing map:
+            iterator.remove();
+          } else {
+            // unfold "null" special value:
+            if (next == NULL) {
+              next = null;
+            }
+            return nextIsSet = true;
           }
-          return nextIsSet = true;
         }
         return false;
       }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/SpecialOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/SpecialOperations.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/SpecialOperations.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/SpecialOperations.java Thu Oct 25 13:10:25 2012
@@ -35,6 +35,8 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.IntsRef;
+import org.apache.lucene.util.fst.Util;
 
 /**
  * Special automata operations.
@@ -209,4 +211,60 @@ final public class SpecialOperations {
     a.clearNumberedStates();
     return accept;
   }
+
+  // TODO: this is a dangerous method ... Automaton could be
+  // huge ... and it's better in general for caller to
+  // enumerate & process in a single walk:
+
+  /**
+   * Returns the set of accepted strings, assuming that at most
+   * <code>limit</code> strings are accepted. If more than <code>limit</code> 
+   * strings are accepted, null is returned. If <code>limit</code>&lt;0, then 
+   * the limit is infinite.
+   */
+  public static Set<IntsRef> getFiniteStrings(Automaton a, int limit) {
+    HashSet<IntsRef> strings = new HashSet<IntsRef>();
+    if (a.isSingleton()) {
+      if (limit > 0) {
+        strings.add(Util.toUTF32(a.singleton, new IntsRef()));
+      } else {
+        return null;
+      }
+    } else if (!getFiniteStrings(a.initial, new HashSet<State>(), strings, new IntsRef(), limit)) {
+      return null;
+    }
+    return strings;
+  }
+  
+  /**
+   * Returns the strings that can be produced from the given state, or
+   * false if more than <code>limit</code> strings are found. 
+   * <code>limit</code>&lt;0 means "infinite".
+   */
+  private static boolean getFiniteStrings(State s, HashSet<State> pathstates, 
+      HashSet<IntsRef> strings, IntsRef path, int limit) {
+    pathstates.add(s);
+    for (Transition t : s.getTransitions()) {
+      if (pathstates.contains(t.to)) {
+        return false;
+      }
+      for (int n = t.min; n <= t.max; n++) {
+        path.grow(path.length+1);
+        path.ints[path.length] = n;
+        path.length++;
+        if (t.to.accept) {
+          strings.add(IntsRef.deepCopyOf(path));
+          if (limit >= 0 && strings.size() > limit) {
+            return false;
+          }
+        }
+        if (!getFiniteStrings(t.to, pathstates, strings, path, limit)) {
+          return false;
+        }
+        path.length--;
+      }
+    }
+    pathstates.remove(s);
+    return true;
+  }
 }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/State.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/State.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/State.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/State.java Thu Oct 25 13:10:25 2012
@@ -165,6 +165,10 @@ public class State implements Comparable
     }
   }
   
+  /** Virtually adds an epsilon transition to the target
+   *  {@code to} state.  This is implemented by copying all
+   *  transitions from {@code to} to this state, and if {@code
+   *  to} is an accept state then set accept for this state. */
   void addEpsilon(State to) {
     if (to.accept) accept = true;
     for (Transition t : to.getTransitions())

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java Thu Oct 25 13:10:25 2012
@@ -399,8 +399,10 @@ public class Builder<T> {
     }
 
     final UnCompiledNode<T> lastNode = frontier[input.length];
-    lastNode.isFinal = true;
-    lastNode.output = NO_OUTPUT;
+    if (lastInput.length != input.length || prefixLenPlus1 != input.length + 1) {
+      lastNode.isFinal = true;
+      lastNode.output = NO_OUTPUT;
+    }
 
     // push conflicting outputs forward, only as far as
     // needed

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java Thu Oct 25 13:10:25 2012
@@ -296,11 +296,13 @@ public final class FST<T> {
       // messy
       bytes = new byte[numBytes];
       in.readBytes(bytes, 0, numBytes);
+      BytesReader reader;
       if (packed) {
-        emptyOutput = outputs.read(getBytesReader(0));
+        reader = getBytesReader(0);
       } else {
-        emptyOutput = outputs.read(getBytesReader(numBytes-1));
+        reader = getBytesReader(numBytes-1);
       }
+      emptyOutput = outputs.readFinalOutput(reader);
     } else {
       emptyOutput = null;
     }
@@ -414,7 +416,7 @@ public final class FST<T> {
     // TODO: this is messy -- replace with sillyBytesWriter; maybe make
     // bytes private
     final int posSave = writer.posWrite;
-    outputs.write(emptyOutput, writer);
+    outputs.writeFinalOutput(emptyOutput, writer);
     emptyOutputBytes = new byte[writer.posWrite-posSave];
 
     if (!packed) {
@@ -638,7 +640,7 @@ public final class FST<T> {
 
       if (arc.nextFinalOutput != NO_OUTPUT) {
         //System.out.println("    write final output");
-        outputs.write(arc.nextFinalOutput, writer);
+        outputs.writeFinalOutput(arc.nextFinalOutput, writer);
       }
 
       if (targetHasArcs && (flags & BIT_TARGET_NEXT) == 0) {
@@ -788,7 +790,7 @@ public final class FST<T> {
             outputs.read(in);
           }
           if (arc.flag(BIT_ARC_HAS_FINAL_OUTPUT)) {
-            outputs.read(in);
+            outputs.readFinalOutput(in);
           }
           if (arc.flag(BIT_STOP_NODE)) {
           } else if (arc.flag(BIT_TARGET_NEXT)) {
@@ -963,7 +965,7 @@ public final class FST<T> {
     }
 
     if (arc.flag(BIT_ARC_HAS_FINAL_OUTPUT)) {
-      arc.nextFinalOutput = outputs.read(in);
+      arc.nextFinalOutput = outputs.readFinalOutput(in);
     } else {
       arc.nextFinalOutput = outputs.getNoOutput();
     }
@@ -1127,7 +1129,7 @@ public final class FST<T> {
       }
 
       if (flag(flags, BIT_ARC_HAS_FINAL_OUTPUT)) {
-        outputs.read(in);
+        outputs.readFinalOutput(in);
       }
 
       if (!flag(flags, BIT_STOP_NODE) && !flag(flags, BIT_TARGET_NEXT)) {
@@ -1221,6 +1223,14 @@ public final class FST<T> {
     }
   }
 
+  /** Returns a {@link BytesReader} for this FST, positioned at
+   *  position 0. */
+  public BytesReader getBytesReader() {
+    return getBytesReader(0);
+  }
+
+  /** Returns a {@link BytesReader} for this FST, positioned at
+   *  the provided position. */
   public BytesReader getBytesReader(int pos) {
     // TODO: maybe re-use via ThreadLocal?
     if (packed) {
@@ -1654,7 +1664,7 @@ public final class FST<T> {
               }
             }
             if (arc.nextFinalOutput != NO_OUTPUT) {
-              outputs.write(arc.nextFinalOutput, writer);
+              outputs.writeFinalOutput(arc.nextFinalOutput, writer);
             }
 
             if (doWriteTarget) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Outputs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Outputs.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Outputs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Outputs.java Thu Oct 25 13:10:25 2012
@@ -49,10 +49,27 @@ public abstract class Outputs<T> {
   /** Eg add("foo", "bar") -> "foobar" */
   public abstract T add(T prefix, T output);
 
+  /** Encode an output value into a {@link DataOutput}. */
   public abstract void write(T output, DataOutput out) throws IOException;
 
+  /** Encode an final node output value into a {@link
+   *  DataOutput}.  By default this just calls {@link #write(Object,
+   *  DataOutput)}. */
+  public void writeFinalOutput(T output, DataOutput out) throws IOException {
+    write(output, out);
+  }
+
+  /** Decode an output value previously written with {@link
+   *  #write(Object, DataOutput)}. */
   public abstract T read(DataInput in) throws IOException;
 
+  /** Decode an output value previously written with {@link
+   *  #writeFinalOutput(Object, DataOutput)}.  By default this
+   *  just calls {@link #read(DataInput)}. */
+  public T readFinalOutput(DataInput in) throws IOException {
+    return read(in);
+  }
+
   /** NOTE: this output is compared with == so you must
    *  ensure that all methods return the single object if
    *  it's really no output */

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java Thu Oct 25 13:10:25 2012
@@ -118,7 +118,7 @@ public final class PositiveIntOutputs ex
 
   private boolean valid(Long o) {
     assert o != null;
-    assert o == NO_OUTPUT || o > 0;
+    assert o == NO_OUTPUT || o > 0: "o=" + o;
     return true;
   }
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java Thu Oct 25 13:10:25 2012
@@ -233,13 +233,14 @@ public final class Util {
   private static class FSTPath<T> implements Comparable<FSTPath<T>> {
     public FST.Arc<T> arc;
     public T cost;
-    public final IntsRef input = new IntsRef();
+    public final IntsRef input;
     final Comparator<T> comparator;
 
-    public FSTPath(T cost, FST.Arc<T> arc, Comparator<T> comparator) {
+    public FSTPath(T cost, FST.Arc<T> arc, Comparator<T> comparator, IntsRef input) {
       this.arc = new FST.Arc<T>().copyFrom(arc);
       this.cost = cost;
       this.comparator = comparator;
+      this.input = input;
     }
 
     @Override
@@ -258,24 +259,29 @@ public final class Util {
     }
   }
 
-  private static class TopNSearcher<T> {
+  /** Utility class to find top N shortest paths from start
+   *  point(s). */
+  public static class TopNSearcher<T> {
 
     private final FST<T> fst;
-    private final FST.Arc<T> fromNode;
+    private final FST.BytesReader bytesReader;
     private final int topN;
+    private final int maxQueueDepth;
+
+    private final FST.Arc<T> scratchArc = new FST.Arc<T>();
     
     final Comparator<T> comparator;
 
-    // Set once the queue has filled:
-    FSTPath<T> bottom = null;
-
     TreeSet<FSTPath<T>> queue = null;
 
-    public TopNSearcher(FST<T> fst, FST.Arc<T> fromNode, int topN, Comparator<T> comparator) {
+    public TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, Comparator<T> comparator) {
       this.fst = fst;
+      this.bytesReader = fst.getBytesReader(0);
       this.topN = topN;
-      this.fromNode = fromNode;
+      this.maxQueueDepth = maxQueueDepth;
       this.comparator = comparator;
+
+      queue = new TreeSet<FSTPath<T>>();
     }
 
     // If back plus this arc is competitive then add to queue:
@@ -284,9 +290,10 @@ public final class Util {
       assert queue != null;
 
       T cost = fst.outputs.add(path.cost, path.arc.output);
-      //System.out.println("  addIfCompetitive bottom=" + bottom + " queue.size()=" + queue.size());
+      //System.out.println("  addIfCompetitive queue.size()=" + queue.size() + " path=" + path + " + label=" + path.arc.label);
 
-      if (bottom != null) {
+      if (queue.size() == maxQueueDepth) {
+        FSTPath<T> bottom = queue.last();
         int comp = comparator.compare(cost, bottom.cost);
         if (comp > 0) {
           // Doesn't compete
@@ -308,33 +315,53 @@ public final class Util {
         // Queue isn't full yet, so any path we hit competes:
       }
 
-      final FSTPath<T> newPath = new FSTPath<T>(cost, path.arc, comparator);
-
-      newPath.input.grow(path.input.length+1);
-      System.arraycopy(path.input.ints, 0, newPath.input.ints, 0, path.input.length);
-      newPath.input.ints[path.input.length] = path.arc.label;
-      newPath.input.length = path.input.length+1;
+      // copy over the current input to the new input
+      // and add the arc.label to the end
+      IntsRef newInput = new IntsRef(path.input.length+1);     
+      System.arraycopy(path.input.ints, 0, newInput.ints, 0, path.input.length);
+      newInput.ints[path.input.length] = path.arc.label;
+      newInput.length = path.input.length+1;
+      final FSTPath<T> newPath = new FSTPath<T>(cost, path.arc, comparator, newInput);
 
-      //System.out.println("    add path=" + newPath);
       queue.add(newPath);
-      if (bottom != null) {
-        final FSTPath<T> removed = queue.pollLast();
-        assert removed == bottom;
-        bottom = queue.last();
-        //System.out.println("    now re-set bottom: " + bottom + " queue=" + queue);
-      } else if (queue.size() == topN) {
-        // Queue just filled up:
-        bottom = queue.last();
-        //System.out.println("    now set bottom: " + bottom);
+
+      if (queue.size() == maxQueueDepth+1) {
+        queue.pollLast();
+      }
+    }
+
+    /** Adds all leaving arcs, including 'finished' arc, if
+     *  the node is final, from this node into the queue.  */
+    public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRef input) throws IOException {
+
+      // De-dup NO_OUTPUT since it must be a singleton:
+      if (startOutput.equals(fst.outputs.getNoOutput())) {
+        startOutput = fst.outputs.getNoOutput();
+      }
+
+      FSTPath<T> path = new FSTPath<T>(startOutput, node, comparator, input);
+      fst.readFirstTargetArc(node, path.arc, bytesReader);
+
+      //System.out.println("add start paths");
+
+      // Bootstrap: find the min starting arc
+      while (true) {
+        if (allowEmptyString || path.arc.label != FST.END_LABEL) {
+          addIfCompetitive(path);
+        }
+        if (path.arc.isLast()) {
+          break;
+        }
+        fst.readNextArc(path.arc, bytesReader);
       }
     }
 
     public MinResult<T>[] search() throws IOException {
-      //System.out.println("  search topN=" + topN);
-      final FST.Arc<T> scratchArc = new FST.Arc<T>();
 
       final List<MinResult<T>> results = new ArrayList<MinResult<T>>();
 
+      //System.out.println("search topN=" + topN);
+
       final FST.BytesReader fstReader = fst.getBytesReader(0);
       final T NO_OUTPUT = fst.outputs.getNoOutput();
 
@@ -344,75 +371,26 @@ public final class Util {
 
       // TODO: maybe we should make an FST.INPUT_TYPE.BYTE0.5!?
       // (nibbles)
+      int rejectCount = 0;
 
       // For each top N path:
       while (results.size() < topN) {
-        //System.out.println("\nfind next path");
+        //System.out.println("\nfind next path: queue.size=" + queue.size());
 
         FSTPath<T> path;
 
         if (queue == null) {
+          // Ran out of paths
+          break;
+        }
 
-          if (results.size() != 0) {
-            // Ran out of paths
-            break;
-          }
-
-          // First pass (top path): start from original fromNode
-          if (topN > 1) {
-            queue = new TreeSet<FSTPath<T>>();
-          }
-
-          T minArcCost = null;
-          FST.Arc<T> minArc = null;
-
-          path = new FSTPath<T>(NO_OUTPUT, fromNode, comparator);
-          fst.readFirstTargetArc(fromNode, path.arc, fstReader);
-
-          // Bootstrap: find the min starting arc
-          while (true) {
-            T arcScore = path.arc.output;
-            //System.out.println("  arc=" + (char) path.arc.label + " cost=" + arcScore);
-            if (minArcCost == null || comparator.compare(arcScore, minArcCost) < 0) {
-              minArcCost = arcScore;
-              minArc = scratchArc.copyFrom(path.arc);
-              //System.out.println("    **");
-            }
-            if (queue != null) {
-              addIfCompetitive(path);
-            }
-            if (path.arc.isLast()) {
-              break;
-            }
-            fst.readNextArc(path.arc, fstReader);
-          }
-
-          assert minArc != null;
-
-          if (queue != null) {
-            // Remove top path since we are now going to
-            // pursue it:
-            path = queue.pollFirst();
-            //System.out.println("  remove init path=" + path);
-            assert path.arc.label == minArc.label;
-            if (bottom != null && queue.size() == topN-1) {
-              bottom = queue.last();
-              //System.out.println("    set init bottom: " + bottom);
-            }
-          } else {
-            path.arc.copyFrom(minArc);
-            path.input.grow(1);
-            path.input.ints[0] = minArc.label;
-            path.input.length = 1;
-            path.cost = minArc.output;
-          }
-
-        } else {
-          path = queue.pollFirst();
-          if (path == null) {
-            // There were less than topN paths available:
-            break;
-          }
+        // Remove top path since we are now going to
+        // pursue it:
+        path = queue.pollFirst();
+
+        if (path == null) {
+          // There were less than topN paths available:
+          break;
         }
 
         if (path.arc.label == FST.END_LABEL) {
@@ -423,7 +401,7 @@ public final class Util {
           continue;
         }
 
-        if (results.size() == topN-1) {
+        if (results.size() == topN-1 && maxQueueDepth == topN) {
           // Last path -- don't bother w/ queue anymore:
           queue = null;
         }
@@ -480,7 +458,13 @@ public final class Util {
           if (path.arc.label == FST.END_LABEL) {
             // Add final output:
             //System.out.println("    done!: " + path);
-            results.add(new MinResult<T>(path.input, fst.outputs.add(path.cost, path.arc.output), comparator));
+            T finalOutput = fst.outputs.add(path.cost, path.arc.output);
+            if (acceptResult(path.input, finalOutput)) {
+              results.add(new MinResult<T>(path.input, finalOutput, comparator));
+            } else {
+              rejectCount++;
+              assert rejectCount + topN <= maxQueueDepth: "maxQueueDepth (" + maxQueueDepth + ") is too small for topN (" + topN + "): rejected " + rejectCount + " paths";
+            }
             break;
           } else {
             path.input.grow(1+path.input.length);
@@ -495,6 +479,10 @@ public final class Util {
         (MinResult<T>[]) new MinResult[results.size()];
       return results.toArray(arr);
     }
+
+    protected boolean acceptResult(IntsRef input, T output) {
+      return true;
+    }
   }
 
   /** Holds a single input (IntsRef) + output, returned by
@@ -521,14 +509,22 @@ public final class Util {
   }
 
   /** Starting from node, find the top N min cost 
-   * completions to a final node.
+   *  completions to a final node.
    *
    *  <p>NOTE: you must share the outputs when you build the
    *  FST (pass doShare=true to {@link
    *  PositiveIntOutputs#getSingleton}). */
+  public static <T> MinResult<T>[] shortestPaths(FST<T> fst, FST.Arc<T> fromNode, T startOutput, Comparator<T> comparator, int topN,
+                                                 boolean allowEmptyString) throws IOException {
 
-  public static <T> MinResult<T>[] shortestPaths(FST<T> fst, FST.Arc<T> fromNode, Comparator<T> comparator, int topN) throws IOException {
-    return new TopNSearcher<T>(fst, fromNode, topN, comparator).search();
+    // All paths are kept, so we can pass topN for
+    // maxQueueDepth and the pruning is admissible:
+    TopNSearcher<T> searcher = new TopNSearcher<T>(fst, topN, topN, comparator);
+
+    // since this search is initialized with a single start node 
+    // it is okay to start with an empty input path here
+    searcher.addStartPaths(fromNode, startOutput, allowEmptyString, new IntsRef());
+    return searcher.search();
   } 
 
   /**
@@ -832,9 +828,22 @@ public final class Util {
   public static BytesRef toBytesRef(IntsRef input, BytesRef scratch) {
     scratch.grow(input.length);
     for(int i=0;i<input.length;i++) {
-      scratch.bytes[i] = (byte) input.ints[i+input.offset];
+      int value = input.ints[i+input.offset];
+      // NOTE: we allow -128 to 255
+      assert value >= Byte.MIN_VALUE && value <= 255: "value " + value + " doesn't fit into byte";
+      scratch.bytes[i] = (byte) value;
     }
     scratch.length = input.length;
     return scratch;
   }
+
+  // Uncomment for debugging:
+
+  /*
+  public static <T> void dotToFile(FST<T> fst, String filePath) throws IOException {
+    Writer w = new OutputStreamWriter(new FileOutputStream(filePath));
+    toDot(fst, w, true, true);
+    w.close();
+  }
+  */
 }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java Thu Oct 25 13:10:25 2012
@@ -712,7 +712,7 @@ public class PackedInts {
    * @param valueCount   how many values the stream holds
    * @param bitsPerValue the number of bits per value
    * @return             a Reader
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error
    * @see PackedInts#getWriterNoHeader(DataOutput, Format, int, int, int)
    * @lucene.internal
    */
@@ -754,7 +754,7 @@ public class PackedInts {
    *
    * @param in           the stream to read data from
    * @return             a Reader
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error
    * @lucene.internal
    */
   public static Reader getReader(DataInput in) throws IOException {
@@ -846,7 +846,7 @@ public class PackedInts {
    *
    * @param in           the stream to read data from
    * @return a direct Reader
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error
    * @lucene.internal
    */
   public static Reader getDirectReader(IndexInput in) throws IOException {
@@ -990,7 +990,7 @@ public class PackedInts {
    * @param bitsPerValue the number of bits per value
    * @param acceptableOverheadRatio an acceptable overhead ratio per value
    * @return             a Writer
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error
    * @lucene.internal
    */
   public static Writer getWriter(DataOutput out,

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedReaderIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedReaderIterator.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedReaderIterator.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/packed/PackedReaderIterator.java Thu Oct 25 13:10:25 2012
@@ -37,7 +37,7 @@ final class PackedReaderIterator extends
     this.format = format;
     bulkOperation = BulkOperation.of(format, bitsPerValue);
     iterations = bulkOperation.computeIterations(valueCount, mem);
-    assert iterations > 0;
+    assert valueCount == 0 || iterations > 0;
     nextBlocks = new long[iterations * bulkOperation.blockCount()];
     nextValues = new LongsRef(new long[iterations * bulkOperation.valueCount()], 0, 0);
     assert iterations * bulkOperation.valueCount() == nextValues.longs.length;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.Codec
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.Codec?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.Codec (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.Codec Thu Oct 25 13:10:25 2012
@@ -14,3 +14,4 @@
 #  limitations under the License.
 
 org.apache.lucene.codecs.lucene40.Lucene40Codec
+org.apache.lucene.codecs.lucene41.Lucene41Codec

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/resources/META-INF/services/org.apache.lucene.codecs.PostingsFormat Thu Oct 25 13:10:25 2012
@@ -14,3 +14,4 @@
 #  limitations under the License.
 
 org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
+org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java Thu Oct 25 13:10:25 2012
@@ -19,7 +19,7 @@ package org.apache.lucene;
 
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.codecs.*;
-import org.apache.lucene.codecs.lucene40.Lucene40Codec;
+import org.apache.lucene.codecs.lucene41.Lucene41Codec;
 import org.apache.lucene.document.*;
 import org.apache.lucene.index.*;
 import org.apache.lucene.search.*;
@@ -31,11 +31,11 @@ import org.apache.lucene.util.*;
 
 public class TestExternalCodecs extends LuceneTestCase {
 
-  private static final class CustomPerFieldCodec extends Lucene40Codec {
+  private static final class CustomPerFieldCodec extends Lucene41Codec {
     
     private final PostingsFormat ramFormat = PostingsFormat.forName("RAMOnly");
-    private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene40");
-    private final PostingsFormat pulsingFormat = PostingsFormat.forName("Pulsing40");
+    private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene41");
+    private final PostingsFormat pulsingFormat = PostingsFormat.forName("Pulsing41");
 
     @Override
     public PostingsFormat getPostingsFormatForField(String field) {