DBreeze.Storage.FSR.Table_WriteToTheEnd C# (CSharp) Method

Table_WriteToTheEnd() public method

public Table_WriteToTheEnd ( byte data ) : byte[]
data byte
return byte[]
        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();
                    _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 = _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);
        }