lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [04/62] [abbrv] [partial] lucenenet git commit: Renamed Lucene.Net.Core folder Lucene.Net because the dotnet.exe pack command doesn't allow creating a NuGet package with a different name than its folder. Working around it with the script was much more co
Date Tue, 04 Apr 2017 17:19:10 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/SortedDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedDocValuesWriter.cs b/src/Lucene.Net.Core/Index/SortedDocValuesWriter.cs
deleted file mode 100644
index fd5ae82..0000000
--- a/src/Lucene.Net.Core/Index/SortedDocValuesWriter.cs
+++ /dev/null
@@ -1,296 +0,0 @@
-using Lucene.Net.Codecs;
-using Lucene.Net.Util;
-using Lucene.Net.Util.Packed;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    /// <summary>
-    /// Buffers up pending byte[] per doc, deref and sorting via
-    ///  int ord, then flushes when segment flushes.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal class SortedDocValuesWriter : DocValuesWriter
-    {
-        internal readonly BytesRefHash hash;
-        private AppendingDeltaPackedInt64Buffer pending;
-        private readonly Counter iwBytesUsed;
-        private long bytesUsed; // this currently only tracks differences in 'pending'
-        private readonly FieldInfo fieldInfo;
-
-        private const int EMPTY_ORD = -1;
-
-        public SortedDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed)
-        {
-            this.fieldInfo = fieldInfo;
-            this.iwBytesUsed = iwBytesUsed;
-            hash = new BytesRefHash(new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)), BytesRefHash.DEFAULT_CAPACITY, new BytesRefHash.DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
-            pending = new AppendingDeltaPackedInt64Buffer(PackedInt32s.COMPACT);
-            bytesUsed = pending.RamBytesUsed();
-            iwBytesUsed.AddAndGet(bytesUsed);
-        }
-
-        public virtual void AddValue(int docID, BytesRef value)
-        {
-            if (docID < pending.Count)
-            {
-                throw new System.ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" appears more than once in this document (only one value is allowed per field)");
-            }
-            if (value == null)
-            {
-                throw new System.ArgumentException("field \"" + fieldInfo.Name + "\": null value not allowed");
-            }
-            if (value.Length > (ByteBlockPool.BYTE_BLOCK_SIZE - 2))
-            {
-                throw new System.ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" is too large, must be <= " + (ByteBlockPool.BYTE_BLOCK_SIZE - 2));
-            }
-
-            // Fill in any holes:
-            while (pending.Count < docID)
-            {
-                pending.Add(EMPTY_ORD);
-            }
-
-            AddOneValue(value);
-        }
-
-        public override void Finish(int maxDoc)
-        {
-            while (pending.Count < maxDoc)
-            {
-                pending.Add(EMPTY_ORD);
-            }
-            UpdateBytesUsed();
-        }
-
-        private void AddOneValue(BytesRef value)
-        {
-            int termID = hash.Add(value);
-            if (termID < 0)
-            {
-                termID = -termID - 1;
-            }
-            else
-            {
-                // reserve additional space for each unique value:
-                // 1. when indexing, when hash is 50% full, rehash() suddenly needs 2*size ints.
-                //    TODO: can this same OOM happen in THPF?
-                // 2. when flushing, we need 1 int per value (slot in the ordMap).
-                iwBytesUsed.AddAndGet(2 * RamUsageEstimator.NUM_BYTES_INT32);
-            }
-
-            pending.Add(termID);
-            UpdateBytesUsed();
-        }
-
-        private void UpdateBytesUsed()
-        {
-            long newBytesUsed = pending.RamBytesUsed();
-            iwBytesUsed.AddAndGet(newBytesUsed - bytesUsed);
-            bytesUsed = newBytesUsed;
-        }
-
-        public override void Flush(SegmentWriteState state, DocValuesConsumer dvConsumer)
-        {
-            int maxDoc = state.SegmentInfo.DocCount;
-
-            Debug.Assert(pending.Count == maxDoc);
-            int valueCount = hash.Count;
-
-            int[] sortedValues = hash.Sort(BytesRef.UTF8SortedAsUnicodeComparer);
-            int[] ordMap = new int[valueCount];
-
-            for (int ord = 0; ord < valueCount; ord++)
-            {
-                ordMap[sortedValues[ord]] = ord;
-            }
-
-            dvConsumer.AddSortedField(fieldInfo, GetBytesRefEnumberable(valueCount, sortedValues),
-                // doc -> ord
-                                      GetOrdsEnumberable(maxDoc, ordMap));
-        }
-
-        public override void Abort()
-        {
-        }
-
-        private IEnumerable<BytesRef> GetBytesRefEnumberable(int valueCount, int[] sortedValues)
-        {
-            for (int i = 0; i < valueCount; ++i)
-            {
-                var scratch = new BytesRef();
-                yield return hash.Get(sortedValues[i], scratch);
-            }
-        }
-
-        private IEnumerable<long?> GetOrdsEnumberable(int maxDoc, int[] ordMap)
-        {
-            AppendingDeltaPackedInt64Buffer.Iterator iter = pending.GetIterator();
-
-            for (int i = 0; i < maxDoc; ++i)
-            {
-                int ord = (int)iter.Next();
-                yield return ord == -1 ? ord : ordMap[ord];
-            }
-        }
-
-        /*
-	  private class IterableAnonymousInnerClassHelper : IEnumerable<BytesRef>
-	  {
-		  private readonly SortedDocValuesWriter OuterInstance;
-
-		  private int ValueCount;
-		  private int[] SortedValues;
-
-		  public IterableAnonymousInnerClassHelper(SortedDocValuesWriter outerInstance, int valueCount, int[] sortedValues)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.ValueCount = valueCount;
-			  this.SortedValues = sortedValues;
-		  }
-
-									// ord -> value
-		  public virtual IEnumerator<BytesRef> GetEnumerator()
-		  {
-			return new ValuesIterator(OuterInstance, SortedValues, ValueCount);
-		  }
-	  }
-
-	  private class IterableAnonymousInnerClassHelper2 : IEnumerable<Number>
-	  {
-		  private readonly SortedDocValuesWriter OuterInstance;
-
-		  private int MaxDoc;
-		  private int[] OrdMap;
-
-		  public IterableAnonymousInnerClassHelper2(SortedDocValuesWriter outerInstance, int maxDoc, int[] ordMap)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.MaxDoc = maxDoc;
-			  this.OrdMap = ordMap;
-		  }
-
-		  public virtual IEnumerator<Number> GetEnumerator()
-		  {
-			return new OrdsIterator(OuterInstance, OrdMap, MaxDoc);
-		  }
-	  }
-
-	  public override void Abort()
-	  {
-	  }
-
-	  // iterates over the unique values we have in ram
-	  private class ValuesIterator : IEnumerator<BytesRef>
-	  {
-		  private readonly SortedDocValuesWriter OuterInstance;
-
-		internal readonly int[] SortedValues;
-		internal readonly BytesRef Scratch = new BytesRef();
-		internal readonly int ValueCount;
-		internal int OrdUpto;
-
-		internal ValuesIterator(SortedDocValuesWriter outerInstance, int[] sortedValues, int valueCount)
-		{
-			this.OuterInstance = outerInstance;
-		  this.SortedValues = sortedValues;
-		  this.ValueCount = valueCount;
-		}
-
-		public override bool HasNext()
-		{
-		  return OrdUpto < ValueCount;
-		}
-
-		public override BytesRef Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new Exception();
-		  }
-		  OuterInstance.Hash.Get(SortedValues[OrdUpto], Scratch);
-		  OrdUpto++;
-		  return Scratch;
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }
-
-	  // iterates over the ords for each doc we have in ram
-	  private class OrdsIterator : IEnumerator<Number>
-	  {
-		  internal bool InstanceFieldsInitialized = false;
-
-		  internal virtual void InitializeInstanceFields()
-		  {
-			  Iter = OuterInstance.Pending.Iterator();
-		  }
-
-		  private readonly SortedDocValuesWriter OuterInstance;
-
-		internal AppendingDeltaPackedLongBuffer.Iterator Iter;
-		internal readonly int[] OrdMap;
-		internal readonly int MaxDoc;
-		internal int DocUpto;
-
-		internal OrdsIterator(SortedDocValuesWriter outerInstance, int[] ordMap, int maxDoc)
-		{
-			this.OuterInstance = outerInstance;
-
-			if (!InstanceFieldsInitialized)
-			{
-				InitializeInstanceFields();
-				InstanceFieldsInitialized = true;
-			}
-		  this.OrdMap = ordMap;
-		  this.MaxDoc = maxDoc;
-		  Debug.Assert(outerInstance.Pending.Size() == maxDoc);
-		}
-
-		public override bool HasNext()
-		{
-		  return DocUpto < MaxDoc;
-		}
-
-		public override Number Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new Exception();
-		  }
-		  int ord = (int) Iter.next();
-		  DocUpto++;
-		  return ord == -1 ? ord : OrdMap[ord];
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }*/
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/SortedSetDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedSetDocValues.cs b/src/Lucene.Net.Core/Index/SortedSetDocValues.cs
deleted file mode 100644
index e7844d0..0000000
--- a/src/Lucene.Net.Core/Index/SortedSetDocValues.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    using BytesRef = Lucene.Net.Util.BytesRef;
-
-    /// <summary>
-    /// A per-document set of presorted byte[] values.
-    /// <p>
-    /// Per-Document values in a SortedDocValues are deduplicated, dereferenced,
-    /// and sorted into a dictionary of unique values. A pointer to the
-    /// dictionary value (ordinal) can be retrieved for each document. Ordinals
-    /// are dense and in increasing sorted order.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    public abstract class SortedSetDocValues
-    {
-        /// <summary>
-        /// Sole constructor. (For invocation by subclass
-        /// constructors, typically implicit.)
-        /// </summary>
-        protected SortedSetDocValues()
-        {
-        }
-
-        /// <summary>
-        /// When returned by <seealso cref="#nextOrd()"/> it means there are no more
-        /// ordinals for the document.
-        /// </summary>
-        public static readonly long NO_MORE_ORDS = -1;
-
-        /// <summary>
-        /// Returns the next ordinal for the current document (previously
-        /// set by <seealso cref="#setDocument(int)"/>. </summary>
-        /// <returns> next ordinal for the document, or <seealso cref="#NO_MORE_ORDS"/>.
-        ///         ordinals are dense, start at 0, then increment by 1 for
-        ///         the next value in sorted order.  </returns>
-        public abstract long NextOrd();
-
-        /// <summary>
-        /// Sets iteration to the specified docID </summary>
-        /// <param name="docID"> document ID  </param>
-        public abstract void SetDocument(int docID);
-
-        /// <summary>
-        /// Retrieves the value for the specified ordinal. </summary>
-        /// <param name="ord"> ordinal to lookup </param>
-        /// <param name="result"> will be populated with the ordinal's value </param>
-        /// <seealso cref= #nextOrd </seealso>
-        public abstract void LookupOrd(long ord, BytesRef result);
-
-        /// <summary>
-        /// Returns the number of unique values. </summary>
-        /// <returns> number of unique values in this SortedDocValues. this is
-        ///         also equivalent to one plus the maximum ordinal. </returns>
-        public abstract long ValueCount { get; }
-
-        /// <summary>
-        /// If {@code key} exists, returns its ordinal, else
-        ///  returns {@code -insertionPoint-1}, like {@code
-        ///  Arrays.binarySearch}.
-        /// </summary>
-        ///  <param name="key"> Key to look up
-        ///  </param>
-        public virtual long LookupTerm(BytesRef key)
-        {
-            BytesRef spare = new BytesRef();
-            long low = 0;
-            long high = ValueCount - 1;
-
-            while (low <= high)
-            {
-                long mid = (int)((uint)(low + high) >> 1);
-                LookupOrd(mid, spare);
-                int cmp = spare.CompareTo(key);
-
-                if (cmp < 0)
-                {
-                    low = mid + 1;
-                }
-                else if (cmp > 0)
-                {
-                    high = mid - 1;
-                }
-                else
-                {
-                    return mid; // key found
-                }
-            }
-
-            return -(low + 1); // key not found.
-        }
-
-        /// <summary>
-        /// Returns a <seealso cref="TermsEnum"/> over the values.
-        /// The enum supports <seealso cref="TermsEnum#ord()"/> and <seealso cref="TermsEnum#seekExact(long)"/>.
-        /// </summary>
-        public virtual TermsEnum GetTermsEnum()
-        {
-            return new SortedSetDocValuesTermsEnum(this);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs b/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
deleted file mode 100644
index c2502cb..0000000
--- a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    using IBits = Lucene.Net.Util.IBits;
-    using BytesRef = Lucene.Net.Util.BytesRef;
-
-    /// <summary>
-    /// Implements a <seealso cref="TermsEnum"/> wrapping a provided
-    /// <seealso cref="SortedSetDocValues"/>.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal class SortedSetDocValuesTermsEnum : TermsEnum
-    {
-        private readonly SortedSetDocValues values;
-        private long currentOrd = -1;
-        private readonly BytesRef term = new BytesRef();
-
-        /// <summary>
-        /// Creates a new TermsEnum over the provided values </summary>
-        public SortedSetDocValuesTermsEnum(SortedSetDocValues values)
-        {
-            this.values = values;
-        }
-
-        public override SeekStatus SeekCeil(BytesRef text)
-        {
-            long ord = values.LookupTerm(text);
-            if (ord >= 0)
-            {
-                currentOrd = ord;
-                term.Offset = 0;
-                // TODO: is there a cleaner way?
-                // term.bytes may be pointing to codec-private byte[]
-                // storage, so we must force new byte[] allocation:
-                term.Bytes = new byte[text.Length];
-                term.CopyBytes(text);
-                return SeekStatus.FOUND;
-            }
-            else
-            {
-                currentOrd = -ord - 1;
-                if (currentOrd == values.ValueCount)
-                {
-                    return SeekStatus.END;
-                }
-                else
-                {
-                    // TODO: hmm can we avoid this "extra" lookup?:
-                    values.LookupOrd(currentOrd, term);
-                    return SeekStatus.NOT_FOUND;
-                }
-            }
-        }
-
-        public override bool SeekExact(BytesRef text)
-        {
-            long ord = values.LookupTerm(text);
-            if (ord >= 0)
-            {
-                term.Offset = 0;
-                // TODO: is there a cleaner way?
-                // term.bytes may be pointing to codec-private byte[]
-                // storage, so we must force new byte[] allocation:
-                term.Bytes = new byte[text.Length];
-                term.CopyBytes(text);
-                currentOrd = ord;
-                return true;
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        public override void SeekExact(long ord)
-        {
-            Debug.Assert(ord >= 0 && ord < values.ValueCount);
-            currentOrd = (int)ord;
-            values.LookupOrd(currentOrd, term);
-        }
-
-        public override BytesRef Next()
-        {
-            currentOrd++;
-            if (currentOrd >= values.ValueCount)
-            {
-                return null;
-            }
-            values.LookupOrd(currentOrd, term);
-            return term;
-        }
-
-        public override BytesRef Term
-        {
-            get { return term; }
-        }
-
-        public override long Ord
-        {
-            get { return currentOrd; }
-        }
-
-        public override int DocFreq
-        {
-            get { throw new System.NotSupportedException(); }
-        }
-
-        public override long TotalTermFreq
-        {
-            get { return -1; }
-        }
-
-        public override DocsEnum Docs(IBits liveDocs, DocsEnum reuse, DocsFlags flags)
-        {
-            throw new System.NotSupportedException();
-        }
-
-        public override DocsAndPositionsEnum DocsAndPositions(IBits liveDocs, DocsAndPositionsEnum reuse, DocsAndPositionsFlags flags)
-        {
-            throw new System.NotSupportedException();
-        }
-
-        public override IComparer<BytesRef> Comparer
-        {
-            get
-            {
-                return BytesRef.UTF8SortedAsUnicodeComparer;
-            }
-        }
-
-        public override void SeekExact(BytesRef term, TermState state)
-        {
-            Debug.Assert(state != null && state is OrdTermState);
-            this.SeekExact(((OrdTermState)state).Ord);
-        }
-
-        public override TermState GetTermState()
-        {
-            OrdTermState state = new OrdTermState();
-            state.Ord = currentOrd;
-            return state;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/SortedSetDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedSetDocValuesWriter.cs b/src/Lucene.Net.Core/Index/SortedSetDocValuesWriter.cs
deleted file mode 100644
index c7db93e..0000000
--- a/src/Lucene.Net.Core/Index/SortedSetDocValuesWriter.cs
+++ /dev/null
@@ -1,464 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    using AppendingDeltaPackedInt64Buffer = Lucene.Net.Util.Packed.AppendingDeltaPackedInt64Buffer;
-    using AppendingPackedInt64Buffer = Lucene.Net.Util.Packed.AppendingPackedInt64Buffer;
-    using ArrayUtil = Lucene.Net.Util.ArrayUtil;
-    using ByteBlockPool = Lucene.Net.Util.ByteBlockPool;
-    using BytesRef = Lucene.Net.Util.BytesRef;
-    using BytesRefHash = Lucene.Net.Util.BytesRefHash;
-    using Counter = Lucene.Net.Util.Counter;
-    using DirectBytesStartArray = Lucene.Net.Util.BytesRefHash.DirectBytesStartArray;
-    using DocValuesConsumer = Lucene.Net.Codecs.DocValuesConsumer;
-    using PackedInt32s = Lucene.Net.Util.Packed.PackedInt32s;
-    using RamUsageEstimator = Lucene.Net.Util.RamUsageEstimator;
-
-    /// <summary>
-    /// Buffers up pending byte[]s per doc, deref and sorting via
-    ///  int ord, then flushes when segment flushes.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal class SortedSetDocValuesWriter : DocValuesWriter
-    {
-        internal readonly BytesRefHash hash;
-        private AppendingPackedInt64Buffer pending; // stream of all termIDs
-        private AppendingDeltaPackedInt64Buffer pendingCounts; // termIDs per doc
-        private readonly Counter iwBytesUsed;
-        private long bytesUsed; // this only tracks differences in 'pending' and 'pendingCounts'
-        private readonly FieldInfo fieldInfo;
-        private int currentDoc;
-        private int[] currentValues = new int[8];
-        private int currentUpto = 0;
-        private int maxCount = 0;
-
-        public SortedSetDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed)
-        {
-            this.fieldInfo = fieldInfo;
-            this.iwBytesUsed = iwBytesUsed;
-            hash = new BytesRefHash(new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)), BytesRefHash.DEFAULT_CAPACITY, new DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
-            pending = new AppendingPackedInt64Buffer(PackedInt32s.COMPACT);
-            pendingCounts = new AppendingDeltaPackedInt64Buffer(PackedInt32s.COMPACT);
-            bytesUsed = pending.RamBytesUsed() + pendingCounts.RamBytesUsed();
-            iwBytesUsed.AddAndGet(bytesUsed);
-        }
-
-        public virtual void AddValue(int docID, BytesRef value)
-        {
-            if (value == null)
-            {
-                throw new System.ArgumentException("field \"" + fieldInfo.Name + "\": null value not allowed");
-            }
-            if (value.Length > (ByteBlockPool.BYTE_BLOCK_SIZE - 2))
-            {
-                throw new System.ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" is too large, must be <= " + (ByteBlockPool.BYTE_BLOCK_SIZE - 2));
-            }
-
-            if (docID != currentDoc)
-            {
-                FinishCurrentDoc();
-            }
-
-            // Fill in any holes:
-            while (currentDoc < docID)
-            {
-                pendingCounts.Add(0); // no values
-                currentDoc++;
-            }
-
-            AddOneValue(value);
-            UpdateBytesUsed();
-        }
-
-        // finalize currentDoc: this deduplicates the current term ids
-        private void FinishCurrentDoc()
-        {
-            Array.Sort(currentValues, 0, currentUpto);
-            int lastValue = -1;
-            int count = 0;
-            for (int i = 0; i < currentUpto; i++)
-            {
-                int termID = currentValues[i];
-                // if its not a duplicate
-                if (termID != lastValue)
-                {
-                    pending.Add(termID); // record the term id
-                    count++;
-                }
-                lastValue = termID;
-            }
-            // record the number of unique term ids for this doc
-            pendingCounts.Add(count);
-            maxCount = Math.Max(maxCount, count);
-            currentUpto = 0;
-            currentDoc++;
-        }
-
-        public override void Finish(int maxDoc)
-        {
-            FinishCurrentDoc();
-
-            // fill in any holes
-            for (int i = currentDoc; i < maxDoc; i++)
-            {
-                pendingCounts.Add(0); // no values
-            }
-        }
-
-        private void AddOneValue(BytesRef value)
-        {
-            int termID = hash.Add(value);
-            if (termID < 0)
-            {
-                termID = -termID - 1;
-            }
-            else
-            {
-                // reserve additional space for each unique value:
-                // 1. when indexing, when hash is 50% full, rehash() suddenly needs 2*size ints.
-                //    TODO: can this same OOM happen in THPF?
-                // 2. when flushing, we need 1 int per value (slot in the ordMap).
-                iwBytesUsed.AddAndGet(2 * RamUsageEstimator.NUM_BYTES_INT32);
-            }
-
-            if (currentUpto == currentValues.Length)
-            {
-                currentValues = ArrayUtil.Grow(currentValues, currentValues.Length + 1);
-                // reserve additional space for max # values per-doc
-                // when flushing, we need an int[] to sort the mapped-ords within the doc
-                iwBytesUsed.AddAndGet((currentValues.Length - currentUpto) * 2 * RamUsageEstimator.NUM_BYTES_INT32);
-            }
-
-            currentValues[currentUpto] = termID;
-            currentUpto++;
-        }
-
-        private void UpdateBytesUsed()
-        {
-            long newBytesUsed = pending.RamBytesUsed() + pendingCounts.RamBytesUsed();
-            iwBytesUsed.AddAndGet(newBytesUsed - bytesUsed);
-            bytesUsed = newBytesUsed;
-        }
-
-        public override void Flush(SegmentWriteState state, DocValuesConsumer dvConsumer)
-        {
-            int maxDoc = state.SegmentInfo.DocCount;
-            int maxCountPerDoc = maxCount;
-            Debug.Assert(pendingCounts.Count == maxDoc);
-            int valueCount = hash.Count;
-
-            int[] sortedValues = hash.Sort(BytesRef.UTF8SortedAsUnicodeComparer);
-            int[] ordMap = new int[valueCount];
-
-            for (int ord = 0; ord < valueCount; ord++)
-            {
-                ordMap[sortedValues[ord]] = ord;
-            }
-
-            dvConsumer.AddSortedSetField(fieldInfo, GetBytesRefEnumberable(valueCount, sortedValues),
-
-                                      // doc -> ordCount
-                                      GetOrdsEnumberable(maxDoc),
-
-                                      // ords
-                                      GetOrdCountEnumberable(maxCountPerDoc, ordMap));
-        }
-
-        public override void Abort()
-        {
-        }
-
-        private IEnumerable<BytesRef> GetBytesRefEnumberable(int valueCount, int[] sortedValues)
-        {
-            for (int i = 0; i < valueCount; ++i)
-            {
-                var scratch = new BytesRef();
-                yield return hash.Get(sortedValues[i], scratch);
-            }
-        }
-
-        private IEnumerable<long?> GetOrdsEnumberable(int maxDoc)
-        {
-            AppendingDeltaPackedInt64Buffer.Iterator iter = pendingCounts.GetIterator();
-
-            Debug.Assert(maxDoc == pendingCounts.Count, "MaxDoc: " + maxDoc + ", pending.Count: " + pending.Count);
-
-            for (int i = 0; i < maxDoc; ++i)
-            {
-                yield return (int)iter.Next();
-            }
-        }
-
-        private IEnumerable<long?> GetOrdCountEnumberable(int maxCountPerDoc, int[] ordMap)
-        {
-            int currentUpTo = 0, currentLength = 0;
-            AppendingPackedInt64Buffer.Iterator iter = pending.GetIterator();
-            AppendingDeltaPackedInt64Buffer.Iterator counts = pendingCounts.GetIterator();
-            int[] currentDoc = new int[maxCountPerDoc];
-
-            for (long i = 0; i < pending.Count; ++i)
-            {
-                while (currentUpTo == currentLength)
-                {
-                    // refill next doc, and sort remapped ords within the doc.
-                    currentUpTo = 0;
-                    currentLength = (int)counts.Next();
-                    for (int j = 0; j < currentLength; j++)
-                    {
-                        currentDoc[j] = ordMap[(int)iter.Next()];
-                    }
-                    Array.Sort(currentDoc, 0, currentLength);
-                }
-                int ord = currentDoc[currentUpTo];
-                currentUpTo++;
-                yield return ord;
-            }
-        }
-
-        /*
-	  private class IterableAnonymousInnerClassHelper : IEnumerable<BytesRef>
-	  {
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		  private int ValueCount;
-		  private int[] SortedValues;
-
-		  public IterableAnonymousInnerClassHelper(SortedSetDocValuesWriter outerInstance, int valueCount, int[] sortedValues)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.ValueCount = valueCount;
-			  this.SortedValues = sortedValues;
-		  }
-
-									// ord -> value
-		  public virtual IEnumerator<BytesRef> GetEnumerator()
-		  {
-			return new ValuesIterator(OuterInstance, SortedValues, ValueCount);
-		  }
-	  }
-
-	  private class IterableAnonymousInnerClassHelper2 : IEnumerable<Number>
-	  {
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		  private int MaxDoc;
-
-		  public IterableAnonymousInnerClassHelper2(SortedSetDocValuesWriter outerInstance, int maxDoc)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.MaxDoc = maxDoc;
-		  }
-
-		  public virtual IEnumerator<Number> GetEnumerator()
-		  {
-			return new OrdCountIterator(OuterInstance, MaxDoc);
-		  }
-	  }
-
-	  private class IterableAnonymousInnerClassHelper3 : IEnumerable<Number>
-	  {
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		  private int MaxCountPerDoc;
-		  private int[] OrdMap;
-
-		  public IterableAnonymousInnerClassHelper3(SortedSetDocValuesWriter outerInstance, int maxCountPerDoc, int[] ordMap)
-		  {
-			  this.OuterInstance = outerInstance;
-			  this.MaxCountPerDoc = maxCountPerDoc;
-			  this.OrdMap = ordMap;
-		  }
-
-		  public virtual IEnumerator<Number> GetEnumerator()
-		  {
-			return new OrdsIterator(OuterInstance, OrdMap, MaxCountPerDoc);
-		  }
-	  }
-
-	  public override void Abort()
-	  {
-	  }
-
-	  // iterates over the unique values we have in ram
-	  private class ValuesIterator : IEnumerator<BytesRef>
-	  {
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		internal readonly int[] SortedValues;
-		internal readonly BytesRef Scratch = new BytesRef();
-		internal readonly int ValueCount;
-		internal int OrdUpto;
-
-		internal ValuesIterator(SortedSetDocValuesWriter outerInstance, int[] sortedValues, int valueCount)
-		{
-			this.OuterInstance = outerInstance;
-		  this.SortedValues = sortedValues;
-		  this.ValueCount = valueCount;
-		}
-
-		public override bool HasNext()
-		{
-		  return OrdUpto < ValueCount;
-		}
-
-		public override BytesRef Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new Exception();
-		  }
-		  OuterInstance.Hash.Get(SortedValues[OrdUpto], Scratch);
-		  OrdUpto++;
-		  return Scratch;
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }
-
-	  // iterates over the ords for each doc we have in ram
-	  private class OrdsIterator : IEnumerator<Number>
-	  {
-		  internal bool InstanceFieldsInitialized = false;
-
-		  internal virtual void InitializeInstanceFields()
-		  {
-			  Iter = OuterInstance.Pending.Iterator();
-			  Counts = OuterInstance.PendingCounts.Iterator();
-		  }
-
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		internal AppendingPackedLongBuffer.Iterator Iter;
-		internal AppendingDeltaPackedLongBuffer.Iterator Counts;
-		internal readonly int[] OrdMap;
-		internal readonly long NumOrds;
-		internal long OrdUpto;
-
-		internal readonly int[] CurrentDoc;
-		internal int CurrentUpto;
-		internal int CurrentLength;
-
-		internal OrdsIterator(SortedSetDocValuesWriter outerInstance, int[] ordMap, int maxCount)
-		{
-			this.OuterInstance = outerInstance;
-
-			if (!InstanceFieldsInitialized)
-			{
-				InitializeInstanceFields();
-				InstanceFieldsInitialized = true;
-			}
-		  this.CurrentDoc = new int[maxCount];
-		  this.OrdMap = ordMap;
-		  this.NumOrds = outerInstance.Pending.Size();
-		}
-
-		public override bool HasNext()
-		{
-		  return OrdUpto < NumOrds;
-		}
-
-		public override Number Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new Exception();
-		  }
-		  while (CurrentUpto == CurrentLength)
-		  {
-			// refill next doc, and sort remapped ords within the doc.
-			CurrentUpto = 0;
-			CurrentLength = (int) Counts.Next();
-			for (int i = 0; i < CurrentLength; i++)
-			{
-			  CurrentDoc[i] = OrdMap[(int) Iter.Next()];
-			}
-			Array.Sort(CurrentDoc, 0, CurrentLength);
-		  }
-		  int ord = CurrentDoc[CurrentUpto];
-		  CurrentUpto++;
-		  OrdUpto++;
-		  // TODO: make reusable Number
-		  return ord;
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }
-
-	  private class OrdCountIterator : IEnumerator<Number>
-	  {
-		  internal bool InstanceFieldsInitialized = false;
-
-		  internal virtual void InitializeInstanceFields()
-		  {
-			  Iter = OuterInstance.PendingCounts.Iterator();
-		  }
-
-		  private readonly SortedSetDocValuesWriter OuterInstance;
-
-		internal AppendingDeltaPackedLongBuffer.Iterator Iter;
-		internal readonly int MaxDoc;
-		internal int DocUpto;
-
-		internal OrdCountIterator(SortedSetDocValuesWriter outerInstance, int maxDoc)
-		{
-			this.OuterInstance = outerInstance;
-
-			if (!InstanceFieldsInitialized)
-			{
-				InitializeInstanceFields();
-				InstanceFieldsInitialized = true;
-			}
-		  this.MaxDoc = maxDoc;
-		  Debug.Assert(outerInstance.PendingCounts.Size() == maxDoc);
-		}
-
-		public override bool HasNext()
-		{
-		  return DocUpto < MaxDoc;
-		}
-
-		public override Number Next()
-		{
-		  if (!HasNext())
-		  {
-			throw new Exception();
-		  }
-		  DocUpto++;
-		  // TODO: make reusable Number
-		  return Iter.Next();
-		}
-
-		public override void Remove()
-		{
-		  throw new System.NotSupportedException();
-		}
-	  }*/
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs b/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
deleted file mode 100644
index 2893acf..0000000
--- a/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
+++ /dev/null
@@ -1,600 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    using Directory = Lucene.Net.Store.Directory;
-    using IOContext = Lucene.Net.Store.IOContext;
-    using IOUtils = Lucene.Net.Util.IOUtils;
-
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal sealed class StandardDirectoryReader : DirectoryReader
-    {
-        private readonly IndexWriter writer;
-        private readonly SegmentInfos segmentInfos;
-        private readonly int termInfosIndexDivisor;
-        private readonly bool applyAllDeletes;
-
-        /// <summary>
-        /// called only from static open() methods </summary>
-        internal StandardDirectoryReader(Directory directory, AtomicReader[] readers, IndexWriter writer, SegmentInfos sis, int termInfosIndexDivisor, bool applyAllDeletes)
-            : base(directory, readers)
-        {
-            this.writer = writer;
-            this.segmentInfos = sis;
-            this.termInfosIndexDivisor = termInfosIndexDivisor;
-            this.applyAllDeletes = applyAllDeletes;
-        }
-
-        /// <summary>
-        /// called from DirectoryReader.open(...) methods </summary>
-        internal static DirectoryReader Open(Directory directory, IndexCommit commit, int termInfosIndexDivisor)
-        {
-            return (DirectoryReader)new FindSegmentsFileAnonymousInnerClassHelper(directory, termInfosIndexDivisor).Run(commit);
-        }
-
-        private class FindSegmentsFileAnonymousInnerClassHelper : SegmentInfos.FindSegmentsFile
-        {
-            private readonly int termInfosIndexDivisor;
-
-            public FindSegmentsFileAnonymousInnerClassHelper(Directory directory, int termInfosIndexDivisor)
-                : base(directory)
-            {
-                this.termInfosIndexDivisor = termInfosIndexDivisor;
-            }
-
-            protected internal override object DoBody(string segmentFileName)
-            {
-                var sis = new SegmentInfos();
-                sis.Read(directory, segmentFileName);
-                var readers = new SegmentReader[sis.Count];
-                for (int i = sis.Count - 1; i >= 0; i--)
-                {
-                    System.IO.IOException prior = null;
-                    bool success = false;
-                    try
-                    {
-                        readers[i] = new SegmentReader(sis.Info(i), termInfosIndexDivisor, IOContext.READ);
-                        success = true;
-                    }
-                    catch (System.IO.IOException ex)
-                    {
-                        prior = ex;
-                    }
-                    finally
-                    {
-                        if (!success)
-                        {
-                            IOUtils.CloseWhileHandlingException(prior, readers);
-                        }
-                    }
-                }
-                return new StandardDirectoryReader(directory, readers, null, sis, termInfosIndexDivisor, false);
-            }
-        }
-
-        /// <summary>
-        /// Used by near real-time search </summary>
-        internal static DirectoryReader Open(IndexWriter writer, SegmentInfos infos, bool applyAllDeletes)
-        {
-            // IndexWriter synchronizes externally before calling
-            // us, which ensures infos will not change; so there's
-            // no need to process segments in reverse order
-            int numSegments = infos.Count;
-
-            IList<SegmentReader> readers = new List<SegmentReader>();
-            Directory dir = writer.Directory;
-
-            SegmentInfos segmentInfos = (SegmentInfos)infos.Clone();
-            int infosUpto = 0;
-            bool success = false;
-            try
-            {
-                for (int i = 0; i < numSegments; i++)
-                {
-                    // NOTE: important that we use infos not
-                    // segmentInfos here, so that we are passing the
-                    // actual instance of SegmentInfoPerCommit in
-                    // IndexWriter's segmentInfos:
-                    SegmentCommitInfo info = infos.Info(i);
-                    Debug.Assert(info.Info.Dir == dir);
-                    ReadersAndUpdates rld = writer.readerPool.Get(info, true);
-                    try
-                    {
-                        SegmentReader reader = rld.GetReadOnlyClone(IOContext.READ);
-                        if (reader.NumDocs > 0 || writer.KeepFullyDeletedSegments)
-                        {
-                            // Steal the ref:
-                            readers.Add(reader);
-                            infosUpto++;
-                        }
-                        else
-                        {
-                            reader.DecRef();
-                            segmentInfos.Remove(infosUpto);
-                        }
-                    }
-                    finally
-                    {
-                        writer.readerPool.Release(rld);
-                    }
-                }
-
-                writer.IncRefDeleter(segmentInfos);
-
-                StandardDirectoryReader result = new StandardDirectoryReader(dir, readers.ToArray(), writer, segmentInfos, writer.Config.ReaderTermsIndexDivisor, applyAllDeletes);
-                success = true;
-                return result;
-            }
-            finally
-            {
-                if (!success)
-                {
-                    foreach (SegmentReader r in readers)
-                    {
-                        try
-                        {
-                            r.DecRef();
-                        }
-#pragma warning disable 168
-                        catch (Exception th)
-#pragma warning restore 168
-                        {
-                            // ignore any exception that is thrown here to not mask any original
-                            // exception.
-                        }
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// this constructor is only used for <seealso cref="#doOpenIfChanged(SegmentInfos)"/> </summary>
-        private static DirectoryReader Open(Directory directory, SegmentInfos infos, IList<AtomicReader> oldReaders, int termInfosIndexDivisor)
-        {
-            // we put the old SegmentReaders in a map, that allows us
-            // to lookup a reader using its segment name
-            IDictionary<string, int?> segmentReaders = new Dictionary<string, int?>();
-
-            if (oldReaders != null)
-            {
-                // create a Map SegmentName->SegmentReader
-                for (int i = 0, c = oldReaders.Count; i < c; i++)
-                {
-                    SegmentReader sr = (SegmentReader)oldReaders[i];
-                    segmentReaders[sr.SegmentName] = Convert.ToInt32(i);
-                }
-            }
-
-            SegmentReader[] newReaders = new SegmentReader[infos.Count];
-
-            // remember which readers are shared between the old and the re-opened
-            // DirectoryReader - we have to incRef those readers
-            bool[] readerShared = new bool[infos.Count];
-
-            for (int i = infos.Count - 1; i >= 0; i--)
-            {
-                // find SegmentReader for this segment
-                int? oldReaderIndex;
-                segmentReaders.TryGetValue(infos.Info(i).Info.Name, out oldReaderIndex);
-                if (oldReaderIndex == null)
-                {
-                    // this is a new segment, no old SegmentReader can be reused
-                    newReaders[i] = null;
-                }
-                else
-                {
-                    // there is an old reader for this segment - we'll try to reopen it
-                    newReaders[i] = (SegmentReader)oldReaders[(int)oldReaderIndex];
-                }
-
-                bool success = false;
-                Exception prior = null;
-                try
-                {
-                    SegmentReader newReader;
-                    if (newReaders[i] == null || infos.Info(i).Info.UseCompoundFile != newReaders[i].SegmentInfo.Info.UseCompoundFile)
-                    {
-                        // this is a new reader; in case we hit an exception we can close it safely
-                        newReader = new SegmentReader(infos.Info(i), termInfosIndexDivisor, IOContext.READ);
-                        readerShared[i] = false;
-                        newReaders[i] = newReader;
-                    }
-                    else
-                    {
-                        if (newReaders[i].SegmentInfo.DelGen == infos.Info(i).DelGen && newReaders[i].SegmentInfo.FieldInfosGen == infos.Info(i).FieldInfosGen)
-                        {
-                            // No change; this reader will be shared between
-                            // the old and the new one, so we must incRef
-                            // it:
-                            readerShared[i] = true;
-                            newReaders[i].IncRef();
-                        }
-                        else
-                        {
-                            // there are changes to the reader, either liveDocs or DV updates
-                            readerShared[i] = false;
-                            // Steal the ref returned by SegmentReader ctor:
-                            Debug.Assert(infos.Info(i).Info.Dir == newReaders[i].SegmentInfo.Info.Dir);
-                            Debug.Assert(infos.Info(i).HasDeletions || infos.Info(i).HasFieldUpdates);
-                            if (newReaders[i].SegmentInfo.DelGen == infos.Info(i).DelGen)
-                            {
-                                // only DV updates
-                                newReaders[i] = new SegmentReader(infos.Info(i), newReaders[i], newReaders[i].LiveDocs, newReaders[i].NumDocs);
-                            }
-                            else
-                            {
-                                // both DV and liveDocs have changed
-                                newReaders[i] = new SegmentReader(infos.Info(i), newReaders[i]);
-                            }
-                        }
-                    }
-                    success = true;
-                }
-                catch (Exception ex)
-                {
-                    prior = ex;
-                }
-                finally
-                {
-                    if (!success)
-                    {
-                        for (i++; i < infos.Count; i++)
-                        {
-                            if (newReaders[i] != null)
-                            {
-                                try
-                                {
-                                    if (!readerShared[i])
-                                    {
-                                        // this is a new subReader that is not used by the old one,
-                                        // we can close it
-                                        newReaders[i].Dispose();
-                                    }
-                                    else
-                                    {
-                                        // this subReader is also used by the old reader, so instead
-                                        // closing we must decRef it
-                                        newReaders[i].DecRef();
-                                    }
-                                }
-                                catch (Exception t)
-                                {
-                                    if (prior == null)
-                                    {
-                                        prior = t;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    // throw the first exception
-                    IOUtils.ReThrow(prior);
-                }
-            }
-            return new StandardDirectoryReader(directory, newReaders, null, infos, termInfosIndexDivisor, false);
-        }
-
-        public override string ToString()
-        {
-            StringBuilder buffer = new StringBuilder();
-            buffer.Append(this.GetType().Name);
-            buffer.Append('(');
-            string segmentsFile = segmentInfos.GetSegmentsFileName();
-            if (segmentsFile != null)
-            {
-                buffer.Append(segmentsFile).Append(":").Append(segmentInfos.Version);
-            }
-            if (writer != null)
-            {
-                buffer.Append(":nrt");
-            }
-            foreach (AtomicReader r in GetSequentialSubReaders())
-            {
-                buffer.Append(' ');
-                buffer.Append(r);
-            }
-            buffer.Append(')');
-            return buffer.ToString();
-        }
-
-        protected internal override DirectoryReader DoOpenIfChanged()
-        {
-            return DoOpenIfChanged((IndexCommit)null);
-        }
-
-        protected internal override DirectoryReader DoOpenIfChanged(IndexCommit commit)
-        {
-            EnsureOpen();
-
-            // If we were obtained by writer.getReader(), re-ask the
-            // writer to get a new reader.
-            if (writer != null)
-            {
-                return DoOpenFromWriter(commit);
-            }
-            else
-            {
-                return DoOpenNoWriter(commit);
-            }
-        }
-
-        protected internal override DirectoryReader DoOpenIfChanged(IndexWriter writer, bool applyAllDeletes)
-        {
-            EnsureOpen();
-            if (writer == this.writer && applyAllDeletes == this.applyAllDeletes)
-            {
-                return DoOpenFromWriter(null);
-            }
-            else
-            {
-                return writer.GetReader(applyAllDeletes);
-            }
-        }
-
-        private DirectoryReader DoOpenFromWriter(IndexCommit commit)
-        {
-            if (commit != null)
-            {
-                return DoOpenFromCommit(commit);
-            }
-
-            if (writer.NrtIsCurrent(segmentInfos))
-            {
-                return null;
-            }
-
-            DirectoryReader reader = writer.GetReader(applyAllDeletes);
-
-            // If in fact no changes took place, return null:
-            if (reader.Version == segmentInfos.Version)
-            {
-                reader.DecRef();
-                return null;
-            }
-
-            return reader;
-        }
-
-        private DirectoryReader DoOpenNoWriter(IndexCommit commit)
-        {
-            if (commit == null)
-            {
-                if (IsCurrent())
-                {
-                    return null;
-                }
-            }
-            else
-            {
-                if (m_directory != commit.Directory)
-                {
-                    throw new System.IO.IOException("the specified commit does not match the specified Directory");
-                }
-                if (segmentInfos != null && commit.SegmentsFileName.Equals(segmentInfos.GetSegmentsFileName(), StringComparison.Ordinal))
-                {
-                    return null;
-                }
-            }
-
-            return DoOpenFromCommit(commit);
-        }
-
-        private DirectoryReader DoOpenFromCommit(IndexCommit commit)
-        {
-            return (DirectoryReader)new FindSegmentsFileAnonymousInnerClassHelper2(this, m_directory).Run(commit);
-        }
-
-        private class FindSegmentsFileAnonymousInnerClassHelper2 : SegmentInfos.FindSegmentsFile
-        {
-            private readonly StandardDirectoryReader outerInstance;
-
-            public FindSegmentsFileAnonymousInnerClassHelper2(StandardDirectoryReader outerInstance, Directory directory)
-                : base(directory)
-            {
-                this.outerInstance = outerInstance;
-            }
-
-            protected internal override object DoBody(string segmentFileName)
-            {
-                SegmentInfos infos = new SegmentInfos();
-                infos.Read(outerInstance.m_directory, segmentFileName);
-                return outerInstance.DoOpenIfChanged(infos);
-            }
-        }
-
-        internal DirectoryReader DoOpenIfChanged(SegmentInfos infos)
-        {
-            return StandardDirectoryReader.Open(m_directory, infos, GetSequentialSubReaders().OfType<AtomicReader>().ToList(), termInfosIndexDivisor);
-        }
-
-        public override long Version
-        {
-            get
-            {
-                EnsureOpen();
-                return segmentInfos.Version;
-            }
-        }
-
-        public override bool IsCurrent()
-        {
-            EnsureOpen();
-            if (writer == null || writer.IsClosed)
-            {
-                // Fully read the segments file: this ensures that it's
-                // completely written so that if
-                // IndexWriter.prepareCommit has been called (but not
-                // yet commit), then the reader will still see itself as
-                // current:
-                SegmentInfos sis = new SegmentInfos();
-                sis.Read(m_directory);
-
-                // we loaded SegmentInfos from the directory
-                return sis.Version == segmentInfos.Version;
-            }
-            else
-            {
-                return writer.NrtIsCurrent(segmentInfos);
-            }
-        }
-
-        protected internal override void DoClose()
-        {
-            Exception firstExc = null;
-            foreach (AtomicReader r in GetSequentialSubReaders())
-            {
-                // try to close each reader, even if an exception is thrown
-                try
-                {
-                    r.DecRef();
-                }
-                catch (Exception t)
-                {
-                    if (firstExc == null)
-                    {
-                        firstExc = t;
-                    }
-                }
-            }
-
-            if (writer != null)
-            {
-                try
-                {
-                    writer.DecRefDeleter(segmentInfos);
-                }
-#pragma warning disable 168
-                catch (ObjectDisposedException ex)
-#pragma warning restore 168
-                {
-                    // this is OK, it just means our original writer was
-                    // closed before we were, and this may leave some
-                    // un-referenced files in the index, which is
-                    // harmless.  The next time IW is opened on the
-                    // index, it will delete them.
-                }
-            }
-
-            // throw the first exception
-            IOUtils.ReThrow(firstExc);
-        }
-
-        public override IndexCommit IndexCommit
-        {
-            get
-            {
-                EnsureOpen();
-                return new ReaderCommit(segmentInfos, m_directory);
-            }
-        }
-
-        internal sealed class ReaderCommit : IndexCommit
-        {
-            internal string segmentsFileName;
-            internal ICollection<string> files;
-            internal Directory dir;
-            internal long generation;
-            internal readonly IDictionary<string, string> userData;
-            internal readonly int segmentCount;
-
-            internal ReaderCommit(SegmentInfos infos, Directory dir)
-            {
-                segmentsFileName = infos.GetSegmentsFileName();
-                this.dir = dir;
-                userData = infos.UserData;
-                files = infos.Files(dir, true);
-                generation = infos.Generation;
-                segmentCount = infos.Count;
-            }
-
-            public override string ToString()
-            {
-                return "DirectoryReader.ReaderCommit(" + segmentsFileName + ")";
-            }
-
-            public override int SegmentCount
-            {
-                get
-                {
-                    return segmentCount;
-                }
-            }
-
-            public override string SegmentsFileName
-            {
-                get
-                {
-                    return segmentsFileName;
-                }
-            }
-
-            public override ICollection<string> FileNames
-            {
-                get
-                {
-                    return files;
-                }
-            }
-
-            public override Directory Directory
-            {
-                get
-                {
-                    return dir;
-                }
-            }
-
-            public override long Generation
-            {
-                get
-                {
-                    return generation;
-                }
-            }
-
-            public override bool IsDeleted
-            {
-                get
-                {
-                    return false;
-                }
-            }
-
-            public override IDictionary<string, string> UserData
-            {
-                get
-                {
-                    return userData;
-                }
-            }
-
-            public override void Delete()
-            {
-                throw new NotSupportedException("this IndexCommit does not support deletions");
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs b/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
deleted file mode 100644
index 381dc61..0000000
--- a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    /// <summary>
-    /// Expert: provides a low-level means of accessing the stored field
-    /// values in an index.  See {@link IndexReader#document(int,
-    /// StoredFieldVisitor)}.
-    ///
-    /// <p><b>NOTE</b>: a {@code StoredFieldVisitor} implementation
-    /// should not try to load or visit other stored documents in
-    /// the same reader because the implementation of stored
-    /// fields for most codecs is not reeentrant and you will see
-    /// strange exceptions as a result.
-    ///
-    /// <p>See <seealso cref="DocumentStoredFieldVisitor"/>, which is a
-    /// <code>StoredFieldVisitor</code> that builds the
-    /// <seealso cref="Document"/> containing all stored fields.  this is
-    /// used by <seealso cref="IndexReader#document(int)"/>.
-    ///
-    /// @lucene.experimental
-    /// </summary>
-
-    public abstract class StoredFieldVisitor
-    {
-        /// <summary>
-        /// Sole constructor. (For invocation by subclass
-        /// constructors, typically implicit.)
-        /// </summary>
-        protected StoredFieldVisitor()
-        {
-        }
-
-        /// <summary>
-        /// Process a binary field. </summary>
-        /// <param name="value"> newly allocated byte array with the binary contents.  </param>
-        public virtual void BinaryField(FieldInfo fieldInfo, byte[] value)
-        {
-        }
-
-        /// <summary>
-        /// Process a string field </summary>
-        public virtual void StringField(FieldInfo fieldInfo, string value)
-        {
-        }
-
-        /// <summary>
-        /// Process a int numeric field. </summary>
-        public virtual void Int32Field(FieldInfo fieldInfo, int value) // LUCENENET specific: Renamed from IntField to Int32Field per .NET conventions
-        {
-        }
-
-        /// <summary>
-        /// Process a long numeric field. </summary>
-        public virtual void Int64Field(FieldInfo fieldInfo, long value) // LUCENENET specific: Renamed from LongField to Int64Field per .NET conventions
-        {
-        }
-
-        /// <summary>
-        /// Process a float numeric field. </summary>
-        public virtual void SingleField(FieldInfo fieldInfo, float value) // LUCENENET specific: Renamed from FloatField to SingleField per .NET conventions
-        {
-        }
-
-        /// <summary>
-        /// Process a double numeric field. </summary>
-        public virtual void DoubleField(FieldInfo fieldInfo, double value)
-        {
-        }
-
-        /// <summary>
-        /// Hook before processing a field.
-        /// Before a field is processed, this method is invoked so that
-        /// subclasses can return a <seealso cref="Status"/> representing whether
-        /// they need that particular field or not, or to stop processing
-        /// entirely.
-        /// </summary>
-        public abstract Status NeedsField(FieldInfo fieldInfo);
-
-        /// <summary>
-        /// Enumeration of possible return values for <seealso cref="#needsField"/>.
-        /// </summary>
-        public enum Status
-        {
-            /// <summary>
-            /// YES: the field should be visited. </summary>
-            YES,
-
-            /// <summary>
-            /// NO: don't visit this field, but continue processing fields for this document. </summary>
-            NO,
-
-            /// <summary>
-            /// STOP: don't visit this field and stop processing any other fields for this document. </summary>
-            STOP
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/StoredFieldsConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StoredFieldsConsumer.cs b/src/Lucene.Net.Core/Index/StoredFieldsConsumer.cs
deleted file mode 100644
index af07bb2..0000000
--- a/src/Lucene.Net.Core/Index/StoredFieldsConsumer.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal abstract class StoredFieldsConsumer
-    {
-        public abstract void AddField(int docID, IIndexableField field, FieldInfo fieldInfo);
-
-        public abstract void Flush(SegmentWriteState state);
-
-        public abstract void Abort();
-
-        public abstract void StartDocument();
-
-        internal abstract void FinishDocument();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/StoredFieldsProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StoredFieldsProcessor.cs b/src/Lucene.Net.Core/Index/StoredFieldsProcessor.cs
deleted file mode 100644
index 6196078..0000000
--- a/src/Lucene.Net.Core/Index/StoredFieldsProcessor.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-using Lucene.Net.Support;
-using System;
-using System.Diagnostics;
-
-namespace Lucene.Net.Index
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    using ArrayUtil = Lucene.Net.Util.ArrayUtil;
-    using Codec = Lucene.Net.Codecs.Codec;
-    using IOContext = Lucene.Net.Store.IOContext;
-    using IOUtils = Lucene.Net.Util.IOUtils;
-    using RamUsageEstimator = Lucene.Net.Util.RamUsageEstimator;
-    using StoredFieldsWriter = Lucene.Net.Codecs.StoredFieldsWriter;
-
-    /// <summary>
-    /// this is a StoredFieldsConsumer that writes stored fields. </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal sealed class StoredFieldsProcessor : StoredFieldsConsumer
-    {
-        internal StoredFieldsWriter fieldsWriter;
-        internal readonly DocumentsWriterPerThread docWriter;
-        internal int lastDocID;
-
-        internal readonly DocumentsWriterPerThread.DocState docState;
-        internal readonly Codec codec;
-
-        public StoredFieldsProcessor(DocumentsWriterPerThread docWriter)
-        {
-            this.docWriter = docWriter;
-            this.docState = docWriter.docState;
-            this.codec = docWriter.codec;
-        }
-
-        private int numStoredFields;
-        private IIndexableField[] storedFields = new IIndexableField[1];
-        private FieldInfo[] fieldInfos = new FieldInfo[1];
-
-        public void Reset()
-        {
-            numStoredFields = 0;
-            Arrays.Fill(storedFields, null);
-            Arrays.Fill(fieldInfos, null);
-        }
-
-        public override void StartDocument()
-        {
-            Reset();
-        }
-
-        public override void Flush(SegmentWriteState state)
-        {
-            int numDocs = state.SegmentInfo.DocCount;
-            if (numDocs > 0)
-            {
-                // It's possible that all documents seen in this segment
-                // hit non-aborting exceptions, in which case we will
-                // not have yet init'd the FieldsWriter:
-                InitFieldsWriter(state.Context);
-                Fill(numDocs);
-            }
-            if (fieldsWriter != null)
-            {
-                bool success = false;
-                try
-                {
-                    fieldsWriter.Finish(state.FieldInfos, numDocs);
-                    success = true;
-                }
-                finally
-                {
-                    if (success)
-                    {
-                        IOUtils.Close(fieldsWriter);
-                    }
-                    else
-                    {
-                        IOUtils.CloseWhileHandlingException(fieldsWriter);
-                    }
-                }
-            }
-        }
-
-        private void InitFieldsWriter(IOContext context)
-        {
-            lock (this)
-            {
-                if (fieldsWriter == null)
-                {
-                    fieldsWriter = codec.StoredFieldsFormat.FieldsWriter(docWriter.directory, docWriter.SegmentInfo, context);
-                    lastDocID = 0;
-                }
-            }
-        }
-
-        public override void Abort()
-        {
-            Reset();
-
-            if (fieldsWriter != null)
-            {
-                fieldsWriter.Abort();
-                fieldsWriter = null;
-                lastDocID = 0;
-            }
-        }
-
-        /// <summary>
-        /// Fills in any hole in the docIDs </summary>
-        internal void Fill(int docID)
-        {
-            // We must "catch up" for all docs before us
-            // that had no stored fields:
-            while (lastDocID < docID)
-            {
-                fieldsWriter.StartDocument(0);
-                lastDocID++;
-                fieldsWriter.FinishDocument();
-            }
-        }
-
-        internal override void FinishDocument()
-        {
-            Debug.Assert(docWriter.TestPoint("StoredFieldsWriter.finishDocument start"));
-
-            InitFieldsWriter(IOContext.DEFAULT);
-            Fill(docState.docID);
-
-            if (fieldsWriter != null && numStoredFields > 0)
-            {
-                fieldsWriter.StartDocument(numStoredFields);
-                for (int i = 0; i < numStoredFields; i++)
-                {
-                    fieldsWriter.WriteField(fieldInfos[i], storedFields[i]);
-                }
-                fieldsWriter.FinishDocument();
-                lastDocID++;
-            }
-
-            Reset();
-            Debug.Assert(docWriter.TestPoint("StoredFieldsWriter.finishDocument end"));
-        }
-
-        public override void AddField(int docID, IIndexableField field, FieldInfo fieldInfo)
-        {
-            if (field.FieldType.IsStored)
-            {
-                if (numStoredFields == storedFields.Length)
-                {
-                    int newSize = ArrayUtil.Oversize(numStoredFields + 1, RamUsageEstimator.NUM_BYTES_OBJECT_REF);
-                    IIndexableField[] newArray = new IIndexableField[newSize];
-                    Array.Copy(storedFields, 0, newArray, 0, numStoredFields);
-                    storedFields = newArray;
-
-                    FieldInfo[] newInfoArray = new FieldInfo[newSize];
-                    Array.Copy(fieldInfos, 0, newInfoArray, 0, numStoredFields);
-                    fieldInfos = newInfoArray;
-                }
-
-                storedFields[numStoredFields] = field;
-                fieldInfos[numStoredFields] = fieldInfo;
-                numStoredFields++;
-
-                Debug.Assert(docState.TestPoint("StoredFieldsWriterPerThread.processFields.writeField"));
-            }
-        }
-    }
-}
\ No newline at end of file


Mime
View raw message