public ulong GetByteSize(uint index) { if ((options & StreamOptions.SingleObject) != 0) { // We have single object stream. if (index != 0) { return(0); } return(objectSize); } else { // We have to locate the object. BPlusTree tree = new BPlusTree(this.objectAddress); ObjectInfo info = tree.Find(journal.ReadService, index); if (info == null) { return(0); } return(info.Size); } }
public unsafe void DeleteChild(string name) { // 1) Find children TS. ulong childTS = 0; Block block = journal.ReadService.Read(BlockType.NodeHeaderBlock, commonAddress); fixed(byte *p = block.Data) { NodeCommonHeader *header = (NodeCommonHeader *)p; childTS = header->ChildrenBTree; } // 2) Find child. BPlusTree tree = new BPlusTree(childTS); ObjectInfo info = tree.Find(journal.ReadService, (uint)name.GetHashCode()); BlockStream stream = BlockStream.FromBase(info.Address, journal.ReadService); ChildTag tag = Common.DeserializeFromArray(stream.Read(info.Size)) as ChildTag; ulong? childAddress = tag.Find(name); // Execute operation Operations.DeleteChild deleteChild = new DeleteChild(childAddress.Value, childTS, name); journal.Execute(deleteChild); }
public unsafe IDriverNode GetVersion(ulong version) { // 1) Extract version typed stream. ulong versionTS; Block block = journal.ReadService.Read(BlockType.NodeHeaderBlock, commonAddress); fixed(byte *p = block.Data) { NodeCommonHeader *header = (NodeCommonHeader *)p; versionTS = header->VersionsBTree; } // 2) Search for version BPlusTree versionTree = new BPlusTree(versionTS); ObjectInfo info = versionTree.Find(journal.ReadService, (uint)version.GetHashCode()); if (info == null) { return(null); } // 3) Locate the version. BlockStream versionTagStream = BlockStream.FromBase(info.Address, journal.ReadService); VersionTag versionTag = Common.DeserializeFromArray(versionTagStream.Read(info.Size)) as VersionTag; ulong?rVersionAddress = versionTag.Find(version); if (!rVersionAddress.HasValue) { return(null); } // 4) Return the node. return(new PhysicalNode(name, commonAddress, rVersionAddress.Value, journal)); }