Top Description Inners Fields Constructors Methods
com.fasterxml.aalto.out

public final Class WNameTable

extends NameTable
Class Inheritance
Imports
javax.xml.stream.XMLStreamException, com.fasterxml.aalto.util.NameTable

This is a symbol table implementation used for storing byte-based WNames.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
LAST_VALID_BUCKET

Bucket index is 8 bits, and value 0 is reserved to represent 'empty' status.

private int
mCollCount

Total number of WNames in collision buckets (included in mCount along with primary entries)

private int
mCollEnd

Index of the first unused collision bucket entry (== size of the used portion of collision list): less than or equal to 0xFF (255), since max number of entries is 255 (8-bit, minus 0 used as 'empty' marker)

private WNameTable.Bucket[]
mCollList

Array of heads of collision bucket chains; size dynamically

private boolean
mCollListShared

Flag that indicates whether underlying data structures for the collision list are shared or not.

private int
mCount

Total number of WNames in the symbol table

pack-priv static final int
private int[]
mMainHash

Array of 2^N size, which contains combination of 24-bits of hash (0 to indicate 'empty' slot), and 8-bit collision bucket index (0 to indicate empty collision bucket chain; otherwise subtract one from index)

private int
mMainHashMask

Mask used to truncate 32-bit hash value to current hash array size; essentially, hash array size - 1 (since hash array sizes are 2^N).

private boolean
mMainHashShared

Flag that indicates whether underlying data structures for the main hash area are shared or not.

private WName[]
mMainNames

Array that contains WName instances matching entries in mMainHash.

private boolean
pack-priv final WNameFactory
private transient boolean
mNeedRehash

This flag is set if, after adding a new entry, it is deemed that a rehash is warranted if any more entries are to be added.

pack-priv final WNameTable
mParent

Parent reference is needed to be able to merge new symbols if and as necessary

Constructor Summary

AccessConstructor and Description
protected
WNameTable(int hashSize)

private
WNameTable(WNameTable parent, WNameFactory f)

Constructor used when creating a child instance

Method Summary

Modifier and TypeMethod and Description
private void
addSymbol(WName symbol)

protected synchronized WNameTable
private void
private int
findBestBucket()

Method called to find the best bucket to spill a WName over to: usually the first bucket that has only one entry, but in general first one of the buckets with least number of entries

public WName
findSymbol(String localName)

public WName
findSymbol(String prefix, String localName)

Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.

public void
public boolean
maybeDirty()

Implements abstract com.fasterxml.aalto.util.NameTable.maybeDirty.

Method called to check to quickly see if a child symbol table may have gotten additional entries.
private synchronized boolean
public boolean
public void
nuke()

Method used by test code, to reset state of the name table.

private void
public int
public String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
private void
unshareMain()

Method that needs to be called, if the main hash structure is (may be) shared.

private void

Field Detail

INITIAL_COLLISION_LENback to summary
pack-priv static final int INITIAL_COLLISION_LEN
LAST_VALID_BUCKETback to summary
pack-priv static final int LAST_VALID_BUCKET

Bucket index is 8 bits, and value 0 is reserved to represent 'empty' status.

mCollCountback to summary
private int mCollCount

Total number of WNames in collision buckets (included in mCount along with primary entries)

mCollEndback to summary
private int mCollEnd

Index of the first unused collision bucket entry (== size of the used portion of collision list): less than or equal to 0xFF (255), since max number of entries is 255 (8-bit, minus 0 used as 'empty' marker)

mCollListback to summary
private WNameTable.Bucket[] mCollList

Array of heads of collision bucket chains; size dynamically

mCollListSharedback to summary
private boolean mCollListShared

Flag that indicates whether underlying data structures for the collision list are shared or not. If they are, then they need to be handled in copy-on-write way, i.e. if they need to be modified, a copy needs to be made first; at this point it will not be shared any more, and can be modified.

This flag needs to be checked when adding new collision entries.

mCountback to summary
private int mCount

Total number of WNames in the symbol table

