Ejemplo n.º 1
0
        /// <summary>
        /// 从指定的流初始化树
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始查询点</param>
        /// <returns>树</returns>
        public static BPlusTreeLong SetupFromExistingStream(Stream fromFile, long seekStart)
        {
            if (fromFile == null)
            {
                throw new ArgumentNullException("fromFile");
            }

            BPlusTreeLong tree = new BPlusTreeLong(fromFile, seekStart, 100, 7, (byte)1); // dummy values for nodesize, keysize

            tree.ReadHeader();
            tree.BlockFile = BlockFile.SetupFromExistingStream(fromFile, seekStart + HeaderSize, StoredConstants.BlockFileHeaderPrefix);

            if (tree.BlockFile.BlockSize != tree.BlockSize)
            {
                throw new BPlusTreeException("inner and outer block sizes should match");
            }

            if (tree.RootNodeBlockNumber != StoredConstants.NullBlockNumber)
            {
                tree.RootNode = BPlusTreeNode.MakeRoot(tree, true);
                tree.RootNode.LoadFromBlock(tree.RootNodeBlockNumber);
            }

            return(tree);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从指定的流初始化块文件
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始索引点</param>
        /// <param name="blockFileHeaderPrefix">块存储头部前缀</param>
        /// <param name="blockSize">块的大小</param>
        /// <returns>块文件</returns>
        public static BlockFile InitializeInStream(Stream fromFile, long seekStart, byte[] blockFileHeaderPrefix, int blockSize)
        {
            BlockFile file = new BlockFile(fromFile, seekStart, blockFileHeaderPrefix, blockSize);

            file.WriteFileHeader();
            return(file);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 从指定的流初始化块文件
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始索引点</param>
        /// <param name="blockFileHeaderPrefix">块存储头部前缀</param>
        /// <returns>块文件</returns>
        public static BlockFile SetupFromExistingStream(Stream fromFile, long seekStart, byte[] blockFileHeaderPrefix)
        {
            BlockFile file = new BlockFile(fromFile, seekStart, blockFileHeaderPrefix, 100); // dummy block size for now

            file.ReadFileHeader();
            return(file);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 从指定的流初始化链式块文件
        /// </summary>
        /// <param name="fromFile">指定的流</param>
        /// <param name="seekStart">流起始索引点</param>
        /// <returns>链式块文件</returns>
        public static LinkedFile SetupFromExistingStream(Stream fromFile, long seekStart)
        {
            LinkedFile file = new LinkedFile(fromFile, seekStart, StoredConstants.LinkedFileHeaderPrefix, 100); // dummy block size for now

            file.ReadFileHeader();
            file.BlockFile = BlockFile.SetupFromExistingStream(fromFile, seekStart + file.FileHeaderSize, StoredConstants.BlockFileHeaderPrefix);
            return(file);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 从指定的流初始化块文件
 /// </summary>
 /// <param name="fromFile">指定的流</param>
 /// <param name="seekStart">流起始索引点</param>
 /// <param name="blockFileHeaderPrefix">块存储头部前缀</param>
 /// <param name="blockSize">块的大小</param>
 /// <returns>块文件</returns>
 public static BlockFile InitializeInStream(Stream fromFile, long seekStart, byte[] blockFileHeaderPrefix, int blockSize)
 {
   BlockFile file = new BlockFile(fromFile, seekStart, blockFileHeaderPrefix, blockSize);
   file.WriteFileHeader();
   return file;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 从指定的流初始化块文件
 /// </summary>
 /// <param name="fromFile">指定的流</param>
 /// <param name="seekStart">流起始索引点</param>
 /// <param name="blockFileHeaderPrefix">块存储头部前缀</param>
 /// <returns>块文件</returns>
 public static BlockFile SetupFromExistingStream(Stream fromFile, long seekStart, byte[] blockFileHeaderPrefix)
 {
   BlockFile file = new BlockFile(fromFile, seekStart, blockFileHeaderPrefix, 100); // dummy block size for now
   file.ReadFileHeader();
   return file;
 }