diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java index e4fa6e99e5c..0da9557d3e5 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java +++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java @@ -41,6 +41,14 @@ public abstract class SortedDocValues extends BinaryDocValues { } } + // nocommit make this final, and impl seekExact(term) to + // fwd to lookupTerm + + // nocommit should we nuke this? the iterator can be + // efficiently built "on top" since ord is part of the + // API? why must it be impl'd here...? + // SortedDocValuesTermsEnum. + public TermsEnum getTermsEnum() { // nocommit who tests this base impl ... // Default impl just uses the existing API; subclasses @@ -161,6 +169,8 @@ public abstract class SortedDocValues extends BinaryDocValues { * @param key Key to look up * @param spare Spare BytesRef **/ + // nocommit make this protected so codecs can impl better + // version ... public int lookupTerm(BytesRef key, BytesRef spare) { int low = 0; diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java index 85c573af969..4f1715253ba 100644 --- a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java +++ b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java @@ -1133,6 +1133,9 @@ class FieldCacheImpl implements FieldCache { final int maxDoc = reader.maxDoc(); SortedDocValues valuesIn = reader.getSortedDocValues(key.field); if (valuesIn != null) { + // nocommit we need thread DV test that would + // uncover this bug!! + // nocommit we should not cache in this case? return valuesIn; } else { diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java new file mode 100644 index 00000000000..f654c6dcb2b --- /dev/null +++ b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java @@ -0,0 +1,112 @@ +package org.apache.lucene.index; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CountDownLatch; + +import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.PackedLongDocValuesField; +import org.apache.lucene.document.SortedBytesDocValuesField; +import org.apache.lucene.document.StraightBytesDocValuesField; +import org.apache.lucene.search.FieldCache; +import org.apache.lucene.store.Directory; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.util._TestUtil; + +public class TestDocValuesWithThreads extends LuceneTestCase { + + public void test() throws Exception { + Directory dir = newDirectory(); + IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy())); + + // nocommit binary, sorted too + final List numbers = new ArrayList(); + final List binary = new ArrayList(); + final List sorted = new ArrayList(); + final int numDocs = atLeast(100); + for(int i=0;i threads = new ArrayList(); + final CountDownLatch startingGun = new CountDownLatch(1); + for(int t=0;t