Skip to content

Commit

Permalink
SOLR-15341: remove indexHeapUsageBytes (apache#94)
Browse files Browse the repository at this point in the history
from /admin/segments and /admin/luke because it's no longer available in Lucene 9
  • Loading branch information
dsmiley authored Apr 26, 2021
1 parent d79b19a commit 175094a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
4 changes: 2 additions & 2 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -575,8 +571,6 @@ public static SimpleOrderedMap<Object> 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));
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 0 additions & 3 deletions solr/webapp/web/partials/core_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ <h2><span>Statistics</span></h2>
<dt class="index_max-doc">Max Doc:</dt>
<dd class="index_max-doc value">{{index.maxDoc}}</dd>

<dt class="index_heap-usage-bytes">Heap Memory Usage:</dt>
<dd class="index_heap-usage-bytes value">{{index.indexHeapUsageBytes}}</dd>

<dt class="index_deleted-docs">Deleted Docs:</dt>
<dd class="index_deleted-docs value">{{index.deletedDocs}}</dd>

Expand Down

0 comments on commit 175094a

Please sign in to comment.