Inheritance: Lucene.Net.Util.LuceneTestCase
Example #1
0
 public override void Run()
 {
     try
     {
         while (run)
         {
             //int n = random.nextInt(2);
             if (type == 0)
             {
                 int      i   = outerInstance.seq.AddAndGet(1);
                 Document doc = DocHelper.CreateDocument(i, "index1", 10);
                 writer.AddDocument(doc);
                 addCount++;
             }
             else if (type == 1)
             {
                 // we may or may not delete because the term may not exist,
                 // however we're opening and closing the reader rapidly
                 IndexReader reader = writer.GetReader();
                 int         id     = r.Next(outerInstance.seq);
                 Term        term   = new Term("id", Convert.ToString(id));
                 int         count  = TestIndexWriterReader.Count(term, reader);
                 writer.DeleteDocuments(term);
                 reader.Dispose();
                 delCount += count;
             }
         }
     }
     catch (Exception ex) when(ex.IsThrowable())
     {
         Console.WriteLine(ex.StackTrace);
         this.ex = ex;
         run     = false;
     }
 }
 override public void  Run()
 {
     try
     {
         while (run_Renamed_Field)
         {
             //int n = random.nextInt(2);
             if (type == 0)
             {
                 int      i   = Enclosing_Instance.seq.AddAndGet(1);
                 Document doc = TestIndexWriterReader.CreateDocument(i, "index1", 10);
                 writer.AddDocument(doc);
                 addCount++;
             }
             else if (type == 1)
             {
                 // we may or may not delete because the term may not exist,
                 // however we're opening and closing the reader rapidly
                 IndexReader reader = writer.GetReader();
                 int         id     = Enclosing_Instance.random.Next(Enclosing_Instance.seq.IntValue());
                 Term        term   = new Term("id", System.Convert.ToString(id));
                 int         count  = TestIndexWriterReader.Count(term, reader);
                 writer.DeleteDocuments(term);
                 reader.Close();
                 delCount += count;
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.Out.WriteLine(ex.StackTrace);
         this.ex           = ex;
         run_Renamed_Field = false;
     }
 }
 private void  InitBlock(long endTime, Lucene.Net.Index.IndexWriter writer, Lucene.Net.Store.Directory[] dirs, System.Collections.IList excs, TestIndexWriterReader enclosingInstance)
 {
     this.endTime = endTime;
     this.writer = writer;
     this.dirs = dirs;
     this.excs = excs;
     this.enclosingInstance = enclosingInstance;
 }
Example #4
0
            public DeleteThreads(TestIndexWriterReader enclosingInstance, IndexWriter mainWriter)
            {
                InitBlock(enclosingInstance);
                this.mainWriter = mainWriter;
                IndexReader reader = mainWriter.GetReader();
                int         maxDoc = reader.MaxDoc();

                random = Enclosing_Instance.NewRandom();
                int iter = random.Next(maxDoc);

                for (int x = 0; x < iter; x++)
                {
                    int           doc = random.Next(iter);
                    System.String id  = reader.Document(doc).Get("id");
                    toDeleteTerms.Add(new Term("id", id));
                }
            }
Example #5
0
            public AddDirectoriesThreads(TestIndexWriterReader enclosingInstance, int numDirs, IndexWriter mainWriter)
            {
                InitBlock(enclosingInstance);
                this.numDirs    = numDirs;
                this.mainWriter = mainWriter;
                addDir          = new MockRAMDirectory();
                IndexWriter writer = new IndexWriter(addDir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);

                writer.SetMaxBufferedDocs(2);
                for (int i = 0; i < NUM_INIT_DOCS; i++)
                {
                    Document doc = Lucene.Net.Index.TestIndexWriterReader.CreateDocument(i, "addindex", 4);
                    writer.AddDocument(doc);
                }

                writer.Close();

                readers = new IndexReader[numDirs];
                for (int i = 0; i < numDirs; i++)
                {
                    readers[i] = IndexReader.Open(addDir);
                }
            }
Example #6
0
 private void  InitBlock(TestIndexWriterReader enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
     threads = new SupportClass.ThreadClass[NUM_THREADS];
 }
 public AnonymousClassThread1(long endTime, Lucene.Net.Index.IndexWriter writer, System.Collections.IList excs, TestIndexWriterReader enclosingInstance)
 {
     InitBlock(endTime, writer, excs, enclosingInstance);
 }
 public InfoStreamAnonymousInnerClassHelper(TestIndexWriterReader outerInstance, AtomicBoolean didWarm)
 {
     this.OuterInstance = outerInstance;
     this.DidWarm = didWarm;
 }
 private void  InitBlock(TestIndexWriterReader enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
     threads = new ThreadClass[NUM_THREADS];
 }
 public DeleteThreads(TestIndexWriterReader enclosingInstance, IndexWriter mainWriter)
 {
     InitBlock(enclosingInstance);
     this.mainWriter = mainWriter;
     IndexReader reader = mainWriter.GetReader();
     int maxDoc = reader.MaxDoc;
     random = Enclosing_Instance.NewRandom();
     int iter = random.Next(maxDoc);
     for (int x = 0; x < iter; x++)
     {
         int doc = random.Next(iter);
         System.String id = reader.Document(doc).Get("id");
         toDeleteTerms.Add(new Term("id", id));
     }
 }
 public ThreadAnonymousInnerClassHelper(TestIndexWriterReader outerInstance, IndexWriter writer, Directory[] dirs, long endTime, IList<Exception> excs)
 {
     this.OuterInstance = outerInstance;
     this.Writer = writer;
     this.Dirs = dirs;
     this.EndTime = endTime;
     this.Excs = excs;
 }
            public AddDirectoriesThreads(TestIndexWriterReader outerInstance, int numDirs, IndexWriter mainWriter)
            {
                this.OuterInstance = outerInstance;

                if (!InstanceFieldsInitialized)
                {
                    InitializeInstanceFields();
                    InstanceFieldsInitialized = true;
                }
                this.NumDirs = numDirs;
                this.MainWriter = mainWriter;
                AddDir = NewDirectory();
                IndexWriter writer = new IndexWriter(AddDir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2));
                TestUtil.ReduceOpenFiles(writer);
                for (int i = 0; i < NUM_INIT_DOCS; i++)
                {
                    Document doc = DocHelper.CreateDocument(i, "addindex", 4);
                    writer.AddDocument(doc);
                }

                writer.Dispose();

                Readers = new IndexReader[numDirs];
                for (int i = 0; i < numDirs; i++)
                {
                    Readers[i] = DirectoryReader.Open(AddDir);
                }
            }
 public FailureAnonymousInnerClassHelper(TestIndexWriterReader outerInstance, MockDirectoryWrapper dir, AtomicBoolean shouldFail)
 {
     this.OuterInstance = outerInstance;
     this.Dir = dir;
     this.ShouldFail = shouldFail;
 }
Example #14
0
 public AnonymousClassThread1(long endTime, Lucene.Net.Index.IndexWriter writer, System.Collections.IList excs, TestIndexWriterReader enclosingInstance)
 {
     InitBlock(endTime, writer, excs, enclosingInstance);
 }
 public AddDirectoriesThreads(TestIndexWriterReader enclosingInstance, int numDirs, IndexWriter mainWriter)
 {
     InitBlock(enclosingInstance);
     this.numDirs = numDirs;
     this.mainWriter = mainWriter;
     addDir = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(addDir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
     writer.SetMaxBufferedDocs(2);
     for (int i = 0; i < NUM_INIT_DOCS; i++)
     {
         Document doc = Lucene.Net.Index.TestIndexWriterReader.CreateDocument(i, "addindex", 4);
         writer.AddDocument(doc);
     }
     
     writer.Close();
     
     readers = new IndexReader[numDirs];
     for (int i = 0; i < numDirs; i++)
         readers[i] = IndexReader.Open(addDir, false);
 }
Example #16
0
 private void  InitBlock(long endTime, Lucene.Net.Index.IndexWriter writer, System.Collections.IList excs, TestIndexWriterReader enclosingInstance)
 {
     this.endTime           = endTime;
     this.writer            = writer;
     this.excs              = excs;
     this.enclosingInstance = enclosingInstance;
 }
 public ThreadAnonymousInnerClassHelper2(TestIndexWriterReader outerInstance, IndexWriter writer, DirectoryReader r, long endTime, IList<Exception> excs)
 {
     this.OuterInstance = outerInstance;
     this.Writer = writer;
     this.r = r;
     this.EndTime = endTime;
     this.Excs = excs;
     rand = new Random(Random().Next());
 }