コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public BTreeOnHeap(HeapOnNode heap, HeapID bTreeHeaderHeapID)
 {
     m_heap = heap;
     m_bTreeHeaderHeapID = bTreeHeaderHeapID;
     byte[] headerBytes = m_heap.GetHeapItem(bTreeHeaderHeapID);
     BTreeHeader = new BTreeOnHeapHeader(headerBytes);
 }
コード例 #3
0
 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();
         }
     }
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 public byte[] GetHeapItem(HeapID heapID)
 {
     return(m_heap.GetHeapItem(heapID));
 }