Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 77C1E100E0 for ; Tue, 3 Sep 2013 13:55:13 +0000 (UTC) Received: (qmail 32615 invoked by uid 500); 3 Sep 2013 13:55:12 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 32607 invoked by uid 99); 3 Sep 2013 13:55:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2013 13:55:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Tue, 03 Sep 2013 13:55:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 69D592388A29; Tue, 3 Sep 2013 13:54:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1519685 - in /lucene/dev/trunk/lucene: core/src/test/org/apache/lucene/index/ facet/src/test/org/apache/lucene/facet/range/ test-framework/src/java/org/apache/lucene/index/ test-framework/src/java/org/apache/lucene/util/ Date: Tue, 03 Sep 2013 13:54:49 -0000 To: commits@lucene.apache.org From: shaie@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130903135449.69D592388A29@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: shaie Date: Tue Sep 3 13:54:48 2013 New Revision: 1519685 URL: http://svn.apache.org/r1519685 Log: LUCENE-5199: Improve LuceneTestCase.defaultCodecSupportsDocsWithField to check the actual DocValuesFormat used per-field Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java?rev=1519685&r1=1519684&r2=1519685&view=diff ============================================================================== --- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java (original) +++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java Tue Sep 3 13:54:48 2013 @@ -327,7 +327,7 @@ public class TestMultiDocValues extends } public void testDocsWithField() throws Exception { - assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField("numbers")); Directory dir = newDirectory(); IndexWriterConfig iwc = newIndexWriterConfig(random(), TEST_VERSION_CURRENT, null); Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java?rev=1519685&r1=1519684&r2=1519685&view=diff ============================================================================== --- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java (original) +++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java Tue Sep 3 13:54:48 2013 @@ -635,7 +635,7 @@ public class TestRangeAccumulator extend // LUCENE-5178 public void testMissingValues() throws Exception { - assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField("field")); Directory d = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), d); Document doc = new Document(); Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1519685&r1=1519684&r2=1519685&view=diff ============================================================================== --- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (original) +++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java Tue Sep 3 13:54:48 2013 @@ -674,7 +674,7 @@ public abstract class BaseDocValuesForma iwriter.close(); SortedDocValues dv = getOnlySegmentReader(ireader).getSortedDocValues("field"); - if (defaultCodecSupportsDocsWithField()) { + if (defaultCodecSupportsDocsWithField("field")) { assertEquals(-1, dv.getOrd(0)); assertEquals(0, dv.getValueCount()); } else { @@ -734,7 +734,7 @@ public abstract class BaseDocValuesForma BytesRef scratch = new BytesRef(); dv.lookupOrd(dv.getOrd(0), scratch); assertEquals(new BytesRef("hello world 2"), scratch); - if (defaultCodecSupportsDocsWithField()) { + if (defaultCodecSupportsDocsWithField("dv")) { assertEquals(-1, dv.getOrd(1)); } dv.get(1, scratch); @@ -1092,7 +1092,8 @@ public abstract class BaseDocValuesForma public void testRandomSortedBytes() throws IOException { Directory dir = newDirectory(); IndexWriterConfig cfg = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - if (!defaultCodecSupportsDocsWithField()) { + final boolean defaultCodecSupportsDocsWithField = defaultCodecSupportsDocsWithField("field"); + if (!defaultCodecSupportsDocsWithField) { // if the codec doesnt support missing, we expect missing to be mapped to byte[] // by the impersonator, but we have to give it a chance to merge them to this cfg.setMergePolicy(newLogMergePolicy()); @@ -1121,14 +1122,14 @@ public abstract class BaseDocValuesForma doc.add(newTextField("id", "noValue", Field.Store.YES)); w.addDocument(doc); } - if (!defaultCodecSupportsDocsWithField()) { + if (!defaultCodecSupportsDocsWithField) { BytesRef bytesRef = new BytesRef(); hash.add(bytesRef); // add empty value for the gaps } if (rarely()) { w.commit(); } - if (!defaultCodecSupportsDocsWithField()) { + if (!defaultCodecSupportsDocsWithField) { // if the codec doesnt support missing, we expect missing to be mapped to byte[] // by the impersonator, but we have to give it a chance to merge them to this w.forceMerge(1); @@ -1253,7 +1254,7 @@ public abstract class BaseDocValuesForma } private void doTestMissingVsFieldCache(LongProducer longs) throws Exception { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("indexed", "dv")); Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf); @@ -2356,7 +2357,7 @@ public abstract class BaseDocValuesForma } public void testTwoNumbersOneMissing() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2385,7 +2386,7 @@ public abstract class BaseDocValuesForma } public void testTwoNumbersOneMissingWithMerging() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2415,7 +2416,7 @@ public abstract class BaseDocValuesForma } public void testThreeNumbersOneMissingWithMerging() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2451,7 +2452,7 @@ public abstract class BaseDocValuesForma } public void testTwoBytesOneMissing() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2483,7 +2484,7 @@ public abstract class BaseDocValuesForma } public void testTwoBytesOneMissingWithMerging() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2516,7 +2517,7 @@ public abstract class BaseDocValuesForma } public void testThreeBytesOneMissingWithMerging() throws IOException { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dv1")); Directory directory = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null); conf.setMergePolicy(newLogMergePolicy()); @@ -2813,7 +2814,7 @@ public abstract class BaseDocValuesForma /** Tests dv against stored fields with threads (all types + missing) */ public void testThreads2() throws Exception { - assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField()); + assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField("dvBin", "dvSorted", "dvNum", "dvSortedSet")); assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet()); Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1519685&r1=1519684&r2=1519685&view=diff ============================================================================== --- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original) +++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Tue Sep 3 13:54:48 2013 @@ -29,6 +29,7 @@ import java.util.logging.Logger; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.codecs.Codec; +import org.apache.lucene.codecs.DocValuesFormat; import org.apache.lucene.document.Field.Store; import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; @@ -1375,11 +1376,19 @@ public abstract class LuceneTestCase ext /** Returns true if the codec "supports" docsWithField * (other codecs return MatchAllBits, because you couldnt write missing values before) */ - public static boolean defaultCodecSupportsDocsWithField() { + public static boolean defaultCodecSupportsDocsWithField(String... fields) { String name = Codec.getDefault().getName(); if (name.equals("Lucene40") || name.equals("Lucene41") || name.equals("Lucene42")) { return false; } + + // check that the actual DocValuesFormat for each field supports docsWithField + for (String field : fields) { + String format = _TestUtil.getDocValuesFormat(field); + if (format.equals("Lucene40") || format.equals("Lucene41") || format.equals("Lucene42")) { + return false; + } + } return true; }