You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by so...@apache.org on 2021/02/26 02:32:53 UTC
[lucene-solr] branch master updated: LUCENE-9639: Implements
SimpleTextVectorReader#ramBytesUsed (#2433)
This is an automated email from the ASF dual-hosted git repository.
sokolov 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 5bca3d1 LUCENE-9639: Implements SimpleTextVectorReader#ramBytesUsed (#2433)
5bca3d1 is described below
commit 5bca3d196096866a8c9e73d619bee656594bb895
Author: zacharymorn <za...@yahoo.com>
AuthorDate: Thu Feb 25 18:32:34 2021 -0800
LUCENE-9639: Implements SimpleTextVectorReader#ramBytesUsed (#2433)
* Use single class imports
---
.../lucene/codecs/simpletext/SimpleTextVectorReader.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorReader.java
index 15603c1..1ef0200 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorReader.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorReader.java
@@ -40,6 +40,7 @@ import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.StringHelper;
/**
@@ -49,6 +50,10 @@ import org.apache.lucene.util.StringHelper;
* @lucene.experimental
*/
public class SimpleTextVectorReader extends VectorReader {
+ // shallowSizeOfInstance for fieldEntries map is included in ramBytesUsed() calculation
+ private static final long BASE_RAM_BYTES_USED =
+ RamUsageEstimator.shallowSizeOfInstance(SimpleTextVectorReader.class)
+ + RamUsageEstimator.shallowSizeOfInstance(BytesRef.class);
private static final BytesRef EMPTY = new BytesRef("");
@@ -174,7 +179,16 @@ public class SimpleTextVectorReader extends VectorReader {
@Override
public long ramBytesUsed() {
- return 0;
+ // mirror implementation of Lucene90VectorReader#ramBytesUsed
+ long totalBytes = BASE_RAM_BYTES_USED;
+ totalBytes += RamUsageEstimator.sizeOf(scratch.bytes());
+ totalBytes +=
+ RamUsageEstimator.sizeOfMap(
+ fieldEntries, RamUsageEstimator.shallowSizeOfInstance(FieldEntry.class));
+ for (FieldEntry entry : fieldEntries.values()) {
+ totalBytes += RamUsageEstimator.sizeOf(entry.ordToDoc);
+ }
+ return totalBytes;
}
@Override