com.fasterxml.aalto.in
Class CharBasedPNameTable

java.lang.Object
  extended by com.fasterxml.aalto.util.NameTable
      extended by com.fasterxml.aalto.in.CharBasedPNameTable

public class CharBasedPNameTable
extends NameTable

This is a symbol table implementation used for storing byte-based PNames, specifically, instances of (PNameC).


Field Summary
protected static float DEFAULT_FILL_FACTOR
           
protected  com.fasterxml.aalto.in.CharBasedPNameTable.Bucket[] mBuckets
          Overflow buckets; if primary doesn't match, lookup is done from here.
protected  boolean mDirty
          Flag that indicates if any changes have been made to the data; used to both determine if bucket array needs to be copied when (first) change is made, and potentially if updated bucket list is to be resync'ed back to master instance.
protected  int mIndexMask
          Mask used to get index from hash values; equal to mBuckets.length - 1, when mBuckets.length is a power of two.
protected  int mSize
          Current size (number of entries); needed to know if and when rehash.
protected  int mSizeThreshold
          Limit that indicates maximum size this instance can hold before it needs to be expanded and rehashed.
protected  PNameC[] mSymbols
          Primary matching symbols; it's expected most match occur from here.
 
Constructor Summary
CharBasedPNameTable(int initialSize)
          Main method for constructing a master symbol table instance; will be called by other public constructors.
 
Method Summary
 PNameC addSymbol(char[] buffer, int start, int len, int hash)
           
 PNameC findSymbol(char[] buffer, int start, int len, int hash)
           
 boolean maybeDirty()
          Method called to check to quickly see if a child symbol table may have gotten additional entries.
 void mergeFromChild(CharBasedPNameTable child)
          Method that allows contents of child table to potentially be "merged in" with contents of this symbol table.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FILL_FACTOR

protected static final float DEFAULT_FILL_FACTOR
See Also:
Constant Field Values

mSymbols

protected PNameC[] mSymbols
Primary matching symbols; it's expected most match occur from here.


mBuckets

protected com.fasterxml.aalto.in.CharBasedPNameTable.Bucket[] mBuckets
Overflow buckets; if primary doesn't match, lookup is done from here.

Note: Number of buckets is half of number of symbol entries, on assumption there's less need for buckets.


mSize

protected int mSize
Current size (number of entries); needed to know if and when rehash.


mSizeThreshold

protected int mSizeThreshold
Limit that indicates maximum size this instance can hold before it needs to be expanded and rehashed. Calculated using fill factor passed in to constructor.


mIndexMask

protected int mIndexMask
Mask used to get index from hash values; equal to mBuckets.length - 1, when mBuckets.length is a power of two.


mDirty

protected boolean mDirty
Flag that indicates if any changes have been made to the data; used to both determine if bucket array needs to be copied when (first) change is made, and potentially if updated bucket list is to be resync'ed back to master instance.

Constructor Detail

CharBasedPNameTable

public CharBasedPNameTable(int initialSize)
Main method for constructing a master symbol table instance; will be called by other public constructors.

Parameters:
initialSize - Minimum initial size for bucket array; internally will always use a power of two equal to or bigger than this value.
Method Detail

mergeFromChild

public void mergeFromChild(CharBasedPNameTable child)
Method that allows contents of child table to potentially be "merged in" with contents of this symbol table.

Note that caller has to make sure symbol table passed in is really a child or sibling of this symbol table.


size

public int size()
Specified by:
size in class NameTable

maybeDirty

public boolean maybeDirty()
Description copied from class: NameTable
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.

Specified by:
maybeDirty in class NameTable

findSymbol

public PNameC findSymbol(char[] buffer,
                         int start,
                         int len,
                         int hash)

addSymbol

public PNameC addSymbol(char[] buffer,
                        int start,
                        int len,
                        int hash)


Copyright © 2012 Fasterxml.com. All Rights Reserved.