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


C# AtomicReader.Clone方法代码示例

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


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

示例1: ParallelAtomicReader

        /// <summary>
        /// Expert: create a ParallelAtomicReader based on the provided
        ///  readers and storedFieldReaders; when a document is
        ///  loaded, only storedFieldsReaders will be used.
        /// </summary>
        public ParallelAtomicReader(bool closeSubReaders, AtomicReader[] readers, AtomicReader[] storedFieldsReaders)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            this.CloseSubReaders = closeSubReaders;
            if (readers.Length == 0 && storedFieldsReaders.Length > 0)
            {
                throw new System.ArgumentException("There must be at least one main reader if storedFieldsReaders are used.");
            }
            this.ParallelReaders = (AtomicReader[])readers.Clone();
            this.StoredFieldsReaders = (AtomicReader[])storedFieldsReaders.Clone();
            if (ParallelReaders.Length > 0)
            {
                AtomicReader first = ParallelReaders[0];
                this.maxDoc = first.MaxDoc;
                this.numDocs = first.NumDocs;
                this.hasDeletions = first.HasDeletions;
            }
            else
            {
                this.maxDoc = this.numDocs = 0;
                this.hasDeletions = false;
            }
            CollectionsHelper.AddAll(CompleteReaderSet, this.ParallelReaders);
            CollectionsHelper.AddAll(CompleteReaderSet, this.StoredFieldsReaders);

            // check compatibility:
            foreach (AtomicReader reader in CompleteReaderSet)
            {
                if (reader.MaxDoc != maxDoc)
                {
                    throw new System.ArgumentException("All readers must have same maxDoc: " + maxDoc + "!=" + reader.MaxDoc);
                }
            }

            // TODO: make this read-only in a cleaner way?
            FieldInfos.Builder builder = new FieldInfos.Builder();
            // build FieldInfos and fieldToReader map:
            foreach (AtomicReader reader in this.ParallelReaders)
            {
                FieldInfos readerFieldInfos = reader.FieldInfos;
                foreach (FieldInfo fieldInfo in readerFieldInfos)
                {
                    // NOTE: first reader having a given field "wins":
                    if (!FieldToReader.ContainsKey(fieldInfo.Name))
                    {
                        builder.Add(fieldInfo);
                        FieldToReader[fieldInfo.Name] = reader;
                        if (fieldInfo.HasVectors())
                        {
                            TvFieldToReader[fieldInfo.Name] = reader;
                        }
                    }
                }
            }
            FieldInfos_Renamed = builder.Finish();

            // build Fields instance
            foreach (AtomicReader reader in this.ParallelReaders)
            {
                Fields readerFields = reader.Fields;
                if (readerFields != null)
                {
                    foreach (string field in readerFields)
                    {
                        // only add if the reader responsible for that field name is the current:
                        if (FieldToReader[field].Equals(reader))
                        {
                            this.Fields_Renamed.AddField(field, readerFields.Terms(field));
                        }
                    }
                }
            }

            // do this finally so any Exceptions occurred before don't affect refcounts:
            foreach (AtomicReader reader in CompleteReaderSet)
            {
                if (!closeSubReaders)
                {
                    reader.IncRef();
                }
                reader.RegisterParentReader(this);
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:92,代码来源:ParallelAtomicReader.cs


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