Exemplo n.º 1
0
        public override FieldsConsumer FieldsConsumer(SegmentWriteState writeState)
        {
            int id = (int)NextID.GetAndIncrement();

            // TODO -- ok to do this up front instead of
            // on close....?  should be ok?
            // Write our ID:
            string      idFileName = IndexFileNames.SegmentFileName(writeState.SegmentInfo.Name, writeState.SegmentSuffix, ID_EXTENSION);
            IndexOutput @out       = writeState.Directory.CreateOutput(idFileName, writeState.Context);
            bool        success    = false;

            try
            {
                CodecUtil.WriteHeader(@out, RAM_ONLY_NAME, VERSION_LATEST);
                @out.WriteVInt32(id);
                success = true;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(@out);
                }
                else
                {
                    IOUtils.Close(@out);
                }
            }

            RAMPostings       postings = new RAMPostings();
            RAMFieldsConsumer consumer = new RAMFieldsConsumer(postings);

            lock (State)
            {
                State[id] = postings;
            }
            return(consumer);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Return and increment current gen.
 /// <para/>
 /// @lucene.internal
 /// </summary>
 public virtual long GetAndIncrementGeneration()
 {
     return(indexingGen.GetAndIncrement());
 }