CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net.cache
Class BinaryMemoryCalculator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.cache.SimpleMemoryCalculator
          extended by com.tangosol.net.cache.BinaryMemoryCalculator
All Implemented Interfaces:
OldCache.UnitCalculator

public class BinaryMemoryCalculator
extends SimpleMemoryCalculator

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

Field Summary
static BinaryMemoryCalculator INSTANCE
          Singleton BinaryMemoryCalculator instance.
 
Fields inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
MAP_FIXED_SIZES, SIZE_BINARY, SIZE_BOOLEAN, SIZE_BYTE, SIZE_CHARACTER, SIZE_DOUBLE, SIZE_ENTRY, SIZE_FLOAT, SIZE_INTEGER, SIZE_LONG, SIZE_OBJECT, SIZE_OBJECT_REF, SIZE_SHORT, SIZE_STRING
 
Constructor Summary
BinaryMemoryCalculator()
           
 
Method Summary
 int calculateUnits(Object oKey, Object oValue)
          Calculate the approximate number of bytes required to cache the given Binary key and value.
static void main(String[] asArg)
          Unit test.
 
Methods inherited from class com.tangosol.net.cache.SimpleMemoryCalculator
calculateShallowSize, padMemorySize, sizeOf, sizeOf
 

Field Detail

INSTANCE

public static final BinaryMemoryCalculator INSTANCE
Singleton BinaryMemoryCalculator instance.

Constructor Detail

BinaryMemoryCalculator

public BinaryMemoryCalculator()
Method Detail

calculateUnits

public int calculateUnits(Object oKey,
                          Object oValue)
Calculate the approximate number of bytes required to cache the given Binary key and value.

Specified by:
calculateUnits in interface OldCache.UnitCalculator
Overrides:
calculateUnits in class SimpleMemoryCalculator
Parameters:
oKey - the key
oValue - the value
Returns:
the number of bytes of memory necessary to cache the given key and value

main

public static void main(String[] asArg)
Unit test.

Usage:

 java com.tangosol.net.cache.BinaryMemoryCalculator
 

Parameters:
asArg - command line arguments

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation