From e8a5ffbea36322372d76b3b38fd11ef75455bc70 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 16 Jul 2015 17:15:18 +0000 Subject: [PATCH] LUCENE-6681: SortingMergePolicy must override MergePolicy.size(...). git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1691421 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../org/apache/lucene/index/SortingMergePolicy.java | 5 +++++ .../apache/lucene/index/TestSortingMergePolicy.java | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 36224095a8c..2bd4eb6625c 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -259,6 +259,9 @@ Bug fixes * LUCENE-6680: Preserve two suggestions that have same key and weight but different payloads (Arcadius Ahouansou via Mike McCandless) +* LUCENE-6681: SortingMergePolicy must override MergePolicy.size(...). + (Christine Poerschke via Adrien Grand) + Changes in Runtime Behavior * LUCENE-6501: The subreader structure in ParallelCompositeReader diff --git a/lucene/misc/src/java/org/apache/lucene/index/SortingMergePolicy.java b/lucene/misc/src/java/org/apache/lucene/index/SortingMergePolicy.java index 7b0c545d963..299ac4be6f4 100644 --- a/lucene/misc/src/java/org/apache/lucene/index/SortingMergePolicy.java +++ b/lucene/misc/src/java/org/apache/lucene/index/SortingMergePolicy.java @@ -260,6 +260,11 @@ public final class SortingMergePolicy extends MergePolicy { return in.useCompoundFile(segments, newSegment, writer); } + @Override + protected long size(SegmentCommitInfo info, IndexWriter writer) throws IOException { + return in.size(info, writer); + } + @Override public String toString() { return "SortingMergePolicy(" + in + ", sorter=" + sorter + ")"; diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java b/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java index 17435c47569..87291175865 100644 --- a/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java +++ b/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java @@ -18,6 +18,8 @@ package org.apache.lucene.index; */ import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -192,4 +194,15 @@ public class TestSortingMergePolicy extends LuceneTestCase { } } + public void testMethodsOverridden() throws Exception { + for (Method m : MergePolicy.class.getDeclaredMethods()) { + if (Modifier.isFinal(m.getModifiers())) continue; + try { + SortingMergePolicy.class.getDeclaredMethod(m.getName(), m.getParameterTypes()); + } catch (NoSuchMethodException e) { + fail("SortingMergePolicy needs to override '"+m+"'"); + } + } + } + }