Lucene.Net.Index.TestBinaryDocValuesUpdates.TestUpdateDifferentDocsInDifferentGens C# (CSharp) Method

TestUpdateDifferentDocsInDifferentGens() private method

private TestUpdateDifferentDocsInDifferentGens ( ) : void
return void
        public virtual void TestUpdateDifferentDocsInDifferentGens()
        {
            // update same document multiple times across generations
            Directory dir = NewDirectory();
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            conf.SetMaxBufferedDocs(4);
            IndexWriter writer = new IndexWriter(dir, conf);
            int numDocs = AtLeast(10);
            for (int i = 0; i < numDocs; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("id", "doc" + i, Store.NO));
                long value = Random().Next();
                doc.Add(new BinaryDocValuesField("f", ToBytes(value)));
                doc.Add(new BinaryDocValuesField("cf", ToBytes(value * 2)));
                writer.AddDocument(doc);
            }

            int numGens = AtLeast(5);
            BytesRef scratch = new BytesRef();
            for (int i = 0; i < numGens; i++)
            {
                int doc = Random().Next(numDocs);
                Term t = new Term("id", "doc" + doc);
                long value = Random().NextLong();
                writer.UpdateBinaryDocValue(t, "f", ToBytes(value));
                writer.UpdateBinaryDocValue(t, "cf", ToBytes(value * 2));
                DirectoryReader reader = DirectoryReader.Open(writer, true);
                foreach (AtomicReaderContext context in reader.Leaves)
                {
                    AtomicReader r = context.AtomicReader;
                    BinaryDocValues fbdv = r.GetBinaryDocValues("f");
                    BinaryDocValues cfbdv = r.GetBinaryDocValues("cf");
                    for (int j = 0; j < r.MaxDoc; j++)
                    {
                        Assert.AreEqual(GetValue(cfbdv, j, scratch), GetValue(fbdv, j, scratch) * 2);
                    }
                }
                reader.Dispose();
            }
            writer.Dispose();
            dir.Dispose();
        }