示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhysicalNode"/> class.
 /// </summary>
 /// <param name="commonAddress">The common address.</param>
 /// <param name="versionAddress">The version address.</param>
 /// <param name="journal">The journal.</param>
 public PhysicalNode(string name, ulong commonAddress, ulong versionAddress, Journalling.IJournal journal)
 {
     this.name           = name;
     this.journal        = journal;
     this.commonAddress  = commonAddress;
     this.versionAddress = versionAddress;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysicalDatabase"/> class.
        /// </summary>
        /// <param name="journal">The journal.</param>
        public unsafe PhysicalDatabase(IJournal journal, Caching.BlockCache cache, JournalRecovery recovery)
        {
            this.journal = journal;
            this.journal.Startup(cache, recovery);

            // Must make sure we construct the first node if not already there ("default node").
            Block block = journal.ReadService.Read(BlockType.NoCache, 0);

            fixed(byte *p = block.Data)
            {
                DatabaseHeader *header = (DatabaseHeader *)p;

                rootAddress = header->RootObjectAddress;
            }

            // We must initialize it.
            if (rootAddress == 0)
            {
                journal.Execute(new Operations.CreateRootObject());
                block = journal.ReadService.Read(BlockType.NoCache, 0);
                fixed(byte *pp = block.Data)
                {
                    DatabaseHeader *header = (DatabaseHeader *)pp;

                    rootAddress = header->RootObjectAddress;
                }

                Debug.Assert(rootAddress != 0);
            }
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysicalNode"/> class.
        /// </summary>
        /// <param name="commonAddress">The common address.</param>
        /// <param name="journal">The journal.</param>
        public unsafe PhysicalNode(string name, ulong commonAddress, Journalling.IJournal journal)
        {
            this.name          = name;
            this.commonAddress = commonAddress;
            this.journal       = journal;

            // We must extract most current version.
            Block block = journal.ReadService.Read(BlockType.NodeHeaderBlock, commonAddress);

            fixed(byte *p = block.Data)
            {
                NodeCommonHeader *header = (NodeCommonHeader *)p;

                this.versionAddress = header->CurrentVersionAddress;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysicalTypedStream"/> class.
        /// </summary>
        /// <param name="headerBlock">The header block.</param>
        /// <param name="journal">The journal.</param>
        public unsafe PhysicalTypedStream(ulong headerBlock, Journalling.IJournal journal)
        {
            this.headerAddress = headerBlock;
            this.journal       = journal;

            // Cache data.
            Block block = journal.ReadService.Read(BlockType.TypedStreamHeader, headerBlock);

            fixed(byte *p = block.Data)
            {
                TypedStreamHeader *header = (TypedStreamHeader *)p;

                type          = new string(header->Type);
                options       = header->Options;
                objectAddress = header->ObjectsAddress;
                objectSize    = header->ObjectSize;
            }
        }