lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject [1/2] lucene-solr:branch_7x: LUCENE-8484: Only drop fully deleted segments in SoftDeletesDirectoryReaderWrapper
Date Wed, 05 Sep 2018 14:38:08 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x adfe98371 -> ae5adf630


LUCENE-8484: Only drop fully deleted segments in SoftDeletesDirectoryReaderWrapper

This specializes the change in LUCENE-8484 since there are valid usecases
where filtered reader should not modify the number of readers if a higher
level reader wants to expose the deleted or soft-deleted docs.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/33400683
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/33400683
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/33400683

Branch: refs/heads/branch_7x
Commit: 334006833ef48d60bf9c9680891b50a917ddb66e
Parents: adfe9837
Author: Simon Willnauer <simonw@apache.org>
Authored: Wed Sep 5 15:26:37 2018 +0200
Committer: Simon Willnauer <simonw@apache.org>
Committed: Wed Sep 5 15:26:37 2018 +0200

----------------------------------------------------------------------
 .../apache/lucene/index/FilterDirectoryReader.java    | 11 +++++------
 .../index/SoftDeletesDirectoryReaderWrapper.java      | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/33400683/lucene/core/src/java/org/apache/lucene/index/FilterDirectoryReader.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/FilterDirectoryReader.java b/lucene/core/src/java/org/apache/lucene/index/FilterDirectoryReader.java
index 1efd482..d9ddb94 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FilterDirectoryReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FilterDirectoryReader.java
@@ -51,16 +51,15 @@ public abstract class FilterDirectoryReader extends DirectoryReader {
    */
   public static abstract class SubReaderWrapper {
 
-    private LeafReader[] wrap(List<? extends LeafReader> readers) {
-      List<LeafReader> wrapped = new ArrayList<>(readers.size());
+    protected LeafReader[] wrap(List<? extends LeafReader> readers) {
+      LeafReader[] wrapped = new LeafReader[readers.size()];
+      int i = 0;
       for (LeafReader reader : readers) {
         LeafReader wrap = wrap(reader);
         assert wrap != null;
-        if (wrap.numDocs() > 0) {
-          wrapped.add(wrap);
-        }
+        wrapped[i++] = wrap;
       }
-      return wrapped.toArray(new LeafReader[0]);
+      return wrapped;
     }
 
     /** Constructor */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/33400683/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java
b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java
index cf3e437..21aac96 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java
@@ -19,8 +19,10 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 import java.io.UncheckedIOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -86,6 +88,18 @@ public final class SoftDeletesDirectoryReaderWrapper extends FilterDirectoryRead
       this.field = field;
     }
 
+    protected LeafReader[] wrap(List<? extends LeafReader> readers) {
+      List<LeafReader> wrapped = new ArrayList<>(readers.size());
+      for (LeafReader reader : readers) {
+        LeafReader wrap = wrap(reader);
+        assert wrap != null;
+        if (wrap.numDocs() != 0) {
+          wrapped.add(wrap);
+        }
+      }
+      return wrapped.toArray(new LeafReader[0]);
+    }
+
     @Override
     public LeafReader wrap(LeafReader reader) {
       CacheHelper readerCacheHelper = reader.getReaderCacheHelper();


Mime
View raw message