CN101521627B - Method and device for inserting nodes - Google Patents

Method and device for inserting nodes Download PDF

Info

Publication number
CN101521627B
CN101521627B CN2009100815815A CN200910081581A CN101521627B CN 101521627 B CN101521627 B CN 101521627B CN 2009100815815 A CN2009100815815 A CN 2009100815815A CN 200910081581 A CN200910081581 A CN 200910081581A CN 101521627 B CN101521627 B CN 101521627B
Authority
CN
China
Prior art keywords
address
node
moving
move
play amount
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN2009100815815A
Other languages
Chinese (zh)
Other versions
CN101521627A (en
Inventor
易毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN2009100815815A priority Critical patent/CN101521627B/en
Publication of CN101521627A publication Critical patent/CN101521627A/en
Application granted granted Critical
Publication of CN101521627B publication Critical patent/CN101521627B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the invention discloses a method and a device for inserting nodes, belonging to the field of data communication. The method includes the following steps: a continuous cavern with a bThe embodiment of the invention discloses a method and a device for inserting nodes, belonging to the field of data communication. The method includes the following steps: a continuous cavern with a binary tree or multiple tree structure is captured, the offset is confirmed according to the layer level of the top layer of the continuous cavern and the layer number of the binary tree or multiple trinary tree or multiple tree structure is captured, the offset is confirmed according to the layer level of the top layer of the continuous cavern and the layer number of the binary tree or multiple tree structure, and the layer number of the binary tree or multiple tree structure is at least 4; when nodes with continuous change are inserted, a starting moving address is captured, and an address raee structure, and the layer number of the binary tree or multiple tree structure is at least 4; when nodes with continuous change are inserted, a starting moving address is captured, and an address range of full node subtrees including positions to be inserted is obtained according to the starting moving address and the offset; a moving end address is obtained; continuous cavern moving is performenge of full node subtrees including positions to be inserted is obtained according to the starting moving address and the offset; a moving end address is obtained; continuous cavern moving is performed according to the staring moving address, the moving end address, a starting inserting address and the offset; when the continuous cavern moving is finished, a clear operation is performed to nodes wd according to the staring moving address, the moving end address, a starting inserting address and the offset; when the continuous cavern moving is finished, a clear operation is performed to nodes with the number equal to the offset adjacent to the moving end address; and the nodes with continuous change are inserted in the full node subtrees including the positions to be inserted. The embodimenith the number equal to the offset adjacent to the moving end address; and the nodes with continuous change are inserted in the full node subtrees including the positions to be inserted. The embodiment of the invention can reduce the moving amount and improve the node insertion efficiency.t of the invention can reduce the moving amount and improve the node insertion efficiency.

Description

Insert the method and apparatus of node
Technical field
The present invention relates to data communication field, particularly a kind of method and apparatus that inserts node.
Background technology
Along with rapid network development, the quantity of route table items is increasing, such as, the IPv4FIB of core router (Forwad Information Base, forwarding information table) has required to realize 1,000,000 the order of magnitude.If realize with TCAM (Ternary Content Addressable Memory, Ternary Content Addressable Memory), ripe at present 18Mb TCAM can only realize the specification of 256K * 72b, just needs this moment the TCAM of 4 18Mb just can reach the requirement of 1M bar.Therefore, be implemented on cost, power consumption, the realization difficulty all beyond affordability with TCAM.Route querying technology based on algorithm has become the general way of data communication industry, and comparing on routing capacity, cost and power consumption with the TCAM device has bigger advantage.
There is multiple implementation the technology of searching present stage based on algorithm, and as the mode based on tries tree (experiment tree), based on the mode of range match (commensurate in scope), and part is based on the mode of searching of TCAM device.Wherein, the mode of range match adopts binary tree (Binary Tree) to realize the maintenance and management of route table items more, be about to the node of the boundary value of route table items as binary tree, the binary tree of a route boundary value is formed in the ordering back, so that carry out follow-up searching.
Search in the binary tree, insert, the complexity of deletion all with the height correlation of tree, the height of tree is the bottleneck of restriction binary tree time efficiency.In theory, arbitrary height can hold 2 for the h balanced binary tree h-1 node, i.e. h=O (lg n), and to insertion, the needed maintenance cost minimum of deletion of this balanced binary tree node.
In order to reach certain performance of searching, based on the searching in the system of binary tree, use the fixing binary tree of floor height to realize treating the maintenance of route table items hard-wired.Simultaneously,, do not use the mode of node band pointer to indicate next node layer position, only depend on the position relation of node to continue to search downwards in order to save memory space and to reduce and search the data volume that need read at every turn.
Because the floor height of binary tree is limited in this type systematic, and the new position after not having the pointer instructs node to move, when having new node to insert, will cause more node to move action, especially when the new node that inserts is the increasing or decreasing node, increase along with the node number, moving action will acutely increase, thereby the node that influences whole system inserts speed, is presented as that in practical application the route table items renewal speed is very slow, particularly when route oscillation, the whole system convergence time is longer.
Prior art provides following two kinds of methods to be implemented in and has inserted node in the binary tree:
The order that first method uses hardware logic to carry out node is moved, and the node that needs are moved moves the position in turn, makes the position that needs to insert node form cavity (hole), will be inserted into node at last and be inserted into emerging cavity.Carrying out node when moving, this method also needs to observe two basic principles: the magnitude relationship that the first, can not destroy each node location in the binary tree; The second, downward from the root node of tree, search out on the path of each effective node and all the cavity can not occur.Wherein, insert the binary tree be inserted into before the node as shown in Figure 1, insert the binary tree that is inserted into behind the node as shown in Figure 2.
But the defective of this method is, when inserting the node of increasing or decreasing, the amount of moving of node will progressively be increased, when interstitial content is increased to 1,000,000 the order of magnitude, moving ninety-nine times out of a hundred all needs to move all interstitial contents, thereby the more new capability of route table items will significantly be descended.
Second method is when inserting the increasing or decreasing node, calculate and insert the optimum state balanced binary tree that whole tree can form behind the node, be mapped to its tree in the hardware memory space one by one again, make it in total tree type preventive maintenance time, the required interstitial content of moving is minimum, reaches to improve the purpose that node inserts speed.Move under the pattern this, behind some nodes of every insertion, will adjust whole tree forcibly, make its binary tree that forms a balance, and then reach the purpose of on average moving least number of times.Wherein, insert the binary tree be inserted into before the node as shown in Figure 3, insert the binary tree that is inserted into behind the node as shown in Figure 4.
But the defective of this method is, a unbalanced binary tree arrangement is more loaded down with trivial details for the process of the binary tree of balance, particularly when the capacity of binary tree is big, need on high performance hardware, use software to realize, the binary tree that this moment, software also needed to set up the band pointer is shone upon the tree of storing in the hardware, so that use when making balancing run, duty ratio is bigger, and need take certain shadow (mirror image) memory headroom.In addition, in having calculated balanced binary tree behind the position of each node, need to pass through for example PCI (Pedpherd Component Interconnect of certain interface, the peripheral element expansion) interface, the node that rearranges is issued in the hardware logic, so that can carry out searching at a high speed, under the very big situation of data volume, the interface between soft, the hardware becomes bottleneck of performance easily.
Summary of the invention
In order to reduce the amount of moving, improve and insert efficient, simplify interface between software and hardware, the embodiment of the invention provides a kind of method and apparatus that inserts node.Described technical scheme is as follows:
On the one hand, the embodiment of the invention provides a kind of method of inserting node, comprising:
Obtain the continuous cavity of complete binary tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of described complete binary tree tree, level according to the top layer in described continuous cavity is obtained initial insertion address, the number of plies of described complete binary tree tree is at least 4 layers, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns;
When the continually varying node inserts, obtain and move initial address, move the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described;
Address realm according to described full node subtree obtains moving the end address;
According to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved;
When continuous cavity move finish after, begin 1 node of offset minus to be carried out clear operation from the described end address of moving to described continuous empty direction;
Described continually varying node is inserted into comprises the full node subtree that is inserted into the position.
On the other hand, the embodiment of the invention provides a kind of device that inserts node, comprising:
First acquisition module, be used to obtain the continuous cavity of complete binary tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of described complete binary tree tree, level according to the top layer in described continuous cavity is obtained initial insertion address, the number of plies of described complete binary tree tree is at least 4 layers, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns;
Second acquisition module is used for obtaining and moving initial address when the continually varying node inserts, and moves the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described;
The 3rd acquisition module is used for obtaining moving the end address according to the address realm of described full node subtree;
Move module, be used for according to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved;
Dump block, be used for when continuous cavity move finish after, begin 1 node of offset minus to be carried out clear operation from the described end address of moving to described continuous empty direction;
Insert module is used for described continually varying node is inserted into and comprises the full node subtree that is inserted into the position.
In embodiments of the present invention, when needs insert the continually varying node in complete y-bend or multiway tree tree, utilize the continuous a plurality of cavities of a slice, and move a plurality of nodes together, can significantly reduce fork tree needed number of times of moving when the node of handling increasing or decreasing inserts, improve and insert efficient, thereby improve the more new capability of route table items.In addition, finish moving fast and safeguarding of node, can significantly reduce the needed computational load amount of software view, simplify the interface between the software and hardware according to the technical scheme of the embodiment of the invention; Do not need the outer shadow space of occupying volume yet, saved memory headroom.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, to do one to the accompanying drawing of required use in embodiment or the description of the Prior Art below introduces simply, apparently, accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is that the insertion that prior art one provides is inserted into the preceding schematic diagram of node;
Fig. 2 is the schematic diagram after insertion that prior art one provides is inserted into node;
Fig. 3 is that the insertion that prior art two provides is inserted into the preceding schematic diagram of node;
Fig. 4 is the schematic diagram after insertion that prior art two provides is inserted into node;
Fig. 5 is that the insertion that the embodiment of the invention one provides is inserted into the preceding schematic diagram of node;
Fig. 6 is the flow chart of the method for the insertion node that provides of the embodiment of the invention one;
Fig. 7 be the embodiment of the invention one provide finish the schematic diagram that node is moved;
Fig. 8 is the schematic diagram of the insertion node apparatus that provides of the embodiment of the invention two.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.Obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
In complete y-bend or multiway tree tree, when the continually varying node inserts operation, when finding a plurality of continuous whens cavity, then carry out once moving continuously of a plurality of nodes, can form a plurality of cavities being inserted into node location like this, at this moment, to a plurality of node of inserting later the time, can reduce the amount of moving, improve and insert efficient.
Embodiment one
The embodiment of the invention provides a kind of method of inserting node, as shown in Figure 6, comprising:
101: the continuous cavity that obtains complete y-bend or multiway tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of complete y-bend or multiway tree tree, obtain initial insertion address according to the level in continuous cavity, wherein, the number of plies of this complete y-bend or multiway tree tree is at least 4 layers.
For convenience, the embodiment of the invention is example with the binary tree, but in actual applications, is not limited to binary tree, also can be ternary tree or multiway tree.Binary tree as shown in Figure 5, the floor height x of this binary tree is 7, is followed successively by 0,1,2,3,4,5,6 layer from top layer to bottom, and there are continuous 63 cavities on the right side, and continuously the level n value in the cavity of the vertex position in cavity is 1, side-play amount offset=2 (x-n-2)=16, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns.Wherein, according to the number formula 2 of subtree h-1 as can be known, continuous empty number is 63, thereby the address of continuous empty top layer as can be known, behind the address of learning continuous empty top layer, horizontal sliding to the right 31 in Fig. 5 can be learnt initial insertion address, horizontal sliding left 31, can learn last empty address, point to initial insertion address with pointer r_hole_top.
102: when the continually varying node inserts, obtain and move initial address, according to moving the address realm that initial address and side-play amount obtain comprising the full node subtree that is inserted into the position.
Particularly, add side-play amount and obtain the address realm of the full node subtree adjacent moving initial address for (to move initial address+1 with continuous cavity, move initial address+side-play amount-1), whether the address realm of judging adjacent full node subtree comprises is inserted into the position, if then obtain comprising the address realm of the full node subtree that is inserted into the position.If not, second boundary address of the address realm of adjacent full node subtree is added side-play amount, the address realm that obtains next adjacent full node subtree is for (to move initial address+side-play amount * m+1, move initial address+side-play amount * (m+1)-1), whether the address realm of the full node subtree that judgement is next adjacent comprises is inserted into the position, up to the address realm that obtains comprising the full node subtree that is inserted into the position, m is a wheel number of moving node, and the value of m is 1,2,3,4,5,6 ...In the present embodiment, the m value is 1,2.
Need to prove, second boundary address is the address near continuous empty direction, address away from continuous empty direction is first boundary address, in Fig. 5, because the cavity is positioned at the right side continuously, therefore, first boundary address is: move initial address+side-play amount * (m+1)-1, this address is away from continuous empty direction, and second boundary address is: move initial address+side-play amount * m+1, this address is near continuous empty direction.
With Fig. 5 is example, moves initial address with pointer r_src indication; To move and subtract 1 after initial address adds side-play amount, the address realm that obtains the full node subtree adjacent with continuous cavity is for (to move initial address+1, move initial address+16-1), this moment m=0, whether the full node subtree address realm that judgement obtains comprises is inserted into the position, if not, then according to the full node subtree address realm and the side-play amount offset that obtain, obtain next adjacent full node subtree address realm for (to move initial address+16 * 1+1, move initial address+16 * 2-1), at this moment, m=1, and whether the address realm of judging the next adjacent full node subtree obtain comprises and is inserted into the position, if not, then according to the address realm and the side-play amount offset of the next adjacent full node subtree that obtains, the address realm that obtains the 3rd adjacent full node subtree is for (to move initial address+16 * 2+1, move initial address+16 * 3-1), at this moment, m=2, judge whether the address realm that obtains the 3rd adjacent full node subtree comprises the position that is inserted into node, those skilled in the art are understandable, by judgement that continues and the passing of constantly expiring the node subtree, according to the address realm that initial address and offset can obtain comprising the full node subtree that is inserted into the position of moving of node.
In embodiments of the present invention, as shown in Figure 5, the address realm that can learn the 3rd full node subtree comprises and is inserted into node location.
103: obtain moving the end address according to 102 address realms that obtain full node subtree.
Particularly, will comprise second boundary address in the address realm of the full node subtree that is inserted into the position subtracts 2 and obtains moving the end address.
As shown in Figure 5, the 3rd full node subtree address realm comprises and is inserted into node location, second boundary address of the 3rd full node subtree address realm is subtracted 2 to be obtained last and need move node, i.e. 3 layers of rightmost side node of second full node subtree, indicate last need move node with pointer r_dst, this node corresponding address is moves the end address.
104: according to move initial address, move the end address, initial insertion address and side-play amount carry out continuous cavity and move.
Particularly, address, initial insertion position is increased 1 obtain the first insertion address, the node of moving the initial address correspondence is copied to first insert the address, offset minus 1 is obtained first side-play amount;
Insert the address with first and increase 2 and obtain second and insert the address, will move initial address and increase 1 and obtain first and move the address, first node of moving the address correspondence is copied to second insert the address, described first offset minus 1 is obtained second side-play amount;
Insert the address with second and increase 1 successively, move the address with first and increase 1 successively, move node that the address increases the address correspondence after 1 successively with first and copy to second and insert the address and increase address after 1 successively, simultaneously, described second side-play amount is subtracted 1 successively;
When second side-play amount equals 2, to duplicate the current node of moving the address correspondence of waiting and copy to the current address that is inserted into, address current to be moved increases 1, and the current site layer address decrement that is inserted into obtains the 3rd side-play amount with described second offset minus 1;
Judge that whether address current to be moved increases address after 1 for moving the end address, if, the node that address current to be moved is increased the 1 address correspondence that obtains copies to the current address that is inserted into that the site layer address decrement obtains that is inserted into, described the 3rd side-play amount is put 0, and finish continuous cavity and move.
Further, when judging that the address that address current to be moved increases after 1 is not when moving the end address, will move the initial address assignment and give initial insertion address;
Initial insertion address is increased 1 obtain the current address that is inserted into, judge whether current to wait to move the address of node be the described end address of moving for another, if, another node current to be moved is copied to the current address that is inserted into, finish continuous cavity and move; If not, finish another current wait to move the moving of node after, judge whether another current address of waiting to move the next node of node is the described end address of moving, and moves moving of end address corresponding node up to finishing.
With Fig. 5 is example, moves operation in order to realize continuous cavity, points to initial insertion address with pointer r_hole_top, pointer r_rsc points to and moves initial address, pointer r_rsd points to and moves the end address, and continuous cavity is moved operation and finished by the translation of 3 pointers, and is specific as follows:
Pointer r_hole_top address increases 1 and obtains the first insertion address, be that pointer r_hole_top points to 5 layers of rightmost side cavity position of binary tree, the node that pointer r_rsc points to is moved the first insertion address reproduction, the first insertion address, simultaneously side-play amount offset is subtracted 1 and obtain first side-play amount;
Insert the address with first and increase 2, obtain second and insert the address, be that pointer r_hole_top points to 4 layers of rightmost side cavity position of binary tree, pointer r_rsc address is increased 1 to be obtained first and moves the address, be 3 layers of rightmost side node that pointer r_rsc points to first the full node subtree adjacent with continuous cavity, at this moment, the node that pointer r_rsc points to moved the cavity position that this moment, r_hole_top pointed to, simultaneously, first offset minus 1 is obtained second side-play amount.
Insert the address with second and increase 1, obtain the 3rd and insert the address, be pointer r_hole_top point to 6 layers of binary trees from the rightmost side several the 3rd cavity positions, move the address with first and increase 1, obtain second and move the address, be that pointer r_rsc points to and empty continuously first adjacent full 2 layers of rightmost side node of node subtree, the node that this moment, pointer r_rsc pointed to moved the cavity position that this moment, pointer r_hole_top pointed to, simultaneously with second offset minus 1;
In the present embodiment, in order to keep the continuity of node, done special processing for the insertion of 2 nodes of beginning.Since the 3rd node, the address of pointer r_hole_top increases 1 successively, and simultaneously, the address of pointer r_rsc increases 1 successively, the node that current pointer r_rsc points to is moved the cavity position that current pointer r_hole_top points to, and second side-play amount subtracts 1 successively simultaneously.
When second side-play amount equals 2, represent that then 16 nodes that the first round need move have moved 14 nodes, at this moment, pointer r_hole_top points to 1 layer of rightmost side cavity position of binary tree, pointer r_rsc points to 2 layers rightmost node of first full node subtree among Fig. 5, the node that this moment, pointer r_rsc pointed to is copied to the cavity position that pointer r_hole_top points to, simultaneously, second offset minus 1, current insert layer address decrement, it is 3 layers the rightmost node that pointer r_rsc points to first full node subtree among Fig. 5, pointer r_hole_top address increases 1, be that pointer r_hole_top points to address, binary tree top layer cavity, whether the address of node of judging pointer r_rsc sensing this moment is for moving the end address, if the node that pointer r_rsc points to is moved the cavity that pointer r_hole_top points to, second side-play amount is put 0, and finish continuous cavity and move.If not, then will move the initial address assignment and give initial insertion address, with moving of beginning next round node.
In the present embodiment, because the first full address of node, 3 layers of leftmost side of node subtree is not to move the end address, at this moment, pointer r_hole_top points to binary tree top mode position, and pointer r_rsc points to the node of 2 layers of binary trees, as shown in Figure 7; Judge whether the address of node that this moment, pointer r_rsc pointed to moves the end address, if not, then the node that this moment, pointer r_rsc pointed to is moved the cavity position that pointer r_hole_top points to.Next, pointer r_rsc address is increased 1 successively, pointer r_hole_top address increases 1 successively, judge whether the address of node that this moment, pointer r_rsc pointed to moves the end address, if not, the node that current pointer r_rsc points to is moved the cavity that pointer r_hole_top points to, so repeatedly,, then finish continuous cavity and move for moving the end address up to address of node that current pointer r_rsc points to; If not, proceed the operation of moving of next round node, in the present embodiment, at this moment, the node that the node that pointer r_rsc points to points to for pointer r_rsd, therefore, end is moved in the cavity continuously.
105; When continuous cavity move finish after, begin to offset is subtracted 1 node carrying out clear operation from moving the end address near continuous empty direction.
Particularly, insert binary tree in order to make the follow-up node that is inserted into, continuous cavity move finish after, need carry out clear operation to offset being subtracted 1 node from moving the end address near continuous empty direction, promptly take turns the node of moving and carry out clear operation second, so that be inserted into node when the node subtree is expired in the 3rd of insertion, be that the 3rd the moving of node in the full node subtree vacated the position.
106: the continually varying node is inserted into comprises the full node subtree that is inserted into the position.
Particularly, be inserted into the 3rd full node subtree, need carry out conventional node to the 3rd full node subtree and move operation, will be inserted into node simultaneously and be inserted into and be inserted into the position in order to be inserted into node.
Wherein, the continually varying node is for increasing progressively node or the node that successively decreases.
In embodiments of the present invention, adopting highly is 22, and each node is that the Binary Tree of 32b realizes the storage of big capacity route table items and searches.Hardware realizes that framework is FPGA (FPGA Field Programmable Gate Array, field programmable gate array) and DDR2 (Double Data Rate, double-speed) SDRAM (Synchronous Dynamic Random Access Memory, Synchronous Dynamic Random Access Memory), the node of Binary Tree is stored in DDR2SDRAM and FPGA inside, control plane CPU (Central Processing Unit, central processing unit) carries out read-write operation by pci interface to FPGA and DDR2 SDRAM.
Before adopting the described insertion method of the embodiment of the invention, the node that inserts 512K increasing or decreasing order on average inserts speed less than 350entry/s.After adopting the method for the embodiment of the invention, continuous room is carried out in the insert action of increasing or decreasing moves, and control plane CPU does not increase the computational load amount with respect to the operation of prior art, and the 1M node that increasing or decreasing is distributed on average inserts speed and can surpass 1200entry/s.In addition, by emulation as can be known, adopt the method for the embodiment of the invention, move continuously under the situation in 1/2 cavity, the number of nodes that need move is reduced to original 30%.
In embodiments of the present invention, in the time need in binary tree, inserting the node of increasing or decreasing, utilize the continuous a plurality of cavities of a slice, and move a plurality of nodes together, can significantly reduce fork tree needed number of times of moving when the node of handling increasing or decreasing inserts, improve and insert efficient, thereby improve the more new capability of route table items.In addition, only need with FPGA/ASIC (Application Specific Integrated Circuit, application-specific integrated circuit (ASIC)) hardware logic, can finish moving fast and safeguarding of node according to the method for the embodiment of the invention, can significantly reduce the needed computational load amount of software view, simplify the interface between the software and hardware; Do not need the outer shadow space of occupying volume yet, saved memory headroom.
Embodiment two
Based on the inventive concept identical with method embodiment, the embodiment of the invention provides a kind of device that inserts node, as shown in Figure 8, comprising:
First acquisition module 801, be used to obtain the continuous cavity of complete y-bend or multiway tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of described complete y-bend or multiway tree tree, level according to the top layer in described continuous cavity is obtained initial insertion address, the number of plies of described complete y-bend or multiway tree tree is at least 4 layers, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns;
Second acquisition module 802 is used for obtaining and moving initial address when the continually varying node inserts, and moves the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described;
The 3rd acquisition module 803 is used for obtaining moving the end address according to the address realm of described full node subtree;
Particularly, the 3rd acquisition module 803 is used for that described second border that comprises the address realm of the full node subtree that is inserted into the position is subtracted 2 and obtains moving the end address, and described second boundary address is the address near continuous empty direction;
Move module 804, be used for according to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved;
Dump block 805, be used for when continuous cavity move finish after, begin 1 node of described offset minus to be carried out clear operation from the described end address of moving to described continuous empty direction;
Insert module 806 is used for described continually varying node is inserted into and comprises the full node subtree that is inserted into the position.
Wherein, first acquisition module 801 is determined side-play amount according to the level of continuous empty top layer and the number of plies of complete y-bend or multiway tree tree, comprising:
First acquisition module 801 obtains side-play amount=2 (x-n-2), wherein, x is the number of plies of complete y-bend or multiway tree tree, n is the level of continuous empty top layer.Detailed process can not repeat them here referring to 101 of method embodiment.
Wherein, second acquisition module 802 comprises according to moving the address realm that initial address and side-play amount obtain comprising the full node subtree that is inserted into the position:
Second acquisition module 802 will be moved initial address and add side-play amount and obtain the address realm of the full node subtree adjacent with continuous cavity for (to move initial address+1, move initial address+side-play amount-1), whether the address realm of judging adjacent full node subtree comprises is inserted into the position, if then obtain comprising the address realm of the full node subtree that is inserted into the position.
Further, second acquisition module 802, also be used for not comprising when being inserted into the position when the address realm of judging adjacent full node subtree, first boundary address of the address realm of described adjacent full node subtree is added described side-play amount, the address realm that obtains the adjacent full node subtree of the described next one is for (to move initial address+side-play amount * m+1, move initial address+side-play amount * (m+1)-1), whether the address realm of the full node subtree that judgement is next adjacent comprises is inserted into the position, up to the address realm that obtains comprising the full node subtree that is inserted into the position, wherein, first boundary address is the address away from described continuous empty direction, m is a wheel number of moving node, and the value of m is 1,2,3,4,5,6 ...
Need to prove that the detailed process of second acquisition module 802 can not repeat them here referring to method embodiment 102.
Wherein, move module 804 according to move initial address, move the end address, initial insertion address and side-play amount carry out continuous cavity and move, comprising:
Address, initial insertion position is increased 1 obtain the first insertion address, the node of moving the initial address correspondence is copied to first insert the address, described offset minus 1 is obtained first side-play amount;
Insert the address with first and increase 2 and obtain second and insert the address, will move initial address and increase 1 and obtain first and move the address, first node of moving the address correspondence is copied to second insert the address, described first offset minus 1 is obtained second side-play amount;
Insert the address with second and increase 1 successively, move the address with first and increase 1 successively, move node that the address increases the address correspondence after 1 successively with first and copy to second and insert the address and increase address after 1 successively, simultaneously, described second side-play amount is subtracted 1 successively;
When described second side-play amount equals 2, to duplicate the current node of moving the address correspondence of waiting and copy to the current address that is inserted into, address current to be moved increases 1, and the current site layer address decrement that is inserted into obtains the 3rd side-play amount with described second offset minus 1;
Judge that whether address current to be moved increases address after 1 for moving the end address, if, the node that address current to be moved is increased the 1 address correspondence that obtains copies to the current address that is inserted into that the site layer address decrement obtains that is inserted into, described the 3rd side-play amount is put 0, and finish continuous cavity and move.
Further, move module 804, also be used for to move the initial address assignment and giving initial insertion address when judging that the address that address current to be moved increases after 1 is not when moving the end address;
Initial insertion address is increased 1 obtain the current address that is inserted into, judge whether current to wait to move the address of node be the described end address of moving for another, if, another node current to be moved is copied to the current address that is inserted into, finish continuous cavity and move; If not, finish another current wait to move the moving of node after, judge whether another current address of waiting to move the next node of node is the described end address of moving, and moves moving of end address corresponding node up to finishing.
Need to prove that the detailed process of moving module can not repeat them here referring to 104 of method embodiment.
Wherein, the continually varying node is node that increases progressively continuously or the node that successively decreases continuously.
In embodiments of the present invention, in the time need in tree converges, inserting the node of increasing or decreasing, utilize the continuous a plurality of cavities of a slice, and move a plurality of nodes together, can significantly reduce fork tree needed number of times of moving when the node of handling increasing or decreasing inserts, improve and insert efficient, thereby improve the more new capability of route table items.In addition, only need to use the FPGA/ASIC hardware logic, can finish moving fast and safeguarding of node, can significantly reduce the needed computational load amount of software view, simplify the interface between the software and hardware; Do not need the outer shadow space of occupying volume yet, saved memory headroom.
One of ordinary skill in the art will appreciate that all or part of step that realizes in the foregoing description method is to instruct relevant hardware to finish by program, described program can be stored in the computer read/write memory medium, and described storage medium is floppy disk, hard disk or the CD etc. of computer.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (15)

1. a method of inserting node is characterized in that, comprising:
Obtain the continuous cavity of complete binary tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of described complete binary tree tree, level according to the top layer in described continuous cavity is obtained initial insertion address, the number of plies of described complete binary tree tree is at least 4 layers, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns;
When the continually varying node inserts, obtain and move initial address, move the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described;
Address realm according to described full node subtree obtains moving the end address;
According to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved;
When continuous cavity move finish after, described continually varying node be inserted into comprise the full node subtree that is inserted into the position.
2. the method for claim 1 is characterized in that, the level of the continuous empty top layer of described basis and the number of plies of described complete binary tree tree are determined side-play amount, comprising:
Determine described side-play amount=2 (x-n-2), wherein, x is the number of plies of described complete binary tree tree, n is the level of continuous empty top layer.
3. the method for claim 1 is characterized in that, describedly moves the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described, comprising:
The described initial address of moving is added the address realm that described side-play amount obtains the full node subtree adjacent with described continuous cavity, whether the address realm of judging described adjacent full node subtree comprises is inserted into the position, if then obtain the described address realm that comprises the full node subtree that is inserted into the position.
4. method as claimed in claim 3 is characterized in that, also comprises:
When the address realm of judging described adjacent full node subtree does not comprise when being inserted into the position, first boundary address of the address realm of described adjacent full node subtree is added described side-play amount, obtain the address realm of next adjacent full node subtree, whether the address realm of judging the full node subtree that the described next one is adjacent comprises is inserted into the position, up to the address realm that obtains comprising the full node subtree that is inserted into the position, wherein, described first boundary address is the address away from described continuous empty direction.
5. the method for claim 1 is characterized in that, described according to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved, comprising:
Address, initial insertion position is increased 1 obtain the first insertion address, the node of moving the initial address correspondence is copied to first insert the address, described offset minus 1 is obtained first side-play amount;
Insert the address with described first and increase 2 and obtain second and insert the address, will move initial address and increase 1 and obtain first and move the address, described first node of moving the address correspondence is copied to described second insert the address, described first offset minus 1 is obtained second side-play amount;
Insert the address with described second and increase 1 successively, move the address with described first and increase 1 successively, move node that the address increases the address correspondence after 1 successively with described first and copy to described second and insert the address and increase address after 1 successively, simultaneously, described second side-play amount is subtracted 1 successively;
When described second side-play amount equals 2, to duplicate the current node of moving the address correspondence of waiting and copy to the current address that is inserted into, address current to be moved increases 1, and the current site layer address decrement that is inserted into obtains the 3rd side-play amount with described second offset minus 1;
Judge that whether address current to be moved increases address after 1 for moving the end address, if, the node that address current to be moved is increased the 1 address correspondence that obtains copies to the current address that is inserted into that the site layer address decrement obtains that is inserted into, described the 3rd side-play amount is put 0, and finish continuous cavity and move.
6. method as claimed in claim 5 is characterized in that, also comprises:
When judging that the address that address current to be moved increases after 1 is not when moving the end address, will move the initial address assignment and give initial insertion address;
Initial insertion address is increased 1 obtain the current address that is inserted into, judge whether current to wait to move the address of node be the described end address of moving for another, if, another node current to be moved is copied to the current address that is inserted into, finish continuous cavity and move; If not, finish another current wait to move the moving of node after, judge whether current address of waiting to move the next node of node is the described end address of moving, and moves moving of end address corresponding node up to finishing.
7. the method for claim 1 is characterized in that, described address realm according to described full node subtree obtains moving the end address and comprises:
Described second boundary address that comprises the address realm of the full node subtree that is inserted into the position is subtracted 2 obtain moving the end address, described second boundary address is the address near continuous empty direction;
8. the method for claim 1 is characterized in that, when continuous cavity move finish after, described method also comprises: begin to described continuous empty direction 1 node of offset minus to be carried out clear operation from the described end address of moving.
9. a device that inserts node is characterized in that, comprising:
First acquisition module, be used to obtain the continuous cavity of complete binary tree tree, determine side-play amount according to the level of continuous empty top layer and the number of plies of described complete binary tree tree, level according to the top layer in described continuous cavity is obtained initial insertion address, the number of plies of described complete binary tree tree is at least 4 layers, described side-play amount represents that continuous nodes moves in the operation every number of moving node of taking turns;
Second acquisition module is used for obtaining and moving initial address when the continually varying node inserts, and moves the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described;
The 3rd acquisition module is used for obtaining moving the end address according to the address realm of described full node subtree;
Move module, be used for according to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved;
Insert module is used for described continually varying node is inserted into and comprises the full node subtree that is inserted into the position.
10. device as claimed in claim 9 is characterized in that, described first acquisition module is determined side-play amount according to the level of continuous empty top layer and the number of plies of described complete binary tree tree, comprising:
Described first acquisition module obtains described side-play amount=2 (x-n-2), wherein, x is the number of plies of complete binary tree tree, n is the level of continuous empty top layer.
11. device as claimed in claim 9 is characterized in that, described second acquisition module is moved the address realm that initial address and described side-play amount obtain comprising the full node subtree that is inserted into the position according to described, comprising:
Described second acquisition module adds the address realm that described side-play amount obtains the full node subtree adjacent with described continuous cavity with the described initial address of moving, whether the address realm of judging described adjacent full node subtree comprises is inserted into the position, if then obtain the described address realm that comprises the full node subtree that is inserted into the position.
12. device as claimed in claim 11, it is characterized in that, described second acquisition module, also be used for not comprising when being inserted into the position when the address realm of judging described adjacent full node subtree, first boundary address of the address realm of described adjacent full node subtree is added described side-play amount, obtain the address realm of next adjacent full node subtree, whether the address realm of judging the full node subtree that the described next one is adjacent comprises is inserted into the position, up to the address realm that obtains comprising the full node subtree that is inserted into the position, wherein, described first boundary address is the address away from described continuous empty direction.
13. the device of insertion node as claimed in claim 9 is characterized in that, described move module according to describedly move initial address, described end address, described initial insertion address and the described side-play amount moved carried out continuous cavity and moved, comprising:
Address, initial insertion position is increased 1 obtain the first insertion address, the node of moving the initial address correspondence is copied to described first insert the address, described offset minus 1 is obtained first side-play amount;
Insert the address with described first and increase 2 and obtain second and insert the address, will move initial address and increase 1 and obtain first and move the address, described first node of moving the address correspondence is copied to described second insert the address, described first offset minus 1 is obtained second side-play amount;
Insert the address with described second and increase 1 successively, move the address with described first and increase 1 successively, move node that the address increases the address correspondence after 1 successively with described first and copy to described second and insert the address and increase address after 1 successively, simultaneously, described second side-play amount is subtracted 1 successively;
When described second side-play amount equals 2, to duplicate the current node of moving the address correspondence of waiting and copy to the current address that is inserted into, address current to be moved increases 1, and the current site layer address decrement that is inserted into obtains the 3rd side-play amount with described second offset minus 1;
Judge that whether address current to be moved increases address after 1 for moving the end address, if, the node that address current to be moved is increased the 1 address correspondence that obtains copies to the current address that is inserted into that the site layer address decrement obtains that is inserted into, described the 3rd side-play amount is put 0, and finish continuous cavity and move.
14. device as claimed in claim 13 is characterized in that,
The described module of moving also is used for will moving the initial address assignment and giving initial insertion address when judging that the address that address current to be moved increases after 1 is not when moving the end address;
Initial insertion address is increased 1 obtain the current address that is inserted into, judge whether current to wait to move the address of node be the described end address of moving for another, if, another node current to be moved is copied to the current address that is inserted into, finish continuous cavity and move; If not, finish another current wait to move the moving of node after, another judges whether current address of waiting to move the next node of node is the described end address of moving, and moves moving of end address corresponding node up to finishing.
15. device as claimed in claim 9 is characterized in that, described device also comprises dump block, be used for when continuous cavity move finish after, begin 1 node of offset minus to be carried out clear operation from the described end address of moving to described continuous empty direction.
CN2009100815815A 2009-04-13 2009-04-13 Method and device for inserting nodes Expired - Fee Related CN101521627B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2009100815815A CN101521627B (en) 2009-04-13 2009-04-13 Method and device for inserting nodes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009100815815A CN101521627B (en) 2009-04-13 2009-04-13 Method and device for inserting nodes

Publications (2)

Publication Number Publication Date
CN101521627A CN101521627A (en) 2009-09-02
CN101521627B true CN101521627B (en) 2011-10-05

Family

ID=41082010

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009100815815A Expired - Fee Related CN101521627B (en) 2009-04-13 2009-04-13 Method and device for inserting nodes

Country Status (1)

Country Link
CN (1) CN101521627B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102143034B (en) * 2010-06-04 2013-11-06 华为技术有限公司 Method and equipment for processing routing table item
CN104144134B (en) * 2014-08-20 2017-10-03 新华三技术有限公司 A kind of array dispatching method and device
CN107196857B (en) * 2017-05-24 2020-06-23 北京东土军悦科技有限公司 Moving method and network equipment
CN109189343B (en) * 2018-09-14 2021-08-10 郑州云海信息技术有限公司 Metadata disk-dropping method, device, equipment and computer-readable storage medium
CN110995876B (en) * 2019-10-11 2021-02-09 中国科学院计算技术研究所 Method and device for storing and searching IP

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6181678B1 (en) * 1997-05-13 2001-01-30 Met Binary-tree data element sorting device and ATM spacer comprising such a device
US6411957B1 (en) * 1999-06-30 2002-06-25 Arm Limited System and method of organizing nodes within a tree structure
CN101315640A (en) * 2008-07-01 2008-12-03 中兴通讯股份有限公司 Directory management method and apparatus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6181678B1 (en) * 1997-05-13 2001-01-30 Met Binary-tree data element sorting device and ATM spacer comprising such a device
US6411957B1 (en) * 1999-06-30 2002-06-25 Arm Limited System and method of organizing nodes within a tree structure
CN101315640A (en) * 2008-07-01 2008-12-03 中兴通讯股份有限公司 Directory management method and apparatus

Also Published As

Publication number Publication date
CN101521627A (en) 2009-09-02

Similar Documents

Publication Publication Date Title
CN101521627B (en) Method and device for inserting nodes
US6839800B2 (en) RAM-based range content addressable memory
CN100536435C (en) Binary tree-based stream classification checking method
EP0439507A4 (en) Memory structure and method of utilization
CN103051543B (en) A kind of process of route prefix, search, increase and delet method
CN102622434B (en) Data storage method, data searching method and device
CN103942161B (en) Redundancy elimination system and method for read-only cache and redundancy elimination method for cache
JP2004229163A (en) Device and method for retrieving fixed length data, computer program, and computer readable recording medium
US10957391B2 (en) Array organization and architecture to perform range-match operations with content addressable memory (CAM) circuits
CN107423321B (en) Method and device suitable for cloud storage of large-batch small files
CN114356248A (en) Data processing method and device
CN110490302B (en) Neural network compiling and optimizing method and device and related products
CN101692653B (en) Management method and management device for routing table
CN116107932B (en) Data queue updating method and device, storage medium and electronic equipment
CN109948056B (en) Evaluation method and device of recommendation system
CN107896193B (en) Switch, and creation method and search method of lookup table of switch
CN104090942A (en) Trie search method and device applied to network processor
CN113342706A (en) Write-optimized extensible hash index structure based on nonvolatile memory and inserting, refreshing and deleting methods
CN101520765B (en) Method and device for determining time sequence parameter of input/output bus
JP2006012006A (en) Cache device and method
CN108351797B (en) Method and system for controlling reparse behavior associated with an intermediate directory
CN104504126A (en) Parallel vector table-checking method and device
CN104285223A (en) Method for modifying root nodes and associated modifying apparatus
CN102760489B (en) Flash block selecting method and data storage device
CN108809726B (en) Method and system for covering node by box

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20111005

Termination date: 20180413

CF01 Termination of patent right due to non-payment of annual fee