|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectno.sesat.search.query.parser.alt.AbstractAlternation
no.sesat.search.query.parser.alt.RotationAlternation
public final class RotationAlternation
SKER-439 - Rotation Alternation
Rotates like-joined DoubleOperatorClauses (forests).
Tree rotation on the Query clause heirarchy is expensive,
and as clauses are immutable and are reused through a weak-referenced cache map,
performing and remembering the rotations directly after tree construction
is a performance benefit over repeated on-the-fly rotations.
The memory increase, taking into account the weak-reference maps is (N-1)^2 +2N -2,
where N is the number leaf clauses in the forest.
From this it can also be shown that the asymptotic complexity is just shy of O(n^2).
XorClauses with Hint.ROTATION_ALTERNATION are used to store these alternations within the query tree.
Typical usecases of these Rotation-variant XorClauses are visitors that are interested in possible combinations, or joins, between leaf clauses, for example the query evaluation and analysis, and the synonym query transformer.
Here's an example of the sequencial rotations on a query clause heirarchy of eight leaf clauses,
all eight leaf clauses are joined by DefaultOperatorClause,
so there is only one forest to perform rotations on.
The numbers one through to eight represent the eight terms in the query string and hence the eight leaf clauses.
In every rotation these leaf clauses refer to the same reused immutable instances.
The letters A through to G represent the DoubleOperatorClauses.
In every rotation these are always different instances as their layout of grandchildren differ.
The number of rotations in any forest is always one less than the number of DoubleOperatorClauses in the forest.
The leaf clauses from left to right always remain in order
so visitors can be assured that the query string at large remains the same.
To perform each rotation, the iterate, top, bottom, and orphan clause must be all determined. This is indicated in the diagram on the forest before the rotation occurs.
Example usecases of the resulting rotations within the query
The questions begs when is this rotation actually used and to what benefit?
Analysis relies on all possible term combinations to
exist with their corresponding tokenPredicates
(which must be exact on the boundaries). The analysis does one complete sweep of the query tree, including
the rotations, looking for tokenPredicates inaccordance with the rules to create the scores for each rule.
ParentFinder class, a utility visitor
implementation, contains the method getParents(root, clause).SynonymQueryTransformer.
Has not yet been fully rewritten to utilise the rotations.
SKER863 - Rewrite SynonymQueryTransformer to use RotationAlternationWhoWhereSplitter is a utility vistor that
splits the query into 'where' and 'who' components.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface no.sesat.search.query.parser.alt.Alternation |
|---|
Alternation.Context |
| Field Summary |
|---|
| Fields inherited from class no.sesat.search.query.parser.alt.AbstractAlternation |
|---|
context |
| Constructor Summary | |
|---|---|
RotationAlternation(Alternation.Context cxt)
Creates a new instance of RotationAlternation. |
|
| Method Summary | ||
|---|---|---|
Clause |
alternate(Clause originalRoot)
Returns a alternated clause where all child forests contain XorClauses. |
|
protected
|
createOperatorClause(Clause left,
Clause right,
T replacementFor)
|
|
protected XorClause.Hint |
getAlternationHint()
|
|
| Methods inherited from class no.sesat.search.query.parser.alt.AbstractAlternation |
|---|
createXorClause, leftChild, leftOpChild, parent, parents, replaceDescendant, replaceOperatorClause, rightChild, rightOpChild |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RotationAlternation(Alternation.Context cxt)
cxt - | Method Detail |
|---|
public Clause alternate(Clause originalRoot)
originalRoot -
protected <T extends UnaryClause> T createOperatorClause(Clause left,
Clause right,
T replacementFor)
createOperatorClause in class AbstractAlternationprotected XorClause.Hint getAlternationHint()
getAlternationHint in class AbstractAlternation
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||