Exemplo n.º 1
0
        /*  Leaving this here will cause a memory leak under .NET 1.1
         * ~SegmentReader()
         * {
         *      // patch for pre-1.4.2 JVMs, whose ThreadLocals leak
         *      //System.Threading.Thread.SetData(termVectorsLocal, null);
         * }
         */

        protected internal override void  DoCommit()
        {
            if (deletedDocsDirty)
            {
                // re-write deleted
                deletedDocs.Write(Directory(), segment + ".tmp");
                Directory().RenameFile(segment + ".tmp", segment + ".del");
            }
            if (undeleteAll && Directory().FileExists(segment + ".del"))
            {
                Directory().DeleteFile(segment + ".del");
            }
            if (normsDirty)
            {
                // re-write norms
                System.Collections.IEnumerator values = norms.Values.GetEnumerator();
                while (values.MoveNext())
                {
                    Norm norm = (Norm)values.Current;
                    if (norm.dirty)
                    {
                        norm.ReWrite();
                    }
                }
            }
            deletedDocsDirty = false;
            normsDirty       = false;
            undeleteAll      = false;
        }
Exemplo n.º 2
0
        protected internal override void  CommitChanges()
        {
            if (deletedDocsDirty)
            {
                // re-write deleted
                si.AdvanceDelGen();

                // We can write directly to the actual name (vs to a
                // .tmp & renaming it) because the file is not live
                // until segments file is written:
                deletedDocs.Write(Directory(), si.GetDelFileName());
            }
            if (undeleteAll && si.HasDeletions())
            {
                si.ClearDelGen();
            }
            if (normsDirty)
            {
                // re-write norms
                si.SetNumFields(fieldInfos.Size());
                System.Collections.IEnumerator it = norms.Values.GetEnumerator();
                while (it.MoveNext())
                {
                    Norm norm = (Norm)it.Current;
                    if (norm.dirty)
                    {
                        norm.ReWrite(si);
                    }
                }
            }
            deletedDocsDirty = false;
            normsDirty       = false;
            undeleteAll      = false;
        }
Exemplo n.º 3
0
        protected internal override void  DoCommit()
        {
            if (deletedDocsDirty)
            {
                // re-write deleted
                System.String oldDelFileName = si.GetDelFileName();
                if (oldDelFileName != null)
                {
                    // Mark this file for deletion.  Note that we don't
                    // actually try to delete it until the new segments files is
                    // successfully written:
                    deleter.AddPendingFile(oldDelFileName);
                }

                si.AdvanceDelGen();

                // We can write directly to the actual name (vs to a
                // .tmp & renaming it) because the file is not live
                // until segments file is written:
                deletedDocs.Write(Directory(), si.GetDelFileName());
            }
            if (undeleteAll && si.HasDeletions())
            {
                System.String oldDelFileName = si.GetDelFileName();
                if (oldDelFileName != null)
                {
                    // Mark this file for deletion.  Note that we don't
                    // actually try to delete it until the new segments files is
                    // successfully written:
                    deleter.AddPendingFile(oldDelFileName);
                }
                si.ClearDelGen();
            }
            if (normsDirty)
            {
                // re-write norms
                si.SetNumFields(fieldInfos.Size());
                System.Collections.IEnumerator values = norms.Values.GetEnumerator();
                while (values.MoveNext())
                {
                    Norm norm = (Norm)values.Current;
                    if (norm.dirty)
                    {
                        norm.ReWrite(si);
                    }
                }
            }
            deletedDocsDirty = false;
            normsDirty       = false;
            undeleteAll      = false;
        }