Ejemplo n.º 1
0
            internal FieldsReader(PerFieldDocValuesFormat outerInstance, FieldsReader other)
            {
                this.outerInstance = outerInstance;

                IDictionary <DocValuesProducer, DocValuesProducer> oldToNew = new JCG.Dictionary <DocValuesProducer, DocValuesProducer>(IdentityEqualityComparer <DocValuesProducer> .Default);

                // First clone all formats
                foreach (KeyValuePair <string, DocValuesProducer> ent in other.formats)
                {
                    DocValuesProducer values = ent.Value;
                    formats[ent.Key]    = values;
                    oldToNew[ent.Value] = values;
                }

                // Then rebuild fields:
                foreach (KeyValuePair <string, DocValuesProducer> ent in other.fields)
                {
                    oldToNew.TryGetValue(ent.Value, out DocValuesProducer producer);
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(producer != null);
                    }
                    fields[ent.Key] = producer;
                }
            }
Ejemplo n.º 2
0
            public FieldsReader(PerFieldDocValuesFormat outerInstance, SegmentReadState readState)
            {
                this.outerInstance = outerInstance;

                // Read _X.per and init each format:
                bool success = false;

                try
                {
                    // Read field name -> format name
                    foreach (FieldInfo fi in readState.FieldInfos)
                    {
                        if (fi.HasDocValues)
                        {
                            string fieldName  = fi.Name;
                            string formatName = fi.GetAttribute(PER_FIELD_FORMAT_KEY);
                            if (formatName != null)
                            {
                                // null formatName means the field is in fieldInfos, but has no docvalues!
                                string suffix = fi.GetAttribute(PER_FIELD_SUFFIX_KEY);
                                if (Debugging.AssertsEnabled)
                                {
                                    Debugging.Assert(suffix != null);
                                }
                                DocValuesFormat format        = DocValuesFormat.ForName(formatName);
                                string          segmentSuffix = GetFullSegmentSuffix(readState.SegmentSuffix, GetSuffix(formatName, suffix));
                                // LUCENENET: Eliminated extra lookup by using TryGetValue instead of ContainsKey
                                if (!formats.TryGetValue(segmentSuffix, out DocValuesProducer field))
                                {
                                    formats[segmentSuffix] = field = format.FieldsProducer(new SegmentReadState(readState, segmentSuffix));
                                }
                                fields[fieldName] = field;
                            }
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        IOUtils.DisposeWhileHandlingException(formats.Values);
                    }
                }
            }
Ejemplo n.º 3
0
            internal FieldsReader(PerFieldDocValuesFormat outerInstance, FieldsReader other)
            {
                this.outerInstance = outerInstance;

                IDictionary <DocValuesProducer, DocValuesProducer> oldToNew = new IdentityHashMap <DocValuesProducer, DocValuesProducer>();

                // First clone all formats
                foreach (KeyValuePair <string, DocValuesProducer> ent in other.formats)
                {
                    DocValuesProducer values = ent.Value;
                    formats[ent.Key]    = values;
                    oldToNew[ent.Value] = values;
                }

                // Then rebuild fields:
                foreach (KeyValuePair <string, DocValuesProducer> ent in other.fields)
                {
                    DocValuesProducer producer;
                    oldToNew.TryGetValue(ent.Value, out producer);
                    Debug.Assert(producer != null);
                    fields[ent.Key] = producer;
                }
            }
Ejemplo n.º 4
0
 public FieldsWriter(PerFieldDocValuesFormat outerInstance, SegmentWriteState state)
 {
     this.outerInstance = outerInstance;
     segmentWriteState  = state;
 }