示例#1
0
        public override DocValuesConsumer NormsConsumer(SegmentWriteState state)
        {
            DocValuesConsumer consumer = @in.NormsConsumer(state);

            Debug.Assert(consumer != null);
            return(new AssertingNormsConsumer(consumer, state.SegmentInfo.DocCount));
        }
示例#2
0
        internal override void Flush(IDictionary <string, InvertedDocEndConsumerPerField> fieldsToFlush, SegmentWriteState state)
        {
            bool success = false;
            DocValuesConsumer normsConsumer = null;

            try
            {
                if (state.FieldInfos.HasNorms)
                {
                    NormsFormat normsFormat = state.SegmentInfo.Codec.NormsFormat;
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(normsFormat != null);
                    }
                    normsConsumer = normsFormat.NormsConsumer(state);

                    foreach (FieldInfo fi in state.FieldInfos)
                    {
                        NormsConsumerPerField toWrite = (NormsConsumerPerField)fieldsToFlush[fi.Name];
                        // we must check the final value of omitNorms for the fieldinfo, it could have
                        // changed for this field since the first time we added it.
                        if (!fi.OmitsNorms)
                        {
                            if (toWrite != null && !toWrite.IsEmpty)
                            {
                                toWrite.Flush(state, normsConsumer);
                                if (Debugging.AssertsEnabled)
                                {
                                    Debugging.Assert(fi.NormType == DocValuesType.NUMERIC);
                                }
                            }
                            else if (fi.IsIndexed)
                            {
                                if (Debugging.AssertsEnabled)
                                {
                                    Debugging.Assert(fi.NormType == DocValuesType.NONE, "got {0}; field={1}", fi.NormType, fi.Name);
                                }
                            }
                        }
                    }
                }
                success = true;
            }
            finally
            {
                if (success)
                {
                    IOUtils.Dispose(normsConsumer);
                }
                else
                {
                    IOUtils.DisposeWhileHandlingException(normsConsumer);
                }
            }
        }