Delete() public abstract method

Delete this commit point. This only applies when using the commit point in the context of IndexWriter's IndexDeletionPolicy.

Upon calling this, the writer is notified that this commit point should be deleted.

Decision that a commit-point should be deleted is taken by the IndexDeletionPolicy in effect and therefore this should only be called by its IndexDeletionPolicy.OnInit(System.Collections.IList) or IndexDeletionPolicy.OnCommit(System.Collections.IList) methods.

public abstract Delete ( ) : void
return void
Exemplo n.º 1
0
            public virtual void  OnInit(System.Collections.IList commits)
            {
                for (System.Collections.IEnumerator iterator = commits.GetEnumerator(); iterator.MoveNext();)
                {
                    IndexCommit commit = (IndexCommit)iterator.Current;
                    System.Collections.Generic.IDictionary <string, string> userData = commit.GetUserData();
                    if (userData.Count > 0)
                    {
                        // Label for a commit point is "Records 1-30"
                        // This code reads the last id ("30" in this example) and deletes it
                        // if it is after the desired rollback point
                        System.String x       = (System.String)userData["index"];
                        System.String lastVal = x.Substring(x.LastIndexOf("-") + 1);
                        int           last    = System.Int32.Parse(lastVal);
                        if (last > rollbackPoint)
                        {
                            /*
                             * System.out.print("\tRolling back commit point:" +
                             * " UserData="+commit.getUserData() +")  ("+(commits.size()-1)+" commit points left) files=");
                             * Collection files = commit.getFileNames();
                             * for (Iterator iterator2 = files.iterator(); iterator2.hasNext();) {
                             * System.out.print(" "+iterator2.next());
                             * }
                             * System.out.println();
                             */

                            commit.Delete();
                        }
                    }
                }
            }
Exemplo n.º 2
0
 public override void Delete()
 {
     lock (outerInstance)
     {
         // Suppress the delete request if this commit point is
         // currently snapshotted.
         if (!outerInstance.m_refCounts.ContainsKey(m_cp.Generation))
         {
             m_cp.Delete();
         }
     }
 }
Exemplo n.º 3
0
 public override void  Delete()
 {
     lock (Enclosing_Instance)
     {
         // Suppress the delete request if this commit point is
         // our current snapshot.
         if (Enclosing_Instance.snapshot == null || !Enclosing_Instance.snapshot.Equals(GetSegmentsFileName()))
         {
             cp.Delete();
         }
     }
 }
Exemplo n.º 4
0
 public virtual void  OnInit(System.Collections.IList commits)
 {
     Enclosing_Instance.VerifyCommitOrder(commits);
     numOnInit++;
     // On init, delete all commit points:
     System.Collections.IEnumerator it = commits.GetEnumerator();
     while (it.MoveNext())
     {
         IndexCommit commit = (IndexCommit)it.Current;
         commit.Delete();
         Assert.IsTrue(commit.IsDeleted());
     }
 }
Exemplo n.º 5
0
 public override void Delete()
 {
     UninterruptableMonitor.Enter(outerInstance);
     try
     {
         // Suppress the delete request if this commit point is
         // currently snapshotted.
         if (!outerInstance.m_refCounts.ContainsKey(m_cp.Generation))
         {
             m_cp.Delete();
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(outerInstance);
     }
 }
Exemplo n.º 6
0
            public virtual void  OnCommit(System.Collections.IList commits)
            {
                Enclosing_Instance.VerifyCommitOrder(commits);

                IndexCommit lastCommit = (IndexCommit)commits[commits.Count - 1];

                // Any commit older than expireTime should be deleted:
                double expireTime = dir.FileModified(lastCommit.GetSegmentsFileName()) / 1000.0 - expirationTimeSeconds;

                System.Collections.IEnumerator it = commits.GetEnumerator();

                while (it.MoveNext())
                {
                    IndexCommit commit  = (IndexCommit)it.Current;
                    double      modTime = dir.FileModified(commit.GetSegmentsFileName()) / 1000.0;
                    if (commit != lastCommit && modTime < expireTime)
                    {
                        commit.Delete();
                        numDelete += 1;
                    }
                }
            }