From 6d373dbb4e563b427207da38ca5629a595c786e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 30 Aug 2024 15:00:32 +0200 Subject: [PATCH] Remove IOException from MultiTermQuery#getTermsCount (#13701) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither this method nor any of the two overrides can throw an IOException. This change removes the throws clauses from this method in order simplify not have to handle them on the callers side. --- .../core/src/java/org/apache/lucene/search/MultiTermQuery.java | 2 +- .../core/src/java/org/apache/lucene/search/TermInSetQuery.java | 2 +- .../join/src/java/org/apache/lucene/search/join/TermsQuery.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java b/lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java index 5a56286ebed3..8192f6121656 100644 --- a/lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/MultiTermQuery.java @@ -313,7 +313,7 @@ public final TermsEnum getTermsEnum(Terms terms) throws IOException { * Return the number of unique terms contained in this query, if known up-front. If not known, -1 * will be returned. */ - public long getTermsCount() throws IOException { + public long getTermsCount() { return -1; } diff --git a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java index 4e1abab09cc1..da01b24f0bd2 100644 --- a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java @@ -137,7 +137,7 @@ protected void swap(int i, int j) { } @Override - public long getTermsCount() throws IOException { + public long getTermsCount() { return termData.size(); } diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java index 729feb19b9c4..f781fc6a29eb 100644 --- a/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java +++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java @@ -95,7 +95,7 @@ protected TermsEnum getTermsEnum(Terms terms, AttributeSource atts) throws IOExc } @Override - public long getTermsCount() throws IOException { + public long getTermsCount() { return terms.size(); }