Class ExpressionPool
- All Implemented Interfaces:
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.
- Author:
- Kohsuke KAWAGUCHI
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
expression cache by closed hash. -
Constructor Summary
ConstructorsConstructorDescriptionExpressionPool
(ExpressionPool parent) creates new expression pool as a child pool of the given parent pool. -
Method Summary
Modifier and TypeMethodDescriptionfinal Expression
final Expression
createAttribute
(NameClass nameClass) final Expression
createAttribute
(NameClass nameClass, Expression content, String defaultValue) final Expression
createChoice
(Expression left, Expression right) final Expression
createConcur
(Expression left, Expression right) final Expression
createData
(XSDatatype dt) final Expression
createData
(org.relaxng.datatype.Datatype dt, StringPair typeName) final Expression
createData
(org.relaxng.datatype.Datatype dt, StringPair typeName, Expression except) final Expression
final Expression
createInterleave
(Expression left, Expression right) final Expression
createList
(Expression exp) final Expression
createMixed
(Expression body) final Expression
final Expression
createOneOrMore
(Expression child) final Expression
createOptional
(Expression child) final Expression
createSequence
(Expression left, Expression right) final Expression
createValue
(XSDatatype dt, Object value) final Expression
createValue
(org.relaxng.datatype.Datatype dt, StringPair typeName, Object value) final Expression
createZeroOrMore
(Expression child) protected final Expression
unify
(Expression exp) unifies expressions.
-
Constructor Details
-
ExpressionPool
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
public ExpressionPool()
-
-
Method Details
-
createAttribute
-
createAttribute
public final Expression createAttribute(NameClass nameClass, Expression content, String defaultValue) -
createEpsilon
-
createNullSet
-
createAnyString
-
createChoice
-
createOneOrMore
-
createZeroOrMore
-
createOptional
-
createData
-
createData
-
createData
public final Expression createData(org.relaxng.datatype.Datatype dt, StringPair typeName, Expression except) -
createValue
-
createValue
public final Expression createValue(org.relaxng.datatype.Datatype dt, StringPair typeName, Object value) -
createList
-
createMixed
-
createSequence
-
createConcur
-
createInterleave
-
unify
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.
-