19 using System.Collections.Generic;
22 namespace Lucene.Net.Index
49 private System.String snapshot;
53 this.primary = primary;
56 public virtual void OnInit<T>(IList<T> commits) where T :
IndexCommit
60 primary.OnInit(WrapCommits(commits));
61 lastCommit = commits[commits.Count - 1];
65 public virtual void OnCommit<T>(IList<T> commits) where T :
IndexCommit
69 primary.OnCommit(WrapCommits(commits));
70 lastCommit = commits[commits.Count - 1];
88 if (lastCommit == null)
90 throw new System.SystemException(
"no index commits to snapshot !");
96 throw new System.SystemException(
"snapshot is already set; please call release() first");
102 public virtual void Release()
106 if (snapshot != null)
109 throw new System.SystemException(
"snapshot was not set; please call snapshot() first");
117 this.enclosingInstance = enclosingInstance;
119 private SnapshotDeletionPolicy enclosingInstance;
120 public SnapshotDeletionPolicy Enclosing_Instance
124 return enclosingInstance;
128 internal IndexCommit cp;
129 internal MyCommitPoint(SnapshotDeletionPolicy enclosingInstance, IndexCommit cp)
131 InitBlock(enclosingInstance);
135 public override string ToString()
137 return "SnapshotDeletionPolicy.SnapshotCommitPoint(" + cp +
")";
140 public override string SegmentsFileName
142 get {
return cp.SegmentsFileName; }
145 public override ICollection<string> FileNames
147 get {
return cp.FileNames; }
152 get {
return cp.Directory; }
155 public override void Delete()
157 lock (Enclosing_Instance)
161 if (Enclosing_Instance.snapshot == null || !Enclosing_Instance.snapshot.Equals(SegmentsFileName))
166 public override bool IsDeleted
168 get {
return cp.IsDeleted; }
173 get {
return cp.Version; }
176 public override long Generation
178 get {
return cp.Generation; }
181 public override IDictionary<string, string> UserData
183 get {
return cp.UserData; }
186 public override bool IsOptimized
188 get {
return cp.IsOptimized; }
192 private IList<IndexCommit> WrapCommits<T>(IList<T> commits) where T : IndexCommit
194 int count = commits.Count;
195 var myCommits =
new List<IndexCommit>(count);
196 for (
int i = 0; i < count; i++)
198 myCommits.Add(
new MyCommitPoint(
this, commits[i]));