Exemple #1
0
        /// <summary>
        /// Creates an external index, but does not load it
        /// </summary>
        /// <param name="Parent"></param>
        /// <param name="IndexColumns"></param>
        /// <returns></returns>
        public static TreeIndex CreateExternalIndex(Table Parent, Key IndexColumns)
        {
            Schema     columns = BinaryRecordTree.NonClusteredIndexColumns(Parent.Columns, IndexColumns);
            ShellTable storage = new ShellTable(Parent.Host, Host.RandomName, Parent.Host.TempDB, columns, Page.DEFAULT_SIZE);

            return(new TreeIndex(storage, Parent, Host.RandomName, IndexColumns));
        }
Exemple #2
0
 /// <summary>
 /// This method should be used for creating a brand new table object
 /// </summary>
 /// <param name="Host"></param>
 /// <param name="Alias"></param>
 /// <param name="Dir"></param>
 /// <param name="Columns"></param>
 /// <param name="PageSize"></param>
 /// <param name="ClusterKey"></param>
 public TreeTable(Host Host, string Path, Schema Columns, Key ClusterColumns, BinaryRecordTree.TreeAffinity State, int PageSize)
     : base(Host, Path, Columns, PageSize)
 {
     this._Cluster           = BinaryRecordTree.CreateClusteredIndex(this, ClusterColumns, State);
     this._TableType         = "CLUSTER_SCRIBE";
     this._Header.ClusterKey = ClusterColumns;
 }
Exemple #3
0
        /// <summary>
        /// Creates and builds a temporary index
        /// </summary>
        /// <param name="Parent"></param>
        /// <param name="IndexColumns"></param>
        /// <returns></returns>
        public static TreeIndex BuildTemporaryIndex(Table Parent, Key IndexColumns)
        {
            Schema     columns = BinaryRecordTree.NonClusteredIndexColumns(Parent.Columns, IndexColumns);
            ShellTable storage = new ShellTable(Parent.Host, Host.RandomName, Parent.Host.TempDB, columns, Page.DEFAULT_SIZE);
            TreeIndex  idx     = new TreeIndex(storage, Parent, Host.RandomName, IndexColumns);

            idx.Calibrate();
            Parent.Host.TableStore.PlaceInRecycleBin(storage.Key);
            return(idx);
        }
Exemple #4
0
        /// <summary>
        /// Creates a new index
        /// </summary>
        /// <param name="Storage"></param>
        /// <param name="Parent"></param>
        /// <param name="IndexColumns"></param>
        public TreeIndex(Table Storage, Table Parent, string Name, Key IndexColumns)
        {
            this._Header       = new IndexHeader(Name, -1, -1, -1, 0, 0, IndexColumns);
            this._Storage      = Storage;
            this._Parent       = Parent;
            this._IndexColumns = IndexColumns;
            Schema s = BinaryRecordTree.NonClusteredIndexColumns(this._Parent.Columns, this._IndexColumns);

            //this._Tree = new Cluster(this._Storage, s, Key.Build(this._IndexColumns.Count), null, this._Header, ClusterState.Universal);
            this._Tree = new BinaryRecordTree(Storage, Key.Build(this._IndexColumns.Count), s, null, Header, BinaryRecordTree.TreeAffinity.Unconstrained);
        }
Exemple #5
0
        /// <summary>
        /// Opens an existing index
        /// </summary>
        /// <param name="Storage"></param>
        /// <param name="Parent"></param>
        /// <param name="Header"></param>
        public TreeIndex(Table Storage, Table Parent, IndexHeader Header)
        {
            this._Storage      = Storage;
            this._Parent       = Parent;
            this._Header       = Header;
            this._IndexColumns = Header.IndexColumns;
            Page   root = this._Storage.GetPage(Header.RootPageID);
            Schema s    = BinaryRecordTree.NonClusteredIndexColumns(this._Parent.Columns, Header.IndexColumns);

            this._Tree = new BinaryRecordTree(Storage, Key.Build(this._IndexColumns.Count), s, root, Header, BinaryRecordTree.TreeAffinity.Unconstrained);
        }
Exemple #6
0
        /// <summary>
        /// This method should be used for creating a table object from an existing table on disk
        /// </summary>
        /// <param name="Host"></param>
        /// <param name="Header"></param>
        /// <param name="ClusterKey"></param>
        public TreeTable(Host Host, TableHeader Header)
            : base(Host, Header)
        {
            if (Header.RootPageID == -1)
            {
                throw new ArgumentException("The root page ID cannot be null");
            }

            // Get the sort key //
            Key k = Header.ClusterKey;

            // Get the root page ID //
            Page root = this.GetPage(Header.RootPageID);

            // Cluster //
            BinaryRecordTree.TreeAffinity x = this._Header.ClusterKeyState;
            this._Cluster = new BinaryRecordTree(this, k, this.Columns, root, this.Header, x);

            this._TableType = "CLUSTER_SCRIBE";
        }