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 2014/02/26 15:44:12 UTC
svn commit: r1572063 [6/22] - in /lucene/dev/branches/lucene5376: ./
dev-tools/ dev-tools/idea/.idea/ dev-tools/idea/lucene/sandbox/
dev-tools/idea/solr/contrib/morphlines-core/ dev-tools/maven/lucene/
dev-tools/maven/lucene/core/src/java/ dev-tools/ma...
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java Wed Feb 26 14:43:56 2014
@@ -27,7 +27,7 @@ import java.util.LinkedHashMap;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.OpenBitSet;
+import org.apache.lucene.util.FixedBitSet;
final class SloppyPhraseScorer extends Scorer {
private PhrasePositions min, max;
@@ -152,7 +152,7 @@ final class SloppyPhraseScorer extends S
return true; // not a repeater
}
PhrasePositions[] rg = rptGroups[pp.rptGroup];
- OpenBitSet bits = new OpenBitSet(rg.length); // for re-queuing after collisions are resolved
+ FixedBitSet bits = new FixedBitSet(rg.length); // for re-queuing after collisions are resolved
int k0 = pp.rptInd;
int k;
while((k=collide(pp)) >= 0) {
@@ -161,16 +161,21 @@ final class SloppyPhraseScorer extends S
return false; // exhausted
}
if (k != k0) { // careful: mark only those currently in the queue
+ bits = FixedBitSet.ensureCapacity(bits, k);
bits.set(k); // mark that pp2 need to be re-queued
}
}
// collisions resolved, now re-queue
// empty (partially) the queue until seeing all pps advanced for resolving collisions
int n = 0;
+ // TODO would be good if we can avoid calling cardinality() in each iteration!
+ int numBits = bits.length(); // larges bit we set
while (bits.cardinality() > 0) {
PhrasePositions pp2 = pq.pop();
rptStack[n++] = pp2;
- if (pp2.rptGroup >= 0 && bits.get(pp2.rptInd)) {
+ if (pp2.rptGroup >= 0
+ && pp2.rptInd < numBits // this bit may not have been set
+ && bits.get(pp2.rptInd)) {
bits.clear(pp2.rptInd);
}
}
@@ -405,7 +410,7 @@ final class SloppyPhraseScorer extends S
} else {
// more involved - has multi-terms
ArrayList<HashSet<PhrasePositions>> tmp = new ArrayList<HashSet<PhrasePositions>>();
- ArrayList<OpenBitSet> bb = ppTermsBitSets(rpp, rptTerms);
+ ArrayList<FixedBitSet> bb = ppTermsBitSets(rpp, rptTerms);
unionTermGroups(bb);
HashMap<Term,Integer> tg = termGroups(rptTerms, bb);
HashSet<Integer> distinctGroupIDs = new HashSet<Integer>(tg.values());
@@ -467,10 +472,10 @@ final class SloppyPhraseScorer extends S
}
/** bit-sets - for each repeating pp, for each of its repeating terms, the term ordinal values is set */
- private ArrayList<OpenBitSet> ppTermsBitSets(PhrasePositions[] rpp, HashMap<Term,Integer> tord) {
- ArrayList<OpenBitSet> bb = new ArrayList<OpenBitSet>(rpp.length);
+ private ArrayList<FixedBitSet> ppTermsBitSets(PhrasePositions[] rpp, HashMap<Term,Integer> tord) {
+ ArrayList<FixedBitSet> bb = new ArrayList<FixedBitSet>(rpp.length);
for (PhrasePositions pp : rpp) {
- OpenBitSet b = new OpenBitSet(tord.size());
+ FixedBitSet b = new FixedBitSet(tord.size());
Integer ord;
for (Term t: pp.terms) {
if ((ord=tord.get(t))!=null) {
@@ -483,14 +488,14 @@ final class SloppyPhraseScorer extends S
}
/** union (term group) bit-sets until they are disjoint (O(n^^2)), and each group have different terms */
- private void unionTermGroups(ArrayList<OpenBitSet> bb) {
+ private void unionTermGroups(ArrayList<FixedBitSet> bb) {
int incr;
for (int i=0; i<bb.size()-1; i+=incr) {
incr = 1;
int j = i+1;
while (j<bb.size()) {
if (bb.get(i).intersects(bb.get(j))) {
- bb.get(i).union(bb.get(j));
+ bb.get(i).or(bb.get(j));
bb.remove(j);
incr = 0;
} else {
@@ -501,7 +506,7 @@ final class SloppyPhraseScorer extends S
}
/** map each term to the single group that contains it */
- private HashMap<Term,Integer> termGroups(LinkedHashMap<Term,Integer> tord, ArrayList<OpenBitSet> bb) throws IOException {
+ private HashMap<Term,Integer> termGroups(LinkedHashMap<Term,Integer> tord, ArrayList<FixedBitSet> bb) throws IOException {
HashMap<Term,Integer> tg = new HashMap<Term,Integer>();
Term[] t = tord.keySet().toArray(new Term[0]);
for (int i=0; i<bb.size(); i++) { // i is the group no.
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SortField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SortField.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SortField.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/SortField.java Wed Feb 26 14:43:56 2014
@@ -23,10 +23,6 @@ import java.util.Comparator;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.StringHelper;
-// TODO(simonw) -- for cleaner transition, maybe we should make
-// a new SortField that subclasses this one and always uses
-// index values?
-
/**
* Stores information about how to sort documents by terms in an individual
* field. Fields must be indexed in order to sort by them.
@@ -106,9 +102,6 @@ public class SortField {
// Used for 'sortMissingFirst/Last'
public Object missingValue = null;
- // Only used with type=STRING
- public boolean sortMissingLast;
-
/** Creates a sort by terms in the given field with the type of term
* values explicitly given.
* @param field Name of field to sort by. Can be <code>null</code> if
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java Wed Feb 26 14:43:56 2014
@@ -64,9 +64,9 @@ public class SpanNearQuery extends SpanQ
this.clauses = new ArrayList<SpanQuery>(clauses.length);
for (int i = 0; i < clauses.length; i++) {
SpanQuery clause = clauses[i];
- if (i == 0) { // check field
+ if (field == null) { // check field
field = clause.getField();
- } else if (!clause.getField().equals(field)) {
+ } else if (clause.getField() != null && !clause.getField().equals(field)) {
throw new IllegalArgumentException("Clauses must have same field.");
}
this.clauses.add(clause);
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java Wed Feb 26 14:43:56 2014
@@ -62,7 +62,7 @@ public class SpanNotQuery extends SpanQu
this.pre = (pre >=0) ? pre : 0;
this.post = (post >= 0) ? post : 0;
- if (!include.getField().equals(exclude.getField()))
+ if (include.getField() != null && exclude.getField() != null && !include.getField().equals(exclude.getField()))
throw new IllegalArgumentException("Clauses must have same field.");
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Wed Feb 26 14:43:56 2014
@@ -54,7 +54,7 @@ public class SpanOrQuery extends SpanQue
public final void addClause(SpanQuery clause) {
if (field == null) {
field = clause.getField();
- } else if (!clause.getField().equals(field)) {
+ } else if (clause.getField() != null && !clause.getField().equals(field)) {
throw new IllegalArgumentException("Clauses must have same field.");
}
this.clauses.add(clause);
@@ -132,7 +132,6 @@ public class SpanOrQuery extends SpanQue
final SpanOrQuery that = (SpanOrQuery) o;
if (!clauses.equals(that.clauses)) return false;
- if (!clauses.isEmpty() && !field.equals(that.field)) return false;
return getBoost() == that.getBoost();
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java Wed Feb 26 14:43:56 2014
@@ -34,7 +34,11 @@ public abstract class SpanQuery extends
* to search for spans. */
public abstract Spans getSpans(AtomicReaderContext context, Bits acceptDocs, Map<Term,TermContext> termContexts) throws IOException;
- /** Returns the name of the field matched by this query.*/
+ /**
+ * Returns the name of the field matched by this query.
+ * <p>
+ * Note that this may return null if the query matches no terms.
+ */
public abstract String getField();
@Override
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java Wed Feb 26 14:43:56 2014
@@ -23,22 +23,117 @@ import java.util.Arrays;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
-// TODO: maybe merge with BitVector? Problem is BitVector
-// caches its cardinality...
-
-/** BitSet of fixed length (numBits), backed by accessible
- * ({@link #getBits}) long[], accessed with an int index,
- * implementing Bits and DocIdSet. Unlike {@link
- * OpenBitSet} this bit set does not auto-expand, cannot
- * handle long index, and does not have fastXX/XX variants
- * (just X).
- *
+/**
+ * BitSet of fixed length (numBits), backed by accessible ({@link #getBits})
+ * long[], accessed with an int index, implementing {@link Bits} and
+ * {@link DocIdSet}. If you need to manage more than 2.1B bits, use
+ * {@link LongBitSet}.
+ *
* @lucene.internal
- **/
+ */
public final class FixedBitSet extends DocIdSet implements Bits {
- private final long[] bits;
- private final int numBits;
- private final int wordLength;
+
+ /**
+ * A {@link DocIdSetIterator} which iterates over set bits in a
+ * {@link FixedBitSet}.
+ */
+ public static final class FixedBitSetIterator extends DocIdSetIterator {
+
+ final int numBits, numWords;
+ final long[] bits;
+ int doc = -1;
+
+ /** Creates an iterator over the given {@link FixedBitSet}. */
+ public FixedBitSetIterator(FixedBitSet bits) {
+ this(bits.bits, bits.numBits, bits.numWords);
+ }
+
+ /** Creates an iterator over the given array of bits. */
+ public FixedBitSetIterator(long[] bits, int numBits, int wordLength) {
+ this.bits = bits;
+ this.numBits = numBits;
+ this.numWords = wordLength;
+ }
+
+ @Override
+ public int nextDoc() {
+ if (doc == NO_MORE_DOCS || ++doc >= numBits) {
+ return doc = NO_MORE_DOCS;
+ }
+ int i = doc >> 6;
+ final int subIndex = doc & 0x3f; // index within the word
+ long word = bits[i] >> subIndex; // skip all the bits to the right of index
+
+ if (word != 0) {
+ return doc = doc + Long.numberOfTrailingZeros(word);
+ }
+
+ while (++i < numWords) {
+ word = bits[i];
+ if (word != 0) {
+ return doc = (i << 6) + Long.numberOfTrailingZeros(word);
+ }
+ }
+
+ return doc = NO_MORE_DOCS;
+ }
+
+ @Override
+ public int docID() {
+ return doc;
+ }
+
+ @Override
+ public long cost() {
+ return numBits;
+ }
+
+ @Override
+ public int advance(int target) {
+ if (doc == NO_MORE_DOCS || target >= numBits) {
+ return doc = NO_MORE_DOCS;
+ }
+ int i = target >> 6;
+ final int subIndex = target & 0x3f; // index within the word
+ long word = bits[i] >> subIndex; // skip all the bits to the right of index
+
+ if (word != 0) {
+ return doc = target + Long.numberOfTrailingZeros(word);
+ }
+
+ while (++i < numWords) {
+ word = bits[i];
+ if (word != 0) {
+ return doc = (i << 6) + Long.numberOfTrailingZeros(word);
+ }
+ }
+
+ return doc = NO_MORE_DOCS;
+ }
+ }
+
+ /**
+ * If the given {@link FixedBitSet} is large enough to hold {@code numBits},
+ * returns the given bits, otherwise returns a new {@link FixedBitSet} which
+ * can hold the requested number of bits.
+ *
+ * <p>
+ * <b>NOTE:</b> the returned bitset reuses the underlying {@code long[]} of
+ * the given {@code bits} if possible. Also, calling {@link #length()} on the
+ * returned bits may return a value greater than {@code numBits}.
+ */
+ public static FixedBitSet ensureCapacity(FixedBitSet bits, int numBits) {
+ if (numBits < bits.length()) {
+ return bits;
+ } else {
+ int numWords = bits2words(numBits);
+ long[] arr = bits.getBits();
+ if (numWords >= arr.length) {
+ arr = ArrayUtil.grow(arr, numWords + 1);
+ }
+ return new FixedBitSet(arr, arr.length << 6);
+ }
+ }
/** returns the number of 64 bit words it would take to hold numBits */
public static int bits2words(int numBits) {
@@ -49,97 +144,62 @@ public final class FixedBitSet extends D
return numLong;
}
+ /**
+ * Returns the popcount or cardinality of the intersection of the two sets.
+ * Neither set is modified.
+ */
+ public static long intersectionCount(FixedBitSet a, FixedBitSet b) {
+ return BitUtil.pop_intersect(a.bits, b.bits, 0, Math.min(a.numWords, b.numWords));
+ }
+
+ /**
+ * Returns the popcount or cardinality of the union of the two sets. Neither
+ * set is modified.
+ */
+ public static long unionCount(FixedBitSet a, FixedBitSet b) {
+ long tot = BitUtil.pop_union(a.bits, b.bits, 0, Math.min(a.numWords, b.numWords));
+ if (a.numWords < b.numWords) {
+ tot += BitUtil.pop_array(b.bits, a.numWords, b.numWords - a.numWords);
+ } else if (a.numWords > b.numWords) {
+ tot += BitUtil.pop_array(a.bits, b.numWords, a.numWords - b.numWords);
+ }
+ return tot;
+ }
+
+ /**
+ * Returns the popcount or cardinality of "a and not b" or
+ * "intersection(a, not(b))". Neither set is modified.
+ */
+ public static long andNotCount(FixedBitSet a, FixedBitSet b) {
+ long tot = BitUtil.pop_andnot(a.bits, b.bits, 0, Math.min(a.numWords, b.numWords));
+ if (a.numWords > b.numWords) {
+ tot += BitUtil.pop_array(a.bits, b.numWords, a.numWords - b.numWords);
+ }
+ return tot;
+ }
+
+ final long[] bits;
+ final int numBits;
+ final int numWords;
+
public FixedBitSet(int numBits) {
this.numBits = numBits;
bits = new long[bits2words(numBits)];
- wordLength = bits.length;
+ numWords = bits.length;
}
public FixedBitSet(long[] storedBits, int numBits) {
- this.wordLength = bits2words(numBits);
- if (wordLength > storedBits.length) {
+ this.numWords = bits2words(numBits);
+ if (numWords > storedBits.length) {
throw new IllegalArgumentException("The given long array is too small to hold " + numBits + " bits");
}
this.numBits = numBits;
this.bits = storedBits;
}
- /**
- * Makes a full copy of the bits, while allowing to expand/shrink the bitset.
- * If {@code numBits < other.numBits}, then only the first {@code numBits}
- * are copied from other.
- */
- public FixedBitSet(FixedBitSet other, int numBits) {
- wordLength = bits2words(numBits);
- bits = new long[wordLength];
- System.arraycopy(other.bits, 0, bits, 0, Math.min(other.wordLength, wordLength));
- this.numBits = numBits;
- }
-
@Override
public DocIdSetIterator iterator() {
- // define locally so we don't have "enclosing acces" issue
- final long[] bits = this.bits;
- final int wordLength = this.wordLength;
- final int numBits = this.numBits;
- return new DocIdSetIterator() {
- int doc = -1;
- @Override
- public int nextDoc() throws IOException {
- if (doc == NO_MORE_DOCS || ++doc >= numBits) {
- return doc = NO_MORE_DOCS;
- }
- int i = doc >> 6;
- final int subIndex = doc & 0x3f; // index within the word
- long word = bits[i] >> subIndex; // skip all the bits to the right of index
-
- if (word != 0) {
- return doc = doc + Long.numberOfTrailingZeros(word);
- }
-
- while (++i < wordLength) {
- word = bits[i];
- if (word != 0) {
- return doc = (i << 6) + Long.numberOfTrailingZeros(word);
- }
- }
-
- return doc = NO_MORE_DOCS;
- }
-
- @Override
- public int docID() {
- return doc;
- }
-
- @Override
- public long cost() {
- return bits.length;
- }
-
- @Override
- public int advance(int target) throws IOException {
- if (doc == NO_MORE_DOCS || target >= numBits) {
- return doc = NO_MORE_DOCS;
- }
- int i = target >> 6;
- final int subIndex = target & 0x3f; // index within the word
- long word = bits[i] >> subIndex; // skip all the bits to the right of index
-
- if (word != 0) {
- return doc = target + Long.numberOfTrailingZeros(word);
- }
-
- while (++i < wordLength) {
- word = bits[i];
- if (word != 0) {
- return doc = (i << 6) + Long.numberOfTrailingZeros(word);
- }
- }
-
- return doc = NO_MORE_DOCS;
- }
- };
+ return new FixedBitSetIterator(bits, numBits, numWords);
}
@Override
@@ -172,7 +232,7 @@ public final class FixedBitSet extends D
@Override
public boolean get(int index) {
- assert index >= 0 && index < numBits: "index=" + index;
+ assert index >= 0 && index < numBits: "index=" + index + ", numBits=" + numBits;
int i = index >> 6; // div 64
// signed shift will keep a negative index and force an
// array-index-out-of-bounds-exception, removing the need for an explicit check.
@@ -182,7 +242,7 @@ public final class FixedBitSet extends D
}
public void set(int index) {
- assert index >= 0 && index < numBits: "index=" + index + " numBits=" + numBits;
+ assert index >= 0 && index < numBits: "index=" + index + ", numBits=" + numBits;
int wordNum = index >> 6; // div 64
int bit = index & 0x3f; // mod 64
long bitmask = 1L << bit;
@@ -221,7 +281,7 @@ public final class FixedBitSet extends D
* -1 is returned if there are no more set bits.
*/
public int nextSetBit(int index) {
- assert index >= 0 && index < numBits;
+ assert index >= 0 && index < numBits : "index=" + index + ", numBits=" + numBits;
int i = index >> 6;
final int subIndex = index & 0x3f; // index within the word
long word = bits[i] >> subIndex; // skip all the bits to the right of index
@@ -230,7 +290,7 @@ public final class FixedBitSet extends D
return index + Long.numberOfTrailingZeros(word);
}
- while(++i < wordLength) {
+ while(++i < numWords) {
word = bits[i];
if (word != 0) {
return (i<<6) + Long.numberOfTrailingZeros(word);
@@ -272,6 +332,12 @@ public final class FixedBitSet extends D
// advance after last doc that would be accepted if standard
// iteration is used (to exhaust it):
obs.advance(numBits);
+ } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
+ final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
+ or(fbs.bits, fbs.numWords);
+ // advance after last doc that would be accepted if standard
+ // iteration is used (to exhaust it):
+ fbs.advance(numBits);
} else {
int doc;
while ((doc = iter.nextDoc()) < numBits) {
@@ -282,16 +348,36 @@ public final class FixedBitSet extends D
/** this = this OR other */
public void or(FixedBitSet other) {
- or(other.bits, other.wordLength);
+ or(other.bits, other.numWords);
}
- private void or(final long[] otherArr, final int otherLen) {
+ private void or(final long[] otherArr, final int otherNumWords) {
+ assert otherNumWords <= numWords : "numWords=" + numWords + ", otherNumWords=" + otherNumWords;
final long[] thisArr = this.bits;
- int pos = Math.min(wordLength, otherLen);
+ int pos = Math.min(numWords, otherNumWords);
while (--pos >= 0) {
thisArr[pos] |= otherArr[pos];
}
}
+
+ /** this = this XOR other */
+ public void xor(FixedBitSet other) {
+ assert other.numWords <= numWords : "numWords=" + numWords + ", other.numWords=" + other.numWords;
+ final long[] thisBits = this.bits;
+ final long[] otherBits = other.bits;
+ int pos = Math.min(numWords, other.numWords);
+ while (--pos >= 0) {
+ thisBits[pos] ^= otherBits[pos];
+ }
+ }
+
+ /** Does in-place XOR of the bits provided by the iterator. */
+ public void xor(DocIdSetIterator iter) throws IOException {
+ int doc;
+ while ((doc = iter.nextDoc()) < numBits) {
+ flip(doc, doc + 1);
+ }
+ }
/** Does in-place AND of the bits provided by the
* iterator. */
@@ -302,6 +388,12 @@ public final class FixedBitSet extends D
// advance after last doc that would be accepted if standard
// iteration is used (to exhaust it):
obs.advance(numBits);
+ } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
+ final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
+ and(fbs.bits, fbs.numWords);
+ // advance after last doc that would be accepted if standard
+ // iteration is used (to exhaust it):
+ fbs.advance(numBits);
} else {
if (numBits == 0) return;
int disiDoc, bitSetDoc = nextSetBit(0);
@@ -316,19 +408,28 @@ public final class FixedBitSet extends D
}
}
+ /** returns true if the sets have any elements in common */
+ public boolean intersects(FixedBitSet other) {
+ int pos = Math.min(numWords, other.numWords);
+ while (--pos>=0) {
+ if ((bits[pos] & other.bits[pos]) != 0) return true;
+ }
+ return false;
+ }
+
/** this = this AND other */
public void and(FixedBitSet other) {
- and(other.bits, other.wordLength);
+ and(other.bits, other.numWords);
}
- private void and(final long[] otherArr, final int otherLen) {
+ private void and(final long[] otherArr, final int otherNumWords) {
final long[] thisArr = this.bits;
- int pos = Math.min(this.wordLength, otherLen);
+ int pos = Math.min(this.numWords, otherNumWords);
while(--pos >= 0) {
thisArr[pos] &= otherArr[pos];
}
- if (this.wordLength > otherLen) {
- Arrays.fill(thisArr, otherLen, this.wordLength, 0L);
+ if (this.numWords > otherNumWords) {
+ Arrays.fill(thisArr, otherNumWords, this.numWords, 0L);
}
}
@@ -341,6 +442,12 @@ public final class FixedBitSet extends D
// advance after last doc that would be accepted if standard
// iteration is used (to exhaust it):
obs.advance(numBits);
+ } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
+ final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
+ andNot(fbs.bits, fbs.numWords);
+ // advance after last doc that would be accepted if standard
+ // iteration is used (to exhaust it):
+ fbs.advance(numBits);
} else {
int doc;
while ((doc = iter.nextDoc()) < numBits) {
@@ -354,9 +461,9 @@ public final class FixedBitSet extends D
andNot(other.bits, other.bits.length);
}
- private void andNot(final long[] otherArr, final int otherLen) {
+ private void andNot(final long[] otherArr, final int otherNumWords) {
final long[] thisArr = this.bits;
- int pos = Math.min(this.wordLength, otherLen);
+ int pos = Math.min(this.numWords, otherNumWords);
while(--pos >= 0) {
thisArr[pos] &= ~otherArr[pos];
}
@@ -439,8 +546,8 @@ public final class FixedBitSet extends D
* @param endIndex one-past the last bit to clear
*/
public void clear(int startIndex, int endIndex) {
- assert startIndex >= 0 && startIndex < numBits;
- assert endIndex >= 0 && endIndex <= numBits;
+ assert startIndex >= 0 && startIndex < numBits : "startIndex=" + startIndex + ", numBits=" + numBits;
+ assert endIndex >= 0 && endIndex <= numBits : "endIndex=" + endIndex + ", numBits=" + numBits;
if (endIndex <= startIndex) {
return;
}
@@ -467,7 +574,9 @@ public final class FixedBitSet extends D
@Override
public FixedBitSet clone() {
- return new FixedBitSet(this, numBits);
+ long[] bits = new long[this.bits.length];
+ System.arraycopy(this.bits, 0, bits, 0, bits.length);
+ return new FixedBitSet(bits, numBits);
}
/** returns true if both sets have the same bits set */
@@ -489,7 +598,7 @@ public final class FixedBitSet extends D
@Override
public int hashCode() {
long h = 0;
- for (int i = wordLength; --i>=0;) {
+ for (int i = numWords; --i>=0;) {
h ^= bits[i];
h = (h << 1) | (h >>> 63); // rotate left
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/SloppyMath.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/SloppyMath.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/SloppyMath.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/java/org/apache/lucene/util/SloppyMath.java Wed Feb 26 14:43:56 2014
@@ -48,11 +48,10 @@ public class SloppyMath {
double h2 = 1 - cos((lon1 - lon2) * TO_RADIANS);
double h = (h1 + cos(x1) * cos(x2) * h2) / 2;
- double avgLat = Math.abs((x1 + x2) / 2d);
- int index = (int)(avgLat * RADIUS_INDEXER + 0.5) % earthDiameterPerLatitude.length;
- double radius = earthDiameterPerLatitude[index];
+ double avgLat = (x1 + x2) / 2d;
+ double diameter = earthDiameter(avgLat);
- return radius * asin(Math.min(1, Math.sqrt(h)));
+ return diameter * asin(Math.min(1, Math.sqrt(h)));
}
@@ -137,7 +136,13 @@ public class SloppyMath {
}
}
}
-
+
+ /** Return an approximate value of the diameter of the earth at the given latitude, in kilometers. */
+ public static double earthDiameter(double latitude) {
+ final int index = (int)(Math.abs(latitude) * RADIUS_INDEXER + 0.5) % earthDiameterPerLatitude.length;
+ return earthDiameterPerLatitude[index];
+ }
+
// haversin
private static final double TO_RADIANS = Math.PI / 180D;
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java Wed Feb 26 14:43:56 2014
@@ -33,7 +33,7 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.BasicAutomata;
@@ -232,7 +232,7 @@ public class TestMockAnalyzer extends Ba
for (int i = 0; i < iters; i++) {
final CharacterRunAutomaton dfa = new CharacterRunAutomaton(AutomatonTestUtil.randomAutomaton(random()));
final boolean lowercase = random().nextBoolean();
- final int limit = _TestUtil.nextInt(random(), 0, 500);
+ final int limit = TestUtil.nextInt(random(), 0, 500);
Analyzer a = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {
@@ -248,7 +248,7 @@ public class TestMockAnalyzer extends Ba
public void testForwardOffsets() throws Exception {
int num = atLeast(10000);
for (int i = 0; i < num; i++) {
- String s = _TestUtil.randomHtmlishString(random(), 20);
+ String s = TestUtil.randomHtmlishString(random(), 20);
StringReader reader = new StringReader(s);
MockCharFilter charfilter = new MockCharFilter(reader, 2);
MockAnalyzer analyzer = new MockAnalyzer(random());
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestToken.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestToken.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestToken.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/TestToken.java Wed Feb 26 14:43:56 2014
@@ -22,7 +22,7 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.util.Attribute;
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import java.io.StringReader;
import java.util.HashMap;
@@ -246,17 +246,17 @@ public class TestToken extends LuceneTes
public void testAttributeReflection() throws Exception {
Token t = new Token("foobar", 6, 22, 8);
- _TestUtil.assertAttributeReflection(t,
- new HashMap<String,Object>() {{
- put(CharTermAttribute.class.getName() + "#term", "foobar");
- put(TermToBytesRefAttribute.class.getName() + "#bytes", new BytesRef("foobar"));
- put(OffsetAttribute.class.getName() + "#startOffset", 6);
- put(OffsetAttribute.class.getName() + "#endOffset", 22);
- put(PositionIncrementAttribute.class.getName() + "#positionIncrement", 1);
- put(PayloadAttribute.class.getName() + "#payload", null);
- put(TypeAttribute.class.getName() + "#type", TypeAttribute.DEFAULT_TYPE);
- put(FlagsAttribute.class.getName() + "#flags", 8);
- }});
+ TestUtil.assertAttributeReflection(t,
+ new HashMap<String, Object>() {{
+ put(CharTermAttribute.class.getName() + "#term", "foobar");
+ put(TermToBytesRefAttribute.class.getName() + "#bytes", new BytesRef("foobar"));
+ put(OffsetAttribute.class.getName() + "#startOffset", 6);
+ put(OffsetAttribute.class.getName() + "#endOffset", 22);
+ put(PositionIncrementAttribute.class.getName() + "#positionIncrement", 1);
+ put(PayloadAttribute.class.getName() + "#payload", null);
+ put(TypeAttribute.class.getName() + "#type", TypeAttribute.DEFAULT_TYPE);
+ put(FlagsAttribute.class.getName() + "#flags", 8);
+ }});
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java Wed Feb 26 14:43:56 2014
@@ -20,7 +20,8 @@ package org.apache.lucene.analysis.token
import org.apache.lucene.analysis.TestToken;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+
import java.nio.CharBuffer;
import java.util.HashMap;
import java.util.Formatter;
@@ -132,7 +133,7 @@ public class TestCharTermAttributeImpl e
public void testAttributeReflection() throws Exception {
CharTermAttributeImpl t = new CharTermAttributeImpl();
t.append("foobar");
- _TestUtil.assertAttributeReflection(t, new HashMap<String,Object>() {{
+ TestUtil.assertAttributeReflection(t, new HashMap<String, Object>() {{
put(CharTermAttribute.class.getName() + "#term", "foobar");
put(TermToBytesRefAttribute.class.getName() + "#bytes", new BytesRef("foobar"));
}});
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpl.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpl.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpl.java Wed Feb 26 14:43:56 2014
@@ -17,7 +17,7 @@ package org.apache.lucene.analysis.token
* limitations under the License.
*/
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase;
import java.util.Collections;
@@ -27,21 +27,21 @@ public class TestSimpleAttributeImpl ext
// this checks using reflection API if the defaults are correct
public void testAttributes() {
- _TestUtil.assertAttributeReflection(new PositionIncrementAttributeImpl(),
- Collections.singletonMap(PositionIncrementAttribute.class.getName()+"#positionIncrement", 1));
- _TestUtil.assertAttributeReflection(new PositionLengthAttributeImpl(),
- Collections.singletonMap(PositionLengthAttribute.class.getName()+"#positionLength", 1));
- _TestUtil.assertAttributeReflection(new FlagsAttributeImpl(),
- Collections.singletonMap(FlagsAttribute.class.getName()+"#flags", 0));
- _TestUtil.assertAttributeReflection(new TypeAttributeImpl(),
- Collections.singletonMap(TypeAttribute.class.getName()+"#type", TypeAttribute.DEFAULT_TYPE));
- _TestUtil.assertAttributeReflection(new PayloadAttributeImpl(),
- Collections.singletonMap(PayloadAttribute.class.getName()+"#payload", null));
- _TestUtil.assertAttributeReflection(new KeywordAttributeImpl(),
- Collections.singletonMap(KeywordAttribute.class.getName()+"#keyword", false));
- _TestUtil.assertAttributeReflection(new OffsetAttributeImpl(), new HashMap<String,Object>() {{
- put(OffsetAttribute.class.getName()+"#startOffset", 0);
- put(OffsetAttribute.class.getName()+"#endOffset", 0);
+ TestUtil.assertAttributeReflection(new PositionIncrementAttributeImpl(),
+ Collections.singletonMap(PositionIncrementAttribute.class.getName() + "#positionIncrement", 1));
+ TestUtil.assertAttributeReflection(new PositionLengthAttributeImpl(),
+ Collections.singletonMap(PositionLengthAttribute.class.getName() + "#positionLength", 1));
+ TestUtil.assertAttributeReflection(new FlagsAttributeImpl(),
+ Collections.singletonMap(FlagsAttribute.class.getName() + "#flags", 0));
+ TestUtil.assertAttributeReflection(new TypeAttributeImpl(),
+ Collections.singletonMap(TypeAttribute.class.getName() + "#type", TypeAttribute.DEFAULT_TYPE));
+ TestUtil.assertAttributeReflection(new PayloadAttributeImpl(),
+ Collections.singletonMap(PayloadAttribute.class.getName() + "#payload", null));
+ TestUtil.assertAttributeReflection(new KeywordAttributeImpl(),
+ Collections.singletonMap(KeywordAttribute.class.getName() + "#keyword", false));
+ TestUtil.assertAttributeReflection(new OffsetAttributeImpl(), new HashMap<String, Object>() {{
+ put(OffsetAttribute.class.getName() + "#startOffset", 0);
+ put(OffsetAttribute.class.getName() + "#endOffset", 0);
}});
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java Wed Feb 26 14:43:56 2014
@@ -24,7 +24,7 @@ import org.apache.lucene.store.ByteArray
import org.apache.lucene.store.ByteArrayDataOutput;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
@@ -85,8 +85,8 @@ public abstract class AbstractTestCompre
final int iterations = atLeast(10);
for (int i = 0; i < iterations; ++i) {
final byte[] decompressed = randomArray();
- final int off = random().nextBoolean() ? 0 : _TestUtil.nextInt(random(), 0, decompressed.length);
- final int len = random().nextBoolean() ? decompressed.length - off : _TestUtil.nextInt(random(), 0, decompressed.length - off);
+ final int off = random().nextBoolean() ? 0 : TestUtil.nextInt(random(), 0, decompressed.length);
+ final int len = random().nextBoolean() ? decompressed.length - off : TestUtil.nextInt(random(), 0, decompressed.length - off);
final byte[] compressed = compress(decompressed, off, len);
final byte[] restored = decompress(compressed, len);
assertArrayEquals(Arrays.copyOfRange(decompressed, off, off+len), restored);
@@ -138,7 +138,7 @@ public abstract class AbstractTestCompre
}
public void testConstant() throws IOException {
- final byte[] decompressed = new byte[_TestUtil.nextInt(random(), 1, 10000)];
+ final byte[] decompressed = new byte[TestUtil.nextInt(random(), 1, 10000)];
Arrays.fill(decompressed, (byte) random().nextInt());
test(decompressed);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestBitVector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestBitVector.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestBitVector.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestBitVector.java Wed Feb 26 14:43:56 2014
@@ -23,7 +23,8 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* <code>TestBitVector</code> tests the <code>BitVector</code>, obviously.
@@ -231,10 +232,10 @@ public class TestBitVector extends Lucen
public void testClearedBitNearEnd() throws IOException {
Directory d = newDirectory();
- final int numBits = _TestUtil.nextInt(random(), 7, 1000);
+ final int numBits = TestUtil.nextInt(random(), 7, 1000);
BitVector bv = new BitVector(numBits);
bv.invertAll();
- bv.clear(numBits-_TestUtil.nextInt(random(), 1, 7));
+ bv.clear(numBits- TestUtil.nextInt(random(), 1, 7));
bv.write(d, "test", newIOContext(random()));
assertEquals(numBits-1, bv.count());
d.close();
@@ -242,7 +243,7 @@ public class TestBitVector extends Lucen
public void testMostlySet() throws IOException {
Directory d = newDirectory();
- final int numBits = _TestUtil.nextInt(random(), 30, 1000);
+ final int numBits = TestUtil.nextInt(random(), 30, 1000);
for(int numClear=0;numClear<20;numClear++) {
BitVector bv = new BitVector(numBits);
bv.invertAll();
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java Wed Feb 26 14:43:56 2014
@@ -33,7 +33,7 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.junit.BeforeClass;
public class TestLucene40PostingsReader extends LuceneTestCase {
@@ -53,7 +53,7 @@ public class TestLucene40PostingsReader
* depends heavily on term vectors cross-check at checkIndex
*/
public void testPostings() throws Exception {
- Directory dir = newFSDirectory(_TestUtil.getTempDir("postings"));
+ Directory dir = newFSDirectory(TestUtil.getTempDir("postings"));
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwc.setCodec(Codec.forName("Lucene40"));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
@@ -116,7 +116,7 @@ public class TestLucene40PostingsReader
StringBuilder sb = new StringBuilder();
int i = random().nextInt(terms.length);
while (i < terms.length) {
- int tf = _TestUtil.nextInt(random(), 1, maxTF);
+ int tf = TestUtil.nextInt(random(), 1, maxTF);
for (int j = 0; j < tf; j++) {
shuffled.add(terms[i]);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java Wed Feb 26 14:43:56 2014
@@ -36,7 +36,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.junit.BeforeClass;
// TODO: really this should be in BaseTestPF or somewhere else? useful test!
@@ -49,7 +49,7 @@ public class TestReuseDocsEnum extends L
public void testReuseDocsEnumNoReuse() throws IOException {
Directory dir = newDirectory();
- Codec cp = _TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
+ Codec cp = TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
int numdocs = atLeast(20);
@@ -76,7 +76,7 @@ public class TestReuseDocsEnum extends L
// tests for reuse only if bits are the same either null or the same instance
public void testReuseDocsEnumSameBitsOrNull() throws IOException {
Directory dir = newDirectory();
- Codec cp = _TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
+ Codec cp = TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
int numdocs = atLeast(20);
@@ -120,7 +120,7 @@ public class TestReuseDocsEnum extends L
// make sure we never reuse from another reader even if it is the same field & codec etc
public void testReuseDocsEnumDifferentReader() throws IOException {
Directory dir = newDirectory();
- Codec cp = _TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
+ Codec cp = TestUtil.alwaysPostingsFormat(new Lucene40RWPostingsFormat());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(cp));
int numdocs = atLeast(20);
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat.java Wed Feb 26 14:43:56 2014
@@ -19,13 +19,13 @@ package org.apache.lucene.codecs.lucene4
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.index.BasePostingsFormatTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* Tests BlockPostingsFormat
*/
public class TestBlockPostingsFormat extends BasePostingsFormatTestCase {
- private final Codec codec = _TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat());
+ private final Codec codec = TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat());
@Override
protected Codec getCodec() {
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java Wed Feb 26 14:43:56 2014
@@ -30,7 +30,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* Tests special cases of BlockPostingsFormat
@@ -43,9 +43,9 @@ public class TestBlockPostingsFormat2 ex
@Override
public void setUp() throws Exception {
super.setUp();
- dir = newFSDirectory(_TestUtil.getTempDir("testDFBlockSize"));
+ dir = newFSDirectory(TestUtil.getTempDir("testDFBlockSize"));
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
- iwc.setCodec(_TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
+ iwc.setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
iw = new RandomIndexWriter(random(), dir, iwc.clone());
iw.setDoRandomForceMerge(false); // we will ourselves
}
@@ -53,7 +53,7 @@ public class TestBlockPostingsFormat2 ex
@Override
public void tearDown() throws Exception {
iw.close();
- _TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
+ TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
iwc.setOpenMode(OpenMode.APPEND);
IndexWriter iw = new IndexWriter(dir, iwc.clone());
iw.forceMerge(1);
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java Wed Feb 26 14:43:56 2014
@@ -17,7 +17,6 @@ package org.apache.lucene.codecs.lucene4
* limitations under the License.
*/
-import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -53,7 +52,8 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.English;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@@ -83,7 +83,7 @@ public class TestBlockPostingsFormat3 ex
}
};
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
- iwc.setCodec(_TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
+ iwc.setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
// TODO we could actually add more fields implemented with different PFs
// or, just put this test into the usual rotation?
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc.clone());
@@ -123,7 +123,7 @@ public class TestBlockPostingsFormat3 ex
doc.add(field7);
doc.add(field8);
for (int i = 0; i < MAXDOC; i++) {
- String stringValue = Integer.toString(i) + " verycommon " + English.intToEnglish(i).replace('-', ' ') + " " + _TestUtil.randomSimpleString(random());
+ String stringValue = Integer.toString(i) + " verycommon " + English.intToEnglish(i).replace('-', ' ') + " " + TestUtil.randomSimpleString(random());
field1.setStringValue(stringValue);
field2.setStringValue(stringValue);
field3.setStringValue(stringValue);
@@ -136,7 +136,7 @@ public class TestBlockPostingsFormat3 ex
}
iw.close();
verify(dir);
- _TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
+ TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
iwc.setOpenMode(OpenMode.APPEND);
IndexWriter iw2 = new IndexWriter(dir, iwc.clone());
iw2.forceMerge(1);
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene45/TestLucene45DocValuesFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene45/TestLucene45DocValuesFormat.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene45/TestLucene45DocValuesFormat.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/lucene45/TestLucene45DocValuesFormat.java Wed Feb 26 14:43:56 2014
@@ -19,13 +19,13 @@ package org.apache.lucene.codecs.lucene4
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.index.BaseCompressingDocValuesFormatTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* Tests Lucene45DocValuesFormat
*/
public class TestLucene45DocValuesFormat extends BaseCompressingDocValuesFormatTestCase {
- private final Codec codec = _TestUtil.alwaysDocValuesFormat(new Lucene45DocValuesFormat());
+ private final Codec codec = TestUtil.alwaysDocValuesFormat(new Lucene45DocValuesFormat());
@Override
protected Codec getCodec() {
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java Wed Feb 26 14:43:56 2014
@@ -46,7 +46,8 @@ import org.apache.lucene.search.TermQuer
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* Basic tests of PerFieldDocValuesFormat
@@ -67,7 +68,7 @@ public class TestPerFieldDocValuesFormat
@Override
protected boolean codecAcceptsHugeBinaryValues(String field) {
- return _TestUtil.fieldSupportsHugeBinaryDocValues(field);
+ return TestUtil.fieldSupportsHugeBinaryDocValues(field);
}
// just a simple trivial test
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java Wed Feb 26 14:43:56 2014
@@ -43,7 +43,8 @@ import org.apache.lucene.search.TermQuer
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.junit.Test;
/**
@@ -107,7 +108,7 @@ public class TestPerFieldPostingsFormat2
addDocs2(writer, 10);
writer.commit();
assertEquals(30, writer.maxDoc());
- _TestUtil.checkIndex(dir);
+ TestUtil.checkIndex(dir);
writer.forceMerge(1);
assertEquals(30, writer.maxDoc());
writer.close();
@@ -240,7 +241,7 @@ public class TestPerFieldPostingsFormat2
final int docsPerRound = 97;
int numRounds = atLeast(1);
for (int i = 0; i < numRounds; i++) {
- int num = _TestUtil.nextInt(random(), 30, 60);
+ int num = TestUtil.nextInt(random(), 30, 60);
IndexWriterConfig config = newIndexWriterConfig(random(),
TEST_VERSION_CURRENT, new MockAnalyzer(random()));
config.setOpenMode(OpenMode.CREATE_OR_APPEND);
@@ -251,7 +252,7 @@ public class TestPerFieldPostingsFormat2
FieldType customType = new FieldType(TextField.TYPE_NOT_STORED);
customType.setTokenized(random().nextBoolean());
customType.setOmitNorms(random().nextBoolean());
- Field field = newField("" + k, _TestUtil
+ Field field = newField("" + k, TestUtil
.randomRealisticUnicodeString(random(), 128), customType);
doc.add(field);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java Wed Feb 26 14:43:56 2014
@@ -26,8 +26,8 @@ import org.apache.lucene.store.ByteArray
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
import org.junit.Ignore;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
@@ -38,7 +38,7 @@ public class Test2BBinaryDocValues exten
// indexes Integer.MAX_VALUE docs with a fixed binary field
public void testFixedBinary() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BFixedBinary"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BFixedBinary"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@@ -98,7 +98,7 @@ public class Test2BBinaryDocValues exten
// indexes Integer.MAX_VALUE docs with a variable binary field
public void testVariableBinary() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BVariableBinary"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BVariableBinary"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java Wed Feb 26 14:43:56 2014
@@ -22,7 +22,7 @@ import java.util.Arrays;
import org.apache.lucene.document.Document;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -31,7 +31,7 @@ public class Test2BDocs extends LuceneTe
@BeforeClass
public static void beforeClass() throws Exception {
- dir = newFSDirectory(_TestUtil.getTempDir("2Bdocs"));
+ dir = newFSDirectory(TestUtil.getTempDir("2Bdocs"));
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
Document doc = new Document();
for (int i = 0; i < 262144; i++) {
@@ -61,7 +61,7 @@ public class Test2BDocs extends LuceneTe
}
public void testExactlyAtLimit() throws Exception {
- Directory dir2 = newFSDirectory(_TestUtil.getTempDir("2BDocs2"));
+ Directory dir2 = newFSDirectory(TestUtil.getTempDir("2BDocs2"));
IndexWriter iw = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
Document doc = new Document();
for (int i = 0; i < 262143; i++) {
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java Wed Feb 26 14:43:56 2014
@@ -23,8 +23,8 @@ import org.apache.lucene.document.Numeri
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
import org.junit.Ignore;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
@@ -35,7 +35,7 @@ public class Test2BNumericDocValues exte
// indexes Integer.MAX_VALUE docs with an increasing dv field
public void testNumerics() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BNumerics"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BNumerics"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java Wed Feb 26 14:43:56 2014
@@ -28,8 +28,9 @@ import org.apache.lucene.document.TextFi
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.junit.Ignore;
@@ -46,7 +47,7 @@ public class Test2BPositions extends Luc
// uses lots of space and takes a few minutes
@Ignore("Very slow. Enable manually by removing @Ignore.")
public void test() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BPositions"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPositions"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java Wed Feb 26 14:43:56 2014
@@ -29,8 +29,9 @@ import org.apache.lucene.store.BaseDirec
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
@@ -44,7 +45,7 @@ public class Test2BPostings extends Luce
@Nightly
public void test() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BPostings"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPostings"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java Wed Feb 26 14:43:56 2014
@@ -30,8 +30,8 @@ import org.apache.lucene.index.FieldInfo
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.junit.Ignore;
@@ -50,7 +50,7 @@ public class Test2BPostingsBytes extends
// with some codecs needs more heap space as well.
@Ignore("Very slow. Enable manually by removing @Ignore.")
public void test() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes1"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes1"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@@ -93,7 +93,7 @@ public class Test2BPostingsBytes extends
IndexReader subReaders[] = new IndexReader[1000];
Arrays.fill(subReaders, oneThousand);
MultiReader mr = new MultiReader(subReaders);
- BaseDirectoryWrapper dir2 = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes2"));
+ BaseDirectoryWrapper dir2 = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes2"));
if (dir2 instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir2).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@@ -108,7 +108,7 @@ public class Test2BPostingsBytes extends
subReaders = new IndexReader[2000];
Arrays.fill(subReaders, oneMillion);
mr = new MultiReader(subReaders);
- BaseDirectoryWrapper dir3 = newFSDirectory(_TestUtil.getTempDir("2BPostingsBytes3"));
+ BaseDirectoryWrapper dir3 = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes3"));
if (dir3 instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir3).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java Wed Feb 26 14:43:56 2014
@@ -26,8 +26,8 @@ import org.apache.lucene.store.BaseDirec
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
import org.junit.Ignore;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
@@ -38,7 +38,7 @@ public class Test2BSortedDocValues exten
// indexes Integer.MAX_VALUE docs with a fixed binary field
public void testFixedSorted() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BFixedSorted"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BFixedSorted"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@@ -95,7 +95,7 @@ public class Test2BSortedDocValues exten
// indexes Integer.MAX_VALUE docs with a fixed binary field
// TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issues
public void test2BOrds() throws Exception {
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BOrds"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BOrds"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java Wed Feb 26 14:43:56 2014
@@ -62,7 +62,7 @@ public class Test2BTerms extends LuceneT
addAttribute(TermToBytesRefAttribute.class);
bytes.length = TOKEN_LEN;
this.random = random;
- nextSave = _TestUtil.nextInt(random, 500000, 1000000);
+ nextSave = TestUtil.nextInt(random, 500000, 1000000);
}
@Override
@@ -75,7 +75,7 @@ public class Test2BTerms extends LuceneT
if (--nextSave == 0) {
savedTerms.add(BytesRef.deepCopyOf(bytes));
System.out.println("TEST: save term=" + bytes);
- nextSave = _TestUtil.nextInt(random, 500000, 1000000);
+ nextSave = TestUtil.nextInt(random, 500000, 1000000);
}
return true;
}
@@ -144,11 +144,11 @@ public class Test2BTerms extends LuceneT
System.out.println("Starting Test2B");
final long TERM_COUNT = ((long) Integer.MAX_VALUE) + 100000000;
- final int TERMS_PER_DOC = _TestUtil.nextInt(random(), 100000, 1000000);
+ final int TERMS_PER_DOC = TestUtil.nextInt(random(), 100000, 1000000);
List<BytesRef> savedTerms = null;
- BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("2BTerms"));
+ BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BTerms"));
//MockDirectoryWrapper dir = newFSDirectory(new File("/p/lucene/indices/2bindex"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
@@ -212,7 +212,7 @@ public class Test2BTerms extends LuceneT
r.close();
System.out.println("TEST: now CheckIndex...");
- CheckIndex.Status status = _TestUtil.checkIndex(dir);
+ CheckIndex.Status status = TestUtil.checkIndex(dir);
final long tc = status.segmentInfos.get(0).termIndexStatus.termCount;
assertTrue("count " + tc + " is not > " + Integer.MAX_VALUE, tc > Integer.MAX_VALUE);
@@ -224,13 +224,13 @@ public class Test2BTerms extends LuceneT
System.out.println("TEST: findTerms");
final TermsEnum termsEnum = MultiFields.getTerms(r, "field").iterator(null);
final List<BytesRef> savedTerms = new ArrayList<BytesRef>();
- int nextSave = _TestUtil.nextInt(random(), 500000, 1000000);
+ int nextSave = TestUtil.nextInt(random(), 500000, 1000000);
BytesRef term;
while((term = termsEnum.next()) != null) {
if (--nextSave == 0) {
savedTerms.add(BytesRef.deepCopyOf(term));
System.out.println("TEST: add " + term);
- nextSave = _TestUtil.nextInt(random(), 500000, 1000000);
+ nextSave = TestUtil.nextInt(random(), 500000, 1000000);
}
}
return savedTerms;
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java Wed Feb 26 14:43:56 2014
@@ -25,8 +25,9 @@ import org.apache.lucene.store.MMapDirec
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
@@ -41,7 +42,7 @@ public class Test4GBStoredFields extends
@Nightly
public void test() throws Exception {
- MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(_TestUtil.getTempDir("4GBStoredFields")));
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.getTempDir("4GBStoredFields")));
dir.setThrottling(MockDirectoryWrapper.Throttling.NEVER);
IndexWriter w = new IndexWriter(dir,
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java Wed Feb 26 14:43:56 2014
@@ -46,7 +46,7 @@ import org.apache.lucene.store.MockDirec
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
public class TestAddIndexes extends LuceneTestCase {
@@ -66,7 +66,7 @@ public class TestAddIndexes extends Luce
addDocs(writer, 100);
assertEquals(100, writer.maxDoc());
writer.close();
- _TestUtil.checkIndex(dir);
+ TestUtil.checkIndex(dir);
writer = newWriter(
aux,
@@ -91,7 +91,7 @@ public class TestAddIndexes extends Luce
writer.addIndexes(aux, aux2);
assertEquals(190, writer.maxDoc());
writer.close();
- _TestUtil.checkIndex(dir);
+ TestUtil.checkIndex(dir);
// make sure the old index is correct
verifyNumDocs(aux, 40);
@@ -540,7 +540,7 @@ public class TestAddIndexes extends Luce
private void verifyTermDocs(Directory dir, Term term, int numDocs)
throws IOException {
IndexReader reader = DirectoryReader.open(dir);
- DocsEnum docsEnum = _TestUtil.docs(random(), reader, term.field, term.bytes, null, null, DocsEnum.FLAG_NONE);
+ DocsEnum docsEnum = TestUtil.docs(random(), reader, term.field, term.bytes, null, null, DocsEnum.FLAG_NONE);
int count = 0;
while (docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)
count++;
@@ -915,7 +915,7 @@ public class TestAddIndexes extends Luce
CommitAndAddIndexes3 c = new CommitAndAddIndexes3(NUM_COPY);
c.launchThreads(-1);
- Thread.sleep(_TestUtil.nextInt(random(), 10, 500));
+ Thread.sleep(TestUtil.nextInt(random(), 10, 500));
// Close w/o first stopping/joining the threads
if (VERBOSE) {
@@ -940,7 +940,7 @@ public class TestAddIndexes extends Luce
CommitAndAddIndexes3 c = new CommitAndAddIndexes3(NUM_COPY);
c.launchThreads(-1);
- Thread.sleep(_TestUtil.nextInt(random(), 10, 500));
+ Thread.sleep(TestUtil.nextInt(random(), 10, 500));
// Close w/o first stopping/joining the threads
if (VERBOSE) {
@@ -1016,7 +1016,7 @@ public class TestAddIndexes extends Luce
assertEquals(100, writer.maxDoc());
writer.commit();
writer.close();
- _TestUtil.checkIndex(dir);
+ TestUtil.checkIndex(dir);
writer = newWriter(
aux,
@@ -1141,7 +1141,7 @@ public class TestAddIndexes extends Luce
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random()));
- conf.setCodec(_TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1 + random().nextInt(20))));
+ conf.setCodec(TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1 + random().nextInt(20))));
IndexWriter w = new IndexWriter(dir, conf);
try {
w.addIndexes(toAdd);
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java Wed Feb 26 14:43:56 2014
@@ -29,7 +29,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
/**
* Test that a plain default puts codec headers in all files.
@@ -49,7 +49,7 @@ public class TestAllFilesHaveCodecHeader
doc.add(bodyField);
for (int i = 0; i < 100; i++) {
idField.setStringValue(Integer.toString(i));
- bodyField.setStringValue(_TestUtil.randomUnicodeString(random()));
+ bodyField.setStringValue(TestUtil.randomUnicodeString(random()));
riw.addDocument(doc);
if (random().nextInt(7) == 0) {
riw.commit();
Modified: lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/dev/branches/lucene5376/lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java Wed Feb 26 14:43:56 2014
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
*/
import java.io.File;
-import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.*;
@@ -176,10 +175,10 @@ public class TestAtomicUpdate extends Lu
directory.close();
// Second in an FSDirectory:
- File dirPath = _TestUtil.getTempDir("lucene.test.atomic");
+ File dirPath = TestUtil.getTempDir("lucene.test.atomic");
directory = newFSDirectory(dirPath);
runTest(directory);
directory.close();
- _TestUtil.rmDir(dirPath);
+ TestUtil.rmDir(dirPath);
}
}