Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.util
Class SimpleMapIndex.IndexCalculator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.cache.SimpleMemoryCalculator
          extended by com.tangosol.util.SimpleMapIndex.IndexCalculator

All Implemented Interfaces:
ConfigurableCacheMap.UnitCalculator, OldCache.UnitCalculator
Enclosing class:
SimpleMapIndex

public static class SimpleMapIndex.IndexCalculator
extends SimpleMemoryCalculator

A stateful calculator used to calculate the cost of a homogeneous index (holding all values of a single type).


Nested Class Summary
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.

 

Field Summary
protected static int DEFAULT_SIZE
          The default size of an entry used if the calculator is unable to calculate the size.
protected  ConfigurableCacheMap.UnitCalculator m_calculator
          The ConfigurableCacheMap.UnitCalculator used to calculate the size of SimpleMapIndex.IndexCalculator.CalculatorState.CONFIGURED types. into Binary to approximate the size.
protected  int m_cbFixed
          If the state is SimpleMapIndex.IndexCalculator.CalculatorState.FIXED, contains a cached cost per instance.
protected  Converter m_converter
          The Converter used to convert SimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN types into Binary to approximate the size.
protected  SimpleMapIndex m_index
          The container index.
protected  SimpleMapIndex.IndexCalculator.CalculatorState m_state
          The SimpleMapIndex.IndexCalculator.CalculatorState of this calculator.

 

Fields inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
MAP_FIXED_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
SimpleMapIndex.IndexCalculator(BackingMapContext ctx, SimpleMapIndex index)
          Construct an IndexCalculator which allows for conversion of items into a serialized format.

 

Method Summary
protected  SimpleMapIndex.IndexCalculator.CalculatorState getCalculatorState(java.lang.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  SimpleMapIndex.IndexCalculator.CalculatorState initialize(java.lang.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(java.lang.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, main, padMemorySize, sizeOf

 

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
The SimpleMapIndex.IndexCalculator.CalculatorState of this calculator.

m_cbFixed

protected int m_cbFixed
If the state is SimpleMapIndex.IndexCalculator.CalculatorState.FIXED, contains a cached cost per instance.

m_converter

protected final Converter m_converter
The Converter used to convert SimpleMapIndex.IndexCalculator.CalculatorState.UNKNOWN types into Binary to approximate the size.

m_calculator

protected final ConfigurableCacheMap.UnitCalculator m_calculator
The ConfigurableCacheMap.UnitCalculator used to calculate the size of SimpleMapIndex.IndexCalculator.CalculatorState.CONFIGURED types. into Binary to approximate the size. The calculator is initialized iff the BackingMapContext associated with the index represents a ConfigurableCacheMap

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

SimpleMapIndex.IndexCalculator

public SimpleMapIndex.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 - the BackingMapContext associated with the indexed cache
index - the container index for this calculator (used only for logging)

Method Detail

getCalculatorState

protected SimpleMapIndex.IndexCalculator.CalculatorState getCalculatorState(java.lang.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(java.lang.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

sizeOf

public int sizeOf(java.lang.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 16-byte boundary:

Class Size
boolean 1
byte 1
short 2
char 2
int 4
long 8
float 4
double 8
Object SimpleMemoryCalculator.SIZE_OBJECT
Boolean SimpleMemoryCalculator.SIZE_OBJECT + 1
Byte SimpleMemoryCalculator.SIZE_OBJECT + 1
Short SimpleMemoryCalculator.SIZE_OBJECT + 2
Character SimpleMemoryCalculator.SIZE_OBJECT + 2
Integer SimpleMemoryCalculator.SIZE_OBJECT + 4
Long SimpleMemoryCalculator.SIZE_OBJECT + 8
Float SimpleMemoryCalculator.SIZE_OBJECT + 4
Double SimpleMemoryCalculator.SIZE_OBJECT + 8
BigInteger SimpleMemoryCalculator.SIZE_OBJECT + 48
BigDecimal SimpleMemoryCalculator.SIZE_OBJECT + 4 + SimpleMemoryCalculator.SIZE_OBJECT_REF + SimpleMemoryCalculator.SIZE_BIGINTEGER
Date SimpleMemoryCalculator.SIZE_OBJECT + SimpleMemoryCalculator.SIZE_OBJECT_REF + 8
Time SimpleMemoryCalculator.SIZE_OBJECT + SimpleMemoryCalculator.SIZE_OBJECT_REF + 8
Timestamp SimpleMemoryCalculator.SIZE_OBJECT + SimpleMemoryCalculator.SIZE_OBJECT_REF + 12
Binary SimpleMemoryCalculator.SIZE_BINARY + array
String SimpleMemoryCalculator.SIZE_STRING + array
array SimpleMemoryCalculator.SIZE_OBJECT + 4 + [element size]*length()
Overrides:
sizeOf in class SimpleMemoryCalculator
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

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.