Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 58013 invoked from network); 26 Feb 2010 13:11:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Feb 2010 13:11:35 -0000 Received: (qmail 14774 invoked by uid 500); 26 Feb 2010 13:11:34 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 14730 invoked by uid 500); 26 Feb 2010 13:11:34 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 14723 invoked by uid 99); 26 Feb 2010 13:11:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2010 13:11:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2010 13:11:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 17C0D2388C10; Fri, 26 Feb 2010 13:10:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r916666 [16/16] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/analyzers/common/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/bg/ contrib/analyzers/... Date: Fri, 26 Feb 2010 13:10:08 -0000 To: java-commits@lucene.apache.org From: rmuir@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100226131017.17C0D2388C10@eris.apache.org> Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Fri Feb 26 13:09:54 2010 @@ -96,7 +96,7 @@ // prepare a small index with just a few documents. super.setUp(); dir = new RAMDirectory(); - anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT); + anlzr = new StandardAnalyzer(TEST_VERSION_CURRENT); IndexWriter iw = new IndexWriter(dir, anlzr, IndexWriter.MaxFieldLength.LIMITED); // add docs not exactly in natural ID order, to verify we do check the order of docs by scores Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java Fri Feb 26 13:09:54 2010 @@ -20,7 +20,6 @@ import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.*; -import org.apache.lucene.util.Version; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -30,11 +29,11 @@ import java.util.Map; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.Term; /** * Test CustomScoreQuery search. */ -@SuppressWarnings({"MagicNumber"}) public class TestCustomScoreQuery extends FunctionTestSetup { /* @override constructor */ @@ -97,23 +96,26 @@ public String name() { return "customAdd"; } - - /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */ - @Override - public float customScore(int doc, float subQueryScore, float valSrcScore) { - return subQueryScore + valSrcScore; - } - - /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/ + @Override - public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl) { - float valSrcScore = valSrcExpl == null ? 0 : valSrcExpl.getValue(); - Explanation exp = new Explanation(valSrcScore + subQueryExpl.getValue(), "custom score: sum of:"); - exp.addDetail(subQueryExpl); - if (valSrcExpl != null) { - exp.addDetail(valSrcExpl); - } - return exp; + protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) { + return new CustomScoreProvider(reader) { + @Override + public float customScore(int doc, float subQueryScore, float valSrcScore) { + return subQueryScore + valSrcScore; + } + + @Override + public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl) { + float valSrcScore = valSrcExpl == null ? 0 : valSrcExpl.getValue(); + Explanation exp = new Explanation(valSrcScore + subQueryExpl.getValue(), "custom score: sum of:"); + exp.addDetail(subQueryExpl); + if (valSrcExpl != null) { + exp.addDetail(valSrcExpl); + } + return exp; + } + }; } } @@ -131,52 +133,55 @@ return "customMulAdd"; } - /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */ @Override - public float customScore(int doc, float subQueryScore, float valSrcScores[]) { - if (valSrcScores.length == 0) { - return subQueryScore; - } - if (valSrcScores.length == 1) { - return subQueryScore + valSrcScores[0]; - // confirm that skipping beyond the last doc, on the - // previous reader, hits NO_MORE_DOCS - } - return (subQueryScore + valSrcScores[0]) * valSrcScores[1]; // we know there are two - } - - /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/ - @Override - public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpls[]) { - if (valSrcExpls.length == 0) { - return subQueryExpl; - } - Explanation exp = new Explanation(valSrcExpls[0].getValue() + subQueryExpl.getValue(), "sum of:"); - exp.addDetail(subQueryExpl); - exp.addDetail(valSrcExpls[0]); - if (valSrcExpls.length == 1) { - exp.setDescription("CustomMulAdd, sum of:"); - return exp; - } - Explanation exp2 = new Explanation(valSrcExpls[1].getValue() * exp.getValue(), "custom score: product of:"); - exp2.addDetail(valSrcExpls[1]); - exp2.addDetail(exp); - return exp2; + protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) { + return new CustomScoreProvider(reader) { + @Override + public float customScore(int doc, float subQueryScore, float valSrcScores[]) { + if (valSrcScores.length == 0) { + return subQueryScore; + } + if (valSrcScores.length == 1) { + return subQueryScore + valSrcScores[0]; + // confirm that skipping beyond the last doc, on the + // previous reader, hits NO_MORE_DOCS + } + return (subQueryScore + valSrcScores[0]) * valSrcScores[1]; // we know there are two + } + + @Override + public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpls[]) { + if (valSrcExpls.length == 0) { + return subQueryExpl; + } + Explanation exp = new Explanation(valSrcExpls[0].getValue() + subQueryExpl.getValue(), "sum of:"); + exp.addDetail(subQueryExpl); + exp.addDetail(valSrcExpls[0]); + if (valSrcExpls.length == 1) { + exp.setDescription("CustomMulAdd, sum of:"); + return exp; + } + Explanation exp2 = new Explanation(valSrcExpls[1].getValue() * exp.getValue(), "custom score: product of:"); + exp2.addDetail(valSrcExpls[1]); + exp2.addDetail(exp); + return exp2; + } + }; } } private final class CustomExternalQuery extends CustomScoreQuery { - private IndexReader reader; - private int[] values; - - public float customScore(int doc, float subScore, float valSrcScore) { - assertTrue(doc <= reader.maxDoc()); - return (float) values[doc]; - } - public void setNextReader(IndexReader r) throws IOException { - reader = r; - values = FieldCache.DEFAULT.getInts(r, INT_FIELD); + @Override + protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) throws IOException { + final int[] values = FieldCache.DEFAULT.getInts(reader, INT_FIELD); + return new CustomScoreProvider(reader) { + @Override + public float customScore(int doc, float subScore, float valSrcScore) throws IOException { + assertTrue(doc <= reader.maxDoc()); + return (float) values[doc]; + } + }; } public CustomExternalQuery(Query q) { @@ -184,8 +189,9 @@ } } + @Test public void testCustomExternalQuery() throws Exception { - QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD,anlzr); + QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, TEXT_FIELD,anlzr); String qtxt = "first aid text"; // from the doc texts in FunctionQuerySetup. Query q1 = qp.parse(qtxt); @@ -203,12 +209,35 @@ s.close(); } + @Test + public void testRewrite() throws Exception { + final IndexSearcher s = new IndexSearcher(dir, true); + + Query q = new TermQuery(new Term(TEXT_FIELD, "first")); + CustomScoreQuery original = new CustomScoreQuery(q); + CustomScoreQuery rewritten = (CustomScoreQuery) original.rewrite(s.getIndexReader()); + assertTrue("rewritten query should be identical, as TermQuery does not rewrite", original == rewritten); + assertTrue("no hits for query", s.search(rewritten,1).totalHits > 0); + assertEquals(s.search(q,1).totalHits, s.search(rewritten,1).totalHits); + + q = new TermRangeQuery(TEXT_FIELD, null, null, true, true); // everything + original = new CustomScoreQuery(q); + rewritten = (CustomScoreQuery) original.rewrite(s.getIndexReader()); + assertTrue("rewritten query should not be identical, as TermRangeQuery rewrites", original != rewritten); + assertTrue("rewritten query should be a CustomScoreQuery", rewritten instanceof CustomScoreQuery); + assertTrue("no hits for query", s.search(rewritten,1).totalHits > 0); + assertEquals(s.search(q,1).totalHits, s.search(original,1).totalHits); + assertEquals(s.search(q,1).totalHits, s.search(rewritten,1).totalHits); + + s.close(); + } + // Test that FieldScoreQuery returns docs with expected score. private void doTestCustomScore(String field, FieldScoreQuery.Type tp, double dboost) throws Exception, ParseException { float boost = (float) dboost; IndexSearcher s = new IndexSearcher(dir, true); FieldScoreQuery qValSrc = new FieldScoreQuery(field, tp); // a query that would score by the field - QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD, anlzr); + QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, TEXT_FIELD, anlzr); String qtxt = "first aid text"; // from the doc texts in FunctionQuerySetup. // regular (boolean) query. Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java Fri Feb 26 13:09:54 2010 @@ -27,6 +27,7 @@ import org.apache.lucene.util.English; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Similarity; +import static org.apache.lucene.util.LuceneTestCaseJ4.TEST_VERSION_CURRENT; import java.io.Reader; import java.io.IOException; @@ -50,7 +51,7 @@ @Override public TokenStream tokenStream(String fieldName, Reader reader) { - TokenStream result = new LowerCaseTokenizer(reader); + TokenStream result = new LowerCaseTokenizer(TEST_VERSION_CURRENT, reader); result = new PayloadFilter(result, fieldName); return result; } Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Fri Feb 26 13:09:54 2010 @@ -37,6 +37,7 @@ import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanNearQuery; +import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.English; import org.apache.lucene.util.LuceneTestCase; @@ -56,20 +57,18 @@ private class PayloadAnalyzer extends Analyzer { @Override public TokenStream tokenStream(String fieldName, Reader reader) { - TokenStream result = new LowerCaseTokenizer(reader); + TokenStream result = new LowerCaseTokenizer(TEST_VERSION_CURRENT, reader); result = new PayloadFilter(result, fieldName); return result; } } private class PayloadFilter extends TokenFilter { - String fieldName; int numSeen = 0; protected PayloadAttribute payAtt; public PayloadFilter(TokenStream input, String fieldName) { super(input); - this.fieldName = fieldName; payAtt = addAttribute(PayloadAttribute.class); } @@ -93,7 +92,7 @@ String[] words = phrase.split("[\\s]+"); SpanQuery clauses[] = new SpanQuery[words.length]; for (int i=0;i uncaughtExceptions = Collections.synchronizedList(new ArrayList()); + public LuceneTestCase() { super(); } @@ -64,7 +85,18 @@ @Override protected void setUp() throws Exception { super.setUp(); + + savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + public void uncaughtException(Thread t, Throwable e) { + uncaughtExceptions.add(new UncaughtExceptionEntry(t, e)); + if (savedUncaughtExceptionHandler != null) + savedUncaughtExceptionHandler.uncaughtException(t, e); + } + }); + ConcurrentMergeScheduler.setTestMode(); + savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount(); } /** @@ -87,6 +119,7 @@ @Override protected void tearDown() throws Exception { + BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount); try { // this isn't as useful as calling directly from the scope where the // index readers are used, because they could be gc'ed just before @@ -104,6 +137,16 @@ purgeFieldCache(FieldCache.DEFAULT); } + Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler); + if (!uncaughtExceptions.isEmpty()) { + System.err.println("The following exceptions were thrown by threads:"); + for (UncaughtExceptionEntry entry : uncaughtExceptions) { + System.err.println("*** Thread: " + entry.thread.getName() + " ***"); + entry.exception.printStackTrace(System.err); + } + fail("Some threads throwed uncaught exceptions!"); + } + super.tearDown(); } Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Fri Feb 26 13:09:54 2010 @@ -18,6 +18,7 @@ */ import org.apache.lucene.index.ConcurrentMergeScheduler; +import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldCache.CacheEntry; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; @@ -30,6 +31,9 @@ import java.util.Arrays; import java.util.Iterator; import java.util.Random; +import java.util.ArrayList; +import java.util.List; +import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -73,6 +77,24 @@ //@RunWith(RunBareWrapper.class) public class LuceneTestCaseJ4 extends TestWatchman { + /** Change this when development starts for new Lucene version: */ + public static final Version TEST_VERSION_CURRENT = Version.LUCENE_31; + + private int savedBoolMaxClauseCount; + + private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null; + + private static class UncaughtExceptionEntry { + public final Thread thread; + public final Throwable exception; + + public UncaughtExceptionEntry(Thread thread, Throwable exception) { + this.thread = thread; + this.exception = exception; + } + } + private List uncaughtExceptions = Collections.synchronizedList(new ArrayList()); + // This is how we get control when errors occur. // Think of this as start/end/success/failed // events. @@ -88,7 +110,17 @@ @Before public void setUp() throws Exception { + savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + public void uncaughtException(Thread t, Throwable e) { + uncaughtExceptions.add(new UncaughtExceptionEntry(t, e)); + if (savedUncaughtExceptionHandler != null) + savedUncaughtExceptionHandler.uncaughtException(t, e); + } + }); + ConcurrentMergeScheduler.setTestMode(); + savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount(); seed = null; } @@ -114,6 +146,7 @@ @After public void tearDown() throws Exception { + BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount); try { // this isn't as useful as calling directly from the scope where the // index readers are used, because they could be gc'ed just before @@ -130,6 +163,16 @@ } finally { purgeFieldCache(FieldCache.DEFAULT); } + + Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler); + if (!uncaughtExceptions.isEmpty()) { + System.err.println("The following exceptions were thrown by threads:"); + for (UncaughtExceptionEntry entry : uncaughtExceptions) { + System.err.println("*** Thread: " + entry.thread.getName() + " ***"); + entry.exception.printStackTrace(System.err); + } + fail("Some threads throwed uncaught exceptions!"); + } } /** @@ -214,7 +257,7 @@ */ public Random newRandom() { if (seed != null) { - throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test"); + throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test"); } return newRandom(seedRnd.nextLong()); } @@ -226,7 +269,7 @@ */ public Random newRandom(long seed) { if (this.seed != null) { - throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test"); + throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test"); } this.seed = Long.valueOf(seed); return new Random(seed); Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Feb 26 13:09:54 2010 @@ -0,0 +1 @@ +/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:909334 Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java Fri Feb 26 13:09:54 2010 @@ -45,9 +45,9 @@ RAMDirectory dirA = new RAMDirectory(); RAMDirectory dirB = new RAMDirectory(); - IndexWriter wA = new IndexWriter(dirA, new WhitespaceAnalyzer(), true, + IndexWriter wA = new IndexWriter(dirA, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED); - IndexWriter wB = new IndexWriter(dirB, new WhitespaceAnalyzer(), true, + IndexWriter wB = new IndexWriter(dirB, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED); long theLong = Long.MAX_VALUE; Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java Fri Feb 26 13:09:54 2010 @@ -164,14 +164,14 @@ int encodedLen1 = IndexableBinaryStringTools.getEncodedLength( originalArray1, 0, numBytes1); if (encodedLen1 > encoded1.length) - encoded1 = new char[ArrayUtil.getNextSize(encodedLen1)]; + encoded1 = new char[ArrayUtil.oversize(encodedLen1, RamUsageEstimator.NUM_BYTES_CHAR)]; IndexableBinaryStringTools.encode(originalArray1, 0, numBytes1, encoded1, 0, encodedLen1); int encodedLen2 = IndexableBinaryStringTools.getEncodedLength(original2, 0, numBytes2); if (encodedLen2 > encoded2.length) - encoded2 = new char[ArrayUtil.getNextSize(encodedLen2)]; + encoded2 = new char[ArrayUtil.oversize(encodedLen2, RamUsageEstimator.NUM_BYTES_CHAR)]; IndexableBinaryStringTools.encode(original2, 0, numBytes2, encoded2, 0, encodedLen2); @@ -308,7 +308,7 @@ int encodedLen = IndexableBinaryStringTools.getEncodedLength(binary, 0, numBytes); if (encoded.length < encodedLen) - encoded = new char[ArrayUtil.getNextSize(encodedLen)]; + encoded = new char[ArrayUtil.oversize(encodedLen, RamUsageEstimator.NUM_BYTES_CHAR)]; IndexableBinaryStringTools.encode(binary, 0, numBytes, encoded, 0, encodedLen); Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestOpenBitSet.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestOpenBitSet.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestOpenBitSet.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestOpenBitSet.java Fri Feb 26 13:09:54 2010 @@ -22,9 +22,6 @@ import org.apache.lucene.search.DocIdSetIterator; -/** - * @version $Id$ - */ public class TestOpenBitSet extends LuceneTestCase { Random rand; @@ -233,7 +230,14 @@ } } - + public void testHashCodeEquals() { + OpenBitSet bs1 = new OpenBitSet(200); + OpenBitSet bs2 = new OpenBitSet(64); + bs1.set(3); + bs2.set(3); + assertEquals(bs1, bs2); + assertEquals(bs1.hashCode(), bs2.hashCode()); + } } Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestRamUsageEstimator.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestRamUsageEstimator.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestRamUsageEstimator.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestRamUsageEstimator.java Fri Feb 26 13:09:54 2010 @@ -25,20 +25,20 @@ String string = new String("test str"); RamUsageEstimator rue = new RamUsageEstimator(); long size = rue.estimateRamUsage(string); - System.out.println("size:" + size); + //System.out.println("size:" + size); string = new String("test strin"); size = rue.estimateRamUsage(string); - System.out.println("size:" + size); + //System.out.println("size:" + size); Holder holder = new Holder(); holder.holder = new Holder("string2", 5000L); size = rue.estimateRamUsage(holder); - System.out.println("size:" + size); + //System.out.println("size:" + size); String[] strings = new String[]{new String("test strin"), new String("hollow"), new String("catchmaster")}; size = rue.estimateRamUsage(strings); - System.out.println("size:" + size); + //System.out.println("size:" + size); } private static final class Holder { Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSmallFloat.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSmallFloat.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSmallFloat.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSmallFloat.java Fri Feb 26 13:09:54 2010 @@ -18,9 +18,6 @@ import java.util.Random; -/** - * @version $Id$ - */ public class TestSmallFloat extends LuceneTestCase { // original lucene byteToFloat Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSortedVIntList.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSortedVIntList.java?rev=916666&r1=916665&r2=916666&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSortedVIntList.java (original) +++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestSortedVIntList.java Fri Feb 26 13:09:54 2010 @@ -20,8 +20,6 @@ import java.io.IOException; import java.util.BitSet; -import org.apache.lucene.util.LuceneTestCase; - import junit.framework.TestSuite; import junit.textui.TestRunner; @@ -193,4 +191,11 @@ public void test12() { tstIllegalArgExc(new int[] {0,1,1,2,3,5,8,0}); } + public void test13Allocation() throws Exception { + int [] a = new int[2000]; // SortedVIntList initial byte size is 128 + for (int i = 0; i < a.length; i++) { + a[i] = (107 + i) * i; + } + tstIterator(new SortedVIntList(a), a); + } }