public class ExpressionPool
extends java.lang.Object
implements java.io.Serializable
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 |
---|---|
static class |
ExpressionPool.ClosedHash
expression cache by closed hash.
|
Modifier and Type | Field and Description |
---|---|
private ExpressionPool.ClosedHash |
expTable
hash table that contains all expressions currently known to this table.
|
private static long |
serialVersionUID |
Constructor and Description |
---|
ExpressionPool() |
ExpressionPool(ExpressionPool parent)
creates new expression pool as a child pool of the given parent pool.
|
private final ExpressionPool.ClosedHash expTable
private static final long serialVersionUID
public ExpressionPool(ExpressionPool parent)
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.
public ExpressionPool()
public final Expression createAttribute(NameClass nameClass)
public final Expression createAttribute(NameClass nameClass, Expression content)
public final Expression createEpsilon()
public final Expression createNullSet()
public final Expression createAnyString()
public final Expression createChoice(Expression left, Expression right)
public final Expression createOneOrMore(Expression child)
public final Expression createZeroOrMore(Expression child)
public final Expression createOptional(Expression child)
public final Expression createData(XSDatatype dt)
public final Expression createData(org.relaxng.datatype.Datatype dt, StringPair typeName)
public final Expression createData(org.relaxng.datatype.Datatype dt, StringPair typeName, Expression except)
public final Expression createValue(XSDatatype dt, java.lang.Object value)
public final Expression createValue(org.relaxng.datatype.Datatype dt, StringPair typeName, java.lang.Object value)
public final Expression createList(Expression exp)
public final Expression createMixed(Expression body)
public final Expression createSequence(Expression left, Expression right)
public final Expression createConcur(Expression left, Expression right)
public final Expression createInterleave(Expression left, Expression right)
protected final Expression unify(Expression exp)