예제 #1
0
            public FieldsReader(PerFieldPostingsFormat 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.Indexed)
                        {
                            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 postings!
                                string suffix = fi.GetAttribute(PER_FIELD_SUFFIX_KEY);
                                Debug.Assert(suffix != null);
                                PostingsFormat format        = PostingsFormat.ForName(formatName);
                                string         segmentSuffix = GetSuffix(formatName, suffix);
                                if (!Formats.ContainsKey(segmentSuffix))
                                {
                                    Formats[segmentSuffix] = format.FieldsProducer(new SegmentReadState(readState, segmentSuffix));
                                }
                                Fields[fieldName] = Formats[segmentSuffix];
                            }
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        IOUtils.CloseWhileHandlingException(Formats.Values);
                    }
                }
            }
예제 #2
0
 public FieldsWriter(PerFieldPostingsFormat outerInstance, SegmentWriteState state)
 {
     this.OuterInstance = outerInstance;
     SegmentWriteState  = state;
 }
예제 #3
0
 public FieldsWriter(PerFieldPostingsFormat outerInstance, SegmentWriteState state)
 {
     this.OuterInstance = outerInstance;
     SegmentWriteState = state;
 }
예제 #4
0
            public FieldsReader(PerFieldPostingsFormat 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.Indexed)
                        {
                            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 postings!
                                string suffix = fi.GetAttribute(PER_FIELD_SUFFIX_KEY);
                                Debug.Assert(suffix != null);
                                PostingsFormat format = PostingsFormat.ForName(formatName);
                                string segmentSuffix = GetSuffix(formatName, suffix);
                                if (!Formats.ContainsKey(segmentSuffix))
                                {
                                    Formats[segmentSuffix] = format.FieldsProducer(new SegmentReadState(readState, segmentSuffix));
                                }
                                Fields[fieldName] = Formats[segmentSuffix];
                            }
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        IOUtils.CloseWhileHandlingException(Formats.Values);
                    }
                }
            }