Exemple #1
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;
        }
Exemple #2
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;
        }