public override FieldWriter AddField(FieldInfo field, long termsFilePointer)
        {
            var writer = new SimpleFieldWriter(field, termsFilePointer, this);

            _fields.Add(writer);
            return(writer);
        }
Example #2
0
        public override FieldWriter AddField(FieldInfo field, long termsFilePointer)
        {
            //System.out.println("FGW: addFfield=" + field.name);
            SimpleFieldWriter writer = new SimpleFieldWriter(this, field, termsFilePointer);

            fields.Add(writer);
            return(writer);
        }
Example #3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_output != null)
                {
                    bool success = false;
                    try
                    {
                        long dirStart   = m_output.GetFilePointer();
                        int  fieldCount = fields.Count;

                        int nonNullFieldCount = 0;
                        for (int i = 0; i < fieldCount; i++)
                        {
                            SimpleFieldWriter field = fields[i];
                            if (field.numIndexTerms > 0)
                            {
                                nonNullFieldCount++;
                            }
                        }

                        m_output.WriteVInt32(nonNullFieldCount);
                        for (int i = 0; i < fieldCount; i++)
                        {
                            SimpleFieldWriter field = fields[i];
                            if (field.numIndexTerms > 0)
                            {
                                m_output.WriteVInt32(field.fieldInfo.Number);
                                m_output.WriteVInt32(field.numIndexTerms);
                                m_output.WriteVInt64(field.termsStart);
                                m_output.WriteVInt64(field.indexStart);
                                m_output.WriteVInt64(field.packedIndexStart);
                                m_output.WriteVInt64(field.packedOffsetsStart);
                            }
                        }
                        WriteTrailer(dirStart);
                        CodecUtil.WriteFooter(m_output);
                        success = true;
                    }
                    finally
                    {
                        if (success)
                        {
                            IOUtils.Dispose(m_output);
                        }
                        else
                        {
                            IOUtils.DisposeWhileHandlingException(m_output);
                        }
                        m_output = null;
                    }
                }
            }
        }
        public override void Dispose()
        {
            if (Output != null)
            {
                bool success = false;
                try
                {
                    long dirStart   = Output.FilePointer;
                    int  fieldCount = _fields.Count;

                    int nonNullFieldCount = 0;
                    for (int i = 0; i < fieldCount; i++)
                    {
                        SimpleFieldWriter field = _fields[i];
                        if (field.NumIndexTerms > 0)
                        {
                            nonNullFieldCount++;
                        }
                    }

                    Output.WriteVInt(nonNullFieldCount);
                    for (int i = 0; i < fieldCount; i++)
                    {
                        SimpleFieldWriter field = _fields[i];
                        if (field.NumIndexTerms > 0)
                        {
                            Output.WriteVInt(field.FieldInfo.Number);
                            Output.WriteVInt(field.NumIndexTerms);
                            Output.WriteVLong(field.TermsStart);
                            Output.WriteVLong(field.IndexStart);
                            Output.WriteVLong(field.PackedIndexStart);
                            Output.WriteVLong(field.PackedOffsetsStart);
                        }
                    }
                    WriteTrailer(dirStart);
                    CodecUtil.WriteFooter(Output);
                    success = true;
                }
                finally
                {
                    if (success)
                    {
                        IOUtils.Close(Output);
                    }
                    else
                    {
                        IOUtils.CloseWhileHandlingException(Output);
                    }
                    Output = null;
                }
            }
        }
 public override FieldWriter AddField(FieldInfo field, long termsFilePointer)
 {
     var writer = new SimpleFieldWriter(field, termsFilePointer, this);
     _fields.Add(writer);
     return writer;
 }