|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectit.unimi.di.mg4j.query.nodes.AbstractQueryBuilderVisitor<DocumentIterator>
it.unimi.di.mg4j.search.DocumentIteratorBuilderVisitor
public class DocumentIteratorBuilderVisitor
A QueryBuilderVisitor
that builds a DocumentIterator
resolving the queries using the objects in it.unimi.di.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 calling 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().
| Field Summary | |
|---|---|
protected ObjectArrayList<Index> |
curr
The stack of selected indices (changed by Select nodes). |
protected Index |
defaultIndex
The default index. |
protected Reference2ReferenceMap<Index,Object> |
index2Parser
A map associating an object with a parse(String) method to each payload-based index. |
protected Object2ReferenceMap<String,Index> |
indexMap
A map associating a textual key to indices. |
protected int |
limit
The limit on prefix queries provided in the constructor. |
protected int |
numberOfDocuments
The number of documents (fetched from the default index). |
protected double |
weight
The last seen, but still not consumed, weight, or Double.NaN. |
protected DoubleArrayList |
weights
The stack of weights. |
| 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. |
protected void |
pushWeight()
Pushes weight, if it is not Double.NaN, or 1, otherwise, on the stack of weights; in either case, sets weight to Double.NaN. |
DocumentIterator |
visit(False node)
Visits False. |
DocumentIterator |
visit(Prefix node)
Visits a Prefix. |
DocumentIterator |
visit(Range node)
Visits a Range. |
DocumentIterator |
visit(Term node)
Visits a Term. |
DocumentIterator |
visit(True node)
Visits True. |
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(Remap node,
DocumentIterator subNode)
Visits a Remap node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Select node,
DocumentIterator subNode)
Visits a Select node after recursing into the corresponding subtree. |
DocumentIterator |
visitPost(Weight node,
DocumentIterator subNode)
Visits a Weight node after recursing into the corresponding subtree. |
boolean |
visitPre(Align node)
Visits an Align node before recursing into the corresponding subtree. |
boolean |
visitPre(And node)
Visits an And node before recursing into the corresponding subtree. |
boolean |
visitPre(Consecutive node)
Visits a Consecutive node before recursing into the corresponding subtree. |
boolean |
visitPre(Difference node)
Visits an Difference node before recursing into the corresponding subtree. |
boolean |
visitPre(LowPass node)
Visits a LowPass node before recursing into the corresponding subtree. |
boolean |
visitPre(MultiTerm node)
Visits a MultiTerm node before recursing into the corresponding subtree. |
boolean |
visitPre(Not node)
Visits a Not node before recursing into the corresponding subtree. |
boolean |
visitPre(Or node)
Visits an Or node before recursing into the corresponding subtree. |
boolean |
visitPre(OrderedAnd node)
Visits an OrderedAnd node before recursing into the corresponding subtree. |
boolean |
visitPre(Remap node)
Visits a Remap node before recursing into the corresponding subtree. |
boolean |
visitPre(Select node)
Visits a Select node before recursing into the corresponding subtree. |
boolean |
visitPre(Weight node)
Visits a Weight node before recursing into the corresponding subtree. |
protected double |
weight()
Returns weight, if it is not Double.NaN, or 1, otherwise; in either case, sets weight to Double.NaN. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Object2ReferenceMap<String,Index> indexMap
protected final Reference2ReferenceMap<Index,Object> index2Parser
parse(String) method to each payload-based index.
protected final Index defaultIndex
protected final int numberOfDocuments
protected final int limit
protected ObjectArrayList<Index> curr
Select nodes).
protected DoubleArrayList weights
protected double weight
Double.NaN.
| 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 |
|---|
protected void pushWeight()
weight, if it is not Double.NaN, or 1, otherwise, on the stack of weights; in either case, sets weight to Double.NaN.
protected double weight()
weight, if it is not Double.NaN, or 1, otherwise; in either case, sets weight to Double.NaN.
weight, if it is not Double.NaN, or 1, otherwise.public DocumentIteratorBuilderVisitor copy()
public DocumentIteratorBuilderVisitor prepare()
AbstractQueryBuilderVisitor
prepare in interface QueryBuilderVisitor<DocumentIterator>prepare in class AbstractQueryBuilderVisitor<DocumentIterator>public DocumentIterator[] newArray(int len)
QueryBuilderVisitorT.
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
QueryBuilderVisitorTerm.
node - the leaf to be visited.
QueryBuilderVisitorException
public DocumentIterator visit(Prefix node)
throws QueryBuilderVisitorException
QueryBuilderVisitorPrefix.
node - the leaf to be visited.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public DocumentIterator visit(Range node)
throws QueryBuilderVisitorException
QueryBuilderVisitorRange.
node - the leaf to be visited.
QueryBuilderVisitorException
public boolean visitPre(And node)
throws QueryBuilderVisitorException
QueryBuilderVisitorAnd 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(And node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorAnd node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the array of results returned by subnodes.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(Consecutive node)
throws QueryBuilderVisitorException
QueryBuilderVisitorConsecutive 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(Consecutive node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorConsecutive node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the array of results returned by subnodes.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(LowPass node)
throws QueryBuilderVisitorException
QueryBuilderVisitorLowPass 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(LowPass node,
DocumentIterator subNode)
QueryBuilderVisitorLowPass node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
public boolean visitPre(Not node)
throws QueryBuilderVisitorException
QueryBuilderVisitorNot 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(Not node,
DocumentIterator subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorNot node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(Or node)
throws QueryBuilderVisitorException
QueryBuilderVisitorOr 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(Or node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorOr node after recursing into the corresponding subtree.
node - the internal node to be visited.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(OrderedAnd node)
throws QueryBuilderVisitorException
QueryBuilderVisitorOrderedAnd 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(OrderedAnd node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorOrderedAnd node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the array of results returned by subnodes.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(Align node)
throws QueryBuilderVisitorException
QueryBuilderVisitorAlign 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(Align node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorAlign node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the array of results returned by subnodes.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(Difference node)
throws QueryBuilderVisitorException
QueryBuilderVisitorDifference 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(Difference node,
DocumentIterator[] subNode)
QueryBuilderVisitorDifference node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the array of results returned by subnodes.
subNodeResult) if the visit should continue, or null.
public boolean visitPre(MultiTerm node)
throws QueryBuilderVisitorException
QueryBuilderVisitorMultiTerm 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(MultiTerm node,
DocumentIterator[] subNode)
throws QueryBuilderVisitorException
QueryBuilderVisitorMultiTerm node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
QueryBuilderVisitorException
public boolean visitPre(Select node)
throws QueryBuilderVisitorException
QueryBuilderVisitorSelect 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)
QueryBuilderVisitorSelect node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
public boolean visitPre(Remap node)
throws QueryBuilderVisitorException
QueryBuilderVisitorRemap 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(Remap node,
DocumentIterator subNode)
QueryBuilderVisitorRemap node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
public boolean visitPre(Weight node)
throws QueryBuilderVisitorException
QueryBuilderVisitorWeight 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(Weight node,
DocumentIterator subNode)
QueryBuilderVisitorWeight node after recursing into the corresponding subtree.
node - the internal node to be visited.subNode - the of result returned by the sole subnode.
subNodeResult) if the visit should continue, or null.
public DocumentIterator visit(True node)
throws QueryBuilderVisitorException
QueryBuilderVisitorTrue.
node - the leaf to be visited.
QueryBuilderVisitorException
public DocumentIterator visit(False node)
throws QueryBuilderVisitorException
QueryBuilderVisitorFalse.
node - the leaf to be visited.
QueryBuilderVisitorException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||