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 aDocumentIteratorVisitorwithout return values.This implementation is hardwired to
Boolean, returns always true onvisitPre(DocumentIterator), returnsBoolean.TRUEon all internal nodes if no subnode returnsnull, returnsBoolean.TRUEon true/false document iterators, returnsnullon 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.AbstractDocumentIteratorVisitorprepare()Prepares the internal state of this visitor for a(nother) visit.Booleanvisit(MultiTermIndexIterator indexIterator)Visits aMultiTermIndexIteratorleaf.Booleanvisit(FalseDocumentIterator falseDocumentIterator)Visits aFalseDocumentIteratorleaf.Booleanvisit(TrueDocumentIterator trueDocumentIterator)Visits aTrueDocumentIteratorleaf.BooleanvisitPost(DocumentIterator documentIterator, Boolean[] subNodeResult)Visits an internal node after recursing into the corresponding subtree.booleanvisitPre(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:DocumentIteratorVisitorPrepares 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:
preparein interfaceDocumentIteratorVisitor<Boolean>- Returns:
- this visitor.
-
visitPre
public boolean visitPre(DocumentIterator documentIterator)
Description copied from interface:DocumentIteratorVisitorVisits an internal node before recursing into the corresponding subtree.- Specified by:
visitPrein 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:DocumentIteratorVisitorBuilds 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:
newArrayin interfaceDocumentIteratorVisitor<Boolean>- Parameters:
len- the required array length.- Returns:
- an array of type
Tof lengthlen, ornullif this document iterator visitor does not return values.
-
visitPost
public Boolean visitPost(DocumentIterator documentIterator, Boolean[] subNodeResult)
Description copied from interface:DocumentIteratorVisitorVisits an internal node after recursing into the corresponding subtree.- Specified by:
visitPostin 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:DocumentIteratorVisitorVisits aMultiTermIndexIteratorleaf.- Specified by:
visitin 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:DocumentIteratorVisitorVisits aTrueDocumentIteratorleaf.- Specified by:
visitin 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:DocumentIteratorVisitorVisits aFalseDocumentIteratorleaf.- Specified by:
visitin interfaceDocumentIteratorVisitor<Boolean>- Parameters:
falseDocumentIterator- the leaf to be visited.- Returns:
- an appropriate return value if the visit should continue, or
null.
-
-