Example #1
0
        /// <summary>
        /// Add a specified number of zero intensities to the given chromatogram, possibly
        /// writing finished blocks to disk.
        /// </summary>
        public void FillZeroes(int chromatogramIndex, int count, BlockWriter writer)
        {
            if (count < 1)
            {
                return;
            }

            // Fill remainder of current block.
            if (_blockIndex > 0)
            {
                while (count > 0 && _blockIndex < _blockSize)
                {
                    _block._data[_blockIndex++] = default(TData);
                    count--;
                }
                if (_blockIndex == _blockSize)
                {
                    _blockIndex = 0;
                }
                if (count == 0)
                {
                    return;
                }
            }

            if (writer != null)
            {
                if (_block == null)
                {
                    NewBlock();
                }
                else
                {
                    // Clear out re-used block.
                    for (int i = 0; i < _blockSize; i++)
                    {
                        _block._data[i] = default(TData);
                    }
                }

                // Write zeroed blocks to disk.
                while (count >= _blockSize)
                {
                    writer.WriteBlock(chromatogramIndex, this);
                    count -= _blockSize;
                }
            }
            else
            {
                // Create new pre-zeroed blocks.
                while (count >= _blockSize)
                {
                    NewBlock();
                    count -= _blockSize;
                }
            }

            _blockIndex = count;
        }
Example #2
0
        /// <summary>
        /// Add a data element to the list for a given chromatogram, and write the block
        /// to disk if it is complete.
        /// </summary>
        public void Add(int chromatogramIndex, TData data, BlockWriter writer)
        {
            // Spill data to disk at block boundaries, if necessary.
            if (_blockIndex == 0)
            {
                if (_blocksInMemory == 0 || writer == null)
                {
                    NewBlock();
                }
                else
                {
                    writer.WriteBlock(chromatogramIndex, this);
                }
            }

            // Store data.
            _block._data[_blockIndex] = data;

            // Wrap index to next block.
            if (++_blockIndex == _blockSize)
            {
                _blockIndex = 0;
            }
        }