Beispiel #1
0
        /// <summary>
        /// 从指定的流初始化链式块文件
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始索引点</param>
        /// <param name="blockSize">块的大小</param>
        /// <returns>链式块文件</returns>
        public static LinkedFile InitializeInStream(Stream fromFile, long seekStart, int blockSize)
        {
            LinkedFile file = new LinkedFile(fromFile, seekStart, StoredConstants.LinkedFileHeaderPrefix, blockSize);

            file.WriteFileHeader();
            file.BlockFile = BlockFile.InitializeInStream(fromFile, seekStart + file.FileHeaderSize, StoredConstants.BlockFileHeaderPrefix, LinkedBlockOverhead + blockSize);
            return(file);
        }
Beispiel #2
0
        /// <summary>
        /// 从指定的流初始化树
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始查询点</param>
        /// <param name="keyLength">键长度</param>
        /// <param name="nodeCapacity">节点容量</param>
        /// <returns>树</returns>
        public static BPlusTreeLong InitializeInStream(Stream fromFile, long seekStart, int keyLength, int nodeCapacity)
        {
            if (fromFile == null)
            {
                throw new ArgumentNullException("fromFile");
            }

            if (fromFile.Length > seekStart)
            {
                throw new BPlusTreeException("can't initialize tree inside written area of stream");
            }

            BPlusTreeLong tree = new BPlusTreeLong(fromFile, seekStart, keyLength, nodeCapacity, (byte)1);

            tree.WriteHeader();
            tree.BlockFile = BlockFile.InitializeInStream(fromFile, seekStart + HeaderSize, StoredConstants.BlockFileHeaderPrefix, tree.BlockSize);

            return(tree);
        }