lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject lucene-solr:branch_7x: LUCENE-8049: IndexWriter.getMergingSegments() signature changed to return Set instead of Collection
Date Mon, 27 Nov 2017 04:30:52 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x d62b0bf3c -> 4e154cf85


LUCENE-8049: IndexWriter.getMergingSegments() signature changed to return Set instead of Collection

(cherry picked from commit 64d95e6)


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

Branch: refs/heads/branch_7x
Commit: 4e154cf85df55c8a063e93439377478aa967d99e
Parents: d62b0bf
Author: David Smiley <dsmiley@apache.org>
Authored: Sun Nov 26 23:25:06 2017 -0500
Committer: David Smiley <dsmiley@apache.org>
Committed: Sun Nov 26 23:30:38 2017 -0500

----------------------------------------------------------------------
 lucene/CHANGES.txt                                          | 3 +++
 .../core/src/java/org/apache/lucene/index/IndexWriter.java  | 6 +++---
 .../src/java/org/apache/lucene/index/LogMergePolicy.java    | 4 ++--
 .../src/java/org/apache/lucene/index/TieredMergePolicy.java | 9 +++++----
 .../java/org/apache/lucene/index/MockRandomMergePolicy.java | 4 ++--
 5 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4e154cf8/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 66f5e2d..c7cb055 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -31,6 +31,9 @@ API Changes
 * LUCENE-7998: DoubleValuesSource.fromQuery() allows you to use the scores
   from a Query as a DoubleValuesSource. (Alan Woodward)
 
+* LUCENE-8049: IndexWriter.getMergingSegments()'s return type was changed from
+  Collection to Set to more accurately reflect it's nature. (David Smiley)
+
 New Features
 
 * LUCENE-8061: Add convenience factory methods to create BBoxes and XYZSolids

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4e154cf8/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 09de980..d6d6cca 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -2287,9 +2287,9 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable
{
    *  (which you do when IndexWriter invokes the
    *  MergePolicy).
    *
-   *  <p>Do not alter the returned collection! */
-  public synchronized Collection<SegmentCommitInfo> getMergingSegments() {
-    return mergingSegments;
+   *  <p>The Set is unmodifiable. */
+  public synchronized Set<SegmentCommitInfo> getMergingSegments() {
+    return Collections.unmodifiableSet(mergingSegments);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4e154cf8/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java
index 4d0ce51..7802563 100644
--- a/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java
+++ b/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java
@@ -19,10 +19,10 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>This class implements a {@link MergePolicy} that tries
@@ -462,7 +462,7 @@ public abstract class LogMergePolicy extends MergePolicy {
     final List<SegmentInfoAndLevel> levels = new ArrayList<>(numSegments);
     final float norm = (float) Math.log(mergeFactor);
 
-    final Collection<SegmentCommitInfo> mergingSegments = writer.getMergingSegments();
+    final Set<SegmentCommitInfo> mergingSegments = writer.getMergingSegments();
 
     for(int i=0;i<numSegments;i++) {
       final SegmentCommitInfo info = infos.info(i);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4e154cf8/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
index b5185fc..cdfdea6 100644
--- a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
+++ b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
@@ -26,6 +26,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 /**
  *  Merges segments of approximately equal size, subject to
@@ -287,8 +288,8 @@ public class TieredMergePolicy extends MergePolicy {
     if (infos.size() == 0) {
       return null;
     }
-    final Collection<SegmentCommitInfo> merging = writer.getMergingSegments();
-    final Collection<SegmentCommitInfo> toBeMerged = new HashSet<>();
+    final Set<SegmentCommitInfo> merging = writer.getMergingSegments();
+    final Set<SegmentCommitInfo> toBeMerged = new HashSet<>();
 
     final List<SegmentCommitInfo> infosSorted = new ArrayList<>(infos.asList());
 
@@ -519,7 +520,7 @@ public class TieredMergePolicy extends MergePolicy {
 
     List<SegmentCommitInfo> eligible = new ArrayList<>();
     boolean forceMergeRunning = false;
-    final Collection<SegmentCommitInfo> merging = writer.getMergingSegments();
+    final Set<SegmentCommitInfo> merging = writer.getMergingSegments();
     boolean segmentIsOriginal = false;
     for(SegmentCommitInfo info : infos) {
       final Boolean isOriginal = segmentsToMerge.get(info);
@@ -594,7 +595,7 @@ public class TieredMergePolicy extends MergePolicy {
       message("findForcedDeletesMerges infos=" + writer.segString(infos) + " forceMergeDeletesPctAllowed="
+ forceMergeDeletesPctAllowed, writer);
     }
     final List<SegmentCommitInfo> eligible = new ArrayList<>();
-    final Collection<SegmentCommitInfo> merging = writer.getMergingSegments();
+    final Set<SegmentCommitInfo> merging = writer.getMergingSegments();
     for(SegmentCommitInfo info : infos) {
       double pctDeletes = 100.*((double) writer.numDeletedDocs(info))/info.info.maxDoc();
       if (pctDeletes > forceMergeDeletesPctAllowed && !merging.contains(info))
{

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4e154cf8/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
b/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
index f9fa601..61efaa2 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
@@ -18,11 +18,11 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import java.util.Set;
 
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
@@ -56,7 +56,7 @@ public class MockRandomMergePolicy extends MergePolicy {
     int numSegments = segmentInfos.size();
 
     List<SegmentCommitInfo> segments = new ArrayList<>();
-    final Collection<SegmentCommitInfo> merging = writer.getMergingSegments();
+    final Set<SegmentCommitInfo> merging = writer.getMergingSegments();
 
     for(SegmentCommitInfo sipc : segmentInfos) {
       if (!merging.contains(sipc)) {


Mime
View raw message