uk.ac.gla.dcs.renaissance.mg4j
Class QueryEngine

java.lang.Object
  extended by uk.ac.gla.dcs.renaissance.mg4j.QueryEngine
All Implemented Interfaces:
it.unimi.dsi.lang.FlyweightPrototype<QueryEngine>

public class QueryEngine
extends Object
implements it.unimi.dsi.lang.FlyweightPrototype<QueryEngine>

A modified version of the QueryEngine (to handle the modified version of the Scorer)

Since:
1.0
Author:
Benjamin Piwowarski, Sebastiano Vigna, Paolo Boldi

Field Summary
protected  it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap<it.unimi.dsi.mg4j.index.Index> index2Weight
          A map associating a weight with each index.
 it.unimi.dsi.fastutil.objects.Object2ReferenceMap<String,it.unimi.dsi.mg4j.index.Index> indexMap
          A map from names to indices.
 it.unimi.dsi.mg4j.query.IntervalSelector intervalSelector
          The current interval selector, if any.
 boolean multiplex
          Whether multiplex is active.
 int numIndices
          The number of indices used by queryParser.
 it.unimi.dsi.mg4j.query.parser.QueryParser queryParser
          The parser used to parse queries.
 
Constructor Summary
QueryEngine(it.unimi.dsi.mg4j.query.parser.QueryParser queryParser, it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitor<it.unimi.dsi.mg4j.search.DocumentIterator> builderVisitor, it.unimi.dsi.fastutil.objects.Object2ReferenceMap<String,it.unimi.dsi.mg4j.index.Index> indexMap)
          Creates a new query engine.
 
Method Summary
 QueryEngine copy()
           
 void equalize(int samples)
          Activate equalisation with the given number of samples-
 int process(it.unimi.dsi.mg4j.query.nodes.Query[] query, int offset, int length, it.unimi.dsi.fastutil.objects.ObjectArrayList<it.unimi.dsi.mg4j.search.score.DocumentScoreInfo<it.unimi.dsi.fastutil.objects.Reference2ObjectMap<it.unimi.dsi.mg4j.index.Index,it.unimi.dsi.mg4j.query.SelectedInterval[]>>> results)
          Processes one or more pre-parsed queries and deposits in a given array a segment of the results corresponding to the queries, using the current settings of this query engine.
 int process(String queries, int offset, int length, it.unimi.dsi.fastutil.objects.ObjectArrayList<it.unimi.dsi.mg4j.search.score.DocumentScoreInfo<it.unimi.dsi.fastutil.objects.Reference2ObjectMap<it.unimi.dsi.mg4j.index.Index,it.unimi.dsi.mg4j.query.SelectedInterval[]>>> results)
          Parses one or more comma-separated queries and deposits in a given array a segment of the results corresponding to the queries, using the current settings of this query engine.
 void score(it.unimi.dsi.mg4j.search.score.Scorer[] scorer, double[] weight)
          Sets the scorers for this query engine.
 void setWeights(it.unimi.dsi.fastutil.objects.Reference2DoubleMap<it.unimi.dsi.mg4j.index.Index> index2Weight)
          Sets the index weights.
 String toString()
           
 void transformer(it.unimi.dsi.mg4j.query.nodes.QueryTransformer transformer)
          Sets the transformer for this engine, or disables query transformation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queryParser

public final it.unimi.dsi.mg4j.query.parser.QueryParser queryParser
The parser used to parse queries.


indexMap

public final it.unimi.dsi.fastutil.objects.Object2ReferenceMap<String,it.unimi.dsi.mg4j.index.Index> indexMap
A map from names to indices.


numIndices

public final int numIndices
The number of indices used by queryParser.


multiplex

public volatile boolean multiplex
Whether multiplex is active.


intervalSelector

public volatile it.unimi.dsi.mg4j.query.IntervalSelector intervalSelector
The current interval selector, if any.


index2Weight

protected final it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap<it.unimi.dsi.mg4j.index.Index> index2Weight
A map associating a weight with each index.

Constructor Detail

QueryEngine

public QueryEngine(it.unimi.dsi.mg4j.query.parser.QueryParser queryParser,
                   it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitor<it.unimi.dsi.mg4j.search.DocumentIterator> builderVisitor,
                   it.unimi.dsi.fastutil.objects.Object2ReferenceMap<String,it.unimi.dsi.mg4j.index.Index> indexMap)
Creates a new query engine.

Parameters:
queryParser - a query parser, or null if this query engine will just process pre-parsed queries.
builderVisitor - a builder visitor to transform queries into document iterators.
indexMap - a map from symbolic name to indices (used for multiplexing and default weight initialisation).
Method Detail

copy

public QueryEngine copy()
Specified by:
copy in interface it.unimi.dsi.lang.FlyweightPrototype<QueryEngine>

equalize

public void equalize(int samples)
Activate equalisation with the given number of samples-

Parameters:
samples - the number of samples for equalisation, or 0 for no equalisation.

score

public void score(it.unimi.dsi.mg4j.search.score.Scorer[] scorer,
                  double[] weight)
Sets the scorers for this query engine.

If scorer has length zero, scoring is disabled. If it has length 1, the only scorer is used for scoring, and the only element of weight is discarded. Otherwise, a LinearAggregator is used to combine results from the given scorers, using the given weights.

Parameters:
scorer - an array of scorers.
weight - a parallel array of weights (not to be confused with index weights).

transformer

public void transformer(it.unimi.dsi.mg4j.query.nodes.QueryTransformer transformer)
Sets the transformer for this engine, or disables query transformation.

Parameters:
transformer - a query transformer, or null to disable query transformation.

setWeights

public void setWeights(it.unimi.dsi.fastutil.objects.Reference2DoubleMap<it.unimi.dsi.mg4j.index.Index> index2Weight)
Sets the index weights.

This method just delegates to Scorer.setWeights(Reference2DoubleMap).

Parameters:
index2Weight - a map from indices to weights.

process

public int process(String queries,
                   int offset,
                   int length,
                   it.unimi.dsi.fastutil.objects.ObjectArrayList<it.unimi.dsi.mg4j.search.score.DocumentScoreInfo<it.unimi.dsi.fastutil.objects.Reference2ObjectMap<it.unimi.dsi.mg4j.index.Index,it.unimi.dsi.mg4j.query.SelectedInterval[]>>> results)
            throws it.unimi.dsi.mg4j.query.parser.QueryParserException,
                   it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitorException,
                   IOException
Parses one or more comma-separated queries and deposits in a given array a segment of the results corresponding to the queries, using the current settings of this query engine.

Results are accumulated with an “and-then” semantics: results are added from each query in order, provided they did not appear before.

Parameters:
queries - one or more queries separated by commas.
offset - the first result to be added to results.
length - the number of results to be added to results
results - an array list that will hold all results.
Returns:
the number of relevant documents scanned while filling results.
Throws:
it.unimi.dsi.mg4j.query.parser.QueryParserException
it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitorException
IOException

process

public int process(it.unimi.dsi.mg4j.query.nodes.Query[] query,
                   int offset,
                   int length,
                   it.unimi.dsi.fastutil.objects.ObjectArrayList<it.unimi.dsi.mg4j.search.score.DocumentScoreInfo<it.unimi.dsi.fastutil.objects.Reference2ObjectMap<it.unimi.dsi.mg4j.index.Index,it.unimi.dsi.mg4j.query.SelectedInterval[]>>> results)
            throws it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitorException,
                   IOException
Processes one or more pre-parsed queries and deposits in a given array a segment of the results corresponding to the queries, using the current settings of this query engine.

Results are accumulated with an “and-then” semantics: results are added from each query in order, provided they did not appear before.

Parameters:
query - an array of queries.
offset - the first result to be added to results.
length - the number of results to be added to results
results - an array list that will hold all results.
Returns:
the number of documents scanned while filling results.
Throws:
it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitorException
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.