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 classexpression 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 Expressionfinal ExpressioncreateAttribute(NameClass nameClass) final ExpressioncreateAttribute(NameClass nameClass, Expression content, String defaultValue) final ExpressioncreateChoice(Expression left, Expression right) final ExpressioncreateConcur(Expression left, Expression right) final ExpressioncreateData(XSDatatype dt) final ExpressioncreateData(org.relaxng.datatype.Datatype dt, StringPair typeName) final ExpressioncreateData(org.relaxng.datatype.Datatype dt, StringPair typeName, Expression except) final Expressionfinal ExpressioncreateInterleave(Expression left, Expression right) final ExpressioncreateList(Expression exp) final ExpressioncreateMixed(Expression body) final Expressionfinal ExpressioncreateOneOrMore(Expression child) final ExpressioncreateOptional(Expression child) final ExpressioncreateSequence(Expression left, Expression right) final ExpressioncreateValue(XSDatatype dt, Object value) final ExpressioncreateValue(org.relaxng.datatype.Datatype dt, StringPair typeName, Object value) final ExpressioncreateZeroOrMore(Expression child) protected final Expressionunify(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.
-