/// <summary>
 /// Uses the provided
 /// <see cref="Lucene.Net.Queries.Function.ValueSource">Lucene.Net.Queries.Function.ValueSource
 /// 	</see>
 /// to assign second
 /// pass scores.
 /// </summary>
 public ExpressionRescorer(Expression expression, Bindings bindings)
     : base(new Sort
         (expression.GetSortField(bindings, true)))
 {
     this.expression = expression;
     this.bindings = bindings;
 }
 internal ExpressionFunctionValues(ValueSource parent, Expression expression, FunctionValues
     [] functionValues)
     : base(parent)
 {
     if (expression == null)
     {
         throw new ArgumentNullException();
     }
     if (functionValues == null)
     {
         throw new ArgumentNullException();
     }
     this.expression = expression;
     this.functionValues = functionValues;
 }
		internal ExpressionValueSource(Bindings bindings, Expression expression)
		{
			if (bindings == null)
			{
				throw new ArgumentNullException();
			}
			if (expression == null)
			{
				throw new ArgumentNullException();
			}
			this.expression = expression;
			variables = new ValueSource[expression.variables.Length];
			bool needsScores = false;
			for (int i = 0; i < variables.Length; i++)
			{
				ValueSource source = bindings.GetValueSource(expression.variables[i]);
				if (source is ScoreValueSource)
				{
					needsScores = true;
				}
				else
				{
				    var valueSource = source as ExpressionValueSource;
				    if (valueSource != null)
					{
						if (valueSource.NeedsScores())
						{
							needsScores = true;
						}
					}
					else
					{
						if (source == null)
						{
							throw new SystemException("Internal error. Variable (" + expression.variables[i]
								 + ") does not exist.");
						}
					}
				}
			    variables[i] = source;
			}
			this.needsScores = needsScores;
		}
Beispiel #4
0
 /// <summary>Adds an Expression to the bindings.</summary>
 /// <remarks>
 /// Adds an Expression to the bindings.
 /// <p>
 /// This can be used to reference expressions from other expressions.
 /// </remarks>
 public void Add(string name, Expression expression)
 {
     map[name] = expression;
 }