Although this unification is essential, this is also the performance bottle neck. In particular, createChoice and createSequence are two most commonly called methods.
For example, when validating a DocBook XML (150KB) twice against DocBook.trex(237KB), createChoice is called 63000 times and createSequence called 23000 times. (the third is the createOptional method and only 1560 times.) And they took more than 10% of validation time, which is the worst time-consuming method.
Therefore, please beware that this class includes several ugly code optimization.
| Modifier and Type | Class and Description |
|---|---|
| public static class | ExpressionPool.ClosedHash
expression cache by closed hash. |
| Modifier and Type | Field and Description |
|---|---|
| private final ExpressionPool. | expTable
hash table that contains all expressions currently known to this table. |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | ExpressionPool(ExpressionPool parent)
creates new expression pool as a child pool of the given parent pool. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| public final Expression | |
| protected final Expression |
| expTable | back to summary |
|---|---|
| private final ExpressionPool. hash table that contains all expressions currently known to this table. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ExpressionPool | back to summary |
|---|---|
| public ExpressionPool(ExpressionPool parent) creates new expression pool as a child pool of the given parent pool. Every expression memorized in the parent pool can be retrieved, but update operations are only performed upon the child pool. In this way, the parent pool can be shared among the multiple threads without interfering performance. Furthermore, you can throw away a child pool after a certain time period to prevent it from eating up memory. | |
| ExpressionPool | back to summary |
|---|---|
| public ExpressionPool() | |
| createAnyString | back to summary |
|---|---|
| public final Expression createAnyString() | |
| createAttribute | back to summary |
|---|---|
| public final Expression createAttribute(NameClass nameClass) | |
| createAttribute | back to summary |
|---|---|
| public final Expression createAttribute(NameClass nameClass, Expression content, String defaultValue) | |
| createChoice | back to summary |
|---|---|
| public final Expression createChoice(Expression left, Expression right) | |
| createConcur | back to summary |
|---|---|
| public final Expression createConcur(Expression left, Expression right) | |
| createData | back to summary |
|---|---|
| public final Expression createData(XSDatatype dt) | |
| createData | back to summary |
|---|---|
| public final Expression createData(Datatype dt, StringPair typeName) | |
| createData | back to summary |
|---|---|
| public final Expression createData(Datatype dt, StringPair typeName, Expression except) | |
| createEpsilon | back to summary |
|---|---|
| public final Expression createEpsilon() | |
| createInterleave | back to summary |
|---|---|
| public final Expression createInterleave(Expression left, Expression right) | |
| createList | back to summary |
|---|---|
| public final Expression createList(Expression exp) | |
| createMixed | back to summary |
|---|---|
| public final Expression createMixed(Expression body) | |
| createNullSet | back to summary |
|---|---|
| public final Expression createNullSet() | |
| createOneOrMore | back to summary |
|---|---|
| public final Expression createOneOrMore(Expression child) | |
| createOptional | back to summary |
|---|---|
| public final Expression createOptional(Expression child) | |
| createSequence | back to summary |
|---|---|
| public final Expression createSequence(Expression left, Expression right) | |
| createValue | back to summary |
|---|---|
| public final Expression createValue(XSDatatype dt, Object value) | |
| createValue | back to summary |
|---|---|
| public final Expression createValue(Datatype dt, StringPair typeName, Object value) | |
| createZeroOrMore | back to summary |
|---|---|
| public final Expression createZeroOrMore(Expression child) | |
| unify | back to summary |
|---|---|
| protected final Expression unify(Expression exp) unifies expressions. If the equivalent expression is already registered in the table, destroy newly created one (so that no two objects represents same expression structure). If it's not registered, then register it and return it. | |
| Modifier and Type | Field and Description |
|---|---|
| private int | count
The total number of mappings in the hash table. |
| private static final int | |
| private static final float | loadFactor
The load factor for the hashtable. |
| private ExpressionPool. | parent
The parent hash table. |
| private static final ObjectStreamField[] | |
| private static final long | |
| private Expression[] | table
The hash table data. |
| private int | threshold
The table is rehashed when its size exceeds this threshold. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Expression | |
| public Expression | |
| public Expression | |
| private Expression | |
| public void | |
| private void | |
| private void | |
| private void |
| count | back to summary |
|---|---|
| private int count The total number of mappings in the hash table. | |
| initialCapacity | back to summary |
|---|---|
| private static final int initialCapacity | |
| loadFactor | back to summary |
|---|---|
| private static final float loadFactor The load factor for the hashtable. | |
| parent | back to summary |
|---|---|
| private ExpressionPool. The parent hash table. can be null. items in the parent hash table will be returned by get method. The field is essentially final but because of the serialization support we cannot mark it as such. | |
| serialPersistentFields | back to summary |
|---|---|
| private static final ObjectStreamField[] serialPersistentFields | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| table | back to summary |
|---|---|
| private Expression[] table The hash table data. | |
| threshold | back to summary |
|---|---|
| private int threshold The table is rehashed when its size exceeds this threshold. (The value of this field is (int)(capacity * loadFactor).) | |
| ClosedHash | back to summary |
|---|---|
| public ClosedHash() | |
| ClosedHash | back to summary |
|---|---|
| public ClosedHash(ExpressionPool. | |
| get | back to summary |
|---|---|
| public Expression get(int hash, Expression child, Class<?> type) | |
| get | back to summary |
|---|---|
| public Expression get(Expression key) | |
| getBinExp | back to summary |
|---|---|
| public Expression getBinExp(Expression left, Expression right, Class<?> type) | |
| getBinExp | back to summary |
|---|---|
| private Expression getBinExp(int hash, Expression left, Expression right, Class<?> type) | |
| put | back to summary |
|---|---|
| public void put(Expression newExp) put method. No two threads can call this method simulatenously, and it's the caller's responsibility to enforce it. | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException | |
| rehash | back to summary |
|---|---|
| private void rehash() rehash. It is possible for one thread to call get method while another thread is performing rehash. Keep this in mind. | |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException | |