You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/04/11 20:48:21 UTC

[1/3] lucenenet git commit: init bytesref on each iteration

Repository: lucenenet
Updated Branches:
  refs/heads/master 31a43f02a -> c83d8e80a


init bytesref on each iteration


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

Branch: refs/heads/master
Commit: 07648a3b20ea9055bbae91cc5cf529c8fe1fc3f3
Parents: 31a43f0
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sat Apr 11 09:01:53 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sat Apr 11 09:01:53 2015 -0400

----------------------------------------------------------------------
 .../Index/BinaryDocValuesWriter.cs              | 115 +------------------
 1 file changed, 2 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/07648a3b/src/Lucene.Net.Core/Index/BinaryDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/BinaryDocValuesWriter.cs b/src/Lucene.Net.Core/Index/BinaryDocValuesWriter.cs
index a1b527d..ee460e4 100644
--- a/src/Lucene.Net.Core/Index/BinaryDocValuesWriter.cs
+++ b/src/Lucene.Net.Core/Index/BinaryDocValuesWriter.cs
@@ -128,28 +128,8 @@ namespace Lucene.Net.Index
             int maxDoc = state.SegmentInfo.DocCount;
             Bytes.Freeze(false);
             dvConsumer.AddBinaryField(FieldInfo, GetBytesIterator(maxDoc));
-            //dvConsumer.AddBinaryField(FieldInfo, new IterableAnonymousInnerClassHelper(this, maxDoc));
         }
 
-        /*
-	  private class IterableAnonymousInnerClassHelper : IEnumerable<BytesRef>
-	  {
-		  private readonly BinaryDocValuesWriter OuterInstance;
-
-		  private int MaxDoc;
-
-		  public IterableAnonymousInnerClassHelper(BinaryDocValuesWriter outerInstance, int maxDoc)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.MaxDoc = maxDoc;
-		  }
-
-		  public virtual IEnumerator<BytesRef> GetEnumerator()
-		  {
-			 return new BytesIterator(OuterInstance, MaxDoc);
-		  }
-	  }*/
-
         internal override void Abort()
         {
         }
@@ -158,7 +138,6 @@ namespace Lucene.Net.Index
         {
             // Use yield return instead of ucsom IEnumerable
 
-            BytesRef value = new BytesRef();
             AppendingDeltaPackedLongBuffer.Iterator lengthsIterator = Lengths.GetIterator();
             int size = (int)Lengths.Size();
             DataInput bytesIterator = Bytes.DataInput;
@@ -167,10 +146,11 @@ namespace Lucene.Net.Index
 
             while (upto < maxDoc)
             {
-                BytesRef v;
+                BytesRef v = null;
                 if (upto < size)
                 {
                     int length = (int)lengthsIterator.Next();
+                    var value = new BytesRef();
                     value.Grow(length);
                     value.Length = length;
                     bytesIterator.ReadBytes(value.Bytes, value.Offset, value.Length);
@@ -179,102 +159,11 @@ namespace Lucene.Net.Index
                     {
                         v = value;
                     }
-                    else
-                    {
-                        v = null;
-                    }
-                }
-                else
-                {
-                    v = null;
                 }
 
                 upto++;
                 yield return v;
             }
         }
-
-        /*
-	  // iterates over the values we have in ram
-	  private class BytesIterator : IEnumerator<BytesRef>
-	  {
-		  internal bool InstanceFieldsInitialized = false;
-
-		  internal virtual void InitializeInstanceFields()
-		  {
-			  LengthsIterator = OuterInstance.Lengths.Iterator();
-              BytesIterator_Renamed = OuterInstance.Bytes.DataInput;
-              Size = (int)OuterInstance.Lengths.Size();
-		  }
-
-		  private readonly BinaryDocValuesWriter OuterInstance;
-
-		internal readonly BytesRef Value = new BytesRef();
-		internal AppendingDeltaPackedLongBuffer.Iterator LengthsIterator;
-		internal DataInput BytesIterator_Renamed;
-		internal int Size;
-		internal readonly int MaxDoc;
-		internal int Upto;
-
-		internal BytesIterator(BinaryDocValuesWriter outerInstance, int maxDoc)
-		{
-			this.OuterInstance = outerInstance;
-
-			if (!InstanceFieldsInitialized)
-			{
-				InitializeInstanceFields();
-				InstanceFieldsInitialized = true;
-			}
-		  this.MaxDoc = maxDoc;
-		}
-
-		public override bool HasNext()
-		{
-		  return Upto < MaxDoc;
-		}
-
-		public override BytesRef Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new NoSuchElementException();
-		  }
-		  BytesRef v;
-		  if (Upto < Size)
-		  {
-			int length = (int) LengthsIterator.Next();
-			Value.Grow(length);
-			Value.Length = length;
-			try
-			{
-			  BytesIterator_Renamed.ReadBytes(Value.Bytes, Value.Offset, Value.Length);
-			}
-			catch (System.IO.IOException ioe)
-			{
-			  // Should never happen!
-			  throw new Exception(ioe.ToString(), ioe);
-			}
-            if (OuterInstance.DocsWithField.Get(Upto))
-			{
-			  v = Value;
-			}
-			else
-			{
-			  v = null;
-			}
-		  }
-		  else
-		  {
-			v = null;
-		  }
-		  Upto++;
-		  return v;
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }*/
     }
 }
\ No newline at end of file


[3/3] lucenenet git commit: Merge remote-tracking branch 'laimis/binarydocvalueswriter_fixes'

