/// <summary> /// writes the annotations to the current database file /// </summary> internal void Write(Prediction.Entry[] lut, Prediction[][] predictionsPerRef) { _blockStream.WriteHeader(_header.Write); WriteLookupTable(_writer, lut); _blockStream.Flush(); WritePredictions(predictionsPerRef); }
/// <summary> /// writes the annotations to the current database file /// </summary> public void Write(Prediction.Entry[] lut, Prediction[][] predictionsPerRef) { // write the header _blockStream.WriteHeader(_header); // write the LUT WriteLookupTable(_writer, lut); _blockStream.Flush(); // write the predictions WritePredictions(predictionsPerRef); }
private static void WriteBlockStream(ICompressionAlgorithm compressionAlgorithm, CacheHeader header, DemoCustomHeader customHeader, MemoryStream ms, string s) { using (var blockStream = new BlockStream(compressionAlgorithm, ms, CompressionMode.Compress, true)) using (var writer = new ExtendedBinaryWriter(blockStream)) { CheckReadException(blockStream); blockStream.WriteHeader(header.Write); var bp = new BlockStream.BlockPosition(); // detect that we have written a block blockStream.GetBlockPosition(bp); writer.WriteOptAscii(s); blockStream.GetBlockPosition(bp); // here we write a test string that won't invoke a new block blockStream.GetBlockPosition(customHeader.DemoPosition); writer.WriteOptAscii(SmallString); blockStream.GetBlockPosition(bp); Assert.Equal(customHeader.DemoPosition.FileOffset, blockStream.Position); blockStream.Flush(); // this will be flushed during dispose writer.WriteOptAscii(FinalString); } }
public void Dispose() { _dataFile?.Flush(); _dataFile?.Close(); _dataFile?.Dispose(); _dataFile = null; _indexFile?.Flush(); _indexFile?.Close(); _indexFile?.Dispose(); _indexFile = null; }
private static void WriteBlockStream(ICompressionAlgorithm compressionAlgorithm, DemoHeader header, DemoCustomHeader customHeader, Stream ms, string s) { using (var blockStream = new BlockStream(compressionAlgorithm, ms, CompressionMode.Compress, true)) using (var writer = new ExtendedBinaryWriter(blockStream)) { CheckReadException(blockStream); blockStream.WriteHeader(header.Write); writer.WriteOptAscii(s); (customHeader.FileOffset, customHeader.InternalOffset) = blockStream.GetBlockPosition(); Assert.Equal(customHeader.FileOffset, blockStream.Position); writer.WriteOptAscii(SmallString); blockStream.Flush(); // this will be flushed during dispose writer.WriteOptAscii(FinalString); } }