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/04/04 17:19:24 UTC

[18/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

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/DocumentsWriterPerThread.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/DocumentsWriterPerThread.cs b/src/Lucene.Net.Core/Index/DocumentsWriterPerThread.cs
deleted file mode 100644
index a516d36..0000000
--- a/src/Lucene.Net.Core/Index/DocumentsWriterPerThread.cs
+++ /dev/null
@@ -1,764 +0,0 @@
-using Lucene.Net.Support;
-using Lucene.Net.Util;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Threading;
-
-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 Allocator = Lucene.Net.Util.ByteBlockPool.Allocator;
-    using Analyzer = Lucene.Net.Analysis.Analyzer;
-    using Codec = Lucene.Net.Codecs.Codec;
-    using Constants = Lucene.Net.Util.Constants;
-    using Counter = Lucene.Net.Util.Counter;
-    using DeleteSlice = Lucene.Net.Index.DocumentsWriterDeleteQueue.DeleteSlice;
-    using Directory = Lucene.Net.Store.Directory;
-    using DirectTrackingAllocator = Lucene.Net.Util.ByteBlockPool.DirectTrackingAllocator;
-    using FlushInfo = Lucene.Net.Store.FlushInfo;
-    using InfoStream = Lucene.Net.Util.InfoStream;
-    using Int32BlockPool = Lucene.Net.Util.Int32BlockPool;
-    using IOContext = Lucene.Net.Store.IOContext;
-    using IMutableBits = Lucene.Net.Util.IMutableBits;
-    using RamUsageEstimator = Lucene.Net.Util.RamUsageEstimator;
-    using Similarity = Lucene.Net.Search.Similarities.Similarity;
-    using TrackingDirectoryWrapper = Lucene.Net.Store.TrackingDirectoryWrapper;
-
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal class DocumentsWriterPerThread
-    {
-        /// <summary>
-        /// The <see cref="IndexingChain"/> must define the <see cref="GetChain(DocumentsWriterPerThread)"/> method
-        /// which returns the <see cref="DocConsumer"/> that the <see cref="DocumentsWriter"/> calls to process the
-        /// documents.
-        /// </summary>
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        internal abstract class IndexingChain
-        {
-            internal abstract DocConsumer GetChain(DocumentsWriterPerThread documentsWriterPerThread);
-        }
-
-        private static readonly IndexingChain defaultIndexingChain = new IndexingChainAnonymousInnerClassHelper();
-
-        public static IndexingChain DefaultIndexingChain
-        {
-            get { return defaultIndexingChain; }
-        }
-
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        private class IndexingChainAnonymousInnerClassHelper : IndexingChain
-        {
-            public IndexingChainAnonymousInnerClassHelper()
-            {
-            }
-
-            internal override DocConsumer GetChain(DocumentsWriterPerThread documentsWriterPerThread)
-            {
-                /*
-                this is the current indexing chain:
-
-                DocConsumer / DocConsumerPerThread
-                  --> code: DocFieldProcessor
-                    --> DocFieldConsumer / DocFieldConsumerPerField
-                      --> code: DocFieldConsumers / DocFieldConsumersPerField
-                        --> code: DocInverter / DocInverterPerField
-                          --> InvertedDocConsumer / InvertedDocConsumerPerField
-                            --> code: TermsHash / TermsHashPerField
-                              --> TermsHashConsumer / TermsHashConsumerPerField
-                                --> code: FreqProxTermsWriter / FreqProxTermsWriterPerField
-                                --> code: TermVectorsTermsWriter / TermVectorsTermsWriterPerField
-                          --> InvertedDocEndConsumer / InvertedDocConsumerPerField
-                            --> code: NormsConsumer / NormsConsumerPerField
-                    --> StoredFieldsConsumer
-                      --> TwoStoredFieldConsumers
-                        -> code: StoredFieldsProcessor
-                        -> code: DocValuesProcessor
-              */
-
-                // Build up indexing chain:
-
-                TermsHashConsumer termVectorsWriter = new TermVectorsConsumer(documentsWriterPerThread);
-                TermsHashConsumer freqProxWriter = new FreqProxTermsWriter();
-
-                InvertedDocConsumer termsHash = new TermsHash(documentsWriterPerThread, freqProxWriter, true, 
-                    new TermsHash(documentsWriterPerThread, termVectorsWriter, false, null));
-                NormsConsumer normsWriter = new NormsConsumer();
-                DocInverter docInverter = new DocInverter(documentsWriterPerThread.docState, termsHash, normsWriter);
-                StoredFieldsConsumer storedFields = new TwoStoredFieldsConsumers(
-                                                            new StoredFieldsProcessor(documentsWriterPerThread), 
-                                                            new DocValuesProcessor(documentsWriterPerThread.bytesUsed));
-                return new DocFieldProcessor(documentsWriterPerThread, docInverter, storedFields);
-            }
-        }
-
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        public class DocState
-        {
-            internal readonly DocumentsWriterPerThread docWriter;
-            internal Analyzer analyzer;
-            internal InfoStream infoStream;
-            internal Similarity similarity;
-            internal int docID;
-            internal IEnumerable<IIndexableField> doc;
-            internal string maxTermPrefix;
-
-            internal DocState(DocumentsWriterPerThread docWriter, InfoStream infoStream)
-            {
-                this.docWriter = docWriter;
-                this.infoStream = infoStream;
-            }
-
-            // Only called by asserts
-            public virtual bool TestPoint(string name)
-            {
-                return docWriter.TestPoint(name);
-            }
-
-            public virtual void Clear()
-            {
-                // don't hold onto doc nor analyzer, in case it is
-                // largish:
-                doc = null;
-                analyzer = null;
-            }
-        }
-
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        internal class FlushedSegment
-        {
-            internal readonly SegmentCommitInfo segmentInfo;
-            internal readonly FieldInfos fieldInfos;
-            internal readonly FrozenBufferedUpdates segmentUpdates;
-            internal readonly IMutableBits liveDocs;
-            internal readonly int delCount;
-
-            internal FlushedSegment(SegmentCommitInfo segmentInfo, FieldInfos fieldInfos, BufferedUpdates segmentUpdates, IMutableBits liveDocs, int delCount)
-            {
-                this.segmentInfo = segmentInfo;
-                this.fieldInfos = fieldInfos;
-                this.segmentUpdates = segmentUpdates != null && segmentUpdates.Any() ? new FrozenBufferedUpdates(segmentUpdates, true) : null;
-                this.liveDocs = liveDocs;
-                this.delCount = delCount;
-            }
-        }
-
-        /// <summary>
-        /// Called if we hit an exception at a bad time (when
-        /// updating the index files) and must discard all
-        /// currently buffered docs.  this resets our state,
-        /// discarding any docs added since last flush.
-        /// </summary>
-        internal virtual void Abort(ISet<string> createdFiles)
-        {
-            //System.out.println(Thread.currentThread().getName() + ": now abort seg=" + segmentInfo.name);
-            hasAborted = aborting = true;
-            try
-            {
-                if (infoStream.IsEnabled("DWPT"))
-                {
-                    infoStream.Message("DWPT", "now abort");
-                }
-                try
-                {
-                    consumer.Abort();
-                }
-#pragma warning disable 168
-                catch (Exception t)
-#pragma warning restore 168
-                {
-                }
-
-                pendingUpdates.Clear();
-                Collections.AddAll(createdFiles, directory.CreatedFiles);
-            }
-            finally
-            {
-                aborting = false;
-                if (infoStream.IsEnabled("DWPT"))
-                {
-                    infoStream.Message("DWPT", "done abort");
-                }
-            }
-        }
-
-        private const bool INFO_VERBOSE = false;
-        internal readonly Codec codec;
-        internal readonly TrackingDirectoryWrapper directory;
-        internal readonly Directory directoryOrig;
-        internal readonly DocState docState;
-        internal readonly DocConsumer consumer;
-        internal readonly Counter bytesUsed;
-
-        internal SegmentWriteState flushState;
-
-        // Updates for our still-in-RAM (to be flushed next) segment
-        internal readonly BufferedUpdates pendingUpdates;
-
-        private readonly SegmentInfo segmentInfo; // Current segment we are working on
-        internal bool aborting = false; // True if an abort is pending
-        internal bool hasAborted = false; // True if the last exception throws by #updateDocument was aborting
-
-        private FieldInfos.Builder fieldInfos;
-        private readonly InfoStream infoStream;
-        private int numDocsInRAM;
-        internal readonly DocumentsWriterDeleteQueue deleteQueue;
-        private readonly DeleteSlice deleteSlice;
-        private readonly NumberFormatInfo nf = CultureInfo.InvariantCulture.NumberFormat;
-        internal readonly Allocator byteBlockAllocator;
-        internal readonly Int32BlockPool.Allocator intBlockAllocator;
-        private readonly LiveIndexWriterConfig indexWriterConfig;
-
-        public DocumentsWriterPerThread(string segmentName, Directory directory, LiveIndexWriterConfig indexWriterConfig, InfoStream infoStream, DocumentsWriterDeleteQueue deleteQueue, FieldInfos.Builder fieldInfos)
-        {
-            this.directoryOrig = directory;
-            this.directory = new TrackingDirectoryWrapper(directory);
-            this.fieldInfos = fieldInfos;
-            this.indexWriterConfig = indexWriterConfig;
-            this.infoStream = infoStream;
-            this.codec = indexWriterConfig.Codec;
-            this.docState = new DocState(this, infoStream);
-            this.docState.similarity = indexWriterConfig.Similarity;
-            bytesUsed = Counter.NewCounter();
-            byteBlockAllocator = new DirectTrackingAllocator(bytesUsed);
-            pendingUpdates = new BufferedUpdates();
-            intBlockAllocator = new Int32BlockAllocator(bytesUsed);
-            this.deleteQueue = deleteQueue;
-            Debug.Assert(numDocsInRAM == 0, "num docs " + numDocsInRAM);
-            pendingUpdates.Clear();
-            deleteSlice = deleteQueue.NewSlice();
-
-            segmentInfo = new SegmentInfo(directoryOrig, Constants.LUCENE_MAIN_VERSION, segmentName, -1, false, codec, null);
-            Debug.Assert(numDocsInRAM == 0);
-            if (INFO_VERBOSE && infoStream.IsEnabled("DWPT"))
-            {
-                infoStream.Message("DWPT", Thread.CurrentThread.Name + " init seg=" + segmentName + " delQueue=" + deleteQueue);
-            }
-            // this should be the last call in the ctor
-            // it really sucks that we need to pull this within the ctor and pass this ref to the chain!
-            consumer = indexWriterConfig.IndexingChain.GetChain(this);
-        }
-
-        internal virtual void SetAborting()
-        {
-            aborting = true;
-        }
-
-        internal virtual bool CheckAndResetHasAborted()
-        {
-            bool retval = hasAborted;
-            hasAborted = false;
-            return retval;
-        }
-
-        internal bool TestPoint(string message)
-        {
-            if (infoStream.IsEnabled("TP"))
-            {
-                infoStream.Message("TP", message);
-            }
-            return true;
-        }
-
-        public virtual void UpdateDocument(IEnumerable<IIndexableField> doc, Analyzer analyzer, Term delTerm)
-        {
-            Debug.Assert(TestPoint("DocumentsWriterPerThread addDocument start"));
-            Debug.Assert(deleteQueue != null);
-            docState.doc = doc;
-            docState.analyzer = analyzer;
-            docState.docID = numDocsInRAM;
-            if (INFO_VERBOSE && infoStream.IsEnabled("DWPT"))
-            {
-                infoStream.Message("DWPT", Thread.CurrentThread.Name + " update delTerm=" + delTerm + " docID=" + docState.docID + " seg=" + segmentInfo.Name);
-            }
-            bool success = false;
-            try
-            {
-                try
-                {
-                    consumer.ProcessDocument(fieldInfos);
-                }
-                finally
-                {
-                    docState.Clear();
-                }
-                success = true;
-            }
-            finally
-            {
-                if (!success)
-                {
-                    if (!aborting)
-                    {
-                        // mark document as deleted
-                        DeleteDocID(docState.docID);
-                        numDocsInRAM++;
-                    }
-                    else
-                    {
-                        Abort(filesToDelete);
-                    }
-                }
-            }
-            success = false;
-            try
-            {
-                consumer.FinishDocument();
-                success = true;
-            }
-            finally
-            {
-                if (!success)
-                {
-                    Abort(filesToDelete);
-                }
-            }
-            FinishDocument(delTerm);
-        }
-
-        public virtual int UpdateDocuments(IEnumerable<IEnumerable<IIndexableField>> docs, Analyzer analyzer, Term delTerm)
-        {
-            Debug.Assert(TestPoint("DocumentsWriterPerThread addDocuments start"));
-            Debug.Assert(deleteQueue != null);
-            docState.analyzer = analyzer;
-            if (INFO_VERBOSE && infoStream.IsEnabled("DWPT"))
-            {
-                infoStream.Message("DWPT", Thread.CurrentThread.Name + " update delTerm=" + delTerm + " docID=" + docState.docID + " seg=" + segmentInfo.Name);
-            }
-            int docCount = 0;
-            bool allDocsIndexed = false;
-            try
-            {
-                foreach (IEnumerable<IIndexableField> doc in docs)
-                {
-                    docState.doc = doc;
-                    docState.docID = numDocsInRAM;
-                    docCount++;
-
-                    bool success = false;
-                    try
-                    {
-                        consumer.ProcessDocument(fieldInfos);
-                        success = true;
-                    }
-                    finally
-                    {
-                        if (!success)
-                        {
-                            // An exc is being thrown...
-                            if (!aborting)
-                            {
-                                // Incr here because finishDocument will not
-                                // be called (because an exc is being thrown):
-                                numDocsInRAM++;
-                            }
-                            else
-                            {
-                                Abort(filesToDelete);
-                            }
-                        }
-                    }
-                    success = false;
-                    try
-                    {
-                        consumer.FinishDocument();
-                        success = true;
-                    }
-                    finally
-                    {
-                        if (!success)
-                        {
-                            Abort(filesToDelete);
-                        }
-                    }
-
-                    FinishDocument(null);
-                }
-                allDocsIndexed = true;
-
-                // Apply delTerm only after all indexing has
-                // succeeded, but apply it only to docs prior to when
-                // this batch started:
-                if (delTerm != null)
-                {
-                    deleteQueue.Add(delTerm, deleteSlice);
-                    Debug.Assert(deleteSlice.IsTailItem(delTerm), "expected the delete term as the tail item");
-                    deleteSlice.Apply(pendingUpdates, numDocsInRAM - docCount);
-                }
-            }
-            finally
-            {
-                if (!allDocsIndexed && !aborting)
-                {
-                    // the iterator threw an exception that is not aborting
-                    // go and mark all docs from this block as deleted
-                    int docID = numDocsInRAM - 1;
-                    int endDocID = docID - docCount;
-                    while (docID > endDocID)
-                    {
-                        DeleteDocID(docID);
-                        docID--;
-                    }
-                }
-                docState.Clear();
-            }
-
-            return docCount;
-        }
-
-        private void FinishDocument(Term delTerm)
-        {
-            /*
-             * here we actually finish the document in two steps 1. push the delete into
-             * the queue and update our slice. 2. increment the DWPT private document
-             * id.
-             *
-             * the updated slice we get from 1. holds all the deletes that have occurred
-             * since we updated the slice the last time.
-             */
-            bool applySlice = numDocsInRAM != 0;
-            if (delTerm != null)
-            {
-                deleteQueue.Add(delTerm, deleteSlice);
-                Debug.Assert(deleteSlice.IsTailItem(delTerm), "expected the delete term as the tail item");
-            }
-            else
-            {
-                applySlice &= deleteQueue.UpdateSlice(deleteSlice);
-            }
-
-            if (applySlice)
-            {
-                deleteSlice.Apply(pendingUpdates, numDocsInRAM);
-            } // if we don't need to apply we must reset!
-            else
-            {
-                deleteSlice.Reset();
-            }
-            ++numDocsInRAM;
-        }
-
-        // Buffer a specific docID for deletion. Currently only
-        // used when we hit an exception when adding a document
-        internal virtual void DeleteDocID(int docIDUpto)
-        {
-            pendingUpdates.AddDocID(docIDUpto);
-            // NOTE: we do not trigger flush here.  this is
-            // potentially a RAM leak, if you have an app that tries
-            // to add docs but every single doc always hits a
-            // non-aborting exception.  Allowing a flush here gets
-            // very messy because we are only invoked when handling
-            // exceptions so to do this properly, while handling an
-            // exception we'd have to go off and flush new deletes
-            // which is risky (likely would hit some other
-            // confounding exception).
-        }
-
-        /// <summary>
-        /// Returns the number of delete terms in this <see cref="DocumentsWriterPerThread"/>
-        /// </summary>
-        public virtual int NumDeleteTerms
-        {
-            get
-            {
-                // public for FlushPolicy
-                return pendingUpdates.numTermDeletes.Get();
-            }
-        }
-
-        /// <summary>
-        /// Returns the number of RAM resident documents in this <see cref="DocumentsWriterPerThread"/>
-        /// </summary>
-        public virtual int NumDocsInRAM
-        {
-            get
-            {
-                // public for FlushPolicy
-                return numDocsInRAM;
-            }
-        }
-
-        /// <summary>
-        /// Prepares this DWPT for flushing. this method will freeze and return the
-        /// <see cref="DocumentsWriterDeleteQueue"/>s global buffer and apply all pending
-        /// deletes to this DWPT.
-        /// </summary>
-        internal virtual FrozenBufferedUpdates PrepareFlush()
-        {
-            Debug.Assert(numDocsInRAM > 0);
-            FrozenBufferedUpdates globalUpdates = deleteQueue.FreezeGlobalBuffer(deleteSlice);
-            /* deleteSlice can possibly be null if we have hit non-aborting exceptions during indexing and never succeeded
-            adding a document. */
-            if (deleteSlice != null)
-            {
-                // apply all deletes before we flush and release the delete slice
-                deleteSlice.Apply(pendingUpdates, numDocsInRAM);
-                Debug.Assert(deleteSlice.IsEmpty);
-                deleteSlice.Reset();
-            }
-            return globalUpdates;
-        }
-
-        /// <summary>
-        /// Flush all pending docs to a new segment </summary>
-        internal virtual FlushedSegment Flush()
-        {
-            Debug.Assert(numDocsInRAM > 0);
-            Debug.Assert(deleteSlice.IsEmpty, "all deletes must be applied in prepareFlush");
-            segmentInfo.DocCount = numDocsInRAM;
-            SegmentWriteState flushState = new SegmentWriteState(infoStream, directory, segmentInfo, fieldInfos.Finish(), indexWriterConfig.TermIndexInterval, pendingUpdates, new IOContext(new FlushInfo(numDocsInRAM, BytesUsed)));
-            double startMBUsed = BytesUsed / 1024.0 / 1024.0;
-
-            // Apply delete-by-docID now (delete-byDocID only
-            // happens when an exception is hit processing that
-            // doc, eg if analyzer has some problem w/ the text):
-            if (pendingUpdates.docIDs.Count > 0)
-            {
-                flushState.LiveDocs = codec.LiveDocsFormat.NewLiveDocs(numDocsInRAM);
-                foreach (int delDocID in pendingUpdates.docIDs)
-                {
-                    flushState.LiveDocs.Clear(delDocID);
-                }
-                flushState.DelCountOnFlush = pendingUpdates.docIDs.Count;
-                pendingUpdates.bytesUsed.AddAndGet(-pendingUpdates.docIDs.Count * BufferedUpdates.BYTES_PER_DEL_DOCID);
-                pendingUpdates.docIDs.Clear();
-            }
-
-            if (aborting)
-            {
-                if (infoStream.IsEnabled("DWPT"))
-                {
-                    infoStream.Message("DWPT", "flush: skip because aborting is set");
-                }
-                return null;
-            }
-
-            if (infoStream.IsEnabled("DWPT"))
-            {
-                infoStream.Message("DWPT", "flush postings as segment " + flushState.SegmentInfo.Name + " numDocs=" + numDocsInRAM);
-            }
-
-            bool success = false;
-
-            try
-            {
-                consumer.Flush(flushState);
-                pendingUpdates.terms.Clear();
-                segmentInfo.SetFiles(new HashSet<string>(directory.CreatedFiles));
-
-                SegmentCommitInfo segmentInfoPerCommit = new SegmentCommitInfo(segmentInfo, 0, -1L, -1L);
-                if (infoStream.IsEnabled("DWPT"))
-                {
-                    infoStream.Message("DWPT", "new segment has " + (flushState.LiveDocs == null ? 0 : (flushState.SegmentInfo.DocCount - flushState.DelCountOnFlush)) + " deleted docs");
-                    infoStream.Message("DWPT", "new segment has " + (flushState.FieldInfos.HasVectors ? "vectors" : "no vectors") + "; " + (flushState.FieldInfos.HasNorms ? "norms" : "no norms") + "; " + (flushState.FieldInfos.HasDocValues ? "docValues" : "no docValues") + "; " + (flushState.FieldInfos.HasProx ? "prox" : "no prox") + "; " + (flushState.FieldInfos.HasFreq ? "freqs" : "no freqs"));
-                    infoStream.Message("DWPT", "flushedFiles=" + Arrays.ToString(segmentInfoPerCommit.Files()));
-                    infoStream.Message("DWPT", "flushed codec=" + codec);
-                }
-
-                BufferedUpdates segmentDeletes;
-                if (pendingUpdates.queries.Count == 0 && pendingUpdates.numericUpdates.Count == 0 && pendingUpdates.binaryUpdates.Count == 0)
-                {
-                    pendingUpdates.Clear();
-                    segmentDeletes = null;
-                }
-                else
-                {
-                    segmentDeletes = pendingUpdates;
-                }
-
-                if (infoStream.IsEnabled("DWPT"))
-                {
-                    double newSegmentSize = segmentInfoPerCommit.GetSizeInBytes() / 1024.0 / 1024.0;
-                    infoStream.Message("DWPT", "flushed: segment=" + segmentInfo.Name + " ramUsed=" + startMBUsed.ToString(nf) + " MB" + " newFlushedSize(includes docstores)=" + newSegmentSize.ToString(nf) + " MB" + " docs/MB=" + (flushState.SegmentInfo.DocCount / newSegmentSize).ToString(nf));
-                }
-
-                Debug.Assert(segmentInfo != null);
-
-                FlushedSegment fs = new FlushedSegment(segmentInfoPerCommit, flushState.FieldInfos, segmentDeletes, flushState.LiveDocs, flushState.DelCountOnFlush);
-                SealFlushedSegment(fs);
-                success = true;
-
-                return fs;
-            }
-            finally
-            {
-                if (!success)
-                {
-                    Abort(filesToDelete);
-                }
-            }
-        }
-
-        private readonly HashSet<string> filesToDelete = new HashSet<string>();
-
-        public virtual ISet<string> PendingFilesToDelete
-        {
-            get { return filesToDelete; }
-        }
-
-        /// <summary>
-        /// Seals the <see cref="Index.SegmentInfo"/> for the new flushed segment and persists
-        /// the deleted documents <see cref="IMutableBits"/>.
-        /// </summary>
-        internal virtual void SealFlushedSegment(FlushedSegment flushedSegment)
-        {
-            Debug.Assert(flushedSegment != null);
-
-            SegmentCommitInfo newSegment = flushedSegment.segmentInfo;
-
-            IndexWriter.SetDiagnostics(newSegment.Info, IndexWriter.SOURCE_FLUSH);
-
-            IOContext context = new IOContext(new FlushInfo(newSegment.Info.DocCount, newSegment.GetSizeInBytes()));
-
-            bool success = false;
-            try
-            {
-                if (indexWriterConfig.UseCompoundFile)
-                {
-                    Collections.AddAll(filesToDelete, IndexWriter.CreateCompoundFile(infoStream, directory, CheckAbort.NONE, newSegment.Info, context));
-                    newSegment.Info.UseCompoundFile = true;
-                }
-
-                // Have codec write SegmentInfo.  Must do this after
-                // creating CFS so that 1) .si isn't slurped into CFS,
-                // and 2) .si reflects useCompoundFile=true change
-                // above:
-                codec.SegmentInfoFormat.SegmentInfoWriter.Write(directory, newSegment.Info, flushedSegment.fieldInfos, context);
-
-                // TODO: ideally we would freeze newSegment here!!
-                // because any changes after writing the .si will be
-                // lost...
-
-                // Must write deleted docs after the CFS so we don't
-                // slurp the del file into CFS:
-                if (flushedSegment.liveDocs != null)
-                {
-                    int delCount = flushedSegment.delCount;
-                    Debug.Assert(delCount > 0);
-                    if (infoStream.IsEnabled("DWPT"))
-                    {
-                        infoStream.Message("DWPT", "flush: write " + delCount + " deletes gen=" + flushedSegment.segmentInfo.DelGen);
-                    }
-
-                    // TODO: we should prune the segment if it's 100%
-                    // deleted... but merge will also catch it.
-
-                    // TODO: in the NRT case it'd be better to hand
-                    // this del vector over to the
-                    // shortly-to-be-opened SegmentReader and let it
-                    // carry the changes; there's no reason to use
-                    // filesystem as intermediary here.
-
-                    SegmentCommitInfo info = flushedSegment.segmentInfo;
-                    Codec codec = info.Info.Codec;
-                    codec.LiveDocsFormat.WriteLiveDocs(flushedSegment.liveDocs, directory, info, delCount, context);
-                    newSegment.DelCount = delCount;
-                    newSegment.AdvanceDelGen();
-                }
-
-                success = true;
-            }
-            finally
-            {
-                if (!success)
-                {
-                    if (infoStream.IsEnabled("DWPT"))
-                    {
-                        infoStream.Message("DWPT", "hit exception creating compound file for newly flushed segment " + newSegment.Info.Name);
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Get current segment info we are writing. </summary>
-        internal virtual SegmentInfo SegmentInfo
-        {
-            get
-            {
-                return segmentInfo;
-            }
-        }
-
-        public virtual long BytesUsed
-        {
-            get { return bytesUsed.Get() + pendingUpdates.bytesUsed.Get(); }
-        }
-
-        /// <summary>
-        /// Initial chunks size of the shared byte[] blocks used to
-        /// store postings data
-        /// </summary>
-        internal static readonly int BYTE_BLOCK_NOT_MASK = ~ByteBlockPool.BYTE_BLOCK_MASK;
-
-        /// <summary>
-        /// if you increase this, you must fix field cache impl for
-        /// getTerms/getTermsIndex requires &lt;= 32768
-        /// </summary>
-        internal static readonly int MAX_TERM_LENGTH_UTF8 = ByteBlockPool.BYTE_BLOCK_SIZE - 2;
-
-        /// <summary>
-        /// NOTE: This was IntBlockAllocator in Lucene
-        /// </summary>
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        private class Int32BlockAllocator : Int32BlockPool.Allocator
-        {
-            private readonly Counter bytesUsed;
-
-            public Int32BlockAllocator(Counter bytesUsed)
-                : base(Int32BlockPool.INT32_BLOCK_SIZE)
-            {
-                this.bytesUsed = bytesUsed;
-            }
-
-            /// <summary>
-            /// Allocate another int[] from the shared pool
-            /// </summary>
-            public override int[] GetInt32Block()
-            {
-                int[] b = new int[Int32BlockPool.INT32_BLOCK_SIZE];
-                bytesUsed.AddAndGet(Int32BlockPool.INT32_BLOCK_SIZE * RamUsageEstimator.NUM_BYTES_INT32);
-                return b;
-            }
-
-            public override void RecycleInt32Blocks(int[][] blocks, int offset, int length)
-            {
-                bytesUsed.AddAndGet(-(length * (Int32BlockPool.INT32_BLOCK_SIZE * RamUsageEstimator.NUM_BYTES_INT32)));
-            }
-        }
-
-        public override string ToString()
-        {
-            return "DocumentsWriterPerThread [pendingDeletes=" + pendingUpdates + ", segment=" + (segmentInfo != null ? segmentInfo.Name : "null") + ", aborting=" + aborting + ", numDocsInRAM=" + numDocsInRAM + ", deleteQueue=" + deleteQueue + "]";
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/DocumentsWriterPerThreadPool.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/DocumentsWriterPerThreadPool.cs b/src/Lucene.Net.Core/Index/DocumentsWriterPerThreadPool.cs
deleted file mode 100644
index 2dc84c1..0000000
--- a/src/Lucene.Net.Core/Index/DocumentsWriterPerThreadPool.cs
+++ /dev/null
@@ -1,408 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Threading;
-
-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 Lucene.Net.Support;
-
-    /// <summary>
-    /// <see cref="DocumentsWriterPerThreadPool"/> controls <see cref="ThreadState"/> instances
-    /// and their thread assignments during indexing. Each <see cref="ThreadState"/> holds
-    /// a reference to a <see cref="DocumentsWriterPerThread"/> that is once a
-    /// <see cref="ThreadState"/> is obtained from the pool exclusively used for indexing a
-    /// single document by the obtaining thread. Each indexing thread must obtain
-    /// such a <see cref="ThreadState"/> to make progress. Depending on the
-    /// <see cref="DocumentsWriterPerThreadPool"/> implementation <see cref="ThreadState"/>
-    /// assignments might differ from document to document.
-    /// <para/>
-    /// Once a <see cref="DocumentsWriterPerThread"/> is selected for flush the thread pool
-    /// is reusing the flushing <see cref="DocumentsWriterPerThread"/>s <see cref="ThreadState"/> with a
-    /// new <see cref="DocumentsWriterPerThread"/> instance.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal abstract class DocumentsWriterPerThreadPool
-    {
-        /// <summary>
-        /// <see cref="ThreadState"/> references and guards a
-        /// <see cref="Index.DocumentsWriterPerThread"/> instance that is used during indexing to
-        /// build a in-memory index segment. <see cref="ThreadState"/> also holds all flush
-        /// related per-thread data controlled by <see cref="DocumentsWriterFlushControl"/>.
-        /// <para/>
-        /// A <see cref="ThreadState"/>, its methods and members should only accessed by one
-        /// thread a time. Users must acquire the lock via <see cref="ReentrantLock.Lock()"/>
-        /// and release the lock in a finally block via <see cref="ReentrantLock.Unlock()"/>
-        /// (on the <see cref="ThreadState"/> instance) before accessing the state.
-        /// </summary>
-#if FEATURE_SERIALIZABLE
-        [Serializable]
-#endif
-        internal sealed class ThreadState : ReentrantLock
-        {
-            internal DocumentsWriterPerThread dwpt;
-
-            // TODO this should really be part of DocumentsWriterFlushControl
-            // write access guarded by DocumentsWriterFlushControl
-            internal volatile bool flushPending = false;
-
-            // TODO this should really be part of DocumentsWriterFlushControl
-            // write access guarded by DocumentsWriterFlushControl
-            internal long bytesUsed = 0;
-
-            // guarded by Reentrant lock
-            internal bool isActive = true;
-
-            internal ThreadState(DocumentsWriterPerThread dpwt)
-            {
-                this.dwpt = dpwt;
-            }
-
-            /// <summary>
-            /// Resets the internal <see cref="DocumentsWriterPerThread"/> with the given one.
-            /// if the given DWPT is <c>null</c> this <see cref="ThreadState"/> is marked as inactive and should not be used
-            /// for indexing anymore. </summary>
-            /// <seealso cref="IsActive"/>
-            internal void Deactivate() // LUCENENET NOTE: Made internal because it is called outside of this context
-            {
-                //Debug.Assert(this.HeldByCurrentThread);
-                isActive = false;
-                Reset();
-            }
-
-            internal void Reset() // LUCENENET NOTE: Made internal because it is called outside of this context
-            {
-                //Debug.Assert(this.HeldByCurrentThread);
-                this.dwpt = null;
-                this.bytesUsed = 0;
-                this.flushPending = false;
-            }
-
-            /// <summary>
-            /// Returns <c>true</c> if this <see cref="ThreadState"/> is still open. This will
-            /// only return <c>false</c> iff the DW has been disposed and this
-            /// <see cref="ThreadState"/> is already checked out for flush.
-            /// </summary>
-            internal bool IsActive
-            {
-                get
-                {
-                    //Debug.Assert(this.HeldByCurrentThread);
-                    return isActive;
-                }
-            }
-
-            internal bool IsInitialized
-            {
-                get
-                {
-                    //Debug.Assert(this.HeldByCurrentThread);
-                    return IsActive && dwpt != null;
-                }
-            }
-
-            /// <summary>
-            /// Returns the number of currently active bytes in this ThreadState's
-            /// <see cref="DocumentsWriterPerThread"/>
-            /// </summary>
-            public long BytesUsedPerThread
-            {
-                get
-                {
-                    //Debug.Assert(this.HeldByCurrentThread);
-                    // public for FlushPolicy
-                    return bytesUsed;
-                }
-            }
-
-            /// <summary>
-            /// Returns this <see cref="ThreadState"/>s <see cref="DocumentsWriterPerThread"/>
-            /// </summary>
-            public DocumentsWriterPerThread DocumentsWriterPerThread
-            {
-                get
-                {
-                    //Debug.Assert(this.HeldByCurrentThread);
-                    // public for FlushPolicy
-                    return dwpt;
-                }
-            }
-
-            /// <summary>
-            /// Returns <c>true</c> iff this <see cref="ThreadState"/> is marked as flush
-            /// pending otherwise <c>false</c>
-            /// </summary>
-            public bool IsFlushPending
-            {
-                get
-                {
-                    return flushPending;
-                }
-            }
-        }
-
-        private ThreadState[] threadStates;
-        private volatile int numThreadStatesActive;
-
-        /// <summary>
-        /// Creates a new <see cref="DocumentsWriterPerThreadPool"/> with a given maximum of <see cref="ThreadState"/>s.
-        /// </summary>
-        internal DocumentsWriterPerThreadPool(int maxNumThreadStates)
-        {
-            if (maxNumThreadStates < 1)
-            {
-                throw new System.ArgumentException("maxNumThreadStates must be >= 1 but was: " + maxNumThreadStates);
-            }
-            threadStates = new ThreadState[maxNumThreadStates];
-            numThreadStatesActive = 0;
-            for (int i = 0; i < threadStates.Length; i++)
-            {
-                threadStates[i] = new ThreadState(null);
-            }
-        }
-
-        public virtual object Clone()
-        {
-            // We should only be cloned before being used:
-            if (numThreadStatesActive != 0)
-            {
-                throw new InvalidOperationException("clone this object before it is used!");
-            }
-
-            DocumentsWriterPerThreadPool clone;
-
-            clone = (DocumentsWriterPerThreadPool)base.MemberwiseClone();
-
-            clone.threadStates = new ThreadState[threadStates.Length];
-            for (int i = 0; i < threadStates.Length; i++)
-            {
-                clone.threadStates[i] = new ThreadState(null);
-            }
-            return clone;
-        }
-
-        /// <summary>
-        /// Returns the max number of <see cref="ThreadState"/> instances available in this
-        /// <see cref="DocumentsWriterPerThreadPool"/>
-        /// </summary>
-        public virtual int MaxThreadStates
-        {
-            get
-            {
-                return threadStates.Length;
-            }
-        }
-
-        /// <summary>
-        /// Returns the active number of <see cref="ThreadState"/> instances.
-        /// </summary>
-        public virtual int NumThreadStatesActive // LUCENENET NOTE: Changed from getActiveThreadState() because the name wasn't clear
-        {
-            get
-            {
-                return numThreadStatesActive;
-            }
-        }
-
-        /// <summary>
-        /// Returns a new <see cref="ThreadState"/> iff any new state is available otherwise
-        /// <c>null</c>.
-        /// <para/>
-        /// NOTE: the returned <see cref="ThreadState"/> is already locked iff non-<c>null</c>.
-        /// </summary>
-        /// <returns> a new <see cref="ThreadState"/> iff any new state is available otherwise
-        ///         <c>null</c> </returns>
-        public virtual ThreadState NewThreadState()
-        {
-            lock (this)
-            {
-                if (numThreadStatesActive < threadStates.Length)
-                {
-                    ThreadState threadState = threadStates[numThreadStatesActive];
-                    threadState.@Lock(); // lock so nobody else will get this ThreadState
-                    bool unlock = true;
-                    try
-                    {
-                        if (threadState.IsActive)
-                        {
-                            // unreleased thread states are deactivated during DW#close()
-                            numThreadStatesActive++; // increment will publish the ThreadState
-                            Debug.Assert(threadState.dwpt == null);
-                            unlock = false;
-                            return threadState;
-                        }
-                        // unlock since the threadstate is not active anymore - we are closed!
-                        Debug.Assert(AssertUnreleasedThreadStatesInactive());
-                        return null;
-                    }
-                    finally
-                    {
-                        if (unlock)
-                        {
-                            // in any case make sure we unlock if we fail
-                            threadState.Unlock();
-                        }
-                    }
-                }
-                return null;
-            }
-        }
-
-        private bool AssertUnreleasedThreadStatesInactive()
-        {
-            lock (this)
-            {
-                for (int i = numThreadStatesActive; i < threadStates.Length; i++)
-                {
-                    Debug.Assert(threadStates[i].TryLock(), "unreleased threadstate should not be locked");
-                    try
-                    {
-                        Debug.Assert(!threadStates[i].IsInitialized, "expected unreleased thread state to be inactive");
-                    }
-                    finally
-                    {
-                        threadStates[i].Unlock();
-                    }
-                }
-                return true;
-            }
-        }
-
-        /// <summary>
-        /// Deactivate all unreleased threadstates
-        /// </summary>
-        internal virtual void DeactivateUnreleasedStates()
-        {
-            lock (this)
-            {
-                for (int i = numThreadStatesActive; i < threadStates.Length; i++)
-                {
-                    ThreadState threadState = threadStates[i];
-                    threadState.@Lock();
-                    try
-                    {
-                        threadState.Deactivate();
-                    }
-                    finally
-                    {
-                        threadState.Unlock();
-                    }
-                }
-            }
-        }
-
-        internal virtual DocumentsWriterPerThread Reset(ThreadState threadState, bool closed)
-        {
-            //Debug.Assert(threadState.HeldByCurrentThread);
-            DocumentsWriterPerThread dwpt = threadState.dwpt;
-            if (!closed)
-            {
-                threadState.Reset();
-            }
-            else
-            {
-                threadState.Deactivate();
-            }
-            return dwpt;
-        }
-
-        internal virtual void Recycle(DocumentsWriterPerThread dwpt)
-        {
-            // don't recycle DWPT by default
-        }
-
-        // you cannot subclass this without being in o.a.l.index package anyway, so
-        // the class is already pkg-private... fix me: see LUCENE-4013
-        public abstract ThreadState GetAndLock(Thread requestingThread, DocumentsWriter documentsWriter); // LUCENENET NOTE: Made public rather than internal
-
-        /// <summary>
-        /// Returns the <i>i</i>th active <seealso cref="ThreadState"/> where <i>i</i> is the
-        /// given ord.
-        /// </summary>
-        /// <param name="ord">
-        ///          the ordinal of the <seealso cref="ThreadState"/> </param>
-        /// <returns> the <i>i</i>th active <seealso cref="ThreadState"/> where <i>i</i> is the
-        ///         given ord. </returns>
-        internal virtual ThreadState GetThreadState(int ord)
-        {
-            return threadStates[ord];
-        }
-
-        /// <summary>
-        /// Returns the <see cref="ThreadState"/> with the minimum estimated number of threads
-        /// waiting to acquire its lock or <c>null</c> if no <see cref="ThreadState"/>
-        /// is yet visible to the calling thread.
-        /// </summary>
-        internal virtual ThreadState MinContendedThreadState()
-        {
-            ThreadState minThreadState = null;
-            int limit = numThreadStatesActive;
-            for (int i = 0; i < limit; i++)
-            {
-                ThreadState state = threadStates[i];
-                if (minThreadState == null || state.QueueLength < minThreadState.QueueLength)
-                {
-                    minThreadState = state;
-                }
-            }
-            return minThreadState;
-        }
-
-        /// <summary>
-        /// Returns the number of currently deactivated <see cref="ThreadState"/> instances.
-        /// A deactivated <see cref="ThreadState"/> should not be used for indexing anymore.
-        /// </summary>
-        /// <returns> the number of currently deactivated <see cref="ThreadState"/> instances. </returns>
-        internal virtual int NumDeactivatedThreadStates()
-        {
-            int count = 0;
-            for (int i = 0; i < threadStates.Length; i++)
-            {
-                ThreadState threadState = threadStates[i];
-                threadState.@Lock();
-                try
-                {
-                    if (!threadState.isActive)
-                    {
-                        count++;
-                    }
-                }
-                finally
-                {
-                    threadState.Unlock();
-                }
-            }
-            return count;
-        }
-
-        /// <summary>
-        /// Deactivates an active <see cref="ThreadState"/>. Inactive <see cref="ThreadState"/> can
-        /// not be used for indexing anymore once they are deactivated. This method should only be used
-        /// if the parent <see cref="DocumentsWriter"/> is closed or aborted.
-        /// </summary>
-        /// <param name="threadState"> the state to deactivate </param>
-        internal virtual void DeactivateThreadState(ThreadState threadState)
-        {
-            Debug.Assert(threadState.IsActive);
-            threadState.Deactivate();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/DocumentsWriterStallControl.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/DocumentsWriterStallControl.cs b/src/Lucene.Net.Core/Index/DocumentsWriterStallControl.cs
deleted file mode 100644
index 1b5c322..0000000
--- a/src/Lucene.Net.Core/Index/DocumentsWriterStallControl.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using Lucene.Net.Support;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-
-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>
-    /// Controls the health status of a <see cref="DocumentsWriter"/> sessions. This class
-    /// used to block incoming indexing threads if flushing significantly slower than
-    /// indexing to ensure the <see cref="DocumentsWriter"/>s healthiness. If flushing is
-    /// significantly slower than indexing the net memory used within an
-    /// <see cref="IndexWriter"/> session can increase very quickly and easily exceed the
-    /// runtime's available memory.
-    /// <para/>
-    /// To prevent OOM Errors and ensure <see cref="IndexWriter"/>'s stability this class blocks
-    /// incoming threads from indexing once 2 x number of available
-    /// <see cref="ThreadState"/>s in <see cref="DocumentsWriterPerThreadPool"/> is exceeded.
-    /// Once flushing catches up and the number of flushing DWPT is equal or lower
-    /// than the number of active <see cref="ThreadState"/>s threads are released and can
-    /// continue indexing.
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    internal sealed class DocumentsWriterStallControl
-    {
-        private volatile bool stalled;
-        private int numWaiting; // only with assert
-        private bool wasStalled; // only with assert
-        private readonly IDictionary<ThreadClass, bool?> waiting = new IdentityHashMap<ThreadClass, bool?>(); // only with assert
-
-        /// <summary>
-        /// Update the stalled flag status. this method will set the stalled flag to
-        /// <c>true</c> iff the number of flushing
-        /// <see cref="DocumentsWriterPerThread"/> is greater than the number of active
-        /// <see cref="DocumentsWriterPerThread"/>. Otherwise it will reset the
-        /// <see cref="DocumentsWriterStallControl"/> to healthy and release all threads
-        /// waiting on <see cref="WaitIfStalled()"/>
-        /// </summary>
-        internal void UpdateStalled(bool stalled)
-        {
-            lock (this)
-            {
-                this.stalled = stalled;
-                if (stalled)
-                {
-                    wasStalled = true;
-                }
-                Monitor.PulseAll(this);
-            }
-        }
-
-        /// <summary>
-        /// Blocks if documents writing is currently in a stalled state.
-        ///
-        /// </summary>
-        internal void WaitIfStalled()
-        {
-            if (stalled)
-            {
-                lock (this)
-                {
-                    if (stalled) // react on the first wakeup call!
-                    {
-                        // don't loop here, higher level logic will re-stall!
-#if !NETSTANDARD
-                        try
-                        {
-#endif
-                            // make sure not to run IncWaiters / DecrWaiters in Debug.Assert as that gets 
-                            // removed at compile time if built in Release mode
-                            var result = IncWaiters();
-                            Debug.Assert(result);
-                            Monitor.Wait(this);
-                            result = DecrWaiters();
-                            Debug.Assert(result);
-#if !NETSTANDARD
-                        }
-                        catch (ThreadInterruptedException e)
-                        {
-                            throw new ThreadInterruptedException("Thread Interrupted Exception", e);
-                        }
-#endif
-                    }
-                }
-            }
-        }
-
-        internal bool AnyStalledThreads()
-        {
-            return stalled;
-        }
-
-        private bool IncWaiters()
-        {
-            numWaiting++;
-            bool existed = waiting.ContainsKey(ThreadClass.Current());
-            Debug.Assert(!existed);
-            waiting[ThreadClass.Current()] = true;
-
-            return numWaiting > 0;
-        }
-
-        private bool DecrWaiters()
-        {
-            numWaiting--;
-            bool removed = waiting.Remove(ThreadClass.Current());
-            Debug.Assert(removed);
-
-            return numWaiting >= 0;
-        }
-
-        internal bool HasBlocked // for tests
-        {
-            get
-            {
-                lock (this)
-                {
-                    return numWaiting > 0;
-                }
-            }
-        }
-
-        internal bool IsHealthy
-        {
-            get
-            {
-                return !stalled; // volatile read!
-            }
-        }
-
-        internal bool IsThreadQueued(ThreadClass t) // for tests
-        {
-            lock (this)
-            {
-                return waiting.ContainsKey(t);
-            }
-        }
-
-        internal bool WasStalled // for tests
-        {
-            get
-            {
-                lock (this)
-                {
-                    return wasStalled;
-                }
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5dc68d0/src/Lucene.Net.Core/Index/FieldInfo.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FieldInfo.cs b/src/Lucene.Net.Core/Index/FieldInfo.cs
deleted file mode 100644
index e8cbb41..0000000
--- a/src/Lucene.Net.Core/Index/FieldInfo.cs
+++ /dev/null
@@ -1,438 +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.
-     */
-
-    /// <summary>
-    ///  Access to the Field Info file that describes document fields and whether or
-    ///  not they are indexed. Each segment has a separate Field Info file. Objects
-    ///  of this class are thread-safe for multiple readers, but only one thread can
-    ///  be adding documents at a time, with no other reader or writer threads
-    ///  accessing this object.
-    ///
-    /// </summary>
-#if FEATURE_SERIALIZABLE
-    [Serializable]
-#endif
-    public sealed class FieldInfo
-    {
-        /// <summary>
-        /// Field's name </summary>
-        public string Name { get; private set; }
-
-        /// <summary>
-        /// Internal field number </summary>
-        public int Number { get; private set; }
-
-        private bool indexed;
-        private DocValuesType docValueType;
-
-        // True if any document indexed term vectors
-        private bool storeTermVector;
-
-        private DocValuesType normType;
-        private bool omitNorms; // omit norms associated with indexed fields
-        private IndexOptions indexOptions;
-        private bool storePayloads; // whether this field stores payloads together with term positions
-
-        private IDictionary<string, string> attributes;
-
-        private long dvGen = -1; // the DocValues generation of this field
-
-        // LUCENENET specific: De-nested the IndexOptions and DocValuesType enums from this class to prevent naming conflicts
-
-        /// <summary>
-        /// Sole Constructor.
-        ///
-        /// @lucene.experimental
-        /// </summary>
-        public FieldInfo(string name, bool indexed, int number, bool storeTermVector, bool omitNorms, 
-            bool storePayloads, IndexOptions indexOptions, DocValuesType docValues, DocValuesType normsType, 
-            IDictionary<string, string> attributes)
-        {
-            this.Name = name;
-            this.indexed = indexed;
-            this.Number = number;
-            this.docValueType = docValues;
-            if (indexed)
-            {
-                this.storeTermVector = storeTermVector;
-                this.storePayloads = storePayloads;
-                this.omitNorms = omitNorms;
-                this.indexOptions = indexOptions;
-                this.normType = !omitNorms ? normsType : DocValuesType.NONE;
-            } // for non-indexed fields, leave defaults
-            else
-            {
-                this.storeTermVector = false;
-                this.storePayloads = false;
-                this.omitNorms = false;
-                this.indexOptions = IndexOptions.NONE;
-                this.normType = DocValuesType.NONE;
-            }
-            this.attributes = attributes;
-            Debug.Assert(CheckConsistency());
-        }
-
-        private bool CheckConsistency()
-        {
-            if (!indexed)
-            {
-                Debug.Assert(!storeTermVector);
-                Debug.Assert(!storePayloads);
-                Debug.Assert(!omitNorms);
-                Debug.Assert(normType == DocValuesType.NONE);
-                Debug.Assert(indexOptions == IndexOptions.NONE);
-            }
-            else
-            {
-                Debug.Assert(indexOptions != IndexOptions.NONE);
-                if (omitNorms)
-                {
-                    Debug.Assert(normType == DocValuesType.NONE);
-                }
-                // Cannot store payloads unless positions are indexed:
-                Debug.Assert(indexOptions.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads);
-            }
-
-            return true;
-        }
-
-        internal void Update(IIndexableFieldType ft)
-        {
-            Update(ft.IsIndexed, false, ft.OmitNorms, false, ft.IndexOptions);
-        }
-
-        // should only be called by FieldInfos#addOrUpdate
-        internal void Update(bool indexed, bool storeTermVector, bool omitNorms, bool storePayloads, IndexOptions indexOptions)
-        {
-            //System.out.println("FI.update field=" + name + " indexed=" + indexed + " omitNorms=" + omitNorms + " this.omitNorms=" + this.omitNorms);
-            if (this.indexed != indexed)
-            {
-                this.indexed = true; // once indexed, always index
-            }
-            if (indexed) // if updated field data is not for indexing, leave the updates out
-            {
-                if (this.storeTermVector != storeTermVector)
-                {
-                    this.storeTermVector = true; // once vector, always vector
-                }
-                if (this.storePayloads != storePayloads)
-                {
-                    this.storePayloads = true;
-                }
-                if (this.omitNorms != omitNorms)
-                {
-                    this.omitNorms = true; // if one require omitNorms at least once, it remains off for life
-                    this.normType = DocValuesType.NONE;
-                }
-                if (this.indexOptions != indexOptions)
-                {
-                    if (this.indexOptions == IndexOptions.NONE)
-                    {
-                        this.indexOptions = indexOptions;
-                    }
-                    else
-                    {
-                        // downgrade
-                        this.indexOptions = this.indexOptions.CompareTo(indexOptions) < 0 ? this.indexOptions : indexOptions;
-                    }
-                    if (this.indexOptions.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0)
-                    {
-                        // cannot store payloads if we don't store positions:
-                        this.storePayloads = false;
-                    }
-                }
-            }
-            Debug.Assert(CheckConsistency());
-        }
-
-        public DocValuesType DocValuesType
-        {
-            internal set
-            {
-                if (docValueType != DocValuesType.NONE && docValueType != value)
-                {
-                    throw new System.ArgumentException("cannot change DocValues type from " + docValueType + " to " + value + " for field \"" + Name + "\"");
-                }
-                docValueType = value;
-                Debug.Assert(CheckConsistency());
-            }
-            get
-            {
-                return docValueType;
-            }
-        }
-
-        /// <summary>
-        /// Returns IndexOptions for the field, or null if the field is not indexed </summary>
-        public IndexOptions IndexOptions
-        {
-            get
-            {
-                return indexOptions;
-            }
-        }
-
-        /// <summary>
-        /// Returns true if this field has any docValues.
-        /// </summary>
-        public bool HasDocValues
-        {
-            get { return docValueType != DocValuesType.NONE; }
-        }
-
-        /// <summary>
-        /// Sets the docValues generation of this field. </summary>
-        public long DocValuesGen
-        {
-            set
-            {
-                this.dvGen = value;
-            }
-            get
-            {
-                return dvGen;
-            }
-        }
-
-        /// <summary>
-        /// Returns <see cref="Index.DocValuesType"/> of the norm. This may be <see cref="DocValuesType.NONE"/> if the field has no norms.
-        /// </summary>
-        public DocValuesType NormType
-        {
-            get
-            {
-                return normType;
-            }
-            internal set
-            {
-                if (normType != DocValuesType.NONE && normType != value)
-                {
-                    throw new System.ArgumentException("cannot change Norm type from " + normType + " to " + value + " for field \"" + Name + "\"");
-                }
-                normType = value;
-                Debug.Assert(CheckConsistency());
-            }
-        }
-
-        internal void SetStoreTermVectors()
-        {
-            storeTermVector = true;
-            Debug.Assert(CheckConsistency());
-        }
-
-        internal void SetStorePayloads()
-        {
-            if (indexed && indexOptions.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0)
-            {
-                storePayloads = true;
-            }
-            Debug.Assert(CheckConsistency());
-        }
-
-        /// <summary>
-        /// Returns true if norms are explicitly omitted for this field
-        /// </summary>
-        public bool OmitsNorms
-        {
-            get { return omitNorms; }
-        }
-
-        /// <summary>
-        /// Returns true if this field actually has any norms.
-        /// </summary>
-        public bool HasNorms
-        {
-            get { return normType != DocValuesType.NONE; }
-        }
-
-        /// <summary>
-        /// Returns true if this field is indexed.
-        /// </summary>
-        public bool IsIndexed
-        {
-            get
-            {
-                return indexed;
-            }
-        }
-
-        /// <summary>
-        /// Returns true if any payloads exist for this field.
-        /// </summary>
-        public bool HasPayloads
-        {
-            get { return storePayloads; }
-        }
-
-        /// <summary>
-        /// Returns true if any term vectors exist for this field.
-        /// </summary>
-        public bool HasVectors
-        {
-            get { return storeTermVector; }
-        }
-
-        /// <summary>
-        /// Get a codec attribute value, or null if it does not exist
-        /// </summary>
-        public string GetAttribute(string key)
-        {
-            if (attributes == null)
-            {
-                return null;
-            }
-            else
-            {
-                string ret;
-                attributes.TryGetValue(key, out ret);
-                return ret;
-            }
-        }
-
-        /// <summary>
-        /// Puts a codec attribute value.
-        /// <p>
-        /// this is a key-value mapping for the field that the codec can use
-        /// to store additional metadata, and will be available to the codec
-        /// when reading the segment via <seealso cref="#getAttribute(String)"/>
-        /// <p>
-        /// If a value already exists for the field, it will be replaced with
-        /// the new value.
-        /// </summary>
-        public string PutAttribute(string key, string value)
-        {
-            if (attributes == null)
-            {
-                attributes = new Dictionary<string, string>();
-            }
-
-            string ret;
-            // The key was not previously assigned, null will be returned
-            if (!attributes.TryGetValue(key, out ret))
-            {
-                ret = null;
-            }
-
-            attributes[key] = value;
-            return ret;
-        }
-
-        /// <summary>
-        /// Returns internal codec attributes map. May be null if no mappings exist.
-        /// </summary>
-        public IDictionary<string, string> Attributes
-        {
-            get { return attributes; }
-        }
-    }
-
-    /// <summary>
-    /// Controls how much information is stored in the postings lists.
-    /// @lucene.experimental
-    /// </summary>
-    public enum IndexOptions // LUCENENET specific: de-nested from FieldInfo to prevent naming collisions
-    {
-        // NOTE: order is important here; FieldInfo uses this
-        // order to merge two conflicting IndexOptions (always
-        // "downgrades" by picking the lowest).
-
-        /// <summary>
-        /// No index options will be used.
-        /// <para/>
-        /// NOTE: This is the same as setting to <c>null</c> in Lucene
-        /// </summary>
-        // LUCENENET specific
-        NONE,
-
-        /// <summary>
-        /// Only documents are indexed: term frequencies and positions are omitted.
-        /// Phrase and other positional queries on the field will throw an exception, and scoring
-        /// will behave as if any term in the document appears only once.
-        /// </summary>
-        // TODO: maybe rename to just DOCS?
-        DOCS_ONLY,
-
-        /// <summary>
-        /// Only documents and term frequencies are indexed: positions are omitted.
-        /// this enables normal scoring, except Phrase and other positional queries
-        /// will throw an exception.
-        /// </summary>
-        DOCS_AND_FREQS,
-
-        /// <summary>
-        /// Indexes documents, frequencies and positions.
-        /// this is a typical default for full-text search: full scoring is enabled
-        /// and positional queries are supported.
-        /// </summary>
-        DOCS_AND_FREQS_AND_POSITIONS,
-
-        /// <summary>
-        /// Indexes documents, frequencies, positions and offsets.
-        /// Character offsets are encoded alongside the positions.
-        /// </summary>
-        DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS
-    }
-
-    /// <summary>
-    /// DocValues types.
-    /// Note that DocValues is strongly typed, so a field cannot have different types
-    /// across different documents.
-    /// </summary>
-    public enum DocValuesType // LUCENENET specific: de-nested from FieldInfo to prevent naming collisions
-    {
-        /// <summary>
-        /// No doc values type will be used.
-        /// <para/>
-        /// NOTE: This is the same as setting to <c>null</c> in Lucene
-        /// </summary>
-        // LUCENENET specific
-        NONE, // LUCENENET NOTE: The value of this option is 0, which is the default value for any .NET value type
-
-        /// <summary>
-        /// A per-document numeric type
-        /// </summary>
-        NUMERIC,
-
-        /// <summary>
-        /// A per-document <see cref="T:byte[]"/>.  Values may be larger than
-        /// 32766 bytes, but different codecs may enforce their own limits.
-        /// </summary>
-        BINARY,
-
-        /// <summary>
-        /// A pre-sorted <see cref="T:byte[]"/>. Fields with this type only store distinct byte values
-        /// and store an additional offset pointer per document to dereference the shared
-        /// byte[]. The stored byte[] is presorted and allows access via document id,
-        /// ordinal and by-value.  Values must be &lt;= 32766 bytes.
-        /// </summary>
-        SORTED,
-
-        /// <summary>
-        /// A pre-sorted ISet&lt;byte[]&gt;. Fields with this type only store distinct byte values
-        /// and store additional offset pointers per document to dereference the shared
-        /// <see cref="T:byte[]"/>s. The stored <see cref="T:byte[]"/> is presorted and allows access via document id,
-        /// ordinal and by-value.  Values must be &lt;= 32766 bytes.
-        /// </summary>
-        SORTED_SET
-    }
-}
\ No newline at end of file