Exemplo n.º 1
0
        // We no longer create new TCs, we simply use the template and modify to another data tree
        public static TableContext CreateNewTableContext(PSTFile file, List <TableColumnDescriptor> columns)
        {
            HeapOnNode heap = HeapOnNode.CreateNewHeap(file);

            TableContextInfo tcInfo = new TableContextInfo();

            tcInfo.rgTCOLDESC = columns;
            tcInfo.UpdateDataLayout();

            HeapID newUserRoot = heap.AddItemToHeap(tcInfo.GetBytes());
            // The heap header may have just been updated
            HeapOnNodeHeader header = heap.HeapHeader;

            header.bClientSig  = OnHeapTypeName.bTypeTC;
            header.hidUserRoot = newUserRoot;
            heap.UpdateHeapHeader(header);

            BTreeOnHeapHeader bTreeHeader = new BTreeOnHeapHeader();

            bTreeHeader.cbKey = TableContextRowID.RecordKeyLength;
            bTreeHeader.cbEnt = TableContextRowID.RecordDataLength;

            tcInfo.hidRowIndex = heap.AddItemToHeap(bTreeHeader.GetBytes());
            // this will replace the item in place (as they have the same size since number of columns was not modified)
            heap.ReplaceHeapItem(header.hidUserRoot, tcInfo.GetBytes());

            return(new TableContext(heap, null));
        }
Exemplo n.º 2
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);
        }