public byte[] GetRowBytes(int rowIndex) { int rowLength = RowLength; byte[] result = new byte[rowLength]; // hnidRows is set to zero if the TC contains no rows if (m_tcInfo.hnidRows.IsEmpty) { throw new ArgumentException("Invalid row index, the table context is empty"); } else if (m_tcInfo.hnidRows.IsHeapID) { // the row matrix is stored in the data tree byte[] rows = m_heap.GetHeapItem(m_tcInfo.hnidRows.HeapID); int offset = (int)rowIndex * rowLength; Array.Copy(rows, offset, result, 0, rowLength); return(result); } else { // indicates that the row matrix is stored in the subnode block, and the NID is the local NID under the subnode BTree if (m_subnodeRows == null) { m_subnodeRows = m_subnodeBTree.GetSubnode(m_tcInfo.hnidRows.NodeID); } int blockIndex = (int)(rowIndex / m_rowsPerBlock); int inBlockRowIndex = (int)(rowIndex % m_rowsPerBlock); DataBlock block = m_subnodeRows.DataTree.GetDataBlock(blockIndex); int offset = inBlockRowIndex * rowLength; Array.Copy(block.Data, offset, result, 0, rowLength); return(result); } }
public BTreeOnHeap(HeapOnNode heap, HeapID bTreeHeaderHeapID) { m_heap = heap; m_bTreeHeaderHeapID = bTreeHeaderHeapID; byte[] headerBytes = m_heap.GetHeapItem(bTreeHeaderHeapID); BTreeHeader = new BTreeOnHeapHeader(headerBytes); }
public static byte[] GetExternalPropertyBytes(HeapOnNode heap, SubnodeBTree subnodeBTree, HeapOrNodeID heapOrNodeID) { if (heapOrNodeID.IsEmpty) { return(new byte[0]); } else if (heapOrNodeID.IsHeapID) { byte[] result = heap.GetHeapItem(heapOrNodeID.HeapID); return(result); } else { // indicates that the item is stored in the subnode block, and the NID is the local NID under the subnode Subnode subnode = subnodeBTree.GetSubnode(heapOrNodeID.NodeID); if (subnode != null) { if (subnode.DataTree == null) { return(new byte[0]); } else { return(subnode.DataTree.GetData()); } } else { throw new MissingSubnodeException(); } } }
private Subnode m_subnodeRows; // for buffering purposes public TableContext(HeapOnNode heap, SubnodeBTree subnodeBTree) { m_heap = heap; m_subnodeBTree = subnodeBTree; m_tcInfo = new TableContextInfo(m_heap.GetHeapItem(m_heap.HeapHeader.hidUserRoot)); BTreeOnHeap <TableContextRowID> bTreeOnHeap = new BTreeOnHeap <TableContextRowID>(m_heap, m_tcInfo.hidRowIndex); if (bTreeOnHeap.BTreeHeader.hidRoot.hidIndex > 0) // hidRoot is set to zero if the BTH is empty. { m_rowIndex = bTreeOnHeap.GetAll(); m_rowIndex.Sort(TableContextRowID.CompareByRowIndex); } m_rowsPerBlock = (int)Math.Floor((double)DataBlock.MaximumDataLength / RowLength); }
public byte[] GetHeapItem(HeapID heapID) { return(m_heap.GetHeapItem(heapID)); }