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 2012/07/19 17:59:32 UTC

svn commit: r1363400 [12/31] - in /lucene/dev/branches/pforcodec_3892: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene...

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Thu Jul 19 15:58:54 2012
@@ -30,6 +30,7 @@ import org.apache.lucene.index.AtomicRea
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.DisjunctionMaxQuery;
@@ -43,7 +44,6 @@ import org.apache.lucene.search.spans.Sp
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.Spans;
-import org.apache.lucene.util.TermContext;
 
 /**
  * Experimental class to get set of payloads for most standard Lucene queries.

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java Thu Jul 19 15:58:54 2012
@@ -17,6 +17,8 @@ package org.apache.lucene.search.similar
  * limitations under the License.
  */
 
+import java.util.Locale;
+
 import org.apache.lucene.search.Explanation;
 
 /**
@@ -92,6 +94,6 @@ public class LMDirichletSimilarity exten
   
   @Override
   public String getName() {
-    return String.format("Dirichlet(%f)", getMu());
+    return String.format(Locale.ROOT, "Dirichlet(%f)", getMu());
   }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java Thu Jul 19 15:58:54 2012
@@ -17,6 +17,8 @@ package org.apache.lucene.search.similar
  * limitations under the License.
  */
 
+import java.util.Locale;
+
 import org.apache.lucene.search.Explanation;
 
 /**
@@ -72,6 +74,6 @@ public class LMJelinekMercerSimilarity e
 
   @Override
   public String getName() {
-    return String.format("Jelinek-Mercer(%f)", getLambda());
+    return String.format(Locale.ROOT, "Jelinek-Mercer(%f)", getLambda());
   }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java Thu Jul 19 15:58:54 2012
@@ -17,6 +17,8 @@ package org.apache.lucene.search.similar
  * limitations under the License.
  */
 
+import java.util.Locale;
+
 import org.apache.lucene.search.CollectionStatistics;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.TermStatistics;
@@ -91,9 +93,9 @@ public abstract class LMSimilarity exten
   public String toString() {
     String coll = collectionModel.getName();
     if (coll != null) {
-      return String.format("LM %s - %s", getName(), coll);
+      return String.format(Locale.ROOT, "LM %s - %s", getName(), coll);
     } else {
-      return String.format("LM %s", getName());
+      return String.format(Locale.ROOT, "LM %s", getName());
     }
   }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java Thu Jul 19 15:58:54 2012
@@ -99,7 +99,7 @@ import org.apache.lucene.util.SmallFloat
  * </ol>
  * <p>
  * <a name="explaintime"/>
