You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2020/12/03 09:55:48 UTC

[lucene-solr] branch master updated: LUCENE-9631: Properly override slice() on subclasses of OffsetRange.

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new a9e180b  LUCENE-9631: Properly override slice() on subclasses of OffsetRange.
a9e180b is described below

commit a9e180b20aea19c1594b7d849ca4852ed767db0a
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Thu Dec 3 10:55:33 2020 +0100

    LUCENE-9631: Properly override slice() on subclasses of OffsetRange.
---
 lucene/CHANGES.txt                                               | 2 ++
 .../apache/lucene/search/matchhighlight/MatchHighlighter.java    | 5 +++++
 .../java/org/apache/lucene/search/matchhighlight/Passage.java    | 9 +++++++++
 3 files changed, 16 insertions(+)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 2d3c279..a922a80 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -186,6 +186,8 @@ Bug fixes
 
 Other
 
+* LUCENE-9631: Properly override slice() on subclasses of OffsetRange. (Dawid Weiss)
+
 * LUCENE-9312: Allow gradle builds against arbitrary JVMs. (Tomoko Uchida, Dawid Weiss)
 
 * LUCENE-9391: Upgrade HPPC to 0.8.2. (Haoyu Zhai)
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java
index d59af2a..277a324 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java
@@ -163,6 +163,11 @@ public class MatchHighlighter {
       super(from, to);
       this.query = query;
     }
+
+    @Override
+    public QueryOffsetRange slice(int from, int to) {
+      return new QueryOffsetRange(query, from, to);
+    }
   }
 
   private static class DocHit {
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java
index 9a4dc4b..7fafedd 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java
@@ -32,6 +32,15 @@ public class Passage extends OffsetRange {
     this.markers = markers;
   }
 
+  /**
+   * Passages can't be sliced as it could split previously determined
+   * highlight markers.
+   */
+  @Override
+  public OffsetRange slice(int from, int to) {
+    throw new RuntimeException("Passages.slice() does not make sense?");
+  }
+
   @Override
   public String toString() {
     return "[" + super.toString() + ", markers=" + markers + "]";