MIN_HASH_SIZEback to summary
pack-priv static final int MIN_HASH_SIZE
mMainHashback to summary
private int[] mMainHash

Array of 2^N size, which contains combination of 24-bits of hash (0 to indicate 'empty' slot), and 8-bit collision bucket index (0 to indicate empty collision bucket chain; otherwise subtract one from index)

mMainHashMaskback to summary
private int mMainHashMask

Mask used to truncate 32-bit hash value to current hash array size; essentially, hash array size - 1 (since hash array sizes are 2^N).

mMainHashSharedback to summary
private boolean mMainHashShared

Flag that indicates whether underlying data structures for the main hash area are shared or not. If they are, then they need to be handled in copy-on-write way, i.e. if they need to be modified, a copy needs to be made first; at this point it will not be shared any more, and can be modified.

This flag needs to be checked both when adding new main entries, and when adding new collision list queues (i.e. creating a new collision list head entry)

mMainNamesback to summary
private WName[] mMainNames

Array that contains WName instances matching entries in mMainHash. Contains nulls for unused entries.

mMainNamesSharedback to summary
private boolean mMainNamesShared
mNameFactoryback to summary
pack-priv final WNameFactory mNameFactory
mNeedRehashback to summary
private transient boolean mNeedRehash

This flag is set if, after adding a new entry, it is deemed that a rehash is warranted if any more entries are to be added.

mParentback to summary
pack-priv final WNameTable mParent

Parent reference is needed to be able to merge new symbols if and as necessary

Constructor Detail

WNameTableback to summary
protected WNameTable(int hashSize)
WNameTableback to summary
private WNameTable(WNameTable parent, WNameFactory f)

Constructor used when creating a child instance

Method Detail

addSymbolback to summary
private void addSymbol(WName symbol)
createChildback to summary
protected synchronized WNameTable createChild(WNameFactory f)
expandCollisionback to summary
private void expandCollision()
findBestBucketback to summary
private int findBestBucket()

Method called to find the best bucket to spill a WName over to: usually the first bucket that has only one entry, but in general first one of the buckets with least number of entries

findSymbolback to summary
public WName findSymbol(String localName) throws XMLStreamException
findSymbolback to summary
public WName findSymbol(String prefix, String localName) throws XMLStreamException

Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.

markAsSharedback to summary
public void markAsShared()
maybeDirtyback to summary
public boolean maybeDirty()

Implements abstract com.fasterxml.aalto.util.NameTable.maybeDirty.

Method called to check to quickly see if a child symbol table may have gotten additional entries. Used for checking to see if a child table should be merged into shared table.

Annotations
@Override
mergeFromChildback to summary
private synchronized boolean mergeFromChild(WNameTable child)
mergeToParentback to summary
public boolean mergeToParent()
nukeback to summary
public void nuke()

Method used by test code, to reset state of the name table.

rehashback to summary
private void rehash()
sizeback to summary
public int size()

Implements abstract com.fasterxml.aalto.util.NameTable.size.

Annotations
@Override
toDebugStringback to summary
public String toDebugString()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
unshareCollisionback to summary
private void unshareCollision()
unshareMainback to summary
private void unshareMain()

Method that needs to be called, if the main hash structure is (may be) shared. This happens every time something is added, even if addition is to the collision list (since collision list index comes from lowest 8 bits of the primary hash entry)

unshareNamesback to summary
private void unshareNames()
com.fasterxml.aalto.out back to summary

pack-priv final Class WNameTable.Bucket

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final WName
pack-priv final WNameTable.Bucket

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public WName
find(String localName)

public WName
find(String prefix, String localName)

public int
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mNameback to summary
pack-priv final WName mName
mNextback to summary
pack-priv final WNameTable.Bucket mNext

Constructor Detail

Bucketback to summary
pack-priv Bucket(WName name, WNameTable.Bucket next)

Method Detail

findback to summary
public WName find(String localName)
findback to summary
public WName find(String prefix, String localName)
lengthback to summary
public int length()
toDebugStringback to summary
public String toDebugString()