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 2015/06/10 11:29:10 UTC
svn commit: r1684615 - in /lucene/dev/trunk/lucene: ./
core/src/java/org/apache/lucene/index/
test-framework/src/test/org/apache/lucene/index/
Author: mikemccand
Date: Wed Jun 10 09:29:09 2015
New Revision: 1684615
URL: http://svn.apache.org/r1684615
Log:
LUCENE-6533: don't cache live docs in SlowCompositeReaderWrapper
Added:
lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/
lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/TestAssertingLeafReader.java (with props)
Modified:
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1684615&r1=1684614&r2=1684615&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Wed Jun 10 09:29:09 2015
@@ -95,6 +95,10 @@ Bug fixes
* LUCENE-6527: Queries now get a dummy Similarity when scores are not needed
in order to not load unnecessary information like norms. (Adrien Grand)
+* LUCENE-6533: SlowCompositeReaderWrapper no longer caches its live docs
+ instance since this can prevent future improvements like a
+ disk-backed live docs (Adrien Grand, Mike McCandless)
+
Changes in Runtime Behavior
* LUCENE-6501: The subreader structure in ParallelCompositeReader
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java?rev=1684615&r1=1684614&r2=1684615&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java Wed Jun 10 09:29:09 2015
@@ -46,7 +46,6 @@ public final class SlowCompositeReaderWr
private final CompositeReader in;
private final Fields fields;
- private final Bits liveDocs;
private final boolean merging;
/** This method is sugar for getting an {@link LeafReader} from
@@ -66,7 +65,6 @@ public final class SlowCompositeReaderWr
super();
in = reader;
fields = MultiFields.getFields(in);
- liveDocs = MultiFields.getLiveDocs(in);
in.registerParentReader(this);
this.merging = merging;
}
@@ -230,7 +228,7 @@ public final class SlowCompositeReaderWr
@Override
public Bits getLiveDocs() {
ensureOpen();
- return liveDocs;
+ return MultiFields.getLiveDocs(in);
}
@Override
Added: lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/TestAssertingLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/TestAssertingLeafReader.java?rev=1684615&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/TestAssertingLeafReader.java (added)
+++ lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/index/TestAssertingLeafReader.java Wed Jun 10 09:29:09 2015
@@ -0,0 +1,74 @@
+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 org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.search.QueryUtils.FCInvisibleMultiReader;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.LuceneTestCase;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class TestAssertingLeafReader extends LuceneTestCase {
+ public void testAssertBits() throws Exception {
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
+ // Not deleted:
+ w.addDocument(new Document());
+
+ // Does get deleted:
+ Document doc = new Document();
+ doc.add(newStringField("id", "0", Field.Store.NO));
+ w.addDocument(doc);
+ w.commit();
+
+ w.deleteDocuments(new Term("id", "0"));
+ w.close();
+
+ // Now we have index with 1 segment with 2 docs one of which is marked deleted
+
+ IndexReader r = DirectoryReader.open(dir);
+ assertEquals(1, r.leaves().size());
+ assertEquals(2, r.maxDoc());
+ assertEquals(1, r.numDocs());
+
+ r = new AssertingDirectoryReader((DirectoryReader) r);
+
+ final IndexReader r2 = SlowCompositeReaderWrapper.wrap(r);
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ for(LeafReaderContext context : r2.leaves()) {
+ context.reader().getLiveDocs().get(0);
+ }
+ }
+ };
+ thread.start();
+ thread.join();
+
+ IOUtils.close(r2, dir);
+ }
+}