public byte[] Table_WriteToTheEnd(byte[] data)
{
long position = 0;
/* Emulation of the direct write to the disk without sequential cache */
//_fsData.Position = position = _fsData.Length;
//_fsData.Write(data, 0, data.Length);
//return ((ulong)position).To_8_bytes_array_BigEndian().Substring(8 - DefaultPointerLen, DefaultPointerLen);
/**************************************************************/
lock (lock_fs)
{
//case when incoming data bigger then buffer, we clean buffer and write data directly to the disk
if (data.Length > _seqBufCapacity)
{
FlushSequentialBuffer();
RIC.DataFilePosition = position = RIC.DataFileLength;
RIC.DataFileWrite(data, 0, data.Length, false);
//_fsData.Position = position = _fsData.Length;
//_fsData.Write(data, 0, data.Length);
return ((ulong)position).To_8_bytes_array_BigEndian().Substring(8 - DefaultPointerLen, DefaultPointerLen);
}
//Time to clean buffer
if (_seqBuf.EOF + data.Length > _seqBufCapacity)
{
FlushSequentialBuffer();
}
//Writing into buffer
position = RIC.DataFileLength + _seqBuf.EOF;
//position = _fsData.Length + _seqBuf.EOF;
_seqBuf.Write_ToTheEnd(data);
//eofData (ptr to the end of file before current commit) will be increased only after flush
}
return ((ulong)position).To_8_bytes_array_BigEndian().Substring(8 - DefaultPointerLen, DefaultPointerLen);
}