Package com.tangosol.util
Class SimpleMapIndex.IndexCalculator
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.net.cache.SimpleMemoryCalculator
-
- com.tangosol.util.SimpleMapIndex.IndexCalculator
-
- All Implemented Interfaces:
ConfigurableCacheMap.UnitCalculator
,OldCache.UnitCalculator
- Enclosing class:
- SimpleMapIndex
public static class SimpleMapIndex.IndexCalculator extends SimpleMemoryCalculator
A statefulcalculator
used to calculate the cost of a homogeneous index (holding all values of a single type).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleMapIndex.IndexCalculator.CalculatorState
The CalculatorState identifies the method used by the calculator to calculate the cost of a key or a value type.-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_SIZE
The default size of an entry used if the calculator is unable to calculate the size.protected static int
ENTRY_OVERHEAD
The average memory cost of creating SegmentedHashMap$Entry or SafeHashMap$Entry.protected static int
INFLATION_OVERHEAD
The memory cost of inflating an InflatableSet.protected ConfigurableCacheMap.UnitCalculator
m_calculator
TheConfigurableCacheMap.UnitCalculator
used to calculate the size ofSimpleMapIndex.IndexCalculator.CalculatorState.CONFIGURED
types. intoBinary
to approximate the size.protected int
m_cbFixed
If the state isSimpleMapIndex.IndexCalculator.CalculatorState.FIXED
, contains a cached cost per instance.protected Converter
m_converter
TheConverter
used to convertSimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN
types intoBinary
to approximate the size.protected SimpleMapIndex
m_index
The container index.protected SimpleMapIndex.IndexCalculator.CalculatorState
m_state
TheSimpleMapIndex.IndexCalculator.CalculatorState
of this calculator.protected static int
MAP_OVERHEAD
The memory cost of a SegmentedHashMap used as the Forward Index.protected static int
SET_OVERHEAD
The memory cost of creating an InflatableSet.-
Fields inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
MAP_FIXED_SIZES, MAP_PRIMITIVE_SIZES, SIZE_BASIC_OBJECT, SIZE_BIGDECIMAL, SIZE_BIGINTEGER, SIZE_BINARY, SIZE_BOOLEAN, SIZE_BYTE, SIZE_CHARACTER, SIZE_DATE, SIZE_DOUBLE, SIZE_ENTRY, SIZE_FLOAT, SIZE_INTEGER, SIZE_LONG, SIZE_OBJECT, SIZE_OBJECT_REF, SIZE_SHORT, SIZE_STRING, SIZE_TIMESTAMP
-
-
Constructor Summary
Constructors Constructor Description IndexCalculator(BackingMapContext ctx, SimpleMapIndex index)
Construct an IndexCalculator which allows for conversion of items into a serialized format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SimpleMapIndex.IndexCalculator.CalculatorState
getCalculatorState(Class clz)
Determine which method to use to count the size of an instance of the specified class.protected Converter
getConverter()
Return the converter used by this IndexCalculator, or null.protected int
getEntrySize()
Return the size of a map entry.protected SimpleMapIndex.IndexCalculator.CalculatorState
initialize(Object o)
Initialize the calculator based on the type of the specified object assuming that the indexed values are homogeneous (of the same type).int
sizeOf(Object o)
Estimate the number of bytes of memory consumed by the given object.-
Methods inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
calculateShallowSize, calculateUnits, getName, isInnerClass, main, padMemorySize, sizeOf
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Field Detail
-
m_index
protected SimpleMapIndex m_index
The container index. Since we use an enum for the state we have to make this inner class a static one and pass the parent index into the constructor.
-
m_state
protected SimpleMapIndex.IndexCalculator.CalculatorState m_state
TheSimpleMapIndex.IndexCalculator.CalculatorState
of this calculator.
-
m_cbFixed
protected int m_cbFixed
If the state isSimpleMapIndex.IndexCalculator.CalculatorState.FIXED
, contains a cached cost per instance.
-
m_converter
protected final Converter m_converter
TheConverter
used to convertSimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN
types intoBinary
to approximate the size.
-
m_calculator
protected final ConfigurableCacheMap.UnitCalculator m_calculator
TheConfigurableCacheMap.UnitCalculator
used to calculate the size ofSimpleMapIndex.IndexCalculator.CalculatorState.CONFIGURED
types. intoBinary
to approximate the size. The calculator is initialized iff theBackingMapContext
associated with the index represents aConfigurableCacheMap
-
MAP_OVERHEAD
protected static final int MAP_OVERHEAD
The memory cost of a SegmentedHashMap used as the Forward Index.
-
ENTRY_OVERHEAD
protected static final int ENTRY_OVERHEAD
The average memory cost of creating SegmentedHashMap$Entry or SafeHashMap$Entry.
-
SET_OVERHEAD
protected static final int SET_OVERHEAD
The memory cost of creating an InflatableSet.This cost does not include post inflation of the set; INFLATION_OVERHEAD should be considered as a one-off memory cost to be added post inflation.
-
INFLATION_OVERHEAD
protected static final int INFLATION_OVERHEAD
The memory cost of inflating an InflatableSet. The inflation can be determined when its size grows from 1 to 2, at which point INFLATION_OVERHEAD should be added to any models predicting memory usage.
-
DEFAULT_SIZE
protected static final int DEFAULT_SIZE
The default size of an entry used if the calculator is unable to calculate the size.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexCalculator
public IndexCalculator(BackingMapContext ctx, SimpleMapIndex index)
Construct an IndexCalculator which allows for conversion of items into a serialized format. The calculator may use the size of the serialized value representation to approximate the size of indexed values.Note:
ExternalizableHelper.CONVERTER_TO_BINARY
can be used to convert Serializable or ExternalizableLite objects- Parameters:
ctx
- theBackingMapContext
associated with the indexed cacheindex
- the container index for this calculator (used only for logging)
-
-
Method Detail
-
getCalculatorState
protected SimpleMapIndex.IndexCalculator.CalculatorState getCalculatorState(Class clz)
Determine which method to use to count the size of an instance of the specified class.- Parameters:
clz
- the type of objects that this calculator will operate on- Returns:
- the
SimpleMapIndex.IndexCalculator.CalculatorState
-
initialize
protected SimpleMapIndex.IndexCalculator.CalculatorState initialize(Object o)
Initialize the calculator based on the type of the specified object assuming that the indexed values are homogeneous (of the same type).- Parameters:
o
- an instance of the value to calculate the size for- Returns:
- the new
SimpleMapIndex.IndexCalculator.CalculatorState
-
getEntrySize
protected int getEntrySize()
Return the size of a map entry.- Overrides:
getEntrySize
in classSimpleMemoryCalculator
- Returns:
- the entry size
-
sizeOf
public int sizeOf(Object o)
Estimate the number of bytes of memory consumed by the given object.The calculation is based on the class of the given object, with reference types assumed to be aligned on a 8-byte boundary:
- Overrides:
sizeOf
in classSimpleMemoryCalculator
- Parameters:
o
- the object to measure the size of- Returns:
- an estimate of the number of bytes required to store the given object in memory
-
getConverter
protected Converter getConverter()
Return the converter used by this IndexCalculator, or null.- Returns:
- the converter used by this IndexCalculator
-
-