コード例 #1
0
        private void  VerifyCommitOrder <T>(IList <T> commits) where T : IndexCommit
        {
            IndexCommit firstCommit = commits[0];
            long        last        = SegmentInfos.GenerationFromSegmentsFileName(firstCommit.SegmentsFileName);

            Assert.AreEqual(last, firstCommit.Generation);
            long lastVersion   = firstCommit.Version;
            long lastTimestamp = firstCommit.Timestamp(null);

            for (int i = 1; i < commits.Count; i++)
            {
                IndexCommit commit       = commits[i];
                long        now          = SegmentInfos.GenerationFromSegmentsFileName(commit.SegmentsFileName);
                long        nowVersion   = commit.Version;
                long        nowTimestamp = commit.Timestamp(null);
                Assert.IsTrue(now > last, "SegmentInfos commits are out-of-order");
                Assert.IsTrue(nowVersion > lastVersion, "SegmentInfos versions are out-of-order");
                Assert.IsTrue(nowTimestamp >= lastTimestamp, "SegmentInfos timestamps are out-of-order: now=" + nowTimestamp + " vs last=" + lastTimestamp);
                Assert.AreEqual(now, commit.Generation);
                last          = now;
                lastVersion   = nowVersion;
                lastTimestamp = nowTimestamp;
            }
        }