mirror of https://github.com/apache/lucene.git
LUCENE-6025: Give AbstractPagedMutable the accountable interface
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1634585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b422645bde
commit
3dfb984bc7
|
@ -20,6 +20,9 @@ package org.apache.lucene.util.packed;
|
||||||
import static org.apache.lucene.util.packed.PackedInts.checkBlockSize;
|
import static org.apache.lucene.util.packed.PackedInts.checkBlockSize;
|
||||||
import static org.apache.lucene.util.packed.PackedInts.numBlocks;
|
import static org.apache.lucene.util.packed.PackedInts.numBlocks;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.apache.lucene.util.Accountable;
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
import org.apache.lucene.util.LongValues;
|
import org.apache.lucene.util.LongValues;
|
||||||
import org.apache.lucene.util.RamUsageEstimator;
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
@ -28,7 +31,7 @@ import org.apache.lucene.util.RamUsageEstimator;
|
||||||
* Base implementation for {@link PagedMutable} and {@link PagedGrowableWriter}.
|
* Base implementation for {@link PagedMutable} and {@link PagedGrowableWriter}.
|
||||||
* @lucene.internal
|
* @lucene.internal
|
||||||
*/
|
*/
|
||||||
abstract class AbstractPagedMutable<T extends AbstractPagedMutable<T>> extends LongValues {
|
abstract class AbstractPagedMutable<T extends AbstractPagedMutable<T>> extends LongValues implements Accountable {
|
||||||
|
|
||||||
static final int MIN_BLOCK_SIZE = 1 << 6;
|
static final int MIN_BLOCK_SIZE = 1 << 6;
|
||||||
static final int MAX_BLOCK_SIZE = 1 << 30;
|
static final int MAX_BLOCK_SIZE = 1 << 30;
|
||||||
|
@ -104,7 +107,7 @@ abstract class AbstractPagedMutable<T extends AbstractPagedMutable<T>> extends L
|
||||||
+ 3 * RamUsageEstimator.NUM_BYTES_INT;
|
+ 3 * RamUsageEstimator.NUM_BYTES_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the number of bytes used by this object. */
|
@Override
|
||||||
public long ramBytesUsed() {
|
public long ramBytesUsed() {
|
||||||
long bytesUsed = RamUsageEstimator.alignObjectSize(baseRamBytesUsed());
|
long bytesUsed = RamUsageEstimator.alignObjectSize(baseRamBytesUsed());
|
||||||
bytesUsed += RamUsageEstimator.alignObjectSize(RamUsageEstimator.shallowSizeOf(subMutables));
|
bytesUsed += RamUsageEstimator.alignObjectSize(RamUsageEstimator.shallowSizeOf(subMutables));
|
||||||
|
@ -113,6 +116,11 @@ abstract class AbstractPagedMutable<T extends AbstractPagedMutable<T>> extends L
|
||||||
}
|
}
|
||||||
return bytesUsed;
|
return bytesUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<? extends Accountable> getChildResources() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract T newUnfilledCopy(long newSize);
|
protected abstract T newUnfilledCopy(long newSize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue