コード例 #1
0
 /// <summary>
 /// Creates a brand new database with no tables.
 /// </summary>
 /// <param name="process">The FrostDB process.</param>
 /// <param name="name">The name of the database.</param>
 public Database2(Process process, string name)
 {
     _process    = process;
     _name       = name;
     _databaseId = _process.DatabaseManager.GetNextDatabaseId();
     _storage    = new DbStorage(_process, name, _databaseId);
 }
コード例 #2
0
 public BTreeContainer(BTreeAddress address, TreeDictionary <int, Page> tree, DbStorage storage, TableSchema2 schema, Process process)
 {
     _tree    = tree;
     _address = address;
     _storage = storage;
     _schema  = schema;
     _process = process;
 }
コード例 #3
0
        /// <summary>
        /// Creates a database from a DBFill object. Used when booting up from disk.
        /// </summary>
        /// <param name="process">The FrostDB process.</param>
        /// <param name="fill">A DBFill object (usually loaded from disk.)</param>
        public Database2(Process process, DbFill fill, DbStorage storage)
        {
            _tables     = new List <Table2>();
            _process    = process;
            _name       = fill.Schema.DatabaseName;
            _databaseId = fill.Schema.DatabaseId;
            _storage    = storage;
            _schema     = fill.Schema;
            FillTables(fill);

            // to do: anything else?
        }
コード例 #4
0
 /// <summary>
 /// Constructs a table based on the specified TableSchema. Used when loading FrostDB from disk.
 /// </summary>
 /// <param name="process">The FrostDB process.</param>
 /// <param name="schema">The table schema (loaded from disk, usually from a DBFill object.)</param>
 /// <param name="dbStorage">The backing storage object for the database this table is attached to</param>
 /// <param name="pager">The in memory cache for FrostDb</param>
 public Table2(Process process, TableSchema2 schema, DbStorage dbStorage, Cache pager)
 {
     _process      = process;
     _schema       = schema;
     _name         = schema.Name;
     _databaseName = schema.DatabaseName;
     _columns      = schema.Columns;
     _tableId      = schema.TableId;
     _databaseId   = schema.DatabaseId;
     _storage      = dbStorage;
     _cache        = pager;
 }
コード例 #5
0
        /// <summary>
        /// Gets a list of databases from disk
        /// </summary>
        /// <returns>A list of databases</returns>
        public Database2[] GetDatabases()
        {
            var databases = GetOnlineDatabases();

            Database2[] result = new Database2[databases.Length];
            int         i      = 0;

            foreach (var db in databases)
            {
                var storage = new DbStorage(_process, db);
                var dbItem  = storage.GetDatabase(db);
                storage.Initialize();
                result[i] = dbItem;
                i++;
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Tries to load a container from disk file. If this is a fresh database, will return a new container.
        /// </summary>
        /// <param name="address">The address of the container to get</param>
        /// <returns>A container from disk</returns>
        private BTreeContainer GetContainerFromDisk(BTreeAddress address)
        {
            Database2    db      = _process.GetDatabase2(address.DatabaseId);
            DbStorage    storage = db.Storage;
            var          tree    = new TreeDictionary <int, Page>();
            TableSchema2 schema  = db.GetTable(address.TableId).Schema;

            // get the first page
            Page page = storage.GetPage(1, address);

            // if this is a brand new table
            if (page == null)
            {
                page = new Page(1, address.TableId, address.DatabaseId, schema, _process);
            }

            tree.Add(page.Id, page);

            return(new BTreeContainer(address, tree, storage, schema, _process));
        }
コード例 #7
0
 public Database(Process process, IDbFill fill, DbStorage dbStorage)
 {
     throw new NotImplementedException();
 }