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


C# IndexWriter.PrepareCommit方法代码示例

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


在下文中一共展示了IndexWriter.PrepareCommit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoWork

            public override void DoWork()
            {
                IndexWriter writer1 = new IndexWriter(Dir1, ((IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(3)).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(2)));
                ((ConcurrentMergeScheduler)writer1.Config.MergeScheduler).SetSuppressExceptions();

                // Intentionally use different params so flush/merge
                // happen @ different times
                IndexWriter writer2 = new IndexWriter(Dir2, ((IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2)).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(3)));
                ((ConcurrentMergeScheduler)writer2.Config.MergeScheduler).SetSuppressExceptions();

                Update(writer1);
                Update(writer2);

                DoFail = true;
                try
                {
                    lock (@lock)
                    {
                        try
                        {
                            writer1.PrepareCommit();
                        }
                        catch (Exception t)
                        {
                            writer1.Rollback();
                            writer2.Rollback();
                            return;
                        }
                        try
                        {
                            writer2.PrepareCommit();
                        }
                        catch (Exception t)
                        {
                            writer1.Rollback();
                            writer2.Rollback();
                            return;
                        }

                        writer1.Commit();
                        writer2.Commit();
                    }
                }
                finally
                {
                    DoFail = false;
                }

                writer1.Dispose();
                writer2.Dispose();
            }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:51,代码来源:TestTransactions.cs

示例2: DoWork

			public override void  DoWork()
			{
				
				IndexWriter writer1 = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
				writer1.SetMaxBufferedDocs(3);
				writer1.MergeFactor = 2;
				((ConcurrentMergeScheduler) writer1.MergeScheduler).SetSuppressExceptions();
				
				IndexWriter writer2 = new IndexWriter(dir2, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
				// Intentionally use different params so flush/merge
				// happen @ different times
				writer2.SetMaxBufferedDocs(2);
				writer2.MergeFactor = 3;
				((ConcurrentMergeScheduler) writer2.MergeScheduler).SetSuppressExceptions();
				
				Update(writer1);
				Update(writer2);
				
				TestTransactions.doFail = true;
				try
				{
					lock (lock_Renamed)
					{
						try
						{
							writer1.PrepareCommit();
						}
						catch (System.Exception t)
						{
							writer1.Rollback();
							writer2.Rollback();
							return ;
						}
						try
						{
							writer2.PrepareCommit();
						}
						catch (System.Exception t)
						{
							writer1.Rollback();
							writer2.Rollback();
							return ;
						}
						
						writer1.Commit();
						writer2.Commit();
					}
				}
				finally
				{
					TestTransactions.doFail = false;
				}
				
				writer1.Close();
				writer2.Close();
			}
开发者ID:synhershko,项目名称:lucene.net,代码行数:56,代码来源:TestTransactions.cs

示例3: TestPrepareCommitRollback

        public virtual void TestPrepareCommitRollback()
        {
            Directory dir = NewDirectory();
            if (dir is MockDirectoryWrapper)
            {
                ((MockDirectoryWrapper)dir).PreventDoubleWrite = false;
            }

            IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy(5)));
            writer.Commit();

            for (int i = 0; i < 23; i++)
            {
                TestIndexWriter.AddDoc(writer);
            }

            DirectoryReader reader = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader.NumDocs);

            writer.PrepareCommit();

            IndexReader reader2 = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader2.NumDocs);

            writer.Rollback();

            IndexReader reader3 = DirectoryReader.OpenIfChanged(reader);
            Assert.IsNull(reader3);
            Assert.AreEqual(0, reader.NumDocs);
            Assert.AreEqual(0, reader2.NumDocs);
            reader.Dispose();
            reader2.Dispose();

            writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
            for (int i = 0; i < 17; i++)
            {
                TestIndexWriter.AddDoc(writer);
            }

            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader.NumDocs);
            reader.Dispose();

            writer.PrepareCommit();

            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader.NumDocs);
            reader.Dispose();

            writer.Commit();
            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(17, reader.NumDocs);
            reader.Dispose();
            writer.Dispose();
            dir.Dispose();
        }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:56,代码来源:TestIndexWriterCommit.cs

示例4: TestPrepareCommitNoChanges

        public virtual void TestPrepareCommitNoChanges()
        {
            Directory dir = NewDirectory();

            IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
            writer.PrepareCommit();
            writer.Commit();
            writer.Dispose();

            IndexReader reader = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader.NumDocs);
            reader.Dispose();
            dir.Dispose();
        }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:14,代码来源:TestIndexWriterCommit.cs

