From 175094ae3110b1fbac487721443431fcecf6132a Mon Sep 17 00:00:00 2001 From: David Smiley Date: Mon, 26 Apr 2021 12:28:16 -0400 Subject: [PATCH] SOLR-15341: remove indexHeapUsageBytes (#94) from /admin/segments and /admin/luke because it's no longer available in Lucene 9 --- solr/CHANGES.txt | 4 +- .../handler/admin/LukeRequestHandler.java | 41 ++++--------------- solr/webapp/web/partials/core_overview.html | 3 -- 3 files changed, 11 insertions(+), 37 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 75c5737fda68..fe5cc0f151d0 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -265,8 +265,8 @@ Other Changes alternative implementations of where ConfigSets come from. (Nazerke Seidan, David Smiley) -* SOLR-15341: Lucene has removed CodecReader#ramBytesUsed in LUCENE-9387, so ramBytesUsed will no longer be reported - in SegmentsInfo handler (janhoy) +* SOLR-15341: Remove indexHeapUsageBytes info from /admin/segments and /admin/luke because it's no + longer available in Lucene -- LUCENE-9387. (janhoy, David Smiley) * SOLR-15146: Allow Collection API and Config Set API to be done in a distributed fashion without going through Overseer (Ilan Ginzburg) diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java index be091a9d74e2..a28ce1c8daed 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java @@ -16,6 +16,10 @@ */ package org.apache.solr.handler.admin; +import static org.apache.lucene.index.IndexOptions.DOCS; +import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS; +import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS; + import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.file.NoSuchFileException; @@ -29,7 +33,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; - import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.CharFilterFactory; import org.apache.lucene.analysis.TokenFilterFactory; @@ -39,13 +42,11 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.FieldInfo; -import org.apache.lucene.index.FilterLeafReader; import org.apache.lucene.index.IndexCommit; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.LeafReader; -import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.MultiTerms; import org.apache.lucene.index.PostingsEnum; import org.apache.lucene.index.Term; @@ -55,7 +56,6 @@ import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.Accountable; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.CharsRefBuilder; @@ -81,18 +81,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.lucene.index.IndexOptions.DOCS; -import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS; -import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS; - /** - * This handler exposes the internal lucene index. It is inspired by and - * modeled on Luke, the Lucene Index Browser by Andrzej Bialecki. - * http://www.getopt.org/luke/ + * Exposes the internal lucene index. It's registered at /admin/luke by default. * - * For more documentation see: - * http://wiki.apache.org/solr/LukeRequestHandler + * It is inspired by and + * modeled on Luke, the Lucene Index Browser that is currently a Lucene module: + * https://github.com/apache/lucene/tree/main/lucene/luke * + * @see SegmentsInfoRequestHandler * @since solr 1.2 */ public class LukeRequestHandler extends RequestHandlerBase @@ -575,8 +571,6 @@ public static SimpleOrderedMap getIndexInfo(DirectoryReader reader) thro indexInfo.add("numDocs", reader.numDocs()); indexInfo.add("maxDoc", reader.maxDoc()); indexInfo.add("deletedDocs", reader.maxDoc() - reader.numDocs()); - indexInfo.add("indexHeapUsageBytes", getIndexHeapUsed(reader)); - indexInfo.add("version", reader.getVersion()); // TODO? Is this different then: IndexReader.getCurrentVersion( dir )? indexInfo.add("segmentCount", reader.leaves().size()); indexInfo.add("current", closeSafe( reader::isCurrent)); @@ -633,23 +627,6 @@ private static long getSegmentsFileLength(IndexCommit commit) { return -1; } - /** Returns the sum of RAM bytes used by each segment */ - private static long getIndexHeapUsed(DirectoryReader reader) { - return reader.leaves().stream() - .map(LeafReaderContext::reader) - .map(FilterLeafReader::unwrap) - .map(leafReader -> { - if (leafReader instanceof Accountable) { - return ((Accountable) leafReader).ramBytesUsed(); - } else { - return -1L; // unsupported - } - }) - .mapToLong(Long::longValue) - .reduce(0, (left, right) -> left == -1 || right == -1 ? -1 : left + right); - // if any leaves are unsupported (-1), we ultimately return -1. - } - // Get terribly detailed information about a particular field. This is a very expensive call, use it with caution // especially on large indexes! @SuppressWarnings("unchecked") diff --git a/solr/webapp/web/partials/core_overview.html b/solr/webapp/web/partials/core_overview.html index 0c3b8e36d2af..b1d651a15e8d 100644 --- a/solr/webapp/web/partials/core_overview.html +++ b/solr/webapp/web/partials/core_overview.html @@ -39,9 +39,6 @@

Statistics

Max Doc:
{{index.maxDoc}}
-
Heap Memory Usage:
-
{{index.indexHeapUsageBytes}}
-
Deleted Docs:
{{index.deletedDocs}}