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

Constructors
Constructor
Description
`VisitorTemplate(LeafReaderContext context)`

## Method Summary

Modifier and Type
Method
Description
`protected CellIterator`
`findSubCellsToVisit(Cell cell)`
Called when doing a divide and conquer to find the next intersecting cells of the query shape that are beneath `cell`.
`protected abstract DocIdSet`
`finish()`
Called last to return the result.
`DocIdSet`
`getDocIdSet()`
`protected void`
`postSiblings(AbstractVisitingPrefixTreeQuery.VNode vNode)`
`protected void`
`preSiblings(AbstractVisitingPrefixTreeQuery.VNode vNode)`
`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`
`visitLeaf(Cell cell)`
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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### VisitorTemplate

public VisitorTemplate(LeafReaderContext context) throws IOException

Throws:
  `IOException`

## Method Details

### getDocIdSet

public DocIdSet getDocIdSet() throws IOException

Throws:
  `IOException`

### findSubCellsToVisit

protected CellIterator findSubCellsToVisit(Cell cell)
Called when doing a divide and conquer to find the next intersecting cells of the query shape that are beneath `cell`. `cell` is guaranteed to have an intersection and thus this must return some number of nodes.

### scan

protected void scan(int scanDetailLevel) throws IOException
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 level `scanDetailLevel` then it calls `visitScanned(org.apache.lucene.spatial.prefix.tree.Cell)`.

Throws:
  `IOException`

### start

protected abstract void start() throws IOException
Called first to setup things.

Throws:
  `IOException`

### finish

protected abstract DocIdSet finish() throws IOException
Called last to return the result.

Throws:
  `IOException`

### visitPrefix

protected abstract boolean visitPrefix(Cell cell) throws IOException
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's `Cell.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

protected abstract void visitLeaf(Cell cell) throws IOException
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

protected void visitScanned(Cell cell) throws IOException
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 call `visitLeaf(org.apache.lucene.spatial.prefix.tree.Cell)` or `visitPrefix(org.apache.lucene.spatial.prefix.tree.Cell)`.

Throws:
  `IOException`

### preSiblings

protected void preSiblings(AbstractVisitingPrefixTreeQuery.VNode vNode) throws IOException

Throws:
  `IOException`

### postSiblings

protected void postSiblings(AbstractVisitingPrefixTreeQuery.VNode vNode) throws IOException

Throws:
  `IOException`