public uint Write(KeyValueRecord data) { if(!_write) { throw new InvalidOperationException("cannot write to readonly file"); } lock(_streamSyncRoot) { _stream.Seek(0, SeekOrigin.End); _stream.Write(data.Hash); _stream.Write(BitConverter.GetBytes(data.Serial)); _stream.Write(BitConverter.GetBytes((uint)data.Key.LongLength)); _stream.Write(BitConverter.GetBytes(data.ValueSize)); _stream.Write(data.Key); data.Value.CopyTo(_stream, data.ValueSize); return (uint)_stream.Position - data.ValueSize; } }
public void WriteHint(KeyValueRecord data, uint valuePosition) { lock(_stream) { _stream.Write(BitConverter.GetBytes(data.Serial)); _stream.Write(BitConverter.GetBytes((uint)data.Key.LongLength)); _stream.Write(BitConverter.GetBytes(data.ValueSize)); _stream.Write(BitConverter.GetBytes(valuePosition)); _stream.Write(data.Key); } }