本文整理汇总了C#中FieldInfo.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# FieldInfo.GetAttribute方法的具体用法?C# FieldInfo.GetAttribute怎么用?C# FieldInfo.GetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.GetAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: GetSorted
public override SortedDocValues GetSorted(FieldInfo field)
{
lock (this)
{
SortedDocValues instance;
if (!SortedInstances.TryGetValue(field.Number, out instance))
{
string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "idx");
IndexInput data = null;
IndexInput index = null;
bool success = false;
try
{
data = Dir.OpenInput(dataName, State.Context);
index = Dir.OpenInput(indexName, State.Context);
var type = LegacyDocValuesType.ValueOf(field.GetAttribute(LegacyKey));
if (type == LegacyDocValuesType.BYTES_FIXED_SORTED)
{
instance = LoadBytesFixedSorted(field, data, index);
}
else if (type == LegacyDocValuesType.BYTES_VAR_SORTED)
{
instance = LoadBytesVarSorted(field, data, index);
}
else
{
throw new InvalidOperationException();
}
CodecUtil.CheckEOF(data);
CodecUtil.CheckEOF(index);
success = true;
}
finally
{
if (success)
{
IOUtils.Close(data, index);
}
else
{
IOUtils.CloseWhileHandlingException(data, index);
}
}
SortedInstances[field.Number] = instance;
}
return instance;
}
}
示例3: GetNumeric
public override NumericDocValues GetNumeric(FieldInfo field)
{
lock (this)
{
NumericDocValues instance;
if (!NumericInstances.TryGetValue(field.Number, out instance))
{
string fileName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
IndexInput input = Dir.OpenInput(fileName, State.Context);
bool success = false;
try
{
var type = LegacyDocValuesType.ValueOf(field.GetAttribute(LegacyKey));
//switch (Enum.Parse(typeof(LegacyDocValuesType), field.GetAttribute(LegacyKey)))
//{
if (type == LegacyDocValuesType.VAR_INTS)
{
instance = LoadVarIntsField(field, input);
}
else if (type == LegacyDocValuesType.FIXED_INTS_8)
{
instance = LoadByteField(field, input);
}
else if (type == LegacyDocValuesType.FIXED_INTS_16)
{
instance = LoadShortField(field, input);
}
else if (type == LegacyDocValuesType.FIXED_INTS_32)
{
instance = LoadIntField(field, input);
}
else if (type == LegacyDocValuesType.FIXED_INTS_64)
{
instance = LoadLongField(field, input);
}
else if (type == LegacyDocValuesType.FLOAT_32)
{
instance = LoadFloatField(field, input);
}
else if (type == LegacyDocValuesType.FLOAT_64)
{
instance = LoadDoubleField(field, input);
}
else
{
throw new InvalidOperationException();
}
CodecUtil.CheckEOF(input);
success = true;
}
finally
{
if (success)
{
IOUtils.Close(input);
}
else
{
IOUtils.CloseWhileHandlingException(input);
}
}
NumericInstances[field.Number] = instance;
}
return instance;
}
}
示例4: GetBinary
public override BinaryDocValues GetBinary(FieldInfo field)
{
lock (this)
{
BinaryDocValues instance;
if (!BinaryInstances.TryGetValue(field.Number, out instance))
{
var type = LegacyDocValuesType.ValueOf(field.GetAttribute(LegacyKey));
if (type == LegacyDocValuesType.BYTES_FIXED_STRAIGHT)
{
instance = LoadBytesFixedStraight(field);
}
else if (type == LegacyDocValuesType.BYTES_VAR_STRAIGHT)
{
instance = LoadBytesVarStraight(field);
}
else if (type == LegacyDocValuesType.BYTES_FIXED_DEREF)
{
instance = LoadBytesFixedDeref(field);
}
else if (type == LegacyDocValuesType.BYTES_VAR_DEREF)
{
instance = LoadBytesVarDeref(field);
}
else
{
throw new InvalidOperationException();
}
BinaryInstances[field.Number] = instance;
}
return instance;
}
}