Class AbstractDocumentIteratorVisitor
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.visitor.AbstractDocumentIteratorVisitor
-
- All Implemented Interfaces:
DocumentIteratorVisitor<Boolean>
- Direct Known Subclasses:
BM25FScorer.Visitor
,CounterCollectionVisitor
,CounterSetupVisitor
,TermCollectionVisitor
,TrueTermsCollectionVisitor
public abstract class AbstractDocumentIteratorVisitor extends Object implements DocumentIteratorVisitor<Boolean>
An abstract implementation of aDocumentIteratorVisitor
without return values.This implementation is hardwired to
Boolean
, returns always true onvisitPre(DocumentIterator)
, returnsBoolean.TRUE
on all internal nodes if no subnode returnsnull
, returnsBoolean.TRUE
on true/false document iterators, returnsnull
on calls tonewArray(int)
, and delegatesvisit(MultiTermIndexIterator)
toDocumentIteratorVisitor.visit(IndexIterator)
.
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentIteratorVisitor()
-
Method Summary
Modifier and Type Method Description Boolean[]
newArray(int len)
Builds an array of given length of typeT
.AbstractDocumentIteratorVisitor
prepare()
Prepares the internal state of this visitor for a(nother) visit.Boolean
visit(MultiTermIndexIterator indexIterator)
Visits aMultiTermIndexIterator
leaf.Boolean
visit(FalseDocumentIterator falseDocumentIterator)
Visits aFalseDocumentIterator
leaf.Boolean
visit(TrueDocumentIterator trueDocumentIterator)
Visits aTrueDocumentIterator
leaf.Boolean
visitPost(DocumentIterator documentIterator, Boolean[] subNodeResult)
Visits an internal node after recursing into the corresponding subtree.boolean
visitPre(DocumentIterator documentIterator)
Visits an internal node before recursing into the corresponding subtree.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.visitor.DocumentIteratorVisitor
visit
-
-
-
-
Method Detail
-
prepare
public AbstractDocumentIteratorVisitor prepare()
Description copied from interface:DocumentIteratorVisitor
Prepares the internal state of this visitor for a(nother) visit.By specification, it must be safe to call this method any number of times.
- Specified by:
prepare
in interfaceDocumentIteratorVisitor<Boolean>
- Returns:
- this visitor.
-
visitPre
public boolean visitPre(DocumentIterator documentIterator)
Description copied from interface:DocumentIteratorVisitor
Visits an internal node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
documentIterator
- the internal node to be visited.- Returns:
- true if the visit should continue.
-
newArray
public Boolean[] newArray(int len)
Description copied from interface:DocumentIteratorVisitor
Builds an array of given length of typeT
.Because of erasure, generic classes in Java cannot allocate arrays of generic types. This impossibility can be a problem if for some reason the
visitPost()
methods expect an actual array of typeT
. This method must provide an array of given length that is an acceptable input for allvisitPost()
methods.Note that by declaring an implementing class of this interface that has a sole constructor accepting an argument of type
Class<T>
, you will force the user to provide the class of the generic type, opening the way for the reflective methods inArray
.- Specified by:
newArray
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
len
- the required array length.- Returns:
- an array of type
T
of lengthlen
, ornull
if this document iterator visitor does not return values.
-
visitPost
public Boolean visitPost(DocumentIterator documentIterator, Boolean[] subNodeResult)
Description copied from interface:DocumentIteratorVisitor
Visits an internal node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
documentIterator
- the internal node to be visited.subNodeResult
- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNode
) if the visit should continue, ornull
.
-
visit
public Boolean visit(MultiTermIndexIterator indexIterator) throws IOException
Description copied from interface:DocumentIteratorVisitor
Visits aMultiTermIndexIterator
leaf.- Specified by:
visit
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
indexIterator
- the leaf to be visited.- Returns:
- an appropriate return value if the visit should continue, or
null
. - Throws:
IOException
-
visit
public Boolean visit(TrueDocumentIterator trueDocumentIterator)
Description copied from interface:DocumentIteratorVisitor
Visits aTrueDocumentIterator
leaf.- Specified by:
visit
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
trueDocumentIterator
- the leaf to be visited.- Returns:
- an appropriate return value if the visit should continue, or
null
.
-
visit
public Boolean visit(FalseDocumentIterator falseDocumentIterator)
Description copied from interface:DocumentIteratorVisitor
Visits aFalseDocumentIterator
leaf.- Specified by:
visit
in interfaceDocumentIteratorVisitor<Boolean>
- Parameters:
falseDocumentIterator
- the leaf to be visited.- Returns:
- an appropriate return value if the visit should continue, or
null
.
-
-