You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/01/26 11:12:18 UTC

[05/11] lucenenet git commit: Lucene.Net.Expressions.Expression refactor: Changed sourceText and variables to properties and renamed PascalCase. Added WritableArray attribute to Variables.

Lucene.Net.Expressions.Expression refactor: Changed sourceText and variables to properties and renamed PascalCase. Added WritableArray attribute to Variables.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c79c9eb7
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c79c9eb7
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c79c9eb7

Branch: refs/heads/api-work
Commit: c79c9eb78faa93e622a78f0607d498c45719bdbb
Parents: 8ade0b4
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jan 26 15:45:00 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jan 26 15:45:00 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Expressions/Expression.cs            | 12 +++++++-----
 src/Lucene.Net.Expressions/ExpressionRescorer.cs    |  2 +-
 src/Lucene.Net.Expressions/ExpressionValueSource.cs | 14 +++++++-------
 3 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c79c9eb7/src/Lucene.Net.Expressions/Expression.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/Expression.cs b/src/Lucene.Net.Expressions/Expression.cs
index 88ef269..7189e6d 100644
--- a/src/Lucene.Net.Expressions/Expression.cs
+++ b/src/Lucene.Net.Expressions/Expression.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Queries.Function;
 using Lucene.Net.Search;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Expressions
 {
@@ -43,10 +44,11 @@ namespace Lucene.Net.Expressions
     public abstract class Expression
 	{
 		/// <summary>The original source text</summary>
-		public readonly string sourceText; // LUCENENET TODO: Make property
+		public string SourceText { get; private set; }
 
         /// <summary>Named variables referred to by this expression</summary>
-        public readonly string[] variables; // LUCENENET TODO: Make property
+        [WritableArray]
+        public string[] Variables { get; private set; }
 
         /// <summary>
         /// Creates a new <see cref="Expression"/>.
@@ -61,8 +63,8 @@ namespace Lucene.Net.Expressions
         protected Expression(string sourceText, string[] variables)
 		{
 			// javadocs
-			this.sourceText = sourceText;
-			this.variables = variables;
+			this.SourceText = sourceText;
+			this.Variables = variables;
 		}
 
 		/// <summary>Evaluates the expression for the given document.</summary>
@@ -70,7 +72,7 @@ namespace Lucene.Net.Expressions
 		/// <param name="document"><c>docId</c> of the document to compute a value for</param>
 		/// <param name="functionValues">
         /// <see cref="Lucene.Net.Queries.Function.FunctionValues"/>
-		/// for each element of <see cref="variables">variables</see>.
+		/// for each element of <see cref="Variables">variables</see>.
 		/// </param>
 		/// <returns>The computed value of the expression for the given document.</returns>
 		public abstract double Evaluate(int document, FunctionValues[] functionValues);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c79c9eb7/src/Lucene.Net.Expressions/ExpressionRescorer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/ExpressionRescorer.cs b/src/Lucene.Net.Expressions/ExpressionRescorer.cs
index bd3de3e..ffed9e5 100644
--- a/src/Lucene.Net.Expressions/ExpressionRescorer.cs
+++ b/src/Lucene.Net.Expressions/ExpressionRescorer.cs
@@ -111,7 +111,7 @@ namespace Lucene.Net.Expressions
             var context = new Dictionary<string, object>();
             var fakeScorer = new FakeScorer { score = firstPassExplanation.Value, doc = docIDInSegment };
             context["scorer"] = fakeScorer;
-            foreach (string variable in expression.variables)
+            foreach (string variable in expression.Variables)
             {
                 result.AddDetail(new Explanation((float)bindings.GetValueSource(variable).GetValues
                     (context, readerContext).DoubleVal(docIDInSegment), "variable \"" + variable + "\""

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c79c9eb7/src/Lucene.Net.Expressions/ExpressionValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/ExpressionValueSource.cs b/src/Lucene.Net.Expressions/ExpressionValueSource.cs
index 897b5bc..85ec736 100644
--- a/src/Lucene.Net.Expressions/ExpressionValueSource.cs
+++ b/src/Lucene.Net.Expressions/ExpressionValueSource.cs
@@ -46,11 +46,11 @@ namespace Lucene.Net.Expressions
 				throw new ArgumentNullException();
 			}
 			this.expression = expression;
-			variables = new ValueSource[expression.variables.Length];
+			variables = new ValueSource[expression.Variables.Length];
 			bool needsScores = false;
 			for (int i = 0; i < variables.Length; i++)
 			{
-				ValueSource source = bindings.GetValueSource(expression.variables[i]);
+				ValueSource source = bindings.GetValueSource(expression.Variables[i]);
 				if (source is ScoreValueSource)
 				{
 					needsScores = true;
@@ -69,7 +69,7 @@ namespace Lucene.Net.Expressions
 					{
 						if (source == null)
 						{
-							throw new InvalidOperationException("Internal error. Variable (" + expression.variables[i]
+							throw new InvalidOperationException("Internal error. Variable (" + expression.Variables[i]
 								 + ") does not exist.");
 						}
 					}
@@ -88,10 +88,10 @@ namespace Lucene.Net.Expressions
 				context = new Hashtable(context);
 				context["valuesCache"] = valuesCache;
 			}
-			FunctionValues[] externalValues = new FunctionValues[expression.variables.Length];
+			FunctionValues[] externalValues = new FunctionValues[expression.Variables.Length];
 			for (int i = 0; i < variables.Length; ++i)
 			{
-				string externalName = expression.variables[i];
+				string externalName = expression.Variables[i];
 				FunctionValues values;
 				if (!valuesCache.TryGetValue(externalName,out values))
 				{
@@ -109,12 +109,12 @@ namespace Lucene.Net.Expressions
 
 		public override SortField GetSortField(bool reverse)
 		{
-			return new ExpressionSortField(expression.sourceText, this, reverse);
+			return new ExpressionSortField(expression.SourceText, this, reverse);
 		}
 
 		public override string GetDescription()
         {
-		    return "expr(" + expression.sourceText + ")";
+		    return "expr(" + expression.SourceText + ")";
 		}
 
 		public override int GetHashCode()