Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
 public void Write(uint index, string type, object obj)
 {
     if ((options & StreamOptions.SingleObject) != 0)
     {
         journal.Execute(new AddObjectSO(headerAddress, obj as byte[]));
     }
     else
     {
         journal.Execute(new AddObject(objectAddress, index, obj as byte[]));
     }
 }
Ejemplo n.º 3
0
 public void AddTypedStream(string type, StreamOptions flags)
 {
     journal.Execute(new AddTypedStream(versionAddress, type, flags));
 }