CN105786931A - Tree structure resource storage and query methods and apparatuses - Google Patents

Tree structure resource storage and query methods and apparatuses Download PDF

Info

Publication number
CN105786931A
CN105786931A CN201410834814.5A CN201410834814A CN105786931A CN 105786931 A CN105786931 A CN 105786931A CN 201410834814 A CN201410834814 A CN 201410834814A CN 105786931 A CN105786931 A CN 105786931A
Authority
CN
China
Prior art keywords
resource
event
thing
hash table
list
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.)
Granted
Application number
CN201410834814.5A
Other languages
Chinese (zh)
Other versions
CN105786931B (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.)
Beijing Shenzhou Taiyue Software Co Ltd
Original Assignee
Beijing Shenzhou Taiyue Software 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 Beijing Shenzhou Taiyue Software Co Ltd filed Critical Beijing Shenzhou Taiyue Software Co Ltd
Priority to CN201410834814.5A priority Critical patent/CN105786931B/en
Publication of CN105786931A publication Critical patent/CN105786931A/en
Application granted granted Critical
Publication of CN105786931B publication Critical patent/CN105786931B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses tree structure resource storage and query methods and apparatuses. The tree structure resource query method comprises the steps of obtaining pre-stored event list and position hash table of tree structure resources, wherein the event list stores event data of resources and sub-resources traversed in sequence during traversal of the tree structure resources by a preorder traversal algorithm, the position hash table records starting positions and an event quantity of the resources in the event list, and the event quantity is the sum of an event quantity of the resources and an event quantity of the sub-resources; querying the starting positions and event quantity of the to-be-queried resources in the event list in the position hash table; and according to the queried starting positions and event quantity, intercepting the event data of the to-be-queried resources and the sub-resources from the event list. According to the technical scheme, the query speed of tree structure resource events under huge data volume can be effectively improved.

Description

