You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/08/21 15:20:30 UTC
svn commit: r1375530 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/ lucene/core/src/java/org/apache/lucene/codecs/
lucene/core/src/java/org/apache/lucene/codecs/bloom/
lucene/core/src/java/org/apache/lucene/codecs/lucene3x/ lucene/core/sr...
Author: uschindler
Date: Tue Aug 21 13:20:28 2012
New Revision: 1375530
URL: http://svn.apache.org/viewvc?rev=1375530&view=rev
Log:
Merged revision(s) 1375522 from lucene/dev/trunk:
LUCENE-4315: Minor fixes for Fields abstract class, TermVectorsWriter, remove UnmodifiableIterator (added before, without issue).
Removed:
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnmodifiableIterator.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/Fields.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingPostingsFormat.java
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java Tue Aug 21 13:20:28 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs;
*/
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeMap;
@@ -39,7 +40,6 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.DoubleBarrelLRUCache;
-import org.apache.lucene.util.UnmodifiableIterator;
/** Handles a terms dict, but decouples all details of
* doc/freqs/positions reading to an instance of {@link
@@ -185,7 +185,7 @@ public class BlockTermsReader extends Fi
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java Tue Aug 21 13:20:28 2012
@@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Locale;
@@ -45,7 +46,6 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.StringHelper;
-import org.apache.lucene.util.UnmodifiableIterator;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RunAutomaton;
import org.apache.lucene.util.automaton.Transition;
@@ -200,7 +200,7 @@ public class BlockTreeTermsReader extend
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java Tue Aug 21 13:20:28 2012
@@ -20,6 +20,7 @@ package org.apache.lucene.codecs;
import java.io.Closeable;
import java.io.IOException;
import java.util.Comparator;
+import java.util.Iterator;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.DocsAndPositionsEnum;
@@ -187,19 +188,21 @@ public abstract class TermVectorsWriter
}
/** Safe (but, slowish) default method to write every
- * vector field in the document. This default
- * implementation requires that the vectors implement
- * both Fields.size and
- * Terms.size. */
+ * vector field in the document. */
protected final void addAllDocVectors(Fields vectors, MergeState mergeState) throws IOException {
if (vectors == null) {
startDocument(0);
return;
}
- final int numFields = vectors.size();
+ int numFields = vectors.size();
if (numFields == -1) {
- throw new IllegalStateException("vectors.size() must be implemented (it returned -1)");
+ // count manually! TODO: Maybe enforce that Fields.size() returns something valid?
+ numFields = 0;
+ for (final Iterator<String> it = vectors.iterator(); it.hasNext(); ) {
+ it.next();
+ numFields++;
+ }
}
startDocument(numFields);
@@ -208,7 +211,9 @@ public abstract class TermVectorsWriter
TermsEnum termsEnum = null;
DocsAndPositionsEnum docsAndPositionsEnum = null;
+ int fieldCount = 0;
for(String fieldName : vectors) {
+ fieldCount++;
final FieldInfo fieldInfo = mergeState.fieldInfos.fieldInfo(fieldName);
assert lastFieldName == null || fieldName.compareTo(lastFieldName) > 0: "lastFieldName=" + lastFieldName + " fieldName=" + fieldName;
@@ -225,9 +230,14 @@ public abstract class TermVectorsWriter
final boolean hasPayloads = terms.hasPayloads();
assert !hasPayloads || hasPositions;
- final int numTerms = (int) terms.size();
+ int numTerms = (int) terms.size();
if (numTerms == -1) {
- throw new IllegalStateException("terms.size() must be implemented (it returned -1)");
+ // count manually. It is stupid, but needed, as Terms.size() is not a mandatory statistics function
+ numTerms = 0;
+ termsEnum = terms.iterator(termsEnum);
+ while(termsEnum.next() != null) {
+ numTerms++;
+ }
}
startField(fieldInfo, numTerms, hasPositions, hasOffsets, hasPayloads);
@@ -263,6 +273,7 @@ public abstract class TermVectorsWriter
}
assert termCount == numTerms;
}
+ assert fieldCount == numFields;
}
/** Return the BytesRef Comparator used to sort terms
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -207,7 +207,7 @@ public class BloomFilteringPostingsForma
}
}
- public int size() throws IOException {
+ public int size() {
return delegateFieldsProducer.size();
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java Tue Aug 21 13:20:28 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs.lucene3
*/
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -41,7 +42,6 @@ import org.apache.lucene.store.IndexInpu
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.UnmodifiableIterator;
/** Exposes flex API on a pre-flex index, as a codec.
* @lucene.experimental
@@ -134,7 +134,7 @@ class Lucene3xFields extends FieldsProdu
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
@@ -144,7 +144,8 @@ class Lucene3xFields extends FieldsProdu
@Override
public int size() {
- return preTerms.size();
+ assert preTerms.size() == fields.size();
+ return fields.size();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs.memory;
*/
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
@@ -43,7 +44,6 @@ import org.apache.lucene.store.RAMOutput
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.UnmodifiableIterator;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RunAutomaton;
import org.apache.lucene.util.automaton.Transition;
@@ -131,7 +131,7 @@ public class DirectPostingsFormat extend
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs.memory;
*/
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedMap;
@@ -48,7 +49,6 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IntsRef;
-import org.apache.lucene.util.UnmodifiableIterator;
import org.apache.lucene.util.fst.Builder;
import org.apache.lucene.util.fst.ByteSequenceOutputs;
import org.apache.lucene.util.fst.BytesRefFSTEnum;
@@ -863,7 +863,7 @@ public class MemoryPostingsFormat extend
return new FieldsProducer() {
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.perfiel
import java.io.Closeable;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -34,7 +35,6 @@ import org.apache.lucene.index.SegmentRe
import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.index.Terms;
import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.UnmodifiableIterator;
/**
* Enables per field format support.
@@ -199,7 +199,7 @@ public abstract class PerFieldPostingsFo
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java Tue Aug 21 13:20:28 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs.simplet
*/
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -43,7 +44,6 @@ import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.OpenBitSet;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.UnmodifiableIterator;
import org.apache.lucene.util.fst.Builder;
import org.apache.lucene.util.fst.BytesRefFSTEnum;
import org.apache.lucene.util.fst.FST;
@@ -608,7 +608,7 @@ class SimpleTextFieldsReader extends Fie
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
private final Map<String,Terms> termsCache = new HashMap<String,Terms>();
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java Tue Aug 21 13:20:28 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.simplet
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
@@ -44,8 +45,6 @@ import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.UnmodifiableIterator;
-
import static org.apache.lucene.codecs.simpletext.SimpleTextTermVectorsWriter.*;
/**
@@ -241,7 +240,7 @@ public class SimpleTextTermVectorsReader
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
@@ -250,7 +249,7 @@ public class SimpleTextTermVectorsReader
}
@Override
- public int size() throws IOException {
+ public int size() {
return fields.size();
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/Fields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/Fields.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/Fields.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/Fields.java Tue Aug 21 13:20:28 2012
@@ -36,7 +36,7 @@ public abstract class Fields implements
/** Returns the number of fields or -1 if the number of
* distinct field names is unknown. If >= 0,
* {@link #iterator} will return as many field names. */
- public abstract int size() throws IOException;
+ public abstract int size();
/** Returns the number of terms for all fields, or -1 if this
* measure isn't stored by the codec. Note that, just like
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java Tue Aug 21 13:20:28 2012
@@ -57,7 +57,7 @@ public class FilterAtomicReader extends
}
@Override
- public int size() throws IOException {
+ public int size() {
return in.size();
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java Tue Aug 21 13:20:28 2012
@@ -27,7 +27,6 @@ import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.UnmodifiableIterator;
/** An {@link AtomicReader} which reads multiple, parallel indexes. Each index
@@ -163,7 +162,7 @@ public final class ParallelAtomicReader
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fields.keySet().iterator());
+ return Collections.unmodifiableSet(fields.keySet()).iterator();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java Tue Aug 21 13:20:28 2012
@@ -1110,14 +1110,8 @@ class FieldCacheImpl implements FieldCac
// Try for coarse estimate for number of bits; this
// should be an underestimate most of the time, which
// is fine -- GrowableWriter will reallocate as needed
- long numUniqueTerms = 0;
- try {
- numUniqueTerms = terms.size();
- } catch (UnsupportedOperationException uoe) {
- numUniqueTerms = -1;
- }
- if (numUniqueTerms != -1) {
-
+ long numUniqueTerms = terms.size();
+ if (numUniqueTerms != -1L) {
if (numUniqueTerms > termCountHardLimit) {
// app is misusing the API (there is more than
// one term per doc); in this case we make best
@@ -1248,13 +1242,8 @@ class FieldCacheImpl implements FieldCac
// Try for coarse estimate for number of bits; this
// should be an underestimate most of the time, which
// is fine -- GrowableWriter will reallocate as needed
- long numUniqueTerms = 0;
- try {
- numUniqueTerms = terms.size();
- } catch (UnsupportedOperationException uoe) {
- numUniqueTerms = -1;
- }
- if (numUniqueTerms != -1) {
+ long numUniqueTerms = terms.size();
+ if (numUniqueTerms != -1L) {
if (numUniqueTerms > termCountHardLimit) {
numUniqueTerms = termCountHardLimit;
}
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -83,7 +83,7 @@ public class AssertingPostingsFormat ext
}
@Override
- public int size() throws IOException {
+ public int size() {
return in.size();
}
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java?rev=1375530&r1=1375529&r2=1375530&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java Tue Aug 21 13:20:28 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.ramonly
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -49,7 +50,6 @@ import org.apache.lucene.store.IndexOutp
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.UnmodifiableIterator;
/** Stores all postings data in RAM, but writes a small
* token (header + single int) to identify which "slot" the
@@ -113,7 +113,7 @@ public class RAMOnlyPostingsFormat exten
@Override
public Iterator<String> iterator() {
- return new UnmodifiableIterator<String>(fieldToTerms.keySet().iterator());
+ return Collections.unmodifiableSet(fieldToTerms.keySet()).iterator();
}
@Override