dsmiley commented on a change in pull request #1497:
URL: https://github.com/apache/lucene-solr/pull/1497#discussion_r426829924



##########
File path: 
solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
##########
@@ -634,17 +635,19 @@ private static long getSegmentsFileLength(IndexCommit 
commit) {
 
   /** Returns the sum of RAM bytes used by each segment */
   private static long getIndexHeapUsed(DirectoryReader reader) {
-    long indexHeapRamBytesUsed = 0;
-    for(LeafReaderContext leafReaderContext : reader.leaves()) {
-      LeafReader leafReader = leafReaderContext.reader();
-      if (leafReader instanceof SegmentReader) {
-        indexHeapRamBytesUsed += ((SegmentReader) leafReader).ramBytesUsed();
-      } else {
-        // Not supported for any reader that is not a SegmentReader
-        return -1;
-      }
-    }
-    return indexHeapRamBytesUsed;
+    return reader.leaves().stream()
+        .map(LeafReaderContext::reader)
+        .map(FilterLeafReader::unwrap)
+        .map(leafReader -> {
+          if (leafReader instanceof Accountable) {

Review comment:
       Feel free to suggest a code snippet; I'm not sure I get it.
   
   One small improvement I see I could make was change the last "map" call to 
be a "mapToLong" instead, and then I can remove the last mapToLong.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to