/// <summary>
        /// 从文件打开B+树
        /// </summary>
        /// <param name="treeFileStream">指定树文件的文件流</param>
        /// <param name="blockFileStream">指定块文件的文件流</param>
        /// <returns>B+树</returns>
        public static BPlusTreeBytes Open(Stream treeFileStream, Stream blockFileStream)
        {
            BPlusTreeLong tree    = BPlusTreeLong.SetupFromExistingStream(treeFileStream, (long)0);
            LinkedFile    archive = LinkedFile.SetupFromExistingStream(blockFileStream, (long)0);

            return(new BPlusTreeBytes(tree, archive));
        }
        /// <summary>
        /// 创建B+树
        /// </summary>
        /// <param name="treeFileStream">指定树文件的文件流</param>
        /// <param name="blockFileStream">指定块文件的文件流</param>
        /// <param name="keyLength">树允许的键的长度</param>
        /// <param name="nodeCapacity">树允许的各子节点的最大容量</param>
        /// <param name="blockSize">块大小</param>
        /// <returns>B+树</returns>
        public static BPlusTreeBytes Create(Stream treeFileStream, Stream blockFileStream, int keyLength, int nodeCapacity, int blockSize)
        {
            BPlusTreeLong tree    = BPlusTreeLong.InitializeInStream(treeFileStream, (long)0, keyLength, nodeCapacity);
            LinkedFile    archive = LinkedFile.InitializeInStream(blockFileStream, (long)0, blockSize);

            return(new BPlusTreeBytes(tree, archive));
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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;
 }
Exemple #6
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;
 }
 /// <summary>
 /// B+树,固定长度字符串为键,映射至Byte数组。
 /// </summary>
 /// <param name="tree">B+树</param>
 /// <param name="archive">链式块文件</param>
 internal BPlusTreeBytes(BPlusTreeLong tree, LinkedFile archive)
 {
     this.tree    = tree;
     this.archive = archive;
 }
Exemple #8
0
 /// <summary>
 /// B+树,固定长度字符串为键,映射至Byte数组。
 /// </summary>
 /// <param name="tree">B+树</param>
 /// <param name="archive">链式块文件</param>
 internal BPlusTreeBytes(BPlusTreeLong tree, LinkedFile archive)
 {
   this.tree = tree;
   this.archive = archive;
 }