private void Initialize() { _heap = new Heap(_node, _reader); var tableHeader = _heap[_heap.UserRoot]; _numColumns = tableHeader[1]; _columnOffsets = new TcColumnOffsets( tableHeader.ToInt16(2), tableHeader.ToInt16(4), tableHeader.ToInt16(6), tableHeader.ToInt16(8)); var rowIndexHid = tableHeader.ToUInt32(10); _rowIndex = new BTree <uint, uint>( _heap, rowIndexHid, s => s.ToUInt32(), s => s.ToUInt32(4)); var rowDataHnid = tableHeader.ToUInt32(14); if (rowDataHnid != 0) { if ((rowDataHnid & 0x1f) == 0) { _rowData = _heap[rowDataHnid]; } else { var subnode = _node.FindSubnode(rowDataHnid); var dataStream = subnode.GetDataStream(); _rowData = new BinaryReader(dataStream).ReadBytes((int)dataStream.Length); } } _columnDefs = new TcColumnDef[_numColumns]; for (var i = 0; i < _numColumns; i++) { var offsetBase = 22 + (i * 8); var tagType = tableHeader.ToUInt16(offsetBase); var tagKey = tableHeader.ToUInt16(offsetBase + 2); var dataOffset = tableHeader.ToUInt16(offsetBase + 4); var dataLength = tableHeader[offsetBase + 6]; var cebIndex = tableHeader[offsetBase + 7]; var def = new TcColumnDef { Tag = new ColumnTag { Type = (PropertyType)tagType, Key = (PropertyKey)tagKey }, Offset = dataOffset, Size = dataLength, CebIndex = cebIndex }; _columnDefs[i] = def; } }
internal TcRow( int rowIndex, TcColumnOffsets offsets, TcColumnDef[] columnDefs, Segment<byte> rowData, Heap heap, Node node, IPstReader reader) { _rowIndex = rowIndex; _offsets = offsets; _columnDefs = columnDefs; _rowData = rowData; _heap = heap; _node = node; _reader = reader; }
private void Initialize() { var block = _reader.FindBlock(_node.DataBid); _heap = new Heap(block); var tableHeader = _heap[_heap.UserRoot]; _numColumns = tableHeader[1]; _columnOffsets = new TcColumnOffsets( BitConverter.ToInt16(tableHeader.Array, tableHeader.Offset + 2), BitConverter.ToInt16(tableHeader.Array, tableHeader.Offset + 4), BitConverter.ToInt16(tableHeader.Array, tableHeader.Offset + 6), BitConverter.ToInt16(tableHeader.Array, tableHeader.Offset + 8)); var rowIndexHid = BitConverter.ToUInt32(tableHeader.Array, tableHeader.Offset + 10); _rowIndex = new BTree<uint, uint>( _heap, rowIndexHid, s => BitConverter.ToUInt32(s.Array, s.Offset), s => BitConverter.ToUInt32(s.Array, s.Offset + 4)); var rowDataHnid = BitConverter.ToUInt32(tableHeader.Array, tableHeader.Offset + 14); if ((rowDataHnid & 0x1f) == 0) { _rowData = _heap[rowDataHnid]; } else { var subnode = _node.FindSubnode(rowDataHnid); var dataBlock = _reader.FindBlock(subnode.DataBid); _rowData = dataBlock.Data; } _columnDefs = new TcColumnDef[_numColumns]; for (int i = 0; i < _numColumns; i++) { var offset = tableHeader.Offset + 22 + (i * 8); var tagType = BitConverter.ToUInt16(tableHeader.Array, offset); var tagKey = BitConverter.ToUInt16(tableHeader.Array, offset + 2); var dataOffset = BitConverter.ToUInt16(tableHeader.Array, offset + 4); var dataLength = tableHeader.Array[offset + 6]; var cebIndex = tableHeader.Array[offset + 7]; var def = new TcColumnDef { Tag = new ColumnTag { Type = (PropertyType)tagType, Key = (PropertyKey)tagKey }, Offset = dataOffset, Size = dataLength, CebIndex = cebIndex }; _columnDefs[i] = def; } }