コード例 #1
0
 /// <summary>Close the BCFile Writer.</summary>
 /// <remarks>
 /// Close the BCFile Writer. Attempting to use the Writer after calling
 /// <code>close</code> is not allowed and may lead to undetermined results.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 public virtual void Close()
 {
     if (closed == true)
     {
         return;
     }
     try
     {
         if (errorCount == 0)
         {
             if (blkInProgress == true)
             {
                 throw new InvalidOperationException("Close() called with active block appender.");
             }
             // add metaBCFileIndex to metaIndex as the last meta block
             BCFile.Writer.BlockAppender appender = PrepareMetaBlock(BCFile.DataIndex.BlockName
                                                                     , GetDefaultCompressionAlgorithm());
             try
             {
                 dataIndex.Write(appender);
             }
             finally
             {
                 appender.Close();
             }
             long offsetIndexMeta = @out.GetPos();
             metaIndex.Write(@out);
             // Meta Index and the trailing section are written out directly.
             @out.WriteLong(offsetIndexMeta);
             ApiVersion.Write(@out);
             BCFile.Magic.Write(@out);
             @out.Flush();
         }
     }
     finally
     {
         closed = true;
     }
 }