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
- Enclosing class:
SimpleMapIndex
A stateful
calculator
used to calculate the cost of a homogeneous index (holding all values of a
single type).-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
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
Modifier and TypeFieldDescriptionprotected static final int
The default size of an entry used if the calculator is unable to calculate the size.protected static final int
The average memory cost of creating SegmentedHashMap$Entry or SafeHashMap$Entry.protected static final int
The memory cost of inflating an InflatableSet.protected final ConfigurableCacheMap.UnitCalculator
TheConfigurableCacheMap.UnitCalculator
used to calculate the size ofSimpleMapIndex.IndexCalculator.CalculatorState.CONFIGURED
types. intoBinary
to approximate the size.protected int
If the state isSimpleMapIndex.IndexCalculator.CalculatorState.FIXED
, contains a cached cost per instance.protected final Converter
TheConverter
used to convertSimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN
types intoBinary
to approximate the size.protected SimpleMapIndex
The container index.TheSimpleMapIndex.IndexCalculator.CalculatorState
of this calculator.protected static final int
The memory cost of a SegmentedHashMap used as the Forward Index.protected static final int
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
ConstructorDescriptionIndexCalculator
(BackingMapContext ctx, SimpleMapIndex index) Construct an IndexCalculator which allows for conversion of items into a serialized format. -
Method Summary
Modifier and TypeMethodDescriptiongetCalculatorState
(Class clz) Determine which method to use to count the size of an instance of the specified class.protected Converter
Return the converter used by this IndexCalculator, or null.protected int
Return the size of a map entry.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
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 Details
-
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
TheSimpleMapIndex.IndexCalculator.CalculatorState
of this calculator. -
m_cbFixed
protected int m_cbFixedIf the state isSimpleMapIndex.IndexCalculator.CalculatorState.FIXED
, contains a cached cost per instance. -
m_converter
TheConverter
used to convertSimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN
types intoBinary
to approximate the size. -
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_OVERHEADThe memory cost of a SegmentedHashMap used as the Forward Index. -
ENTRY_OVERHEAD
protected static final int ENTRY_OVERHEADThe average memory cost of creating SegmentedHashMap$Entry or SafeHashMap$Entry. -
SET_OVERHEAD
protected static final int SET_OVERHEADThe 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_OVERHEADThe 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_SIZEThe default size of an entry used if the calculator is unable to calculate the size.- See Also:
-
-
Constructor Details
-
IndexCalculator
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 Details
-
getCalculatorState
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
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
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
Return the converter used by this IndexCalculator, or null.- Returns:
- the converter used by this IndexCalculator
-