示例5: TestPrepareCommit

        public virtual void TestPrepareCommit()
        {
            Directory dir = NewDirectory();

            IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy(5)));
            writer.Commit();

            for (int i = 0; i < 23; i++)
            {
                TestIndexWriter.AddDoc(writer);
            }

            DirectoryReader reader = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader.NumDocs);

            writer.PrepareCommit();

            IndexReader reader2 = DirectoryReader.Open(dir);
            Assert.AreEqual(0, reader2.NumDocs);

            writer.Commit();

            IndexReader reader3 = DirectoryReader.OpenIfChanged(reader);
            Assert.IsNotNull(reader3);
            Assert.AreEqual(0, reader.NumDocs);
            Assert.AreEqual(0, reader2.NumDocs);
            Assert.AreEqual(23, reader3.NumDocs);
            reader.Dispose();
            reader2.Dispose();

            for (int i = 0; i < 17; i++)
            {
                TestIndexWriter.AddDoc(writer);
            }

            Assert.AreEqual(23, reader3.NumDocs);
            reader3.Dispose();
            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(23, reader.NumDocs);
            reader.Dispose();

            writer.PrepareCommit();

            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(23, reader.NumDocs);
            reader.Dispose();

            writer.Commit();
            reader = DirectoryReader.Open(dir);
            Assert.AreEqual(40, reader.NumDocs);
            reader.Dispose();
            writer.Dispose();
            dir.Dispose();
        }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:54,代码来源:TestIndexWriterCommit.cs

示例6: TestPrepareCommitIsCurrent

 public virtual void TestPrepareCommitIsCurrent()
 {
     Directory dir = NewDirectory();
     IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
     writer.Commit();
     Document doc = new Document();
     writer.AddDocument(doc);
     DirectoryReader r = DirectoryReader.Open(dir);
     Assert.IsTrue(r.Current);
     writer.AddDocument(doc);
     writer.PrepareCommit();
     Assert.IsTrue(r.Current);
     DirectoryReader r2 = DirectoryReader.OpenIfChanged(r);
     Assert.IsNull(r2);
     writer.Commit();
     Assert.IsFalse(r.Current);
     writer.Dispose();
     r.Dispose();
     dir.Dispose();
 }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:20,代码来源:TestDirectoryReader.cs

示例7: TestPrepareCommitIsCurrent

 public void TestPrepareCommitIsCurrent()
 {
     Directory dir = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
     Document doc = new Document();
     writer.AddDocument(doc);
     IndexReader r = IndexReader.Open(dir, true);
     Assert.IsTrue(r.IsCurrent());
     writer.AddDocument(doc);
     writer.PrepareCommit();
     Assert.IsTrue(r.IsCurrent());
     IndexReader r2 = r.Reopen();
     Assert.IsTrue(r == r2);
     writer.Commit();
     Assert.IsFalse(r.IsCurrent());
     writer.Close();
     r.Close();
     dir.Close();
 }
开发者ID:raol,项目名称:lucene.net,代码行数:19,代码来源:TestIndexReader.cs

示例8: TestPrepareCommitNoChanges

		public virtual void  TestPrepareCommitNoChanges()
		{
			MockRAMDirectory dir = new MockRAMDirectory();
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			writer.PrepareCommit();
			writer.Commit();
			writer.Close();
			
			IndexReader reader = IndexReader.Open(dir);
			Assert.AreEqual(0, reader.NumDocs());
			reader.Close();
			dir.Close();
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:14,代码来源:TestIndexWriter.cs

示例9: TestPrepareCommitRollback

		public virtual void  TestPrepareCommitRollback()
		{
			MockRAMDirectory dir = new MockRAMDirectory();
			dir.SetPreventDoubleWrite(false);
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			
			writer.SetMaxBufferedDocs(2);
			writer.SetMergeFactor(5);
			
			for (int i = 0; i < 23; i++)
				AddDoc(writer);
			
			IndexReader reader = IndexReader.Open(dir);
			Assert.AreEqual(0, reader.NumDocs());
			
			writer.PrepareCommit();
			
			IndexReader reader2 = IndexReader.Open(dir);
			Assert.AreEqual(0, reader2.NumDocs());
			
			writer.Rollback();
			
			IndexReader reader3 = reader.Reopen();
			Assert.AreEqual(0, reader.NumDocs());
			Assert.AreEqual(0, reader2.NumDocs());
			Assert.AreEqual(0, reader3.NumDocs());
			reader.Close();
			reader2.Close();
			
			writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			for (int i = 0; i < 17; i++)
				AddDoc(writer);
			
			Assert.AreEqual(0, reader3.NumDocs());
			reader3.Close();
			reader = IndexReader.Open(dir);
			Assert.AreEqual(0, reader.NumDocs());
			reader.Close();
			
			writer.PrepareCommit();
			
			reader = IndexReader.Open(dir);
			Assert.AreEqual(0, reader.NumDocs());
			reader.Close();
			
			writer.Commit();
			reader = IndexReader.Open(dir);
			Assert.AreEqual(17, reader.NumDocs());
			reader.Close();
			writer.Close();
			dir.Close();
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:53,代码来源:TestIndexWriter.cs


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