|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.mg4j.query.nodes.AbstractQueryBuilderVisitor<DocumentIterator>
it.unimi.dsi.mg4j.search.DocumentIteratorBuilderVisitor
public class DocumentIteratorBuilderVisitor
A QueryBuilderVisitor
that builds a DocumentIterator
resolving the queries using the objects in it.unimi.dsi.mg4j.search
.
This elementary builder visitor invokes Index.documents(CharSequence)
to build the leaf index iterators. Thus, the
resulting DocumentIterator
should be carefully
disposed after usage (every
index iterator may open a file or a socket).
Prefix
and MultiTerm
nodes cause the creation of a MultiTermIndexIterator
,
in the first case by callying Index.documents(CharSequence,int)
and
in the second case by creating a MultiTermIndexIterator
with the name and frequency equal to the
maximum frequency over all terms. Other implementations might choose differently.
At construction time, you must provide a map from strings to indices that will be used to resolve
Select
nodes. The map may be null
, in which case
such nodes will cause an IllegalArgumentException
.
If a Select
node contains an index name that does not appear in the map a NoSuchElementException
will be thrown instead.
A production site will likely substitute this builder visitor with one that reuses index readers out of a pool.
Instances of this class may be safely reused by calling prepare()
.
Constructor Summary | |
---|---|
DocumentIteratorBuilderVisitor(Object2ReferenceMap<String,Index> indexMap,
Index defaultIndex,
int limit)
Creates a new builder visitor. |
|
DocumentIteratorBuilderVisitor(Object2ReferenceMap<String,Index> indexMap,
Reference2ReferenceMap<Index,Object> index2Parser,
Index defaultIndex,
int limit)
Creates a new builder visitor with additional parsers for payload-based indices. |
Method Summary | |
---|---|
DocumentIteratorBuilderVisitor |
copy()
|
DocumentIterator[] |
newArray(int len)
Builds an array of given length of type T . |
DocumentIteratorBuilderVisitor |
prepare()
No-op. |
DocumentIterator |
visit(Prefix node)
Visits a Prefix . |
DocumentIterator |
visit(Range node)
Visits a Range . |
DocumentIterator |
visit(Term node)
Visits a Term . |
DocumentIterator |
visitPost(Align node,
DocumentIterator[] subNode)
Visits an Align node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(And node,
DocumentIterator[] subNode)
Visits an And node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Consecutive node,
DocumentIterator[] subNode)
Visits a Consecutive node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Difference node,
DocumentIterator[] subNode)
Visits an Difference node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(LowPass node,
DocumentIterator subNode)
Visits a LowPass node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(MultiTerm node,
DocumentIterator[] subNode)
Visits a MultiTerm node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Not node,
DocumentIterator subNode)
Visits a Not node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(OrderedAnd node,
DocumentIterator[] subNode)
Visits an OrderedAnd node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Or node,
DocumentIterator[] subNode)
Visits an Or node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Select node,
DocumentIterator subNode)
Visits a Select node after recursing into the corresponding subtree. |
boolean |
visitPre(Select node)
Visits a Select node before recursing into the corresponding subtree. |
Methods inherited from class it.unimi.dsi.mg4j.query.nodes.AbstractQueryBuilderVisitor |
---|
visitPre, visitPre, visitPre, visitPre, visitPre, visitPre, visitPre, visitPre, visitPre |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DocumentIteratorBuilderVisitor(Object2ReferenceMap<String,Index> indexMap, Index defaultIndex, int limit)
indexMap
- a map from index names to indices, to be used in Select
nodes, or null
if the only used index is the default index.defaultIndex
- the default index.limit
- a limit that will be used with Prefix
nodes.public DocumentIteratorBuilderVisitor(Object2ReferenceMap<String,Index> indexMap, Reference2ReferenceMap<Index,Object> index2Parser, Index defaultIndex, int limit)
indexMap
- a map from index names to indices, to be used in Select
nodes, or null
if the only used index is the default index.defaultIndex
- the default index.limit
- a limit that will be used with Prefix
nodes.Method Detail |
---|
public DocumentIteratorBuilderVisitor copy()
public DocumentIteratorBuilderVisitor prepare()
AbstractQueryBuilderVisitor
prepare
in interface QueryBuilderVisitor<DocumentIterator>
prepare
in class AbstractQueryBuilderVisitor<DocumentIterator>
public DocumentIterator[] newArray(int len)
QueryBuilderVisitor
T
.
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
type T
. This method must provide an array of given length
that is an acceptable input for all visitPost()
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 in Array
.
len
- the required array length.
T
of length len
.public DocumentIterator visit(Term node) throws QueryBuilderVisitorException
QueryBuilderVisitor
Term
.
node
- the leaf to be visited.
QueryBuilderVisitorException
public DocumentIterator visit(Prefix node) throws QueryBuilderVisitorException
QueryBuilderVisitor
Prefix
.
node
- the leaf to be visited.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visit(Range node) throws QueryBuilderVisitorException
QueryBuilderVisitor
Range
.
node
- the leaf to be visited.
QueryBuilderVisitorException
public DocumentIterator visitPost(And node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
And
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the array of results returned by subnodes.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(Consecutive node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
Consecutive
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the array of results returned by subnodes.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(LowPass node, DocumentIterator subNode)
QueryBuilderVisitor
LowPass
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the of result returned by the sole subnode.
subNode
) if the visit should continue, or null
.public DocumentIterator visitPost(Not node, DocumentIterator subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
Not
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the of result returned by the sole subnode.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(Or node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
Or
node after recursing into the corresponding subtree.
node
- the internal node to be visited.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(OrderedAnd node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
OrderedAnd
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the array of results returned by subnodes.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(Align node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
Align
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the array of results returned by subnodes.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public DocumentIterator visitPost(Difference node, DocumentIterator[] subNode)
QueryBuilderVisitor
Difference
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the array of results returned by subnodes.
subNode
) if the visit should continue, or null
.public DocumentIterator visitPost(MultiTerm node, DocumentIterator[] subNode) throws QueryBuilderVisitorException
QueryBuilderVisitor
MultiTerm
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the of result returned by the sole subnode.
subNode
) if the visit should continue, or null
.
QueryBuilderVisitorException
public boolean visitPre(Select node) throws QueryBuilderVisitorException
QueryBuilderVisitor
Select
node before recursing into the corresponding subtree.
visitPre
in interface QueryBuilderVisitor<DocumentIterator>
visitPre
in class AbstractQueryBuilderVisitor<DocumentIterator>
node
- the node to be visited.
QueryBuilderVisitorException
public DocumentIterator visitPost(Select node, DocumentIterator subNode)
QueryBuilderVisitor
Select
node after recursing into the corresponding subtree.
node
- the internal node to be visited.subNode
- the of result returned by the sole subnode.
subNode
) if the visit should continue, or null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |