Package org.apache.lucene.spatial.prefix
Class AbstractVisitingPrefixTreeQuery.VisitorTemplate
java.lang.Object
org.apache.lucene.spatial.prefix.AbstractPrefixTreeQuery.BaseTermsEnumTraverser
org.apache.lucene.spatial.prefix.AbstractVisitingPrefixTreeQuery.VisitorTemplate
- Enclosing class:
- AbstractVisitingPrefixTreeQuery
public abstract class AbstractVisitingPrefixTreeQuery.VisitorTemplate
extends AbstractPrefixTreeQuery.BaseTermsEnumTraverser
An abstract class designed to make it easy to implement predicates or other operations on a
SpatialPrefixTree
indexed field. An instance of this class is not designed to be
re-used across LeafReaderContext instances so simply create a new one per-leaf. The getDocIdSet()
method here starts the work. It first checks that there are indexed terms; if
not it quickly returns null. Then it calls start()
so a subclass can set up a return
value, like an FixedBitSet
. Then it starts the traversal
process, calling findSubCellsToVisit(org.apache.lucene.spatial.prefix.tree.Cell)
which
by default finds the top cells that intersect queryShape
. If there isn't an indexed
cell for a corresponding cell returned for this method then it's short-circuited until it finds
one, at which point visitPrefix(org.apache.lucene.spatial.prefix.tree.Cell)
is called.
At some depths, of the tree, the algorithm switches to a scanning mode that calls visitScanned(org.apache.lucene.spatial.prefix.tree.Cell)
for each leaf cell found.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
Fields inherited from class org.apache.lucene.spatial.prefix.AbstractPrefixTreeQuery.BaseTermsEnumTraverser
context, maxDoc, postingsEnum, terms, termsEnum
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CellIterator
findSubCellsToVisit
(Cell cell) Called when doing a divide and conquer to find the next intersecting cells of the query shape that are beneathcell
.protected abstract DocIdSet
finish()
Called last to return the result.protected void
protected void
protected void
scan
(int scanDetailLevel) Scans (termsEnum.next()
) terms until a term is found that does not start with curVNode's cell.protected abstract void
start()
Called first to setup things.protected abstract void
Called when an indexed leaf cell is found.protected abstract boolean
visitPrefix
(Cell cell) Visit an indexed non-leaf cell.protected void
visitScanned
(Cell cell) The cell is either indexed as a leaf or is the last level of detail.Methods inherited from class org.apache.lucene.spatial.prefix.AbstractPrefixTreeQuery.BaseTermsEnumTraverser
collectDocs, collectDocs
-
Constructor Details
-
VisitorTemplate
- Throws:
IOException
-
-
Method Details
-
getDocIdSet
- Throws:
IOException
-
findSubCellsToVisit
Called when doing a divide and conquer to find the next intersecting cells of the query shape that are beneathcell
.cell
is guaranteed to have an intersection and thus this must return some number of nodes. -
scan
Scans (termsEnum.next()
) terms until a term is found that does not start with curVNode's cell. If it finds a leaf cell or a cell at levelscanDetailLevel
then it callsvisitScanned(org.apache.lucene.spatial.prefix.tree.Cell)
.- Throws:
IOException
-
start
Called first to setup things.- Throws:
IOException
-
finish
Called last to return the result.- Throws:
IOException
-
visitPrefix
Visit an indexed non-leaf cell. The presence of a prefix cell implies there are leaf cells at further levels. The cell passed should have it'sCell.getShapeRel()
set relative to the filtered shape.- Parameters:
cell
- An intersecting cell; not a leaf.- Returns:
- true to descend to more levels.
- Throws:
IOException
-
visitLeaf
Called when an indexed leaf cell is found. An indexed leaf cell usually means associated documents won't be found at further detail levels. However, if a document has multiple overlapping shapes at different resolutions, then this isn't true.- Throws:
IOException
-
visitScanned
The cell is either indexed as a leaf or is the last level of detail. It might not even intersect the query shape, so be sure to check for that. The default implementation will check that and if passes then callvisitLeaf(org.apache.lucene.spatial.prefix.tree.Cell)
orvisitPrefix(org.apache.lucene.spatial.prefix.tree.Cell)
.- Throws:
IOException
-
preSiblings
- Throws:
IOException
-
postSiblings
- Throws:
IOException
-