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


C# FieldInfo.PutAttribute方法代码示例

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


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

示例1: GetInstance

            internal virtual DocValuesConsumer GetInstance(FieldInfo field)
            {
                DocValuesFormat format = null;
                if (field.DocValuesGen != -1)
                {
                    string formatName = field.GetAttribute(PER_FIELD_FORMAT_KEY);
                    // this means the field never existed in that segment, yet is applied updates
                    if (formatName != null)
                    {
                        format = DocValuesFormat.ForName(formatName);
                    }
                }
                if (format == null)
                {
                    format = OuterInstance.GetDocValuesFormatForField(field.Name);
                }
                if (format == null)
                {
                    throw new InvalidOperationException("invalid null DocValuesFormat for field=\"" + field.Name + "\"");
                }
                string formatName_ = format.Name;

                string previousValue = field.PutAttribute(PER_FIELD_FORMAT_KEY, formatName_);
                Debug.Assert(field.DocValuesGen != -1 || previousValue == null, "formatName=" + formatName_ + " prevValue=" + previousValue);

                int suffix = -1;

                ConsumerAndSuffix consumer;
                Formats.TryGetValue(format, out consumer);
                if (consumer == null)
                {
                    // First time we are seeing this format; create a new instance

                    if (field.DocValuesGen != -1)
                    {
                        string suffixAtt = field.GetAttribute(PER_FIELD_SUFFIX_KEY);
                        // even when dvGen is != -1, it can still be a new field, that never
                        // existed in the segment, and therefore doesn't have the recorded
                        // attributes yet.
                        if (suffixAtt != null)
                        {
                            suffix = Convert.ToInt32(suffixAtt);
                        }
                    }

                    if (suffix == -1)
                    {
                        // bump the suffix
                        if (!Suffixes.TryGetValue(formatName_, out suffix))
                        {
                            suffix = 0;
                        }
                        else
                        {
                            suffix = suffix + 1;
                        }
                    }
                    Suffixes[formatName_] = suffix;

                    string segmentSuffix = GetFullSegmentSuffix(SegmentWriteState.SegmentSuffix, GetSuffix(formatName_, Convert.ToString(suffix)));
                    consumer = new ConsumerAndSuffix();
                    consumer.Consumer = format.FieldsConsumer(new SegmentWriteState(SegmentWriteState, segmentSuffix));
                    consumer.Suffix = suffix;
                    Formats[format] = consumer;
                }
                else
                {
                    // we've already seen this format, so just grab its suffix
                    Debug.Assert(Suffixes.ContainsKey(formatName_));
                    suffix = consumer.Suffix;
                }

                previousValue = field.PutAttribute(PER_FIELD_SUFFIX_KEY, Convert.ToString(suffix));
                Debug.Assert(field.DocValuesGen != -1 || previousValue == null, "suffix=" + Convert.ToString(suffix) + " prevValue=" + previousValue);

                // TODO: we should only provide the "slice" of FIS
                // that this DVF actually sees ...
                return consumer.Consumer;
            }
开发者ID:joyanta,项目名称:lucene.net,代码行数:79,代码来源:PerFieldDocValuesFormat.cs

示例2: AddField

            public override TermsConsumer AddField(FieldInfo field)
            {
                PostingsFormat format = OuterInstance.GetPostingsFormatForField(field.Name);
                if (format == null)
                {
                    throw new InvalidOperationException("invalid null PostingsFormat for field=\"" + field.Name + "\"");
                }
                string formatName = format.Name;

                string previousValue = field.PutAttribute(PER_FIELD_FORMAT_KEY, formatName);
                //Debug.Assert(previousValue == null);

                int suffix;

                FieldsConsumerAndSuffix consumer;
                Formats.TryGetValue(format, out consumer);
                if (consumer == null)
                {
                    // First time we are seeing this format; create a new instance

                    // bump the suffix
                    if (!Suffixes.TryGetValue(formatName, out suffix))
                    {
                        suffix = 0;
                    }
                    else
                    {
                        suffix = suffix + 1;
                    }
                    Suffixes[formatName] = suffix;

                    string segmentSuffix = GetFullSegmentSuffix(field.Name, SegmentWriteState.SegmentSuffix, GetSuffix(formatName, Convert.ToString(suffix)));
                    consumer = new FieldsConsumerAndSuffix();
                    consumer.Consumer = format.FieldsConsumer(new SegmentWriteState(SegmentWriteState, segmentSuffix));
                    consumer.Suffix = suffix;
                    Formats[format] = consumer;
                }
                else
                {
                    // we've already seen this format, so just grab its suffix
                    Debug.Assert(Suffixes.ContainsKey(formatName));
                    suffix = consumer.Suffix;
                }

                previousValue = field.PutAttribute(PER_FIELD_SUFFIX_KEY, Convert.ToString(suffix));
                //Debug.Assert(previousValue == null);

                // TODO: we should only provide the "slice" of FIS
                // that this PF actually sees ... then stuff like
                // .hasProx could work correctly?
                // NOTE: .hasProx is already broken in the same way for the non-perfield case,
                // if there is a fieldinfo with prox that has no postings, you get a 0 byte file.
                return consumer.Consumer.AddField(field);
            }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:54,代码来源:PerFieldPostingsFormat.cs


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