mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-19 19:35:02 +00:00
Remove Accountable interface from BytesReference (#34900)
This commit is contained in:
parent
6da2fb7d5b
commit
c74232037a
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.elasticsearch.common.bytes;
|
package org.elasticsearch.common.bytes;
|
||||||
|
|
||||||
import org.apache.lucene.util.Accountable;
|
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.BytesRefIterator;
|
import org.apache.lucene.util.BytesRefIterator;
|
||||||
import org.elasticsearch.common.io.stream.BytesStream;
|
import org.elasticsearch.common.io.stream.BytesStream;
|
||||||
@ -38,7 +37,7 @@ import java.util.function.ToIntBiFunction;
|
|||||||
/**
|
/**
|
||||||
* A reference to bytes.
|
* A reference to bytes.
|
||||||
*/
|
*/
|
||||||
public abstract class BytesReference implements Accountable, Comparable<BytesReference>, ToXContentFragment {
|
public abstract class BytesReference implements Comparable<BytesReference>, ToXContentFragment {
|
||||||
|
|
||||||
private Integer hash = null; // we cache the hash of this reference since it can be quite costly to re-calculated it
|
private Integer hash = null; // we cache the hash of this reference since it can be quite costly to re-calculated it
|
||||||
|
|
||||||
@ -71,6 +70,11 @@ public abstract class BytesReference implements Accountable, Comparable<BytesRef
|
|||||||
*/
|
*/
|
||||||
public abstract BytesReference slice(int from, int length);
|
public abstract BytesReference slice(int from, int length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of memory used by this BytesReference
|
||||||
|
*/
|
||||||
|
public abstract long ramBytesUsed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A stream input of the bytes.
|
* A stream input of the bytes.
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package org.elasticsearch.index.cache.request;
|
package org.elasticsearch.index.cache.request;
|
||||||
|
|
||||||
import org.apache.lucene.util.Accountable;
|
import org.apache.lucene.util.Accountable;
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.metrics.CounterMetric;
|
import org.elasticsearch.common.metrics.CounterMetric;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,11 +45,11 @@ public final class ShardRequestCache {
|
|||||||
missCount.inc();
|
missCount.inc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCached(Accountable key, Accountable value) {
|
public void onCached(Accountable key, BytesReference value) {
|
||||||
totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed());
|
totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRemoval(Accountable key, Accountable value, boolean evicted) {
|
public void onRemoval(Accountable key, BytesReference value, boolean evicted) {
|
||||||
if (evicted) {
|
if (evicted) {
|
||||||
evictionsMetric.inc();
|
evictionsMetric.inc();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import org.apache.lucene.search.IndexSearcher;
|
|||||||
import org.apache.lucene.search.TermQuery;
|
import org.apache.lucene.search.TermQuery;
|
||||||
import org.apache.lucene.search.TopDocs;
|
import org.apache.lucene.search.TopDocs;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.Accountable;
|
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||||
@ -48,7 +47,6 @@ import org.elasticsearch.test.ESTestCase;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -501,11 +499,6 @@ public class IndicesRequestCacheTests extends ESTestCase {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Accountable> getChildResources() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFragment() {
|
public boolean isFragment() {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user