Exemplo n.º 1
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);
        }
Exemplo n.º 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;
    }