Package com.tangosol.net.cache
Class BinaryMemoryCalculator
java.lang.Object
com.tangosol.util.Base
com.tangosol.net.cache.SimpleMemoryCalculator
com.tangosol.net.cache.BinaryMemoryCalculator
- All Implemented Interfaces:
ConfigurableCacheMap.UnitCalculator
A UnitCalculator implementation that weighs a cache entry based upon the
amount of physical memory (in bytes) required to store the entry.
This implementation can only determine an accurate entry size if both the
entry key and value are Binary
objects; otherwise, an exception will
be thrown during the unit calculation.
- Author:
- jh 2005.12.14
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BinaryMemoryCalculator
Singleton BinaryMemoryCalculator instance.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
-
Method Summary
Modifier and TypeMethodDescriptionint
calculateUnits
(Object oKey, Object oValue) Calculate the approximate number of bytes required to cache the given Binary key and value.static void
Unit test.Methods inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
calculateShallowSize, getEntrySize, getName, isInnerClass, padMemorySize, sizeOf, 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
-
INSTANCE
Singleton BinaryMemoryCalculator instance.
-
-
Constructor Details
-
BinaryMemoryCalculator
public BinaryMemoryCalculator()
-
-
Method Details
-
calculateUnits
Calculate the approximate number of bytes required to cache the given Binary key and value.- Specified by:
calculateUnits
in interfaceConfigurableCacheMap.UnitCalculator
- Overrides:
calculateUnits
in classSimpleMemoryCalculator
- Parameters:
oKey
- the keyoValue
- the value- Returns:
- the number of bytes of memory necessary to cache the given key and value
-
main
Unit test.Usage:
java com.tangosol.net.cache.BinaryMemoryCalculator
- Parameters:
asArg
- command line arguments
-