Ejemplo n.º 1
0
        public Nullable <ulong> FindBlockIDByNodeID(uint nodeID)
        {
            NodeBTreeEntry entry = FindNodeEntryByNodeID(nodeID);

            if (entry == null)
            {
                return(null);
            }
            else
            {
                return(entry.bidData.Value);
            }
        }
Ejemplo n.º 2
0
        public void InsertNodeEntry(NodeBTreeEntry entryToInsert)
        {
            ulong             key  = entryToInsert.nid.Value;
            NodeBTreeLeafPage page = (NodeBTreeLeafPage)FindLeafBTreePage(key);

            if (page.NodeEntryList.Count < NodeBTreeLeafPage.MaximumNumberOfEntries)
            {
                int insertIndex = page.InsertSorted(entryToInsert);
                UpdatePageAndReferences(page);
                if (insertIndex == 0 && page.ParentPage != null)
                {
                    // page key has been modified, we must update the parent
                    UpdateIndexEntry(page.ParentPage, page.BlockID, page.PageKey);
                }
            }
            else
            {
                // We have to split the tree node
                NodeBTreeLeafPage newPage = page.Split();
                if (newPage.PageKey < key)
                {
                    newPage.InsertSorted(entryToInsert);
                }
                else
                {
                    int insertIndex = page.InsertSorted(entryToInsert);
                    if (insertIndex == 0 && page.ParentPage != null)
                    {
                        // page key has been modified, we must update the parent
                        UpdateIndexEntry(page.ParentPage, page.BlockID, page.PageKey);
                    }
                }
                UpdatePageAndReferences(page);
                AddPage(newPage);

                if (page.ParentPage == null)
                {
                    // this is a root page and it's full, we have to create a new root
                    CreateNewRoot();
                }

                InsertIndexEntry(page.ParentPage, newPage.NodeEntryList[0].nid.Value, newPage.BlockID);
            }
        }
Ejemplo n.º 3
0
        public void InsertNodeEntry(NodeID nodeID, DataTree dataTree, SubnodeBTree subnodeBTree, NodeID parentNodeID)
        {
            NodeBTreeEntry entry = new NodeBTreeEntry();

            entry.nid     = nodeID;
            entry.bidData = new BlockID(0);
            if (dataTree != null && dataTree.RootBlock != null)
            {
                entry.bidData = dataTree.RootBlock.BlockID;
            }

            entry.bidSub = new BlockID(0);
            if (subnodeBTree != null && subnodeBTree.RootBlock != null)
            {
                entry.bidSub = subnodeBTree.RootBlock.BlockID;
            }

            entry.nidParent = parentNodeID;
            InsertNodeEntry(entry);
        }