/// <summary> /// Read index node from page segment (lazy-load) /// </summary> public IndexNode(IndexPage page, byte index, BufferSlice segment) { _page = page; _segment = segment; this.Position = new PageAddress(page.PageID, index); this.Slot = segment.ReadByte(P_SLOT); this.Level = segment.ReadByte(P_LEVEL); this.DataBlock = segment.ReadPageAddress(P_DATA_BLOCK); this.NextNode = segment.ReadPageAddress(P_NEXT_NODE); this.Next = new PageAddress[this.Level]; this.Prev = new PageAddress[this.Level]; for (var i = 0; i < this.Level; i++) { this.Prev[i] = segment.ReadPageAddress(P_PREV_NEXT + (i * PageAddress.SIZE * 2)); this.Next[i] = segment.ReadPageAddress(P_PREV_NEXT + (i * PageAddress.SIZE * 2) + PageAddress.SIZE); } this.Key = segment.ReadIndexKey(P_KEY); }
/// <summary> /// Read new DataBlock from filled page segment /// </summary> public DataBlock(DataPage page, byte index, BufferSlice segment) { _page = page; _segment = segment; this.Position = new PageAddress(page.PageID, index); // byte 00: Extend this.Extend = segment.ReadBool(P_EXTEND); // byte 01-05: NextBlock (PageID, Index) this.NextBlock = segment.ReadPageAddress(P_NEXT_BLOCK); // byte 06-EOL: Buffer this.Buffer = segment.Slice(P_BUFFER, segment.Count - P_BUFFER); }