The storage of a kind of tree structured resource, the method and apparatus of inquiry
Technical field
The present invention relates to set data buffer storage inquiring technology field, store particularly to a kind of tree structured resource, The method and apparatus of inquiry.
Background technology
The entity that fault produces can be monitored, as main frame, CPU, table space etc. are referred to as money in monitoring system Source.Ordinary business practice system is also had child resource by the resource composition such as database, main frame, main frame itself, as interior Deposit, cpu etc..These resources would generally produce substantial amounts of alarm event, i.e. resource during monitoring and produce The information of raw fault.Such as main frame itself can be just like " connect disconnect ", the thing such as " cpu utilization rate is too high " Part, and its each child resource also has the alarm event of oneself, such as " the page of the child resource internal memory of main frame Number is too high " event.In IT monitoring system, the resource monitored is usually present tree structure relation, such as figure Shown in 1, Fig. 1 left column is the example of the resource composition resource tree of tree structure relation, and Fig. 1 right side is classified as resource The example of the history alarm event produced.
User is when query event, it is often desirable that can inquire all of selected resource and each child resource thereof Alarm event.But owing to monitoring resource quantity is huge, then the history alarm event number that its resource is corresponding Because the time is accumulative huger.In the case of so many for resource, event is many, historical events is entered During row condition query, for million, ten million above event information, entered by traditional database mode Row SQL (Structured Query Language, SQL) is inquired about, and performance is extremely slow, Consumer's Experience is very poor.
Existing raising query performance scheme is: user is to pay close attention to for the inquiry of resource event 1~2 months interior data, 2 months interior alarm events are loaded in internal memory in advance with table data, When inquiry, by traveling through these cache list, improve the speed of event query.Existing this scheme It is by cache way, although query performance is higher than database SQL inquiry mode, but for tree node Need during resource query to travel through whole event list, when the tree node degree of depth is longer, need substantial amounts of recurrence The situation of traversal child resource event, when data volume is huge, performance is the most unsatisfactory.
Summary of the invention
The invention provides the storage of a kind of tree structured resource, the method and apparatus of inquiry, it is possible to effectively carry Event query speed when high data volume is huge.
For reaching above-mentioned purpose, the technical scheme is that and be achieved in that:
On the one hand, the method that the invention provides the storage of a kind of tree structured resource, including:
Tree structured resource is traveled through by preamble ergodic algorithm;
The order that each resource of traversal being gone out and the event data of each child resource thereof travel through according to preamble is successively It is stored in a list of thing;And in a position Hash table, record each resource in described event column Original position in table and event number;Wherein said event number is the event number of each resource self The event number sum of child resource each with it.
Wherein, before by preamble ergodic algorithm traversal tree structured resource, described method also includes:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching.
Wherein, the event data of described each resource traversal gone out and each child resource thereof travels through according to preamble Order be sequentially stored in a list of thing;And in a position Hash table, record each resource exist Original position and event number in described list of thing include:
During preamble traversal tree structured resource, by the event data of Current resource traveled through out successively and Qi Ge The event data of resource adds the afterbody of described list of thing to;
Original position and the event number of this Current resource is recorded in the Hash table of described position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current It is current that the event number of resource updates in the Hash table of described position this plus the event number of its each child resource The event number of resource.
Corresponding to the method for above-mentioned tree structured resource storage, the invention provides a kind of tree structured resource and deposit The device of storage, including:
Preamble spider module, for traveling through tree structured resource by preamble ergodic algorithm;
Memory cell, is used for the event data of each resource and each child resource thereof traversal gone out according to preamble The order of traversal is sequentially stored in a list of thing, and records each money in a position Hash table Source original position in described list of thing and event number;Wherein said event number is each resource The event number sum of the event number child resource each with it of self.
Alternatively, described device also includes:
Build table module, for setting up an empty list of thing, deposit successively with the order traveled through according to preamble Store up each resource and the event data of each child resource thereof;And set up an empty position Hash table, this position Putting the ID that key name is each resource of Hash table, key assignments is the integer array of two, each for record respectively Individual resource original position in described list of thing and event number;
Load-on module, for, before by preamble ergodic algorithm traversal tree structured resource, providing tree construction The event data in source is loaded in caching.
Wherein, described memory cell includes:
Data add module, when preamble traversal tree structured resource, and the Current resource that will travel through out successively Event data and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle, for record in the Hash table of described position this Current resource original position and Event number;
Quantity more new module, if there is child resource in the Current resource for traversal, then to have traveled through it each During child resource, the event number of Current resource is used to add that the event number of its each child resource updates described The event number of this Current resource in the Hash table of position.
The beneficial effect of the method and apparatus of the tree structured resource storage that the present invention provides:
The present invention travels through tree structured resource by preamble ergodic algorithm, each resource traversal gone out and each The event data of child resource is sequentially stored in a list of thing according to the order that preamble travels through, and one Individual position Hash table records each resource original position in this list of thing and event number, it is ensured that The Coutinuous store of the event data of the event data child resource each with it of each resource self, and can foundation The event number of each resource self and the event number sum of Qi Ge child resource count each money easily The event number in source;Thus when needs query resource, it is possible to look in the Hash table of position the most easily Ask out the resource to be checked original position in list of thing and event number, then at described list of thing In directly intercept out this resource to be checked and the event data of each child resource thereof.
On the other hand, the method that the invention provides the inquiry of a kind of tree structured resource, including:
Obtain list of thing and the position Hash table of the tree structured resource prestored, wherein, described event In list storage have by each resource of traveling through out successively during preamble ergodic algorithm traversal tree structured resource and The event data of its each child resource, in the Hash table of described position, record has each resource at described list of thing In original position and event number;Described event number is that the event number of each resource self is each with it The event number sum of child resource;
The resource to be checked original position in described list of thing and thing is inquired about in the Hash table of described position Number of packages amount;
According to the original position inquired and event number, in described list of thing, intercept out this to be checked Resource and the event data of each child resource thereof.
Said method also includes list of thing and the position Hash table prestoring tree structured resource, described pre- The list of thing and the position Hash table that first store tree structured resource include:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching;
Tree structured resource is traveled through by preamble ergodic algorithm;
Add the event data of the Current resource traveled through out successively and the event data of Qi Ge child resource to institute State the afterbody of list of thing;
Original position and the event number of this Current resource is recorded in the Hash table of described position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current It is current that the event number of resource updates in the Hash table of described position this plus the event number of its each child resource The event number of resource.
Corresponding to the method for above-mentioned tree structured resource inquiry, the invention provides a kind of tree structured resource and look into The device ask, including:
Initialization unit, obtains list of thing and the position Hash table of tree structured resource, wherein, institute in advance State and list of thing stores each traveled through out successively when having by preamble ergodic algorithm traversal tree structured resource Resource and the event data of each child resource thereof, in the Hash table of described position, record has each resource in described thing Original position in part list and event number;Described event number is the event number of each resource self The event number sum of child resource each with it;
Query unit, for inquiring about resource to be checked in described list of thing in the Hash table of described position Original position and event number;
Interception unit, for according to the original position inquired and event number, in described list of thing Intercept out this resource to be checked and the event data of each child resource thereof.
Wherein, described initialization unit also includes:
Build table module, for setting up an empty list of thing, deposit successively with the order traveled through according to preamble Store up each resource and the event data of each child resource thereof;And set up an empty position Hash table, this position Putting the ID that key name is each resource of Hash table, key assignments is the integer array of two, each for record respectively Individual resource original position in described list of thing and event number;
Load-on module, for being loaded into the event data of tree structured resource in caching;
Preamble spider module, for traveling through tree structured resource by preamble ergodic algorithm;
Data add module, when preamble traversal tree structured resource, and the Current resource that will travel through out successively Event data and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle, for record in the Hash table of described position this Current resource original position and Event number;
Quantity more new module, if there is child resource in the Current resource for traversal, then to have traveled through it each During child resource, the event number of Current resource is used to add that the event number of its each child resource updates described The event number of this Current resource in the Hash table of position.
The beneficial effect of the method and apparatus of the tree structured resource inquiry that the present invention provides:
By obtaining list of thing and the position Hash table of tree structured resource in advance, due to this list of thing and Position Hash table be by preamble ergodic algorithm traversal tree structured resource time obtain, traversal is gone out each The event data of resource and each child resource thereof is sequentially stored in this list of thing according to the order that preamble travels through In, and in this position Hash table, record each resource original position in this list of thing and event number Amount, it is ensured that the Coutinuous store of the event data of the event data child resource each with it of each resource self, And can add up easily according to the event number sum of the event number of each resource self and Qi Ge child resource Go out the event number of each resource;Thus when needs query resource, it is possible to breathe out in position the most easily Uncommon table inquires the resource to be checked original position in list of thing and event number, then described List of thing directly intercepts out this resource to be checked and the event data of each child resource thereof, is effectively improved Event query speed when data volume is huge.
Accompanying drawing explanation
Fig. 1 is tree structured resource and the example of history alarm event thereof;
The method flow diagram of a kind of tree structured resource storage that Fig. 2 provides for the embodiment of the present invention;
Fig. 3 is a tree structured resource example;
Fig. 4 is the event data example that in the table structure resource shown in Fig. 3, each resource includes;
The method flow diagram of the another kind of tree structured resource storage that Fig. 5 provides for the embodiment of the present invention;
The structure drawing of device of a kind of tree structured resource storage that Fig. 6 provides for the embodiment of the present invention;
The method flow diagram of a kind of tree structured resource inquiry that Fig. 7 provides for the embodiment of the present invention;
The structure drawing of device of a kind of tree structured resource inquiry that Fig. 8 provides for the embodiment of the present invention.
Detailed description of the invention
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to this Bright embodiment is described in further detail.
The Integral Thought of the present invention is: travel through resource tree by preamble ergodic algorithm, by tree structured resource Event data is found, and is put in list of thing according to the order of preamble traversal, simultaneously by position Hash table The event original position of record resource and event number, so construct list of thing and position Hash table, Event data to be inquired about can be directly intercepted out by original position and event number when inquiry.
As in figure 2 it is shown, the method that a kind of tree structured resource that the embodiment of the present invention provides stores, the method Mainly comprise the steps:
S210, travels through tree structured resource by preamble ergodic algorithm.
Traversal of tree is a kind of important computing of tree.So-called traversal refers to the information of all nodes in tree Access, the most successively to tree in each node access once and only access once.3 kinds of tree most important Traversal mode is called preamble traversal, inorder traversal and postorder traversal.
Preamble traversal is the one of traversal of binary tree, and also referred to as pre-reset mechanism, preorder traversal, preamble is traveled round, Can be denoted as about root.First preamble traversal accesses root node and then travels through left subtree, finally travels through right subtree. When traveling through left and right subtree, the most first access root node, then travel through left subtree, finally travel through right son Tree.It is to be noted that still use preamble traversal method during traversal left and right subtree.
Fig. 3 is a tree structured resource example, with binary tree (7 burls of the degree of depth 3 shown in Fig. 3 Point) tree structured resource as a example by, including seven resources of A, B, C, D, E, F, G, use preamble The order of ergodic algorithm traversal resource is: A-> C-> F-> G-> E-> B-> D.
S220, each resource that traversal is gone out and the event data of each child resource thereof according to preamble travel through suitable Sequence is sequentially stored in a list of thing;And in a position Hash table, record each resource described Original position in list of thing and event number;Wherein said event number is the thing of each resource self The event number sum of number of packages amount child resource each with it.
It should be noted that before by preamble ergodic algorithm traversal tree structured resource, the present invention implements The method of example also includes:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching.
Employing sample data explanation position Hash table below:
{
" 100 ": [0,20], //--100 is key name, and [0,20] is key assignments
“101”:[15,5],
“102”:[20,3]
}
Wherein 100,101,102 is resource ID, and the event original position of resource 100 is 0, length 20; The event original position of resource 101 is 15, a length of 5;The event original position of resource 102 is 20, A length of 3.The length of resource 100 contains position and the length of resource 101, represents that resource 101 is The child resource of resource 100.
This step S220 specifically includes:
During preamble traversal tree structured resource, by the event data of Current resource traveled through out successively and Qi Ge The event data of resource adds the afterbody of list of thing to;
Original position and the event number of this Current resource is recorded in the Hash table of position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current The event number of resource updates this Current resource in the Hash table of position plus the event number of its each child resource Event number.Event number herein is the thing of the event number child resource each with it of each resource self Number of packages amount sum.
As a example by the tree structured resource shown in Fig. 3, if event data such as Fig. 4 that its each resource includes Shown in.Wherein, resource A includes A1, A2 event data, and resource B includes B1 event data, money Source C includes C1, C2, C3 event data, and resource D includes D1 event data, and resource E includes E1 event data, resource F includes F1, F2 event data, and resource G includes G1 event data.
The event data of each resource traversal gone out is sequentially stored in a thing according to the order that preamble travels through In part list, the list of thing information obtained is:
{A1,A2,C1,C2,C3,F1,F2,G1,E1,B1,D1}。
Each resource original position in above-mentioned list of thing and event is recorded in a position Hash table Quantity, the position Hash table information obtained (original position is call number, and 0 starts) is:
{
A:[0,11],
B:[9,2],
C:[2,7],
D:[10,1],
E:[5,1],
F:[6,3],
G:[8,1]
Below as a example by the history alarm event storage of resource, the tree structured resource that the embodiment of the present invention provides The method flow of storage is as it is shown in figure 5, comprise the steps:
S500, sets up an empty list of thing and an empty position Hash table.
S501, is loaded into resource data in caching from database.
It should be noted that this step simply changes in history alarm event, or interval some cycles is restarted During system, just resource data is loaded in caching.
S502, selects resource tree root node.
S503, processes Current resource.
S504, inquires about the history alarm event of Current resource from database.
S505, will inquire history alarm event and add to the afterbody of list of thing.
S506, obtains the event number of Current resource and in the original position of list of thing, at position Hash Table records original position and the event number of this Current resource.
S507, it is judged that whether whole child resources of Current resource have traveled through?If it is, enter step S508, If it does not, enter step S509.
S508, the event number of each child resource updates position and breathes out to use the event number of Current resource to add The event number of this Current resource in uncommon table.
S509, continues preamble traversal resource tree.
Method based on above-mentioned tree structured resource storage, embodiments provides a kind of tree construction money The device of source storage, as shown in Figure 6, including:
Build table module 601, for setting up an empty list of thing, for the order according to preamble traversal Store each resource and the event data of each child resource thereof successively;And set up an empty position Hash table, The key name of this position Hash table is the ID of each resource, and key assignments is the integer array of two, for remembering respectively Record each resource original position in described list of thing and event number;
Load-on module 602, for, before by preamble ergodic algorithm traversal tree structured resource, tying tree The event data of structure resource is loaded in caching.
Preamble spider module 610, for traveling through tree structured resource by preamble ergodic algorithm.
Memory cell 62, is used for the event data of each resource and each child resource thereof traversal gone out according to front The order of sequence traversal is sequentially stored in a list of thing, and records each in a position Hash table Resource original position in described list of thing and event number;Event number herein is each resource The event number sum of the event number child resource each with it of self.
Wherein, described memory cell 62 includes:
Data add module 621, when preamble traversal tree structured resource, current by travel through out successively The event data of resource and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle 622, for recording the start bit of this Current resource in the Hash table of described position Put and event number;
Quantity more new module 623, if the Current resource for traversal exists child resource, is then traveling through During its each child resource, the event number of Current resource is used to add that the event number of its each child resource updates The event number of this Current resource in the Hash table of described position.
It follows that the method and apparatus that the tree structured resource that the embodiment of the present invention provides stores, by front Sequence ergodic algorithm traversal tree structured resource, each resource that traversal is gone out and the event data of each child resource thereof It is sequentially stored in a list of thing according to the order of preamble traversal, and remembers in a position Hash table Record each resource original position in this list of thing and event number, it is ensured that each resource self The Coutinuous store of the event data of event data child resource each with it, and can be according to the thing of each resource self The event number sum of number of packages amount and its each child resource counts the event number of each resource easily;From And when needs query resource, it is possible in the Hash table of position, inquire resource to be checked the most easily exist Original position in list of thing and event number, then directly intercept out this in described list of thing and treat Query resource and the event data of each child resource thereof, be effectively improved data volume huge time event query Speed.
Below with binary tree (7 tree nodes) concrete example of the degree of depth 3:
Existing query scheme is for the number of times of each node resource query event:
The degree of depth 1 resource: resource quantity 1, travels through out all child resources (6), inquires about oneself and owns The event (7 times) of child resource, merged event;
The degree of depth 2 resource: resource quantity 2, travels through out all child resources (2), inquires about oneself and owns The event (3 times) of child resource, merged event;
The degree of depth 3 resource: resource quantity 4, the event (1 time) of query resource;
To sum up, the action of one resource of average lookup:
Inquiry child resource 1 time, query resource event (7+3*2+4*1)/7=17/7, merged event 1 time.
Calculate in this approach, other depth-averaged event query number of times:
Degree of depth 2:(3*1+1*2)/3=5/3=1.67;
Degree of depth 4:(15*1+7*2+3*4+1*8)/15=49/15=3.27;
Degree of depth 5:(31*1+15*2+7*4+3*8+1*16)/31=129/31=4.16;
Degree of depth n:(Σ (2n-i-1) * 2i)/(2n-1) wherein n is the degree of depth, i value 0 to n-1;
And use the solution of the present invention query event number of times:
Each node: inquiring position Hash table 1 time, according to position enquiring event 1 time, and and y-bend The degree of depth of tree is unrelated, is all query event 1 time.
To sum up: the solution of the present invention is to obtain event times with the core capabilities difference of existing scheme.This Invention ability averagely improves search efficiency (Σ (2n-i-1)*2i)/(2n-1) again, wherein n is the degree of depth, i value 0 To n-1.
Based on identical inventive concept, present invention also offers a kind of method that tree structured resource is inquired about, as Shown in Fig. 7, including:
S701, obtains list of thing and the position Hash table of the tree structured resource prestored;
Wherein, in described list of thing storage have by preamble ergodic algorithm traversal tree structured resource time successively Each resource traveled through out and the event data of each child resource thereof, in the Hash table of described position, record has each Resource original position in described list of thing and event number;Described event number be each resource from The event number sum of the event number child resource each with it of body.
S702, inquire about in this position Hash table the resource to be checked original position in this list of thing and Event number.
S703, according to the original position inquired and event number, intercepts out this in this list of thing and treats Query resource and the event data of each child resource thereof.
Specifically, according to the ID of resource to be inquired about, inquire this resource in " position Hash table " Event data initial position in " list of thing " and event number.Then initiateing according to Directory Enquiries Position and event number, just can intercept out the event data of this resource and child resource thereof at " list of thing ".
Such as, the event number still included with each resource shown in the tree structured resource shown in Fig. 3 and Fig. 4 As a example by according to, the list of thing information obtaining tree structured resource in advance is:
{A1,A2,C1,C2,C3,F1,F2,G1,E1,B1,D1}。
Obtain the position Hash table information (original position is call number, and 0 starts) of tree structured resource in advance For:
{
A:[0,11],
B:[9,2],
C:[2,7],
D:[10,1],
E:[5,1],
F:[6,3],
G:[8,1]
}
When needing all events inquiring about C resource, the key assignments obtaining resource C from the Hash table of position is [2,7], according to this key assignments, find the position of sequence number 2 in list of thing, then intercept 7 length Value, is C1, C2, C3, F1, F2, G1, E1.
Wherein, the list of thing and the position Hash table that prestore tree structured resource include:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching;
Tree structured resource is traveled through by preamble ergodic algorithm;
Add the event data of the Current resource traveled through out successively and the event data of Qi Ge child resource to institute State the afterbody of list of thing;
Original position and the event number of this Current resource is recorded in the Hash table of described position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current It is current that the event number of resource updates in the Hash table of described position this plus the event number of its each child resource The event number of resource.
It is appreciated that the list of thing of storage tree structured resource and the step of position Hash table are not every time All can perform during inquiry, simply change at tree structured resource, or just meeting when interval some cycles restarts system Perform.
Method based on above-mentioned tree structured resource inquiry, the embodiment of the present invention additionally provides a kind of tree construction The device of resource query, as shown in Figure 8, including:
Initialization unit 80, obtains list of thing and the position Hash table of tree structured resource in advance, wherein, What in described list of thing, storage traveled through out when having by preamble ergodic algorithm traversal tree structured resource successively is each Individual resource and the event data of each child resource thereof, in the Hash table of described position, record has each resource described Original position in list of thing and event number;Described event number is the event number of each resource self Measure the event number sum of child resource each with it;
Query unit 81, for inquiring about resource to be checked at described list of thing in the Hash table of described position In original position and event number;
Interception unit 82, for according to the original position traveled through out and event number, at described list of thing Middle intercept out this resource to be checked and the event data of each child resource thereof.
Wherein, this initialization unit 80 also includes:
Build table module 801, for setting up an empty list of thing, for the order according to preamble traversal Store each resource and the event data of each child resource thereof successively;And set up an empty position Hash table, The key name of this position Hash table is the ID of each resource, and key assignments is the integer array of two, for remembering respectively Record each resource original position in described list of thing and event number;
Load-on module 802, for being loaded into the event data of tree structured resource in caching;
Preamble spider module 803, for traveling through tree structured resource by preamble ergodic algorithm;
Data add module 804, when preamble traversal tree structured resource, current by travel through out successively The event data of resource and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle 805, for recording the start bit of this Current resource in the Hash table of described position Put and event number;
Quantity more new module 806, if the Current resource for traversal exists child resource, is then traveling through During its each child resource, the event number of Current resource is used to add that the event number of its each child resource updates The event number of this Current resource in the Hash table of described position.
It follows that the method and apparatus that the tree structured resource that the embodiment of the present invention provides is inquired about, by advance First obtain list of thing and the position Hash table of tree structured resource, due to this list of thing and position Hash table It is to obtain when by preamble ergodic algorithm traversal tree structured resource, each resource that traversal is gone out and each The event data of child resource is sequentially stored in this list of thing according to the order that preamble travels through, and in this position Put and Hash table records each resource original position in this list of thing and event number, it is ensured that be each The Coutinuous store of the event data of the event data child resource each with it of individual resource self, and can be according to each The event number of resource self and the event number sum of Qi Ge child resource count each resource easily Event number;Thus when needs query resource, it is possible to travel through out in the Hash table of position the most easily The resource to be checked original position in list of thing and event number are then straight in described list of thing Connect and intercept out this resource to be checked and the event data of each child resource thereof, be effectively improved data volume huge Time event query speed.
The foregoing is only presently preferred embodiments of the present invention, be not intended to limit the protection model of the present invention Enclose.All any modification, equivalent substitution and improvement etc. made within the spirit and principles in the present invention, all Comprise within the scope of the present invention.

Claims (10)

1. the method for a tree structured resource storage, it is characterised in that including:
Tree structured resource is traveled through by preamble ergodic algorithm;
The order that each resource of traversal being gone out and the event data of each child resource thereof travel through according to preamble is successively It is stored in a list of thing;And in a position Hash table, record each resource in described event column Original position in table and event number;Wherein said event number is the event number of each resource self The event number sum of child resource each with it.
Method the most according to claim 1, it is characterised in that traveled through by preamble ergodic algorithm Before tree structured resource, described method also includes:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching.
Method the most according to claim 2, it is characterised in that described each resource that traversal is gone out And the event data of each child resource is sequentially stored in a list of thing according to the order that preamble travels through; And in a position Hash table, record each resource original position in described list of thing and event number Amount includes:
During preamble traversal tree structured resource, by the event data of Current resource traveled through out successively and Qi Ge The event data of resource adds the afterbody of described list of thing to;
Original position and the event number of this Current resource is recorded in the Hash table of described position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current It is current that the event number of resource updates in the Hash table of described position this plus the event number of its each child resource The event number of resource.
4. the device of a tree structured resource storage, it is characterised in that including:
Preamble spider module, for traveling through tree structured resource by preamble ergodic algorithm;
Memory cell, is used for the event data of each resource and each child resource thereof traversal gone out according to preamble The order of traversal is sequentially stored in a list of thing, and records each money in a position Hash table Source original position in described list of thing and event number;Wherein said event number is each resource The event number sum of the event number child resource each with it of self.
Device the most according to claim 4, it is characterised in that described device also includes:
Build table module, for setting up an empty list of thing, deposit successively with the order traveled through according to preamble Store up each resource and the event data of each child resource thereof;And set up an empty position Hash table, this position Putting the ID that key name is each resource of Hash table, key assignments is the integer array of two, each for record respectively Individual resource original position in described list of thing and event number;
Load-on module, for, before by preamble ergodic algorithm traversal tree structured resource, providing tree construction The event data in source is loaded in caching.
Device the most according to claim 5, it is characterised in that described memory cell includes:
Data add module, when preamble traversal tree structured resource, and the Current resource that will travel through out successively Event data and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle, for record in the Hash table of described position this Current resource original position and Event number;
Quantity more new module, if there is child resource in the Current resource for traversal, then to have traveled through it each During child resource, the event number of Current resource is used to add that the event number of its each child resource updates described The event number of this Current resource in the Hash table of position.
7. the method for a tree structured resource inquiry, it is characterised in that including:
Obtain list of thing and the position Hash table of the tree structured resource prestored, wherein, described event In list storage have by each resource of traveling through out successively during preamble ergodic algorithm traversal tree structured resource and The event data of its each child resource, in the Hash table of described position, record has each resource at described list of thing In original position and event number;Described event number is that the event number of each resource self is each with it The event number sum of child resource;
The resource to be checked original position in described list of thing and thing is inquired about in the Hash table of described position Number of packages amount;
According to the original position inquired and event number, in described list of thing, intercept out this to be checked Resource and the event data of each child resource thereof.
Method the most according to claim 7, it is characterised in that described method also includes: deposit in advance The list of thing of storage tree structured resource and position Hash table;
The described list of thing prestoring tree structured resource and position Hash table include:
Set up an empty list of thing, for according to preamble traversal order store successively each resource and The event data of its each child resource;
Setting up an empty position Hash table, the key name of this position Hash table is the ID of each resource, key assignments Be the integer array of two, for record respectively each resource original position in described list of thing and Event number;
The event data of tree structured resource is loaded in caching;
Tree structured resource is traveled through by preamble ergodic algorithm;
Add the event data of the Current resource traveled through out successively and the event data of Qi Ge child resource to institute State the afterbody of list of thing;
Original position and the event number of this Current resource is recorded in the Hash table of described position;
If the Current resource of traversal exists child resource, then when having traveled through its each child resource, use current It is current that the event number of resource updates in the Hash table of described position this plus the event number of its each child resource The event number of resource.
9. the device of a tree structured resource inquiry, it is characterised in that including:
Initialization unit, obtains list of thing and the position Hash table of the tree structured resource prestored, its In, in described list of thing, storage travels through out when having by preamble ergodic algorithm traversal tree structured resource successively Each resource and the event data of each child resource, in the Hash table of described position record have each resource to exist Original position in described list of thing and event number;Described event number is the thing of each resource self The event number sum of number of packages amount child resource each with it;
Query unit, for inquiring about resource to be checked in described list of thing in the Hash table of described position Original position and event number;
Interception unit, for according to the original position inquired and event number, in described list of thing Intercept out this resource to be checked and the event data of each child resource thereof.
Device the most according to claim 9, it is characterised in that described initialization unit also includes:
Build table module, for setting up an empty list of thing, deposit successively with the order traveled through according to preamble Store up each resource and the event data of each child resource thereof;And set up an empty position Hash table, this position Putting the ID that key name is each resource of Hash table, key assignments is the integer array of two, each for record respectively Individual resource original position in described list of thing and event number;
Load-on module, for being loaded into the event data of tree structured resource in caching;
Preamble spider module, for traveling through tree structured resource by preamble ergodic algorithm;
Data add module, when preamble traversal tree structured resource, and the Current resource that will travel through out successively Event data and the event data of Qi Ge child resource add the afterbody of described list of thing to;
Position logging modle, for record in the Hash table of described position this Current resource original position and Event number;
Quantity more new module, if there is child resource in the Current resource for traversal, then to have traveled through it each During child resource, the event number of Current resource is used to add that the event number of its each child resource updates described The event number of this Current resource in the Hash table of position.
CN201410834814.5A 2014-12-26 2014-12-26 A kind of method and apparatus that tree structured resource is stored, inquired Active CN105786931B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410834814.5A CN105786931B (en) 2014-12-26 2014-12-26 A kind of method and apparatus that tree structured resource is stored, inquired

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410834814.5A CN105786931B (en) 2014-12-26 2014-12-26 A kind of method and apparatus that tree structured resource is stored, inquired

Publications (2)

Publication Number Publication Date
CN105786931A true CN105786931A (en) 2016-07-20
CN105786931B CN105786931B (en) 2019-06-04

Family

ID=56389117

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410834814.5A Active CN105786931B (en) 2014-12-26 2014-12-26 A kind of method and apparatus that tree structured resource is stored, inquired

Country Status (1)

Country Link
CN (1) CN105786931B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110532257A (en) * 2019-07-12 2019-12-03 鑫火信息技术(上海)有限公司 A kind of method and system that family's modal data is carried out to visualization presentation
CN111460080A (en) * 2020-03-25 2020-07-28 中国人民解放军国防科技大学 Event map construction and query method and system for open source data heat analysis

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5418947A (en) * 1992-12-23 1995-05-23 At&T Corp. Locating information in an unsorted database utilizing a B-tree
CN103268460A (en) * 2013-06-20 2013-08-28 北京航空航天大学 Integrity verification method of cloud storage data
CN103365695A (en) * 2013-07-31 2013-10-23 广州市动景计算机科技有限公司 Method and device for increasing sub-resource loading speed
CN104008205A (en) * 2014-06-18 2014-08-27 中国人民解放军信息工程大学 Content routing inquiry method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5418947A (en) * 1992-12-23 1995-05-23 At&T Corp. Locating information in an unsorted database utilizing a B-tree
CN103268460A (en) * 2013-06-20 2013-08-28 北京航空航天大学 Integrity verification method of cloud storage data
CN103365695A (en) * 2013-07-31 2013-10-23 广州市动景计算机科技有限公司 Method and device for increasing sub-resource loading speed
CN104008205A (en) * 2014-06-18 2014-08-27 中国人民解放军信息工程大学 Content routing inquiry method and system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110532257A (en) * 2019-07-12 2019-12-03 鑫火信息技术(上海)有限公司 A kind of method and system that family's modal data is carried out to visualization presentation
CN110532257B (en) * 2019-07-12 2022-05-20 鑫火信息技术(上海)有限公司 Method and system for visually presenting family tree data
CN111460080A (en) * 2020-03-25 2020-07-28 中国人民解放军国防科技大学 Event map construction and query method and system for open source data heat analysis
CN111460080B (en) * 2020-03-25 2022-04-22 中国人民解放军国防科技大学 Event map construction and query method and system for open source data heat analysis

Also Published As

Publication number Publication date
CN105786931B (en) 2019-06-04

Similar Documents

Publication Publication Date Title
CN106202112B (en) CACHE DIRECTORY method for refreshing and device
CN105138592B (en) A kind of daily record data storage and search method based on distributed structure/architecture
Singh et al. Bloom filter based optimization scheme for massive data handling in IoT environment
KR101640185B1 (en) Distributed cache for graph data
JP5964808B2 (en) Graph data composite term indexing method, computer-readable medium, and system
Huang et al. Research on architecture and query performance based on distributed graph database Neo4j
US20140280276A1 (en) Database sharding by shard levels
US9449061B2 (en) Storing and processing data organized as flexible records
CN105574054B (en) A kind of distributed caching range query method, apparatus and system
CN104298687B (en) A kind of hash partition management method and device
CN111159219B (en) Data management method, device, server and storage medium
CN104407879A (en) A power grid timing sequence large data parallel loading method
US20130275410A1 (en) Live topological query
CN104933054B (en) The URL storage methods and device of cache resource file, cache server
Huang et al. A multi-partitioning approach to building fast and accurate counting bloom filters
US20180205790A1 (en) Distributed data structure in a software defined networking environment
CN105786931A (en) Tree structure resource storage and query methods and apparatuses
CN102542019A (en) Identification code storage method and identification code storage system as well as identification code indexing method and identification code indexing system
Yuan et al. Partitioning social networks for fast retrieval of time-dependent queries
CN105335530B (en) A method of promoting long data block data de-duplication performance
Osemwegie et al. Performance benchmarking of key-value store NoSQL databases
CN104598567A (en) Data statistics and de-duplication method based on Hadoop MapReduce programming frame
CN103902554B (en) Data access method and device
CN105488056B (en) A kind of object processing method and equipment
CN104794237A (en) Web page information processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: Room 818, 8 / F, 34 Haidian Street, Haidian District, Beijing 100080

Patentee after: BEIJING ULTRAPOWER SOFTWARE Co.,Ltd.

Address before: 100089 Beijing city Haidian District wanquanzhuang Road No. 28 Wanliu new building 6 storey block A Room 601

Patentee before: BEIJING ULTRAPOWER SOFTWARE Co.,Ltd.