コード例 #1
0
            /// <summary>
            /// Commits the edits to the current archive file and disposes of this class.
            /// </summary>
            public override void Commit()
            {
                if (m_disposed)
                {
                    throw new ObjectDisposedException(GetType().FullName);
                }

                GetKeyRange(m_sortedTreeFile.m_firstKey, m_sortedTreeFile.m_lastKey);

                if (m_tree != null)
                {
                    m_tree.Flush();
                    m_tree = null;
                }
                if (m_binaryStream1 != null)
                {
                    m_binaryStream1.Dispose();
                    m_binaryStream1 = null;
                }
                if (m_subStream != null)
                {
                    m_subStream.Dispose();
                    m_subStream = null;
                }

                m_currentTransaction.CommitAndDispose();
                InternalDispose();
            }
コード例 #2
0
        private void CreateArchiveFile <TKey, TValue>(SubFileName fileName, EncodingDefinition storageMethod, int maxSortedTreeBlockSize)
            where TKey : SnapTypeBase <TKey>, new()
            where TValue : SnapTypeBase <TValue>, new()
        {
            if (maxSortedTreeBlockSize < 1024)
            {
                throw new ArgumentOutOfRangeException(nameof(maxSortedTreeBlockSize), "Must be greater than 1024");
            }
            if ((object)storageMethod == null)
            {
                throw new ArgumentNullException("storageMethod");
            }

            using (TransactionalEdit trans = m_fileStructure.BeginEdit())
            {
                using (SubFileStream fs = trans.CreateFile(fileName))
                    using (BinaryStream bs = new BinaryStream(fs))
                    {
                        int blockSize = m_fileStructure.Snapshot.Header.DataBlockSize;

                        while (blockSize > maxSortedTreeBlockSize)
                        {
                            blockSize >>= 2;
                        }

                        SortedTree <TKey, TValue> tree = SortedTree <TKey, TValue> .Create(bs, blockSize, storageMethod);

                        tree.Flush();
                    }
                trans.ArchiveType = FileType;
                trans.CommitAndDispose();
            }
        }