Posted by sy...@apache.org.
Merge remote-tracking branch 'laimis/binarydocvalueswriter_fixes'


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

Branch: refs/heads/master
Commit: c83d8e80a78ca236c1c20197cdc03188aab139c3
Parents: 5091a1d 07648a3
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Sat Apr 11 21:48:01 2015 +0300
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Sat Apr 11 21:48:01 2015 +0300

----------------------------------------------------------------------
 .../Index/BinaryDocValuesWriter.cs              | 115 +------------------
 1 file changed, 2 insertions(+), 113 deletions(-)
----------------------------------------------------------------------



[2/3] lucenenet git commit: Cleanup

Posted by sy...@apache.org.
Cleanup


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

Branch: refs/heads/master
Commit: 5091a1d333b4ff1e6efe3339e4415c83b1301447
Parents: 31a43f0
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Sat Apr 11 21:47:24 2015 +0300
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Sat Apr 11 21:47:24 2015 +0300

----------------------------------------------------------------------
 .../Function/ValueSources/DoubleFieldSource.cs               | 7 ++-----
 .../Function/ValueSources/FloatFieldSource.cs                | 7 ++-----
 src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs   | 7 ++-----
 .../Function/ValueSources/MaxFloatFunction.cs                | 8 ++------
 .../Function/ValueSources/MinFloatFunction.cs                | 8 ++------
 5 files changed, 10 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
index 95c74fd..ed6a71c 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
@@ -52,21 +52,18 @@ namespace Lucene.Net.Queries.Function.ValueSources
         {
             var arr = cache.GetDoubles(readerContext.AtomicReader, field, parser, true);
             var valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
-            return new DoubleDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
+            return new DoubleDocValuesAnonymousInnerClassHelper(this, arr, valid);
 
         }
 
         private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues
         {
-            private readonly DoubleFieldSource outerInstance;
-
             private readonly FieldCache.Doubles arr;
             private readonly Bits valid;
 
-            public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource outerInstance, DoubleFieldSource @this, FieldCache.Doubles arr, Bits valid)
+            public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource @this, FieldCache.Doubles arr, Bits valid)
                 : base(@this)
             {
-                this.outerInstance = outerInstance;
                 this.arr = arr;
                 this.valid = valid;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
index b3ba445..a396867 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
@@ -52,20 +52,17 @@ namespace Lucene.Net.Queries.Function.ValueSources
         {
             var arr = cache.GetFloats(readerContext.AtomicReader, field, parser, true);
             var valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
-            return new FloatDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
+            return new FloatDocValuesAnonymousInnerClassHelper(this, arr, valid);
         }
 
         private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
         {
-            private readonly FloatFieldSource outerInstance;
-
             private readonly FieldCache.Floats arr;
             private readonly Bits valid;
 
-            public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource outerInstance, FloatFieldSource @this, FieldCache.Floats arr, Bits valid)
+            public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource @this, FieldCache.Floats arr, Bits valid)
                 : base(@this)
             {
-                this.outerInstance = outerInstance;
                 this.arr = arr;
                 this.valid = valid;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
index 0eb8cad..5d405bc 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
@@ -45,20 +45,17 @@ namespace Lucene.Net.Queries.Function.ValueSources
             FunctionValues trueVals = trueSource.GetValues(context, readerContext);
             FunctionValues falseVals = falseSource.GetValues(context, readerContext);
 
-            return new FunctionValuesAnonymousInnerClassHelper(this, ifVals, trueVals, falseVals);
+            return new FunctionValuesAnonymousInnerClassHelper(ifVals, trueVals, falseVals);
         }
 
         private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
         {
-            private readonly IfFunction outerInstance;
-
             private readonly FunctionValues ifVals;
             private readonly FunctionValues trueVals;
             private readonly FunctionValues falseVals;
 
-            public FunctionValuesAnonymousInnerClassHelper(IfFunction outerInstance, FunctionValues ifVals, FunctionValues trueVals, FunctionValues falseVals)
+            public FunctionValuesAnonymousInnerClassHelper(FunctionValues ifVals, FunctionValues trueVals, FunctionValues falseVals)
             {
-                this.outerInstance = outerInstance;
                 this.ifVals = ifVals;
                 this.trueVals = trueVals;
                 this.falseVals = falseVals;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
index 6e6126c..d126343 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 using System;
+using System.Linq;
 
 namespace Lucene.Net.Queries.Function.ValueSources
 {
@@ -39,12 +40,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
             {
                 return 0.0f;
             }
-            float val = float.NegativeInfinity;
-            foreach (FunctionValues vals in valsArr)
-            {
-                val = Math.Max(vals.FloatVal(doc), val);
-            }
-            return val;
+            return valsArr.Select(vals => vals.FloatVal(doc)).Concat(new[] {float.NegativeInfinity}).Max();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
index 3284b44..5c38c2d 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 using System;
+using System.Linq;
 
 namespace Lucene.Net.Queries.Function.ValueSources
 {
@@ -39,12 +40,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
             {
                 return 0.0f;
             }
-            float val = float.PositiveInfinity;
-            foreach (FunctionValues vals in valsArr)
-            {
-                val = Math.Min(vals.FloatVal(doc), val);
-            }
-            return val;
+            return valsArr.Select(vals => vals.FloatVal(doc)).Concat(new[] {float.PositiveInfinity}).Min();
         }
     }
 }
\ No newline at end of file