Exemple #1
0
        // Creates a memory stream with the first 4K bytes of the record.
        private void CreateMemoryStream()
        {
            byte[] pData;
            int cbData = INITIAL_READ;
            int totalSize;

            log.ReadRecordPrefix(this.recordSequenceNumber, out pData, ref cbData, out totalSize, out this.prevSeqNum, out this.nextSeqNum);

            if (cbData < FileLogRecordHeader.Size)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.LogCorrupt());

            this.header = new FileLogRecordHeader(pData);
            this.recordSize = totalSize - FileLogRecordHeader.Size;

            int streamSize = Math.Min(this.recordSize,
                                      INITIAL_READ - FileLogRecordHeader.Size);

            this.stream = new MemoryStream(
                pData,
                FileLogRecordHeader.Size,
                streamSize,
                false);

            if (totalSize <= INITIAL_READ)
            {
                // Record is smaller than 4K.  We have read the entire record.
                this.entireRecordRead = true;
            }
        }
Exemple #2
0
        public AppendHelper(IList <ArraySegment <byte> > data,
                            SequenceNumber prev,
                            SequenceNumber next,
                            bool restartArea)
        {
            this.prev = prev;
            this.next = next;

            this.header = new FileLogRecordHeader(null);
            this.header.IsRestartArea = restartArea;
            this.header.PreviousLsn   = prev;
            this.header.NextUndoLsn   = next;

            this.blobs   = new UnmanagedBlob[data.Count + 1];
            this.handles = new GCHandle[data.Count + 1];

            try
            {
                this.handles[0]         = GCHandle.Alloc(header.Bits, GCHandleType.Pinned);
                this.blobs[0].cbSize    = (uint)FileLogRecordHeader.Size;
                this.blobs[0].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(header.Bits, 0);

                for (int i = 0; i < data.Count; i++)
                {
                    handles[i + 1]         = GCHandle.Alloc(data[i].Array, GCHandleType.Pinned);
                    blobs[i + 1].cbSize    = (uint)data[i].Count;
                    blobs[i + 1].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(data[i].Array, data[i].Offset);
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Exemple #3
0
        public AppendHelper(IList<ArraySegment<byte>> data, 
                                SequenceNumber prev, 
                                SequenceNumber next,
                                bool restartArea)
        {
            this.prev = prev;
            this.next = next;

            this.header = new FileLogRecordHeader(null);
            this.header.IsRestartArea = restartArea;
            this.header.PreviousLsn = prev;
            this.header.NextUndoLsn = next;

            this.blobs = new UnmanagedBlob[data.Count + 1];
            this.handles = new GCHandle[data.Count + 1];

            try
            {
                this.handles[0] = GCHandle.Alloc(header.Bits, GCHandleType.Pinned);
                this.blobs[0].cbSize = (uint)FileLogRecordHeader.Size;
                this.blobs[0].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(header.Bits, 0);

                for (int i = 0; i < data.Count; i++)
                {
                    handles[i + 1] = GCHandle.Alloc(data[i].Array, GCHandleType.Pinned);
                    blobs[i + 1].cbSize = (uint)data[i].Count;
                    blobs[i + 1].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(data[i].Array, data[i].Offset);
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Exemple #4
0
        // Creates a memory stream with the first 4K bytes of the record.
        private void CreateMemoryStream()
        {
            byte[] pData;
            int    cbData = INITIAL_READ;
            int    totalSize;

            log.ReadRecordPrefix(this.recordSequenceNumber, out pData, ref cbData, out totalSize, out this.prevSeqNum, out this.nextSeqNum);

            if (cbData < FileLogRecordHeader.Size)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.LogCorrupt());
            }

            this.header     = new FileLogRecordHeader(pData);
            this.recordSize = totalSize - FileLogRecordHeader.Size;

            int streamSize = Math.Min(this.recordSize,
                                      INITIAL_READ - FileLogRecordHeader.Size);

            this.stream = new MemoryStream(
                pData,
                FileLogRecordHeader.Size,
                streamSize,
                false);

            if (totalSize <= INITIAL_READ)
            {
                // Record is smaller than 4K.  We have read the entire record.
                this.entireRecordRead = true;
            }
        }