Package com.sun.corba.ee.impl.misc
Class CacheTable<K>
- java.lang.Object
-
- com.sun.corba.ee.impl.misc.CacheTable<K>
-
public class CacheTable<K> extends java.lang.ObjectThis is a hash table implementation that simultaneously maps key to value and value to key. It is used for marshalling and unmarshalling value types, where it is necessary to track the correspondence between object instances and their offsets in a stream. It is also used for tracking indirections for Strings that represent codebases and repositoryids. Since the offset is always non-negative, only non-negative values should be stored here (and storing -1 will cause failures). Also note that the same key (Object) may be stored with multiple values (int offsets) due to the way readResolve works (see also GlassFish issue 1605).- Since:
- 1.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCacheTable.Entry<K>
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcacheTypeprivate intentryCountprivate static intINITIAL_SIZEprivate static intINITIAL_THRESHHOLDprivate CacheTable.Entry<K>[]mapprivate static intMAX_SIZEprivate booleannoReverseMapprivate ORBorbprivate CacheTable.Entry<K>[]rmapprivate intsizeprivate intthreshholdprivate static ORBUtilSystemExceptionwrapper
-
Constructor Summary
Constructors Constructor Description CacheTable(java.lang.String cacheType, ORB orb, boolean u)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(K key)booleancontainsVal(int val)voiddone()KgetKey(int val)Return the key where (key,val) is present in the map.intgetVal(K key)Returns some int val where (key,val) is in this CacheTable.private voidgrow()private inthash(int val)private inthash(K key)private inthashModTableSize(int h)private voidinitTables()voidput(K key, int val)Store the (key,val) pair in the hash table, unless (key,val) is already present.private booleanput_table(K key, int val)
-
-
-
Field Detail
-
wrapper
private static final ORBUtilSystemException wrapper
-
noReverseMap
private boolean noReverseMap
-
cacheType
private java.lang.String cacheType
-
INITIAL_SIZE
private static final int INITIAL_SIZE
- See Also:
- Constant Field Values
-
MAX_SIZE
private static final int MAX_SIZE
- See Also:
- Constant Field Values
-
INITIAL_THRESHHOLD
private static final int INITIAL_THRESHHOLD
- See Also:
- Constant Field Values
-
size
private int size
-
threshhold
private int threshhold
-
entryCount
private int entryCount
-
map
private CacheTable.Entry<K>[] map
-
rmap
private CacheTable.Entry<K>[] rmap
-
orb
private ORB orb
-
-
Constructor Detail
-
CacheTable
public CacheTable(java.lang.String cacheType, ORB orb, boolean u)
-
-
Method Detail
-
initTables
private void initTables()
-
grow
private void grow()
-
hashModTableSize
private int hashModTableSize(int h)
-
hash
private int hash(K key)
-
hash
private int hash(int val)
-
put
public final void put(K key, int val)
Store the (key,val) pair in the hash table, unless (key,val) is already present. Returns true if a new (key,val) pair was added, else false. val must be non-negative, but this is not checked.- Parameters:
key- Key for tableval- Non-negative value
-
put_table
private boolean put_table(K key, int val)
-
containsKey
public final boolean containsKey(K key)
-
getVal
public final int getVal(K key)
Returns some int val where (key,val) is in this CacheTable.- Parameters:
key- Key to lookup- Returns:
- Value found
-
containsVal
public final boolean containsVal(int val)
-
getKey
public final K getKey(int val)
Return the key where (key,val) is present in the map.- Parameters:
val- Value to lookup- Returns:
- Key for the value
-
done
public void done()
-
-