- * When {@link IndexSearcher#explain(Query, int)} is called, queries consult the Similarity's DocScorer for an 
+ * When {@link IndexSearcher#explain(org.apache.lucene.search.Query, int)} is called, queries consult the Similarity's DocScorer for an 
  * explanation of how it computed its score. The query passes in a the document id and an explanation of how the frequency
  * was computed.
  *

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java Thu Jul 19 15:58:54 2012
@@ -611,7 +611,6 @@ public abstract class TFIDFSimilarity ex
    * @param termStats term-level statistics for the term
    * @return an Explain object that includes both an idf score factor 
              and an explanation for the term.
-   * @throws IOException
    */
   public Explanation idfExplain(CollectionStatistics collectionStats, TermStatistics termStats) {
     final long df = termStats.docFreq();
@@ -632,7 +631,6 @@ public abstract class TFIDFSimilarity ex
    * @return an Explain object that includes both an idf 
    *         score factor for the phrase and an explanation 
    *         for each term.
-   * @throws IOException
    */
   public Explanation idfExplain(CollectionStatistics collectionStats, TermStatistics termStats[]) {
     final long max = collectionStats.maxDoc();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java Thu Jul 19 15:58:54 2012
@@ -24,11 +24,11 @@ import java.util.Set;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 
 /**

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java Thu Jul 19 15:58:54 2012
@@ -19,9 +19,9 @@ package org.apache.lucene.search.spans;
 
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 
 import java.io.IOException;
 import java.util.ArrayList;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java Thu Jul 19 15:58:54 2012
@@ -19,9 +19,9 @@ package org.apache.lucene.search.spans;
 
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.PriorityQueue;
-import org.apache.lucene.util.TermContext;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -285,7 +285,7 @@ public class NearSpansUnordered extends 
     }
   }
 
-  private void addToList(SpansCell cell) throws IOException {
+  private void addToList(SpansCell cell) {
     if (last != null) {			  // add next to end of list
       last.next = cell;
     } else
@@ -301,7 +301,7 @@ public class NearSpansUnordered extends 
     last.next = null;
   }
 
-  private void queueToList() throws IOException {
+  private void queueToList() {
     last = first = null;
     while (queue.top() != null) {
       addToList(queue.pop());

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java Thu Jul 19 15:58:54 2012
@@ -23,13 +23,13 @@ import java.util.Map;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.MultiTermQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TopTermsRewrite;
 import org.apache.lucene.search.ScoringRewrite;
 import org.apache.lucene.search.BooleanClause.Occur; // javadocs only
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 
 /**
  * Wraps any {@link MultiTermQuery} as a {@link SpanQuery}, 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java Thu Jul 19 15:58:54 2012
@@ -30,9 +30,9 @@ import java.util.Set;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 
 /** Matches spans which are near one another.  One can specify <i>slop</i>, the

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java Thu Jul 19 15:58:54 2012
@@ -20,9 +20,9 @@ package org.apache.lucene.search.spans;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Thu Jul 19 15:58:54 2012
@@ -29,9 +29,9 @@ import java.util.Set;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.PriorityQueue;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.search.Query;
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java Thu Jul 19 15:58:54 2012
@@ -20,9 +20,9 @@ package org.apache.lucene.search.spans;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 
 import java.io.IOException;
 import java.util.ArrayList;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java Thu Jul 19 15:58:54 2012
@@ -22,11 +22,11 @@ import java.util.Map;
 
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 
 /** Base class for span-based queries. */
 public abstract class SpanQuery extends Query {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Thu Jul 19 15:58:54 2012
@@ -21,11 +21,11 @@ import org.apache.lucene.index.AtomicRea
 import org.apache.lucene.index.Fields;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.index.TermState;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java Thu Jul 19 15:58:54 2012
@@ -20,11 +20,11 @@ package org.apache.lucene.search.spans;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.*;
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.search.similarities.Similarity.SloppySimScorer;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.TermContext;
 
 import java.io.IOException;
 import java.util.HashMap;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java Thu Jul 19 15:58:54 2012
@@ -37,7 +37,7 @@ public class TermSpans extends Spans {
   protected int count;
   protected int position;
 
-  public TermSpans(DocsAndPositionsEnum postings, Term term) throws IOException {
+  public TermSpans(DocsAndPositionsEnum postings, Term term) {
     this.postings = postings;
     this.term = term;
     doc = -1;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java Thu Jul 19 15:58:54 2012
@@ -18,11 +18,11 @@ package org.apache.lucene.store;
  */
 
 import org.apache.lucene.codecs.Codec; // javadocs
+import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.codecs.LiveDocsFormat; // javadocs
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.IndexFormatTooOldException;
 import org.apache.lucene.store.DataOutput; // javadocs
-import org.apache.lucene.util.CodecUtil; // javadocs
 import org.apache.lucene.util.IOUtils;
 
 import java.util.Collection;
@@ -122,50 +122,43 @@ public final class CompoundFileDirectory
   /** Helper method that reads CFS entries from an input stream */
   private static final Map<String, FileEntry> readEntries(
       IndexInputSlicer handle, Directory dir, String name) throws IOException {
-    final IndexInput stream = handle.openFullSlice();
-    final Map<String, FileEntry> mapping;
-    boolean success = false;
+    IOException priorE = null;
+    IndexInput stream = null, entriesStream = null;
     try {
+      stream = handle.openFullSlice();
       final int firstInt = stream.readInt();
       // NOTE: as long as we want to throw indexformattooold (vs corruptindexexception), we need
       // to read the magic ourselves. See SegmentInfos which also has this.
       if (firstInt == CodecUtil.CODEC_MAGIC) {
         CodecUtil.checkHeaderNoMagic(stream, CompoundFileWriter.DATA_CODEC, 
             CompoundFileWriter.VERSION_START, CompoundFileWriter.VERSION_START);
-        IndexInput input = null;
-        try {
-          final String entriesFileName = IndexFileNames.segmentFileName(
-                                                IndexFileNames.stripExtension(name), "",
-                                                IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION);
-          input = dir.openInput(entriesFileName, IOContext.READONCE);
-          CodecUtil.checkHeader(input, CompoundFileWriter.ENTRY_CODEC, CompoundFileWriter.VERSION_START, CompoundFileWriter.VERSION_START);
-          final int numEntries = input.readVInt();
-          mapping = new HashMap<String, CompoundFileDirectory.FileEntry>(
-              numEntries);
-          for (int i = 0; i < numEntries; i++) {
-            final FileEntry fileEntry = new FileEntry();
-            final String id = input.readString();
-            assert !mapping.containsKey(id): "id=" + id + " was written multiple times in the CFS";
-            mapping.put(id, fileEntry);
-            fileEntry.offset = input.readLong();
-            fileEntry.length = input.readLong();
-          }
-          success = true;
-          return mapping;
-        } finally {
-          IOUtils.close(input);
+        final String entriesFileName = IndexFileNames.segmentFileName(
+                                              IndexFileNames.stripExtension(name), "",
+                                              IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION);
+        entriesStream = dir.openInput(entriesFileName, IOContext.READONCE);
+        CodecUtil.checkHeader(entriesStream, CompoundFileWriter.ENTRY_CODEC, CompoundFileWriter.VERSION_START, CompoundFileWriter.VERSION_START);
+        final int numEntries = entriesStream.readVInt();
+        final Map<String, FileEntry> mapping = new HashMap<String,FileEntry>(numEntries);
+        for (int i = 0; i < numEntries; i++) {
+          final FileEntry fileEntry = new FileEntry();
+          final String id = entriesStream.readString();
+          assert !mapping.containsKey(id): "id=" + id + " was written multiple times in the CFS";
+          mapping.put(id, fileEntry);
+          fileEntry.offset = entriesStream.readLong();
+          fileEntry.length = entriesStream.readLong();
         }
+        return mapping;
       } else {
         throw new IndexFormatTooOldException(stream, firstInt,
             CodecUtil.CODEC_MAGIC, CodecUtil.CODEC_MAGIC);
       }
+    } catch (IOException ioe) {
+      priorE = ioe;
     } finally {
-      if (success) {
-        IOUtils.close(stream);
-      } else {
-        IOUtils.closeWhileHandlingException(stream);
-      }
+      IOUtils.closeWhileHandlingException(priorE, stream, entriesStream);
     }
+    // this is needed until Java 7's real try-with-resources:
+    throw new AssertionError("impossible to get here");
   }
   
   public Directory getDirectory() {
@@ -265,7 +258,7 @@ public final class CompoundFileDirectory
   }
   
   @Override
-  public void sync(Collection<String> names) throws IOException {
+  public void sync(Collection<String> names) {
     throw new UnsupportedOperationException();
   }
   
@@ -288,7 +281,7 @@ public final class CompoundFileDirectory
     }
     return new IndexInputSlicer() {
       @Override
-      public void close() throws IOException {
+      public void close() {
       }
       
       @Override

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java Thu Jul 19 15:58:54 2012
@@ -29,9 +29,8 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.MergePolicy.MergeAbortedException;
-import org.apache.lucene.util.CodecUtil;
 import org.apache.lucene.util.IOUtils;
 
 /**
@@ -78,7 +77,7 @@ final class CompoundFileWriter implement
    * @throws NullPointerException
    *           if <code>dir</code> or <code>name</code> is null
    */
-  CompoundFileWriter(Directory dir, String name) throws IOException {
+  CompoundFileWriter(Directory dir, String name) {
     if (dir == null)
       throw new NullPointerException("directory cannot be null");
     if (name == null)
@@ -174,7 +173,7 @@ final class CompoundFileWriter implement
    * output stream.
    */
   private final long copyFileEntry(IndexOutput dataOut, FileEntry fileEntry)
-      throws IOException, MergeAbortedException {
+      throws IOException {
     final IndexInput is = fileEntry.dir.openInput(fileEntry.file, IOContext.READONCE);
     boolean success = false;
     try {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Directory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Directory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Directory.java Thu Jul 19 15:58:54 2012
@@ -230,7 +230,7 @@ public abstract class Directory implemen
         base.close();
       }
       @Override
-      public IndexInput openFullSlice() throws IOException {
+      public IndexInput openFullSlice() {
         return (IndexInput) base.clone();
       }
     };

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Lock.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Lock.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Lock.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/Lock.java Thu Jul 19 15:58:54 2012
@@ -67,7 +67,7 @@ public abstract class Lock {
    *         out of bounds
    * @throws IOException if obtain() throws IOException
    */
-  public boolean obtain(long lockWaitTimeout) throws LockObtainFailedException, IOException {
+  public boolean obtain(long lockWaitTimeout) throws IOException {
     failureReason = null;
     boolean locked = obtain();
     if (lockWaitTimeout < 0 && lockWaitTimeout != LOCK_OBTAIN_WAIT_FOREVER)
@@ -128,7 +128,7 @@ public abstract class Lock {
      * be obtained
      * @throws IOException if {@link Lock#obtain} throws IOException
      */
-    public Object run() throws LockObtainFailedException, IOException {
+    public Object run() throws IOException {
       boolean locked = false;
       try {
          locked = lock.obtain(lockWaitTimeout);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java Thu Jul 19 15:58:54 2012
@@ -27,9 +27,7 @@ import java.nio.channels.ClosedChannelEx
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileChannel.MapMode;
 
-import java.util.Collections;
-import java.util.Set;
-import java.util.WeakHashMap;
+import java.util.Iterator;
 
 import java.security.AccessController;
 import java.security.PrivilegedExceptionAction;
@@ -37,6 +35,7 @@ import java.security.PrivilegedActionExc
 import java.lang.reflect.Method;
 
 import org.apache.lucene.util.Constants;
+import org.apache.lucene.util.WeakIdentityMap;
 
 /** File-based {@link Directory} implementation that uses
  *  mmap for reading, and {@link
@@ -261,7 +260,7 @@ public class MMapDirectory extends FSDir
     private ByteBuffer curBuf; // redundant for speed: buffers[curBufIndex]
   
     private boolean isClone = false;
-    private final Set<MMapIndexInput> clones = Collections.newSetFromMap(new WeakHashMap<MMapIndexInput,Boolean>());
+    private final WeakIdentityMap<MMapIndexInput,Boolean> clones = WeakIdentityMap.newConcurrentHashMap();
 
     MMapIndexInput(String resourceDescription, RandomAccessFile raf, long offset, long length, int chunkSizePower) throws IOException {
       super(resourceDescription);
@@ -431,9 +430,7 @@ public class MMapDirectory extends FSDir
       }
       
       // register the new clone in our clone list to clean it up on closing:
-      synchronized(this.clones) {
-        this.clones.add(clone);
-      }
+      this.clones.put(clone, Boolean.TRUE);
       
       return clone;
     }
@@ -449,35 +446,25 @@ public class MMapDirectory extends FSDir
       try {
         if (isClone || buffers == null) return;
         
+        // make local copy, then un-set early
+        final ByteBuffer[] bufs = buffers;
+        unsetBuffers();
+        
         // for extra safety unset also all clones' buffers:
-        synchronized(this.clones) {
-          for (final MMapIndexInput clone : this.clones) {
-            assert clone.isClone;
-            clone.unsetBuffers();
-          }
-          this.clones.clear();
+        for (Iterator<MMapIndexInput> it = this.clones.keyIterator(); it.hasNext();) {
+          final MMapIndexInput clone = it.next();
+          assert clone.isClone;
+          clone.unsetBuffers();
         }
+        this.clones.clear();
         
-        curBuf = null; curBufIndex = 0; // nuke curr pointer early
-        for (int bufNr = 0; bufNr < buffers.length; bufNr++) {
-          cleanMapping(buffers[bufNr]);
+        for (final ByteBuffer b : bufs) {
+          cleanMapping(b);
         }
       } finally {
         unsetBuffers();
       }
     }
-
-    // make sure we have identity on equals/hashCode for WeakHashMap
-    @Override
-    public int hashCode() {
-      return System.identityHashCode(this);
-    }
-
-    // make sure we have identity on equals/hashCode for WeakHashMap
-    @Override
-    public boolean equals(Object obj) {
-      return obj == this;
-    }
   }
 
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java Thu Jul 19 15:58:54 2012
@@ -94,13 +94,13 @@ public class NIOFSDirectory extends FSDi
       }
 
       @Override
-      public IndexInput openSlice(String sliceDescription, long offset, long length) throws IOException {
+      public IndexInput openSlice(String sliceDescription, long offset, long length) {
         return new NIOFSIndexInput(sliceDescription, path, descriptor, descriptor.getChannel(), offset,
             length, BufferedIndexInput.bufferSize(context), getReadChunkSize());
       }
 
       @Override
-      public IndexInput openFullSlice() throws IOException {
+      public IndexInput openFullSlice() {
         return openSlice("full-slice", 0, descriptor.length);
       }
     };
@@ -117,7 +117,7 @@ public class NIOFSDirectory extends FSDi
       channel = file.getChannel();
     }
     
-    public NIOFSIndexInput(String sliceDescription, File path, Descriptor file, FileChannel fc, long off, long length, int bufferSize, int chunkSize) throws IOException {
+    public NIOFSIndexInput(String sliceDescription, File path, Descriptor file, FileChannel fc, long off, long length, int bufferSize, int chunkSize) {
       super("NIOFSIndexInput(" + sliceDescription + " in path=\"" + path + "\" slice=" + off + ":" + (off+length) + ")", file, off, length, bufferSize, chunkSize);
       channel = fc;
       isClone = true;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java Thu Jul 19 15:58:54 2012
@@ -84,6 +84,10 @@ public class NRTCachingDirectory extends
     maxCachedBytes = (long) (maxCachedMB*1024*1024);
   }
 
+  public Directory getDelegate() {
+    return delegate;
+  }
+
   @Override
   public LockFactory getLockFactory() {
     return delegate.getLockFactory();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java Thu Jul 19 15:58:54 2012
@@ -63,7 +63,7 @@ public class NativeFSLockFactory extends
    * directory itself. Be sure to create one instance for each directory
    * your create!
    */
-  public NativeFSLockFactory() throws IOException {
+  public NativeFSLockFactory() {
     this((File) null);
   }
 
@@ -73,7 +73,7 @@ public class NativeFSLockFactory extends
    *
    * @param lockDirName where lock files are created.
    */
-  public NativeFSLockFactory(String lockDirName) throws IOException {
+  public NativeFSLockFactory(String lockDirName) {
     this(new File(lockDirName));
   }
 
@@ -83,7 +83,7 @@ public class NativeFSLockFactory extends
    * 
    * @param lockDir where lock files are created.
    */
-  public NativeFSLockFactory(File lockDir) throws IOException {
+  public NativeFSLockFactory(File lockDir) {
     setLockDir(lockDir);
   }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java Thu Jul 19 15:58:54 2012
@@ -147,7 +147,7 @@ public class RAMOutputStream extends Ind
     }
   }
 
-  private final void switchCurrentBuffer() throws IOException {
+  private final void switchCurrentBuffer() {
     if (currentBufferIndex == file.numBuffers()) {
       currentBuffer = file.addBuffer(BUFFER_SIZE);
     } else {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java Thu Jul 19 15:58:54 2012
@@ -73,13 +73,13 @@ public class SimpleFSDirectory extends F
       }
 
       @Override
-      public IndexInput openSlice(String sliceDescription, long offset, long length) throws IOException {
+      public IndexInput openSlice(String sliceDescription, long offset, long length) {
         return new SimpleFSIndexInput("SimpleFSIndexInput(" + sliceDescription + " in path=\"" + file.getPath() + "\" slice=" + offset + ":" + (offset+length) + ")", descriptor, offset,
             length, BufferedIndexInput.bufferSize(context), getReadChunkSize());
       }
 
       @Override
-      public IndexInput openFullSlice() throws IOException {
+      public IndexInput openFullSlice() {
         return openSlice("full-slice", 0, descriptor.length);
       }
     };
@@ -124,7 +124,7 @@ public class SimpleFSDirectory extends F
       this.end = file.length;
     }
     
-    public SimpleFSIndexInput(String resourceDesc, Descriptor file, long off, long length, int bufferSize, int chunkSize) throws IOException {
+    public SimpleFSIndexInput(String resourceDesc, Descriptor file, long off, long length, int bufferSize, int chunkSize) {
       super(resourceDesc, bufferSize);
       this.file = file;
       this.chunkSize = chunkSize;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java Thu Jul 19 15:58:54 2012
@@ -60,7 +60,7 @@ public class SimpleFSLockFactory extends
    * directory itself. Be sure to create one instance for each directory
    * your create!
    */
-  public SimpleFSLockFactory() throws IOException {
+  public SimpleFSLockFactory() {
     this((File) null);
   }
 
@@ -68,7 +68,7 @@ public class SimpleFSLockFactory extends
    * Instantiate using the provided directory (as a File instance).
    * @param lockDir where lock files should be created.
    */
-  public SimpleFSLockFactory(File lockDir) throws IOException {
+  public SimpleFSLockFactory(File lockDir) {
     setLockDir(lockDir);
   }
 
@@ -76,7 +76,7 @@ public class SimpleFSLockFactory extends
    * Instantiate using the provided directory name (String).
    * @param lockDirName where lock files should be created.
    */
-  public SimpleFSLockFactory(String lockDirName) throws IOException {
+  public SimpleFSLockFactory(String lockDirName) {
     setLockDir(new File(lockDirName));
   }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/VerifyingLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/VerifyingLockFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/VerifyingLockFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/store/VerifyingLockFactory.java Thu Jul 19 15:58:54 2012
@@ -69,8 +69,7 @@ public class VerifyingLockFactory extend
     }
 
     @Override
-    public synchronized boolean obtain(long lockWaitTimeout)
-      throws LockObtainFailedException, IOException {
+    public synchronized boolean obtain(long lockWaitTimeout) throws IOException {
       boolean obtained = lock.obtain(lockWaitTimeout);
       if (obtained)
         verify((byte) 1);
@@ -78,8 +77,7 @@ public class VerifyingLockFactory extend
     }
 
     @Override
-    public synchronized boolean obtain()
-      throws LockObtainFailedException, IOException {
+    public synchronized boolean obtain() throws IOException {
       return lock.obtain();
     }
 
@@ -105,7 +103,7 @@ public class VerifyingLockFactory extend
    * @param port the port {@link LockVerifyServer} is
             listening on
   */
-  public VerifyingLockFactory(byte id, LockFactory lf, String host, int port) throws IOException {
+  public VerifyingLockFactory(byte id, LockFactory lf, String host, int port) {
     this.id = id;
     this.lf = lf;
     this.host = host;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRef.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRef.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRef.java Thu Jul 19 15:58:54 2012
@@ -23,7 +23,13 @@ import java.util.Comparator;
  *  existing byte[].  The {@link #bytes} member should never be null;
  *  use {@link #EMPTY_BYTES} if necessary.
  *
- *  @lucene.experimental */
+ * <p><b>Important note:</b> Unless otherwise noted, Lucene uses this class to
+ * represent terms that are encoded as <b>UTF8</b> bytes in the index. To
+ * convert them to a Java {@link String} (which is UTF16), use {@link #utf8ToString}.
+ * Using code like {@code new String(bytes, offset, length)} to do this
+ * is <b>wrong</b>, as it does not respect the correct character set
+ * and may return wrong results (depending on the platform's defaults)!
+ */
 public final class BytesRef implements Comparable<BytesRef>,Cloneable {
   /** An empty byte array for convenience */
   public static final byte[] EMPTY_BYTES = new byte[0]; 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java Thu Jul 19 15:58:54 2012
@@ -50,7 +50,7 @@ public interface BytesRefIterator {
   public static final BytesRefIterator EMPTY = new BytesRefIterator() {
 
     @Override
-    public BytesRef next() throws IOException {
+    public BytesRef next() {
       return null;
     }
     

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Constants.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Constants.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Constants.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Constants.java Thu Jul 19 15:58:54 2012
@@ -117,9 +117,14 @@ public final class Constants {
     Package pkg = LucenePackage.get();
     String v = (pkg == null) ? null : pkg.getImplementationVersion();
     if (v == null) {
-      v = LUCENE_MAIN_VERSION + "-SNAPSHOT";
-    } else if (!v.startsWith(LUCENE_MAIN_VERSION)) {
-      v = LUCENE_MAIN_VERSION + "-SNAPSHOT " + v;
+      String parts[] = LUCENE_MAIN_VERSION.split("\\.");
+      if (parts.length == 4) {
+        // alpha/beta
+        assert parts[2].equals("0");
+        v = parts[0] + "." + parts[1] + "-SNAPSHOT";
+      } else {
+        v = LUCENE_MAIN_VERSION + "-SNAPSHOT";
+      }
     }
     LUCENE_VERSION = ident(v);
   }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/IOUtils.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/IOUtils.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/IOUtils.java Thu Jul 19 15:58:54 2012
@@ -21,6 +21,7 @@ import java.io.BufferedReader;
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -331,5 +332,24 @@ public final class IOUtils {
     }
   }
 
-
+  /**
+   * Copy one file's contents to another file. The target will be overwritten
+   * if it exists. The source must exist.
+   */
+  public static void copy(File source, File target) throws IOException {
+    FileInputStream fis = null;
+    FileOutputStream fos = null;
+    try {
+      fis = new FileInputStream(source);
+      fos = new FileOutputStream(target);
+      
+      final byte [] buffer = new byte [1024 * 8];
+      int len;
+      while ((len = fis.read(buffer)) > 0) {
+        fos.write(buffer, 0, len);
+      }
+    } finally {
+      close(fis, fos);
+    }
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/MathUtil.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/MathUtil.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/MathUtil.java Thu Jul 19 15:58:54 2012
@@ -27,9 +27,14 @@ public final class MathUtil {
   private MathUtil() {
   }
 
-  /** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */
+  /**
+   * Returns {@code x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))}
+   * @param base must be {@code > 1}
+   */
   public static int log(long x, int base) {
-    assert base > 1;
+    if (base <= 1) {
+      throw new IllegalArgumentException("base must be > 1");
+    }
     int ret = 0;
     while (x >= base) {
       x /= base;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/NamedThreadFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/NamedThreadFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/NamedThreadFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/NamedThreadFactory.java Thu Jul 19 15:58:54 2012
@@ -17,6 +17,7 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
+import java.util.Locale;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -43,7 +44,7 @@ public class NamedThreadFactory implemen
     final SecurityManager s = System.getSecurityManager();
     group = (s != null) ? s.getThreadGroup() : Thread.currentThread()
         .getThreadGroup();
-    this.threadNamePrefix = String.format(NAME_PATTERN,
+    this.threadNamePrefix = String.format(Locale.ROOT, NAME_PATTERN,
         checkPrefix(threadNamePrefix), threadPoolNumber.getAndIncrement());
   }
 
@@ -57,7 +58,7 @@ public class NamedThreadFactory implemen
    * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
    */
   public Thread newThread(Runnable r) {
-    final Thread t = new Thread(group, r, String.format("%s-%d",
+    final Thread t = new Thread(group, r, String.format(Locale.ROOT, "%s-%d",
         this.threadNamePrefix, threadNumber.getAndIncrement()), 0);
     t.setDaemon(false);
     t.setPriority(Thread.NORM_PRIORITY);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/PagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/PagedBytes.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/PagedBytes.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/PagedBytes.java Thu Jul 19 15:58:54 2012
@@ -288,7 +288,7 @@ public final class PagedBytes {
   }
 
   /** Copy BytesRef in */
-  public void copy(BytesRef bytes) throws IOException {
+  public void copy(BytesRef bytes) {
     int byteCount = bytes.length;
     int bytesUpto = bytes.offset;
     while (byteCount > 0) {
@@ -318,7 +318,7 @@ public final class PagedBytes {
   /** Copy BytesRef in, setting BytesRef out to the result.
    * Do not use this if you will use freeze(true).
    * This only supports bytes.length <= blockSize */
-  public void copy(BytesRef bytes, BytesRef out) throws IOException {
+  public void copy(BytesRef bytes, BytesRef out) {
     int left = blockSize - upto;
     if (bytes.length > left || currentBlock==null) {
       if (currentBlock != null) {
@@ -374,7 +374,7 @@ public final class PagedBytes {
 
   /** Copy bytes in, writing the length as a 1 or 2 byte
    *  vInt prefix. */
-  public long copyUsingLengthPrefix(BytesRef bytes) throws IOException {
+  public long copyUsingLengthPrefix(BytesRef bytes) {
     if (bytes.length >= 32768) {
       throw new IllegalArgumentException("max length is 32767 (got " + bytes.length + ")");
     }
@@ -488,7 +488,7 @@ public final class PagedBytes {
     }
 
     @Override
-    public void writeBytes(byte[] b, int offset, int length) throws IOException {
+    public void writeBytes(byte[] b, int offset, int length) {
       assert b.length >= offset + length;
       if (length == 0) {
         return;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java Thu Jul 19 15:58:54 2012
@@ -559,7 +559,7 @@ public final class RamUsageEstimator {
    */
   public static String humanReadableUnits(long bytes) {
     return humanReadableUnits(bytes, 
-        new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)));
+        new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ROOT)));
   }
 
   /**

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java Thu Jul 19 15:58:54 2012
@@ -44,8 +44,6 @@ public final class RecyclingByteBlockAll
    *          maximum number of buffered byte block
    * @param bytesUsed
    *          {@link AtomicLong} reference counting internally allocated bytes
-   * 
-   * @see DummyConcurrentLock
    */
   public RecyclingByteBlockAllocator(int blockSize, int maxBufferedBlocks,
       AtomicLong bytesUsed) {
@@ -56,8 +54,7 @@ public final class RecyclingByteBlockAll
   }
 
   /**
-   * Creates a new {@link RecyclingByteBlockAllocator} with a
-   * {@link DummyConcurrentLock} instance.
+   * Creates a new {@link RecyclingByteBlockAllocator}.
    * 
    * @param blockSize
    *          the block size in bytes
@@ -71,8 +68,7 @@ public final class RecyclingByteBlockAll
   /**
    * Creates a new {@link RecyclingByteBlockAllocator} with a block size of
    * {@link ByteBlockPool#BYTE_BLOCK_SIZE}, upper buffered docs limit of
-   * {@link #DEFAULT_BUFFERED_BLOCKS} ({@value #DEFAULT_BUFFERED_BLOCKS}) and a
-   * {@link DummyConcurrentLock} instance.
+   * {@link #DEFAULT_BUFFERED_BLOCKS} ({@value #DEFAULT_BUFFERED_BLOCKS}).
    * 
    */
   public RecyclingByteBlockAllocator() {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java Thu Jul 19 15:58:54 2012
@@ -588,7 +588,7 @@ public final class UnicodeUtil {
         out[out_offset++] = (char)(((b&0xf)<<12) + ((utf8[offset]&0x3f)<<6) + (utf8[offset+1]&0x3f));
         offset += 2;
       } else {
-        assert b < 0xf8: "b=" + b;
+        assert b < 0xf8: "b = 0x" + Integer.toHexString(b);
         int ch = ((b&0x7)<<18) + ((utf8[offset]&0x3f)<<12) + ((utf8[offset+1]&0x3f)<<6) + (utf8[offset+2]&0x3f);
         offset += 3;
         if (ch < UNI_MAX_BMP) {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Version.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Version.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Version.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/Version.java Thu Jul 19 15:58:54 2012
@@ -73,7 +73,7 @@ public enum Version { 
   }
   
   public static Version parseLeniently(String version) {
-    String parsedMatchVersion = version.toUpperCase(Locale.ENGLISH);
+    String parsedMatchVersion = version.toUpperCase(Locale.ROOT);
     return Version.valueOf(parsedMatchVersion.replaceFirst("^(\\d)\\.(\\d)$", "LUCENE_$1$2"));
   }
 }
\ No newline at end of file

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java Thu Jul 19 15:58:54 2012
@@ -21,7 +21,9 @@ import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -38,9 +40,10 @@ import java.util.concurrent.ConcurrentHa
  * 
  * <p>This implementation was forked from <a href="http://cxf.apache.org/">Apache CXF</a>
  * but modified to <b>not</b> implement the {@link java.util.Map} interface and
- * without any set/iterator views on it, as those are error-prone
- * and inefficient, if not implemented carefully. Lucene's implementation also
- * supports {@code null} keys, but those are never weak!
+ * without any set views on it, as those are error-prone and inefficient,
+ * if not implemented carefully. The map only contains {@link Iterator} implementations
+ * on the values and not-GCed keys. Lucene's implementation also supports {@code null}
+ * keys, but those are never weak!
  *
  * @lucene.internal
  */
@@ -97,6 +100,70 @@ public final class WeakIdentityMap<K,V> 
     reap();
     return backingStore.size();
   }
+  
+  /** Returns an iterator over all weak keys of this map.
+   * Keys already garbage collected will not be returned.
+   * This Iterator does not support removals. */
+  public Iterator<K> keyIterator() {
+    reap();
+    final Iterator<IdentityWeakReference> iterator = backingStore.keySet().iterator();
+    return new Iterator<K>() {
+      // holds strong reference to next element in backing iterator:
+      private Object next = null;
+      // the backing iterator was already consumed:
+      private boolean nextIsSet = false;
+    
+      @Override
+      public boolean hasNext() {
+        return nextIsSet ? true : 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;
+          }
+        }
+        throw new NoSuchElementException();
+      }
+      
+      @Override
+      public void remove() {
+        throw new UnsupportedOperationException();
+      }
+      
+      private boolean setNext() {
+        assert !nextIsSet;
+        while (iterator.hasNext()) {
+          next = iterator.next().get();
+          if (next == null) {
+            // already garbage collected!
+            continue;
+          }
+          // unfold "null" special value
+          if (next == NULL) {
+            next = null;
+          }
+          return nextIsSet = true;
+        }
+        return false;
+      }
+    };
+  }
+  
+  /** Returns an iterator over all values of this map.
+   * This iterator may return values whose key is already
+   * garbage collected while iterator is consumed. */
+  public Iterator<V> valueIterator() {
+    reap();
+    return backingStore.values().iterator();
+  }
 
   private void reap() {
     Reference<?> zombie;
@@ -104,6 +171,9 @@ public final class WeakIdentityMap<K,V> 
       backingStore.remove(zombie);
     }
   }
+  
+  // we keep a hard reference to our NULL key, so map supports null keys that never get GCed:
+  static final Object NULL = new Object();
 
   private static final class IdentityWeakReference extends WeakReference<Object> {
     private final int hash;
@@ -129,9 +199,6 @@ public final class WeakIdentityMap<K,V> 
       }
       return false;
     }
-  
-    // we keep a hard reference to our NULL key, so map supports null keys that never get GCed:
-    private static final Object NULL = new Object();
   }
 }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/BasicAutomata.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/BasicAutomata.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/BasicAutomata.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/BasicAutomata.java Thu Jul 19 15:58:54 2012
@@ -29,8 +29,9 @@
 
 package org.apache.lucene.util.automaton;
 
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.*;
+
+import org.apache.lucene.util.BytesRef;
 
 /**
  * Construction of basic automata.
@@ -239,4 +240,25 @@ final public class BasicAutomata {
     a.deterministic = true;
     return a;
   }
+
+  /**
+   * Returns a new (deterministic and minimal) automaton that accepts the union
+   * of the given collection of {@link BytesRef}s representing UTF-8 encoded
+   * strings.
+   * 
+   * @param utf8Strings
+   *          The input strings, UTF-8 encoded. The collection must be in sorted
+   *          order.
+   * 
+   * @return An {@link Automaton} accepting all input strings. The resulting
+   *         automaton is codepoint based (full unicode codepoints on
+   *         transitions).
+   */
+  public static Automaton makeStringUnion(Collection<BytesRef> utf8Strings) {
+    if (utf8Strings.isEmpty()) {
+      return makeEmpty();
+    } else {
+      return DaciukMihovAutomatonBuilder.build(utf8Strings);
+    }
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py Thu Jul 19 15:58:54 2012
@@ -121,7 +121,7 @@ def main():
 
   w('package org.apache.lucene.util.automaton;')
   w('')
-  w('/**')
+  w('/*')
   w(' * Licensed to the Apache Software Foundation (ASF) under one or more')
   w(' * contributor license agreements.  See the NOTICE file distributed with')
   w(' * this work for additional information regarding copyright ownership.')

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/FST.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/FST.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/FST.java Thu Jul 19 15:58:54 2012
@@ -28,12 +28,12 @@ import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.store.DataInput;
 import org.apache.lucene.store.DataOutput;
 import org.apache.lucene.store.InputStreamDataInput;
 import org.apache.lucene.store.OutputStreamDataOutput;
 import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.CodecUtil;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.IntsRef;
 import org.apache.lucene.util.PriorityQueue;
@@ -669,6 +669,8 @@ public final class FST<T> {
       // 2nd pass just "expands" all arcs to take up a fixed
       // byte size
       final int sizeNeeded = fixedArrayStart + nodeIn.numArcs * maxBytesPerArc;
+      assert ((long) fixedArrayStart) + ((long) nodeIn.numArcs) * maxBytesPerArc < Integer.MAX_VALUE: "FST too large (> 2.1 GB)";
+
       bytes = ArrayUtil.grow(bytes, sizeNeeded);
       // TODO: we could make this a vInt instead
       bytes[fixedArrayStart-4] = (byte) (maxBytesPerArc >> 24);
@@ -685,7 +687,7 @@ public final class FST<T> {
         destPos -= maxBytesPerArc;
         srcPos -= bytesPerArc[arcIdx];
         if (srcPos != destPos) {
-          assert destPos > srcPos;
+          assert destPos > srcPos: "destPos=" + destPos + " srcPos=" + srcPos + " arcIdx=" + arcIdx + " maxBytesPerArc=" + maxBytesPerArc + " bytesPerArc[arcIdx]=" + bytesPerArc[arcIdx] + " nodeIn.numArcs=" + nodeIn.numArcs;
           System.arraycopy(bytes, srcPos, bytes, destPos, bytesPerArc[arcIdx]);
         }
       }
@@ -1194,6 +1196,7 @@ public final class FST<T> {
     public void writeByte(byte b) {
       assert posWrite <= bytes.length;
       if (bytes.length == posWrite) {
+        assert bytes.length < Integer.MAX_VALUE: "FST too large (> 2.1 GB)";
         bytes = ArrayUtil.grow(bytes);
       }
       assert posWrite < bytes.length: "posWrite=" + posWrite + " bytes.length=" + bytes.length;
@@ -1203,6 +1206,7 @@ public final class FST<T> {
     public void setPosWrite(int posWrite) {
       this.posWrite = posWrite;
       if (bytes.length < posWrite) {
+        assert bytes.length < Integer.MAX_VALUE: "FST too large (> 2.1 GB)";
         bytes = ArrayUtil.grow(bytes, posWrite);
       }
     }
@@ -1210,6 +1214,7 @@ public final class FST<T> {
     @Override
     public void writeBytes(byte[] b, int offset, int length) {
       final int size = posWrite + length;
+      assert bytes.length < Integer.MAX_VALUE: "FST too large (> 2.1 GB)";
       bytes = ArrayUtil.grow(bytes, size);
       System.arraycopy(b, offset, bytes, posWrite, length);
       posWrite += length;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java Thu Jul 19 15:58:54 2012
@@ -155,6 +155,11 @@ final class NodeHash<T> {
 
   private void rehash() throws IOException {
     final int[] oldTable = table;
+
+    if (oldTable.length >= Integer.MAX_VALUE/2) {
+      throw new IllegalStateException("FST too large (> 2.1 GB)");
+    }
+
     table = new int[2*table.length];
     mask = table.length-1;
     for(int idx=0;idx<oldTable.length;idx++) {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/fst/PositiveIntOutputs.java Thu Jul 19 15:58:54 2012
@@ -42,6 +42,15 @@ public final class PositiveIntOutputs ex
     this.doShare = doShare;
   }
 
+  /** Returns the instance of PositiveIntOutputs. */
+  public static PositiveIntOutputs getSingleton() {
+    return getSingleton(true);
+  }
+
+  /** Expert: pass doShare=false to disable output sharing.
+   *  In some cases this may result in a smaller FST,
+   *  however it will also break methods like {@link
+   *  Util#getByOutput} and {@link Util#shortestPaths}. */
   public static PositiveIntOutputs getSingleton(boolean doShare) {
     return doShare ? singletonShare : singletonNoShare;
   }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+// This file has been automatically generated, DO NOT EDIT
+
 package org.apache.lucene.util.packed;
 
 /*
@@ -24,62 +26,37 @@ import java.io.IOException;
 import java.util.Arrays;
 
 /**
- * Direct wrapping of 16 bit values to a backing array of shorts.
+ * Direct wrapping of 16-bits values to a backing array.
  * @lucene.internal
  */
+final class Direct16 extends PackedInts.MutableImpl {
+  final short[] values;
 
-class Direct16 extends PackedInts.MutableImpl {
-  private final short[] values;
-  private static final int BITS_PER_VALUE = 16;
-
-  public Direct16(int valueCount) {
-    super(valueCount, BITS_PER_VALUE);
+  Direct16(int valueCount) {
+    super(valueCount, 16);
     values = new short[valueCount];
   }
 
-  public Direct16(DataInput in, int valueCount) throws IOException {
-    super(valueCount, BITS_PER_VALUE);
-    short[] values = new short[valueCount];
-    for(int i=0;i<valueCount;i++) {
+  Direct16(DataInput in, int valueCount) throws IOException {
+    this(valueCount);
+    for (int i = 0; i < valueCount; ++i) {
       values[i] = in.readShort();
     }
     final int mod = valueCount % 4;
     if (mod != 0) {
-      final int pad = 4-mod;
-      // round out long
-      for(int i=0;i<pad;i++) {
+      for (int i = mod; i < 4; ++i) {
         in.readShort();
       }
     }
-
-    this.values = values;
-  }
-
-  /**
-   * Creates an array backed by the given values.
-   * </p><p>
-   * Note: The values are used directly, so changes to the values will
-   * affect the structure.
-   * @param values   used as the internal backing array.
-   */
-  public Direct16(short[] values) {
-    super(values.length, BITS_PER_VALUE);
-    this.values = values;
   }
 
+  @Override
   public long get(final int index) {
-    assert index >= 0 && index < size();
-    return 0xFFFFL & values[index];
+    return values[index] & 0xFFFFL;
   }
 
   public void set(final int index, final long value) {
-    values[index] = (short)(value & 0xFFFF);
-  }
-
-  @Override
-  public void fill(int fromIndex, int toIndex, long val) {
-    assert (val & 0xffffL) == val;
-    Arrays.fill(values, fromIndex, toIndex, (short) val);
+    values[index] = (short) (value);
   }
 
   public long ramBytesUsed() {
@@ -87,7 +64,7 @@ class Direct16 extends PackedInts.Mutabl
   }
 
   public void clear() {
-    Arrays.fill(values, (short)0);
+    Arrays.fill(values, (short) 0L);
   }
 
   @Override
@@ -99,4 +76,35 @@ class Direct16 extends PackedInts.Mutabl
   public boolean hasArray() {
     return true;
   }
+
+  @Override
+  public int get(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int gets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + gets; i < end; ++i, ++o) {
+      arr[o] = values[i] & 0xFFFFL;
+    }
+    return gets;
+  }
+
+  public int set(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int sets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + sets; i < end; ++i, ++o) {
+      values[i] = (short) arr[o];
+    }
+    return sets;
+  }
+
+  @Override
+  public void fill(int fromIndex, int toIndex, long val) {
+    assert val == (val & 0xFFFFL);
+    Arrays.fill(values, fromIndex, toIndex, (short) val);
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+// This file has been automatically generated, DO NOT EDIT
+
 package org.apache.lucene.util.packed;
 
 /*
@@ -24,58 +26,37 @@ import java.io.IOException;
 import java.util.Arrays;
 
 /**
- * Direct wrapping of 32 bit values to a backing array of ints.
+ * Direct wrapping of 32-bits values to a backing array.
  * @lucene.internal
  */
+final class Direct32 extends PackedInts.MutableImpl {
+  final int[] values;
 
-class Direct32 extends PackedInts.MutableImpl {
-  private final int[] values;
-  private static final int BITS_PER_VALUE = 32;
-
-  public Direct32(int valueCount) {
-    super(valueCount, BITS_PER_VALUE);
+  Direct32(int valueCount) {
+    super(valueCount, 32);
     values = new int[valueCount];
   }
 
-  public Direct32(DataInput in, int valueCount) throws IOException {
-    super(valueCount, BITS_PER_VALUE);
-    int[] values = new int[valueCount];
-    for(int i=0;i<valueCount;i++) {
+  Direct32(DataInput in, int valueCount) throws IOException {
+    this(valueCount);
+    for (int i = 0; i < valueCount; ++i) {
       values[i] = in.readInt();
     }
     final int mod = valueCount % 2;
     if (mod != 0) {
-      in.readInt();
+      for (int i = mod; i < 2; ++i) {
+        in.readInt();
+      }
     }
-
-    this.values = values;
-  }
-
-  /**
-   * Creates an array backed by the given values.
-   * </p><p>
-   * Note: The values are used directly, so changes to the given values will
-   * affect the structure.
-   * @param values   used as the internal backing array.
-   */
-  public Direct32(int[] values) {
-    super(values.length, BITS_PER_VALUE);
-    this.values = values;
   }
 
+  @Override
   public long get(final int index) {
-    assert index >= 0 && index < size();
-    return 0xFFFFFFFFL & values[index];
+    return values[index] & 0xFFFFFFFFL;
   }
 
   public void set(final int index, final long value) {
-    values[index] = (int)(value & 0xFFFFFFFF);
-  }
-
-  @Override
-  public void fill(int fromIndex, int toIndex, long val) {
-    assert (val & 0xffffffffL) == val;
-    Arrays.fill(values, fromIndex, toIndex, (int) val);
+    values[index] = (int) (value);
   }
 
   public long ramBytesUsed() {
@@ -83,11 +64,11 @@ class Direct32 extends PackedInts.Mutabl
   }
 
   public void clear() {
-    Arrays.fill(values, 0);
+    Arrays.fill(values, (int) 0L);
   }
-  
+
   @Override
-  public int[] getArray() {
+  public Object getArray() {
     return values;
   }
 
@@ -95,4 +76,35 @@ class Direct32 extends PackedInts.Mutabl
   public boolean hasArray() {
     return true;
   }
+
+  @Override
+  public int get(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int gets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + gets; i < end; ++i, ++o) {
+      arr[o] = values[i] & 0xFFFFFFFFL;
+    }
+    return gets;
+  }
+
+  public int set(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int sets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + sets; i < end; ++i, ++o) {
+      values[i] = (int) arr[o];
+    }
+    return sets;
+  }
+
+  @Override
+  public void fill(int fromIndex, int toIndex, long val) {
+    assert val == (val & 0xFFFFFFFFL);
+    Arrays.fill(values, fromIndex, toIndex, (int) val);
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+// This file has been automatically generated, DO NOT EDIT
+
 package org.apache.lucene.util.packed;
 
 /*
@@ -24,62 +26,67 @@ import java.io.IOException;
 import java.util.Arrays;
 
 /**
- * Direct wrapping of 64 bit values to a backing array of longs.
+ * Direct wrapping of 64-bits values to a backing array.
  * @lucene.internal
  */
-class Direct64 extends PackedInts.MutableImpl {
-  private final long[] values;
-  private static final int BITS_PER_VALUE = 64;
+final class Direct64 extends PackedInts.MutableImpl {
+  final long[] values;
 
-  public Direct64(int valueCount) {
-    super(valueCount, BITS_PER_VALUE);
+  Direct64(int valueCount) {
+    super(valueCount, 64);
     values = new long[valueCount];
   }
 
-  public Direct64(DataInput in, int valueCount) throws IOException {
-    super(valueCount, BITS_PER_VALUE);
-    long[] values = new long[valueCount];
-    for(int i=0;i<valueCount;i++) {
+  Direct64(DataInput in, int valueCount) throws IOException {
+    this(valueCount);
+    for (int i = 0; i < valueCount; ++i) {
       values[i] = in.readLong();
     }
+  }
+
+  @Override
+  public long get(final int index) {
+    return values[index];
+  }
 
-    this.values = values;
+  public void set(final int index, final long value) {
+    values[index] = (value);
   }
 
-  /**
-   * Creates an array backed by the given values.
-   * </p><p>
-   * Note: The values are used directly, so changes to the given values will
-   * affect the structure.
-   * @param values   used as the internal backing array.
-   */
-  public Direct64(long[] values) {
-    super(values.length, BITS_PER_VALUE);
-    this.values = values;
+  public long ramBytesUsed() {
+    return RamUsageEstimator.sizeOf(values);
   }
 
-  public long get(final int index) {
-    assert index >= 0 && index < size();
-    return values[index];
+  public void clear() {
+    Arrays.fill(values, 0L);
+  }
+
+  @Override
+  public Object getArray() {
+    return values;
+  }
+
+  @Override
+  public boolean hasArray() {
+    return true;
   }
 
   @Override
   public int get(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
     assert index >= 0 && index < valueCount;
     assert off + len <= arr.length;
+
     final int gets = Math.min(valueCount - index, len);
     System.arraycopy(values, index, arr, off, gets);
     return gets;
   }
 
-  public void set(final int index, final long value) {
-    values[index] = value;
-  }
-
-  @Override
   public int set(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
     assert index >= 0 && index < valueCount;
     assert off + len <= arr.length;
+
     final int sets = Math.min(valueCount - index, len);
     System.arraycopy(arr, off, values, index, sets);
     return sets;
@@ -89,23 +96,4 @@ class Direct64 extends PackedInts.Mutabl
   public void fill(int fromIndex, int toIndex, long val) {
     Arrays.fill(values, fromIndex, toIndex, val);
   }
-
-  public long ramBytesUsed() {
-    return RamUsageEstimator.sizeOf(values);
-  }
-
-  public void clear() {
-    Arrays.fill(values, 0L);
-  }
-
-  @Override
-  public long[] getArray() {
-    return values;
-  }
-
-  @Override
-  public boolean hasArray() {
-    return true;
-  }
-
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+// This file has been automatically generated, DO NOT EDIT
+
 package org.apache.lucene.util.packed;
 
 /*
@@ -24,63 +26,37 @@ import java.io.IOException;
 import java.util.Arrays;
 
 /**
- * Direct wrapping of 8 bit values to a backing array of bytes.
+ * Direct wrapping of 8-bits values to a backing array.
  * @lucene.internal
  */
+final class Direct8 extends PackedInts.MutableImpl {
+  final byte[] values;
 
-class Direct8 extends PackedInts.MutableImpl {
-  private final byte[] values;
-  private static final int BITS_PER_VALUE = 8;
-
-  public Direct8(int valueCount) {
-    super(valueCount, BITS_PER_VALUE);
+  Direct8(int valueCount) {
+    super(valueCount, 8);
     values = new byte[valueCount];
   }
 
-  public Direct8(DataInput in, int valueCount)
-          throws IOException {
-    super(valueCount, BITS_PER_VALUE);
-    byte[] values = new byte[valueCount];
-    for(int i=0;i<valueCount;i++) {
+  Direct8(DataInput in, int valueCount) throws IOException {
+    this(valueCount);
+    for (int i = 0; i < valueCount; ++i) {
       values[i] = in.readByte();
     }
     final int mod = valueCount % 8;
     if (mod != 0) {
-      final int pad = 8-mod;
-      // round out long
-      for(int i=0;i<pad;i++) {
+      for (int i = mod; i < 8; ++i) {
         in.readByte();
       }
     }
-
-    this.values = values;
-  }
-
-  /**
-   * Creates an array backed by the given values.
-   * </p><p>
-   * Note: The values are used directly, so changes to the given values will
-   * affect the structure.
-   * @param values used as the internal backing array.
-   */
-  public Direct8(byte[] values) {
-    super(values.length, BITS_PER_VALUE);
-    this.values = values;
   }
 
+  @Override
   public long get(final int index) {
-    assert index >= 0 && index < size();
-    return 0xFFL & values[index];
+    return values[index] & 0xFFL;
   }
 
   public void set(final int index, final long value) {
-    values[index] = (byte)(value & 0xFF);
-  }
-
-  @Override
-  public void fill(int fromIndex, int toIndex, long val) {
-    assert (val & 0xffL) == val;
-    Arrays.fill(values, fromIndex, toIndex, (byte) val);
+    values[index] = (byte) (value);
   }
 
   public long ramBytesUsed() {
@@ -88,7 +64,7 @@ class Direct8 extends PackedInts.Mutable
   }
 
   public void clear() {
-    Arrays.fill(values, (byte)0);
+    Arrays.fill(values, (byte) 0L);
   }
 
   @Override
@@ -100,4 +76,35 @@ class Direct8 extends PackedInts.Mutable
   public boolean hasArray() {
     return true;
   }
+
+  @Override
+  public int get(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int gets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + gets; i < end; ++i, ++o) {
+      arr[o] = values[i] & 0xFFL;
+    }
+    return gets;
+  }
+
+  public int set(int index, long[] arr, int off, int len) {
+    assert len > 0 : "len must be > 0 (got " + len + ")";
+    assert index >= 0 && index < valueCount;
+    assert off + len <= arr.length;
+
+    final int sets = Math.min(valueCount - index, len);
+    for (int i = index, o = off, end = index + sets; i < end; ++i, ++o) {
+      values[i] = (byte) arr[o];
+    }
+    return sets;
+  }
+
+  @Override
+  public void fill(int fromIndex, int toIndex, long val) {
+    assert val == (val & 0xFFL);
+    Arrays.fill(values, fromIndex, toIndex, (byte) val);
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/DirectPackedReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/DirectPackedReader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/DirectPackedReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/util/packed/DirectPackedReader.java Thu Jul 19 15:58:54 2012
@@ -32,8 +32,7 @@ final class DirectPackedReader extends P
   // masks[n-1] masks for bottom n bits
   private final long[] masks;
 
-  public DirectPackedReader(int bitsPerValue, int valueCount, IndexInput in)
-    throws IOException {
+  public DirectPackedReader(int bitsPerValue, int valueCount, IndexInput in) {
     super(valueCount, bitsPerValue);
     this.in = in;