当前位置: 首页>>代码示例>>C#>>正文


C# Index.IndexCommit类代码示例

本文整理汇总了C#中Lucene.Net.Index.IndexCommit的典型用法代码示例。如果您正苦于以下问题:C# IndexCommit类的具体用法?C# IndexCommit怎么用?C# IndexCommit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexCommit类属于Lucene.Net.Index命名空间,在下文中一共展示了IndexCommit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCommit

        public virtual void OnCommit(IList<IndexCommit> commits)
		{
			lock (this)
			{
				primary.OnCommit(WrapCommits(commits));
				lastCommit = commits[commits.Count - 1];
			}
		}
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:8,代码来源:SnapshotDeletionPolicy.cs

示例2: OnInit

 public virtual void OnInit(List<IndexCommitPoint> commits)
 {
     lock (this)
     {
         primary.OnInit(WrapCommits(commits));
         lastCommit = (IndexCommit)(commits[commits.Count - 1]);
     }
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:8,代码来源:SnapshotDeletionPolicy.cs

示例3: OnCommit

		public virtual void  OnCommit(System.Collections.IList commits)
		{
			lock (this)
			{
				primary.OnCommit(WrapCommits(commits));
				lastCommit = (IndexCommit) commits[commits.Count - 1];
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:SnapshotDeletionPolicy.cs

示例4: Reopen

		public override IndexReader Reopen(IndexCommit commit)
		{
			EnsureOpen();
			IndexReader r = in_Renamed.Reopen(commit);
			if (r != in_Renamed)
				return new DirectoryOwningReader(r, ref_Renamed);
			return this;
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:8,代码来源:DirectoryOwningReader.cs

示例5: CheckMaxDoc

 protected internal virtual void CheckMaxDoc(IndexCommit commit, int expectedMaxDoc)
 {
     IndexReader reader = DirectoryReader.Open(commit);
     try
     {
         Assert.AreEqual(expectedMaxDoc, reader.MaxDoc);
     }
     finally
     {
         reader.Dispose();
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:12,代码来源:TestSnapshotDeletionPolicy.cs

示例6: TestMultiThreadedSnapshotting

        public virtual void TestMultiThreadedSnapshotting()
        {
            Directory dir = NewDirectory();
            IndexWriter writer = new IndexWriter(dir, GetConfig(Random(), DeletionPolicy));
            SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy)writer.Config.DelPolicy;

            ThreadClass[] threads = new ThreadClass[10];
            IndexCommit[] snapshots = new IndexCommit[threads.Length];
            for (int i = 0; i < threads.Length; i++)
            {
                int finalI = i;
                threads[i] = new ThreadAnonymousInnerClassHelper2(this, writer, sdp, snapshots, finalI);
                threads[i].Name = "t" + i;
            }

            foreach (ThreadClass t in threads)
            {
                t.Start();
            }

            foreach (ThreadClass t in threads)
            {
                t.Join();
            }

            // Do one last commit, so that after we release all snapshots, we stay w/ one commit
            writer.AddDocument(new Document());
            writer.Commit();

            for (int i = 0; i < threads.Length; i++)
            {
                sdp.Release(snapshots[i]);
                writer.DeleteUnusedFiles();
            }
            Assert.AreEqual(1, DirectoryReader.ListCommits(dir).Count);
            writer.Dispose();
            dir.Dispose();
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:38,代码来源:TestSnapshotDeletionPolicy.cs

示例7: CheckSnapshotExists

 protected internal virtual void CheckSnapshotExists(Directory dir, IndexCommit c)
 {
     string segFileName = c.SegmentsFileName;
     Assert.IsTrue(SlowFileExists(dir, segFileName), "segments file not found in directory: " + segFileName);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:5,代码来源:TestSnapshotDeletionPolicy.cs

示例8: Open

        internal static DirectoryIndexReader Open(Directory directory, bool closeDirectory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, bool readOnly)
        {
            SegmentInfos.FindSegmentsFile finder = new AnonymousClassFindSegmentsFile(closeDirectory, deletionPolicy, directory, readOnly);

            if (commit == null)
                return (DirectoryIndexReader) finder.Run();
            else
            {
                if (directory != commit.GetDirectory())
                    throw new System.IO.IOException("the specified commit does not match the specified Directory");
                // this can and will directly throw IOException if the specified commit point has been deleted
                return (DirectoryIndexReader)finder.DoBody(commit.GetSegmentsFileName());
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:14,代码来源:DirectoryIndexReader.cs

示例9: Run

			public System.Object Run(IndexCommit commit)
			{
				if (commit != null)
				{
					if (directory != commit.GetDirectory())
						throw new System.IO.IOException("the specified commit does not match the specified Directory");
					return DoBody(commit.GetSegmentsFileName());
				}
				
				System.String segmentFileName = null;
				long lastGen = - 1;
				long gen = 0;
				int genLookaheadCount = 0;
				System.IO.IOException exc = null;
				bool retry = false;
				
				int method = 0;
				
				// Loop until we succeed in calling doBody() without
				// hitting an IOException.  An IOException most likely
				// means a commit was in process and has finished, in
				// the time it took us to load the now-old infos files
				// (and segments files).  It's also possible it's a
				// true error (corrupt index).  To distinguish these,
				// on each retry we must see "forward progress" on
				// which generation we are trying to load.  If we
				// don't, then the original error is real and we throw
				// it.
				
				// We have three methods for determining the current
				// generation.  We try the first two in parallel, and
				// fall back to the third when necessary.
				
				while (true)
				{
					
					if (0 == method)
					{
						
						// Method 1: list the directory and use the highest
						// segments_N file.  This method works well as long
						// as there is no stale caching on the directory
						// contents (NOTE: NFS clients often have such stale
						// caching):
						System.String[] files = null;
						
						long genA = - 1;
						
						files = directory.ListAll();
						
						if (files != null)
							genA = Lucene.Net.Index.SegmentInfos.GetCurrentSegmentGeneration(files);
						
						Lucene.Net.Index.SegmentInfos.Message("directory listing genA=" + genA);
						
						// Method 2: open segments.gen and read its
						// contents.  Then we take the larger of the two
						// gen's.  This way, if either approach is hitting
						// a stale cache (NFS) we have a better chance of
						// getting the right generation.
						long genB = - 1;
						for (int i = 0; i < Lucene.Net.Index.SegmentInfos.defaultGenFileRetryCount; i++)
						{
							IndexInput genInput = null;
							try
							{
								genInput = directory.OpenInput(IndexFileNames.SEGMENTS_GEN);
							}
							catch (System.IO.FileNotFoundException e)
							{
								Lucene.Net.Index.SegmentInfos.Message("segments.gen open: FileNotFoundException " + e);
								break;
							}
							catch (System.IO.IOException e)
							{
								Lucene.Net.Index.SegmentInfos.Message("segments.gen open: IOException " + e);
							}
							
							if (genInput != null)
							{
								try
								{
									int version = genInput.ReadInt();
									if (version == Lucene.Net.Index.SegmentInfos.FORMAT_LOCKLESS)
									{
										long gen0 = genInput.ReadLong();
										long gen1 = genInput.ReadLong();
										Lucene.Net.Index.SegmentInfos.Message("fallback check: " + gen0 + "; " + gen1);
										if (gen0 == gen1)
										{
											// The file is consistent.
											genB = gen0;
											break;
										}
									}
								}
								catch (System.IO.IOException err2)
								{
									// will retry
								}
//.........这里部分代码省略.........
开发者ID:VirtueMe,项目名称:ravendb,代码行数:101,代码来源:SegmentInfos.cs

示例10: Open

 internal static IndexReader Open(Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, bool readOnly, int termInfosIndexDivisor)
 {
     return (IndexReader) new AnonymousClassFindSegmentsFile(readOnly, deletionPolicy, termInfosIndexDivisor, directory).Run(commit);
 }
开发者ID:synhershko,项目名称:lucene.net,代码行数:4,代码来源:DirectoryReader.cs

示例11: Release

 /// <summary>
 /// Deletes a snapshotted commit. Once this method returns, the snapshot
 /// information is persisted in the directory.
 /// </summary>
 /// <seealso cref= SnapshotDeletionPolicy#release </seealso>
 public override void Release(IndexCommit commit)
 {
     lock (this)
     {
         base.Release(commit);
         bool success = false;
         try
         {
             Persist();
             success = true;
         }
         finally
         {
             if (!success)
             {
                 try
                 {
                     IncRef(commit);
                 }
                 catch (Exception e)
                 {
                     // Suppress so we keep throwing original exception
                 }
             }
         }
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:32,代码来源:PersistentSnapshotDeletionPolicy.cs

示例12: Open

		public static IndexReader Open(IndexCommit commit)
		{
			return Open(commit.GetDirectory(), null, commit, false, DEFAULT_TERMS_INDEX_DIVISOR);
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:4,代码来源:IndexReader.cs

示例13: SetIndexCommit

 /// <summary>
 /// Expert: allows to open a certain commit point. The default is null which
 /// opens the latest commit point.
 ///
 /// <p>Only takes effect when IndexWriter is first created.
 /// </summary>
 public IndexWriterConfig SetIndexCommit(IndexCommit commit)
 {
     this.Commit = commit;
     return this;
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:11,代码来源:IndexWriterConfig.cs

示例14: DoReopenNoWriter

        private IndexReader DoReopenNoWriter(bool openReadOnly, IndexCommit commit)
        {
            lock (this)
            {
                if (commit == null)
                {
                    if (hasChanges)
                    {
                        // We have changes, which means we are not readOnly:
                        System.Diagnostics.Debug.Assert(readOnly == false);
                        // and we hold the write lock:
                        System.Diagnostics.Debug.Assert(writeLock != null);
                        // so no other writer holds the write lock, which
                        // means no changes could have been done to the index:
                        System.Diagnostics.Debug.Assert(IsCurrent());

                        if (openReadOnly)
                        {
                            return Clone(openReadOnly);
                        }
                        else
                        {
                            return this;
                        }
                    }
                    else if (IsCurrent())
                    {
                        if (openReadOnly != readOnly)
                        {
                            // Just fallback to clone
                            return Clone(openReadOnly);
                        }
                        else
                        {
                            return this;
                        }
                    }
                }
                else
                {
                    if (internalDirectory != commit.Directory)
                        throw new System.IO.IOException("the specified commit does not match the specified Directory");
                    if (segmentInfos != null && commit.SegmentsFileName.Equals(segmentInfos.GetCurrentSegmentFileName()))
                    {
                        if (readOnly != openReadOnly)
                        {
                            // Just fallback to clone
                            return Clone(openReadOnly);
                        }
                        else
                        {
                            return this;
                        }
                    }
                }

                return (IndexReader)new AnonymousFindSegmentsFile(internalDirectory, openReadOnly, this).Run(commit);
            }
        }
开发者ID:synhershko,项目名称:lucene.net,代码行数:59,代码来源:DirectoryReader.cs

示例15: DoOpenIfChanged

 protected internal override sealed DirectoryReader DoOpenIfChanged(IndexCommit commit)
 {
     return WrapDirectoryReader(@in.DoOpenIfChanged(commit));
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:4,代码来源:FilterDirectoryReader.cs


注:本文中的Lucene.Net.Index.IndexCommit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。