Lucene.Net.Index.TestBinaryDocValuesUpdates.TestMultipleBinaryDocValues C# (CSharp) Метод

TestMultipleBinaryDocValues() приватный Метод

private TestMultipleBinaryDocValues ( ) : void
Результат void
        public virtual void TestMultipleBinaryDocValues()
        {
            Directory dir = NewDirectory();
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            conf.SetMaxBufferedDocs(10); // prevent merges
            IndexWriter writer = new IndexWriter(dir, conf);

            for (int i = 0; i < 2; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("dvUpdateKey", "dv", Store.NO));
                doc.Add(new BinaryDocValuesField("bdv1", ToBytes(i)));
                doc.Add(new BinaryDocValuesField("bdv2", ToBytes(i)));
                writer.AddDocument(doc);
            }
            writer.Commit();

            // update all docs' bdv1 field
            writer.UpdateBinaryDocValue(new Term("dvUpdateKey", "dv"), "bdv1", ToBytes(17L));
            writer.Dispose();

            DirectoryReader reader = DirectoryReader.Open(dir);
            AtomicReader r = (AtomicReader)reader.Leaves[0].Reader;

            BinaryDocValues bdv1 = r.GetBinaryDocValues("bdv1");
            BinaryDocValues bdv2 = r.GetBinaryDocValues("bdv2");
            BytesRef scratch = new BytesRef();
            for (int i = 0; i < r.MaxDoc; i++)
            {
                Assert.AreEqual(17, GetValue(bdv1, i, scratch));
                Assert.AreEqual(i, GetValue(bdv2, i, scratch));
            }

            reader.Dispose();
            dir.Dispose();
        }