CN105786931B - A kind of method and apparatus that tree structured resource is stored, inquired - Google Patents
A kind of method and apparatus that tree structured resource is stored, inquired Download PDFInfo
- Publication number
- CN105786931B CN105786931B CN201410834814.5A CN201410834814A CN105786931B CN 105786931 B CN105786931 B CN 105786931B CN 201410834814 A CN201410834814 A CN 201410834814A CN 105786931 B CN105786931 B CN 105786931B
- Authority
- CN
- China
- Prior art keywords
- resource
- thing
- event
- list
- event number
- 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.)
- Active
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses the method and apparatus of a kind of storage of tree structured resource, inquiry.The tree structured resource querying method includes: the list of thing and position Hash table for obtaining pre-stored tree structured resource, wherein, the event data of each resource and its each child resource that successively traverse out when traversing tree structured resource by preamble ergodic algorithm is stored in the list of thing, record has initial position and event number of each resource in the list of thing in the position Hash table;The event number is the event number of each resource itself and the sum of the event number of its each child resource;Initial position and event number of the resource to be checked in the list of thing are inquired in the position Hash table;According to the initial position and event number inquired, the event data of the resource to be checked and its each child resource is intercepted out in the list of thing.Technical solution of the present invention can effectively improve data volume it is huge when tree structured resource event inquiry velocity.
Description
Technical field
The present invention relates to set data buffer storage inquiring technology field, the in particular to side that a kind of tree structured resource is stored, inquired
Method and device.
Background technique
The entity of failure generation can be monitored in monitoring system, such as host, CPU, table space are known as resource.Ordinary business practice
For system by resource compositions such as database, hosts, host itself also has child resource, such as memory, cpu etc..These resources were monitoring
A large amount of alarm event, the i.e. information of resource generation failure would generally be generated in journey.Such as host itself can be just like " connection is disconnected
Open ", the events such as " cpu utilization rate is excessively high ", and its each child resource also has the alarm event of oneself, such as the child resource memory of host
" memory number of pages is excessively high " event.In IT monitoring system, usually there is tree structure relation in the resource monitored, as shown in Figure 1,
Fig. 1 left column is the example of the resource composition resource tree of tree structure relation, and the right side Fig. 1 is classified as showing for the history alarm event of resource generation
Example.
User is in query event, it is often desirable that can inquire all alarm things of selected resource and its each child resource
Part.But due to monitoring resource quantity it is huge, then the corresponding history alarm event number of its resource because the time it is accumulative huger.
In the case where so for resource more than more, event, when carrying out condition query to historical events, for million, the ten million above thing
Part information carries out structured query language (Structured Query Language, SQL) by traditional database mode
Inquiry, performance is extremely slow, and user experience is very poor.
Existing raising query performance scheme is: user is usually in concern 1~2 month for the inquiry of resource event
Data, the alarm event in 2 months is loaded into memory in advance with table data, it is slow by traversing these in inquiry
List is deposited, the speed of event query is improved.Existing this scheme is by cache way, although query performance is higher than database
SQL query mode, but be directed to tree node resource query when need to be traversed for whole event list, when tree node depth is longer,
The case where needing a large amount of recursive traversal child resource event, when data volume is huge, performance is also unsatisfactory.
Summary of the invention
The present invention provides the method and apparatus of a kind of storage of tree structured resource, inquiry, can effectively improve data volume
Event query speed when huge.
In order to achieve the above objectives, the technical scheme of the present invention is realized as follows:
On the one hand, the present invention provides a kind of methods of tree structured resource storage, comprising:
Tree structured resource is traversed by preamble ergodic algorithm;
The event data of each resource traversed out and its each child resource is sequentially stored according to the sequence that preamble traverses
In one list of thing;And initial position and thing of each resource in the list of thing are recorded in a position Hash table
Number of packages amount;Wherein the event number is the event number of each resource itself and the sum of the event number of its each child resource.
Wherein, before traversing tree structured resource by preamble ergodic algorithm, the method also includes:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each sub- money
The event data in source;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, and key assignments is two
Integer array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching.
Wherein, the sequence that each resource that will be traversed out and its event data of each child resource are traversed according to preamble according to
It is secondary to be stored in a list of thing;And starting of each resource in the list of thing is recorded in a position Hash table
Position and event number include:
When preamble traverses tree structured resource, by the thing of the event data of the Current resource successively traversed out and Qi Ge child resource
Number of packages is according to the tail portion for being added to the list of thing;
Initial position and the event number of the Current resource are recorded in the position Hash table;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the thing of Current resource is used
Number of packages amount updates the event number of the Current resource in the position Hash table plus the event number of its each child resource.
Corresponding to the method for above-mentioned tree structured resource storage, the present invention provides a kind of dresses of tree structured resource storage
It sets, comprising:
Preamble spider module, for traversing tree structured resource by preamble ergodic algorithm;
Storage unit, the event data of each resource and its each child resource for that will traverse out traverse suitable according to preamble
Sequence is sequentially stored in a list of thing, and records each resource in the list of thing in a position Hash table
Initial position and event number;Wherein the event number is the event number of each resource itself and the event of its each child resource
The sum of quantity.
Optionally, described device further include:
Table module is built, for establishing an empty list of thing, each money is stored successively with the sequence traversed according to preamble
The event data of source and its each child resource;And an empty position Hash table is established, the key name of the position Hash table is each
The ID of resource, the integer array that key assignments is two, for recording initial position of each resource in the list of thing respectively
And event number;
Loading module is used for before traversing tree structured resource by preamble ergodic algorithm, by the event of tree structured resource
Data are loaded into caching.
Wherein, the storage unit includes:
Data adding module, when for preamble traversal tree structured resource, by the event number of the Current resource successively traversed out
It is added to the tail portion of the list of thing according to the event data with its each child resource;
Position logging modle, for recording initial position and the event number of the Current resource in the position Hash table
Amount;
Quantity update module, if there are child resources for the Current resource for traversing, when having traversed its each child resource,
The current money in the position Hash table is updated plus the event number of its each child resource using the event number of Current resource
The event number in source.
The method and apparatus of tree structured resource provided by the invention storage the utility model has the advantages that
The present invention traverses tree structured resource by preamble ergodic algorithm, by each resource traversed out and its each child resource
Event data is sequentially stored in a list of thing according to the sequence that preamble traverses, and is recorded respectively in a position Hash table
Initial position and event number of a resource in the list of thing ensure that the event data and its each son of each resource itself
The Coutinuous store of the event data of resource, and can be according to the event number of each resource itself and the event number of Qi Ge child resource
The sum of easily count the event number of each resource;Thus when needing query resource, it can be very easily in position
Initial position and event number of the resource to be checked in list of thing are inquired in Hash table, then in the list of thing
Directly intercept out the event data of the resource to be checked and its each child resource.
On the other hand, the present invention provides a kind of methods of tree structured resource inquiry, comprising:
Obtain the list of thing and position Hash table of pre-stored tree structured resource, wherein deposit in the list of thing
Contain the event number of each resource and its each child resource that successively traverse out when traversing tree structured resource by preamble ergodic algorithm
According to record has initial position and event number of each resource in the list of thing in the position Hash table;The thing
Number of packages amount is the event number of each resource itself and the sum of the event number of its each child resource;
Initial position and event number of the resource to be checked in the list of thing are inquired in the position Hash table;
According to the initial position and event number inquired, intercepted out in the list of thing resource to be checked and its
The event data of each child resource.
The above method further includes the list of thing and position Hash table that tree structured resource is stored in advance, described that tree is stored in advance
The list of thing and position Hash table of infrastructure resource include:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each sub- money
The event data in source;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, and key assignments is two
Integer array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching;
Tree structured resource is traversed by preamble ergodic algorithm;
The event data of the event data of the Current resource successively traversed out and Qi Ge child resource is added to the event
The tail portion of list;
Initial position and the event number of the Current resource are recorded in the position Hash table;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the thing of Current resource is used
Number of packages amount updates the event number of the Current resource in the position Hash table plus the event number of its each child resource.
Corresponding to the method for above-mentioned tree structured resource inquiry, the present invention provides a kind of dresses of tree structured resource inquiry
It sets, comprising:
Initialization unit obtains the list of thing and position Hash table of tree structured resource, wherein the list of thing in advance
In be stored with the thing of each resource and its each child resource successively traversed out when traversing tree structured resource by preamble ergodic algorithm
Number of packages evidence, record has initial position and event number of each resource in the list of thing in the position Hash table;Institute
State the sum of the event number of event number and its each child resource that event number is each resource itself;
Query unit, for inquiring start bit of the resource to be checked in the list of thing in the position Hash table
It sets and event number;
Interception unit, for according to the initial position and event number inquired, intercepting out in the list of thing should
The event data of resource to be checked and its each child resource.
Wherein, the initialization unit further include:
Table module is built, for establishing an empty list of thing, each money is stored successively with the sequence traversed according to preamble
The event data of source and its each child resource;And an empty position Hash table is established, the key name of the position Hash table is each
The ID of resource, the integer array that key assignments is two, for recording initial position of each resource in the list of thing respectively
And event number;
Loading module, for the event data of tree structured resource to be loaded into caching;
Preamble spider module, for traversing tree structured resource by preamble ergodic algorithm;
Data adding module, when for preamble traversal tree structured resource, by the event number of the Current resource successively traversed out
It is added to the tail portion of the list of thing according to the event data with its each child resource;
Position logging modle, for recording initial position and the event number of the Current resource in the position Hash table
Amount;
Quantity update module, if there are child resources for the Current resource for traversing, when having traversed its each child resource,
The current money in the position Hash table is updated plus the event number of its each child resource using the event number of Current resource
The event number in source.
The method and apparatus of tree structured resource provided by the invention inquiry the utility model has the advantages that
By obtaining the list of thing and position Hash table of tree structured resource in advance, due to the list of thing and position Hash
Table is the acquisition when traversing tree structured resource by preamble ergodic algorithm, by each resource traversed out and its thing of each child resource
Number of packages is sequentially stored in the list of thing according to according to the sequence of preamble traversal, and records each resource in Hash table in the position
Initial position and event number in the list of thing ensure that the event data and its each child resource of each resource itself
The Coutinuous store of event data, and can be according to the event number of each resource itself and the sum of the event number side of Qi Ge child resource
Just geo-statistic goes out the event number of each resource;Thus when needing query resource, it can be very easily in position Hash table
In inquire initial position and event number of the resource to be checked in list of thing, then directly cut in the list of thing
The event data for taking out the resource to be checked and its each child resource, effectively improve data volume it is huge when event query speed
Degree.
Detailed description of the invention
Fig. 1 is the example of tree structured resource and its history alarm event;
Fig. 2 is a kind of method flow diagram of tree structured resource storage provided in an embodiment of the present invention;
Fig. 3 is a tree structured resource example;
Fig. 4 is the event data example that each resource includes in table structure resource shown in Fig. 3;
Fig. 5 is the method flow diagram of another tree structured resource storage provided in an embodiment of the present invention;
Fig. 6 is a kind of structure drawing of device of tree structured resource storage provided in an embodiment of the present invention;
Fig. 7 is a kind of method flow diagram of tree structured resource inquiry provided in an embodiment of the present invention;
Fig. 8 is a kind of structure drawing of device of tree structured resource inquiry provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention
Formula is described in further detail.
Integral Thought of the invention is: resource tree is traversed by preamble ergodic algorithm, by the event data of tree structured resource
It finds, is put into list of thing according to the sequence that preamble traverses, while recording the event start bit of resource by position Hash table
It sets and event number, constructs list of thing and position Hash table in this way, it can by initial position and event number in inquiry
Directly to intercept out the event data to be inquired.
As shown in Fig. 2, a kind of method of tree structured resource storage provided in an embodiment of the present invention, this method mainly includes such as
Lower step:
S210 traverses tree structured resource by preamble ergodic algorithm.
Traversal of tree is the important operation of one kind of tree.So-called traversal refers to the access of the information to nodes all in tree,
Successively node each in tree access once and is only accessed primary.3 kinds of most important traversal modes of tree are referred to as preamble
Traversal, inorder traversal and postorder traversal.
Preamble traversal is one kind of traversal of binary tree, and also referred to as pre-reset mechanism, preorder traversal, preamble is traveled round, and can be denoted as root
Left and right.Then preamble traversal access root node first traverses left subtree, finally traverse right subtree.When traversing left and right subtree, still
Root node is first so accessed, left subtree is then traversed, finally traverses right subtree.It is to be noted that when traversal left and right subtree still
Using preamble traversal method.
Fig. 3 is a tree structured resource example, is provided with the tree construction of the binary tree (7 tree nodes) of depth 3 shown in Fig. 3
For source, including seven resources of A, B, C, D, E, F, G, using the sequence of preamble ergodic algorithm traversal resource are as follows: A- > C- > F- > G-
>E->B->D。
S220 successively deposits the sequence that the event data of each resource traversed out and its each child resource is traversed according to preamble
Storage is in a list of thing;And initial position of each resource in the list of thing is recorded in a position Hash table
And event number;Wherein the event number be each resource itself event number and its each child resource event number it
With.
It should be noted that before traversing tree structured resource by preamble ergodic algorithm, the method for the embodiment of the present invention
Further include:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each sub- money
The event data in source;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, and key assignments is two
Integer array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching.
Position Hash table is illustrated using sample data below:
{
" 100 ": [0,20], // -- 100 be key name, and [0,20] is key assignments
“101”:[15,5],
“102”:[20,3]
}
Wherein 100,101,102 be resource ID, and the event initial position of resource 100 is 0, length 20;The event of resource 101
Initial position is 15, length 5;The event initial position of resource 102 is 20, length 3.The length of resource 100 contains money
The position in source 101 and length indicate that resource 101 is the child resource of resource 100.
This step S220 is specifically included:
When preamble traverses tree structured resource, by the thing of the event data of the Current resource successively traversed out and Qi Ge child resource
Number of packages is according to the tail portion for being added to list of thing;
Initial position and the event number of the Current resource are recorded in the Hash table of position;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the thing of Current resource is used
Number of packages amount updates the event number of the Current resource in the Hash table of position plus the event number of its each child resource.Thing herein
Number of packages amount is the event number of each resource itself and the sum of the event number of its each child resource.
By taking tree structured resource shown in Fig. 3 as an example, if the event data that its each resource includes is as shown in Figure 4.Wherein,
Resource A includes A1, A2 event data, and resource B includes B1 event data, and resource C includes C1, C2, C3 event data, resource D packet
D1 event data is included, resource E includes E1 event data, and resource F includes F1, F2 event data, and resource G includes G1 event data.
The event data of each resource traversed out is sequentially stored in a list of thing according to the sequence that preamble traverses
In, obtained list of thing information are as follows:
{A1,A2,C1,C2,C3,F1,F2,G1,E1,B1,D1}。
Initial position and event number of each resource in above-mentioned list of thing are recorded in a position Hash table, are obtained
To position Hash table information (initial position is call number, and 0 starts) are as follows:
{
A:[0,11],
B:[9,2],
C:[2,7],
D:[10,1],
E:[5,1],
F:[6,3],
G:[8,1]
Below by taking the storage of the history alarm event of resource as an example, tree structured resource storage provided in an embodiment of the present invention
Method flow is as shown in figure 5, include the following steps:
S500 establishes an empty list of thing and an empty position Hash table.
Resource data is loaded into caching by S501 from database.
It should be noted that this step is only changed in history alarm event, or interval some cycles are when restarting system,
Resource data is loaded into caching.
S502 selects resource root vertex.
S503 handles Current resource.
S504 inquires the history alarm event of Current resource from database.
S505, the tail portion for history alarm event will be inquired being added to list of thing.
S506 obtains the event number of Current resource and the initial position in list of thing, records in the Hash table of position
The initial position of the Current resource and event number.
Does S507 judge that whole child resources of Current resource have traversed? if so, S508 is entered step, if not, into
Enter step S509.
S508, being updated using the event number of Current resource plus the event number of each child resource should in the Hash table of position
The event number of Current resource.
S509 continues preamble and traverses resource tree.
Based on the method that above-mentioned tree structured resource stores, the embodiment of the invention provides a kind of storages of tree structured resource
Device, as shown in Figure 6, comprising:
Table module 601 is built, for establishing an empty list of thing, the sequence for traversing according to preamble is successively stored respectively
The event data of a resource and its each child resource;And an empty position Hash table is established, the key name of the position Hash table is
The ID of each resource, the integer array that key assignments is two, for recording starting of each resource in the list of thing respectively
Position and event number;
Loading module 602 is used for before traversing tree structured resource by preamble ergodic algorithm, by the thing of tree structured resource
Number of packages evidence is loaded into caching.
Preamble spider module 610, for traversing tree structured resource by preamble ergodic algorithm.
Storage unit 62, what the event data of each resource and its each child resource for that will traverse out was traversed according to preamble
Sequence is sequentially stored in a list of thing, and records each resource in the list of thing in a position Hash table
Initial position and event number;Event number herein is the event number of each resource itself and the event of its each child resource
The sum of quantity.
Wherein, the storage unit 62 includes:
Data adding module 621, when for preamble traversal tree structured resource, by the event of the Current resource successively traversed out
Data and the event data of Qi Ge child resource are added to the tail portion of the list of thing;
Position logging modle 622, for recording initial position and the event of the Current resource in the position Hash table
Quantity;
Quantity update module 623 is traversing its each child resource if there are child resources for the Current resource for traversing
When, it is current that this in the position Hash table is updated plus the event number of its each child resource using the event number of Current resource
The event number of resource.
It follows that the method and apparatus of tree structured resource storage provided in an embodiment of the present invention, are traversed by preamble and are calculated
Method traverses tree structured resource, the sequence that each resource traversed out and its event data of each child resource are traversed according to preamble according to
It is secondary to be stored in a list of thing, and start bit of each resource in the list of thing is recorded in a position Hash table
It sets and event number, ensure that the Coutinuous store of the event data of each resource itself and the event data of its each child resource, and
Each resource can be easily counted according to the sum of the event number of each resource itself and event number of Qi Ge child resource
Event number;To very easily inquire resource to be checked in the Hash table of position and exist when needing query resource
Initial position and event number in list of thing, then directly intercepted out in the list of thing resource to be checked and its
The event data of each child resource, effectively improve data volume it is huge when event query speed.
Below with the binary tree of depth 3 (7 tree nodes) concrete example:
Existing query scheme is directed to the number of each node resource query event:
1 resource of depth: resource quantity 1 traverses out all child resources (6), inquires the event of oneself and all child resources
(7 times), merged event;
2 resource of depth: resource quantity 2 traverses out all child resources (2), inquires the event of oneself and all child resources
(3 times), merged event;
3 resource of depth: resource quantity 4, the event (1 time) of query resource;
To sum up, the movement 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.
It calculates in this approach, other depth-averaged event query numbers:
Depth 2:(3*1+1*2)/3=5/3=1.67;
Depth 4:(15*1+7*2+3*4+1*8)/15=49/15=3.27;
Depth 5:(31*1+15*2+7*4+3*8+1*16)/31=129/31=4.16;
Depth n:(Σ (2n-i-1) * 2i)/(2n-1) wherein n is depth, i value 0 arrives n-1;
And use the solution of the present invention query event number:
Each node: inquiring position Hash table 1 time, according to position enquiring event 1 time, and with the depth of binary tree without
It closes, is all query event 1 time.
To sum up: the core capabilities difference of the solution of the present invention and existing scheme is to obtain event times.Ability of the present invention
Averagely improve search efficiency (Σ (2n-i-1)*2i)/(2n- 1) again, wherein n is depth, and i value 0 arrives n-1.
Based on identical inventive concept, the present invention also provides a kind of methods of tree structured resource inquiry, as shown in fig. 7,
Include:
S701 obtains the list of thing and position Hash table of pre-stored tree structured resource;
Wherein, it is stored in the list of thing when traversing tree structured resource by preamble ergodic algorithm and successively traverses out
The event data of each resource and its each child resource, record has each resource in the list of thing in the position Hash table
Initial position and event number;The event number is the event number of each resource itself and the event number of its each child resource
The sum of amount.
S702 inquires initial position and event number of the resource to be checked in the list of thing in the position in Hash table
Amount.
S703 intercepts out the resource to be checked according to the initial position and event number inquired in the list of thing
And its event data of each child resource.
Specifically, according to the ID of the resource to be inquired, the event data for inquiring the resource in " position Hash table " exists
Initial position and event number in " list of thing ".It then, can be in " thing according to the initial position of Directory Enquiries and event number
Part list " intercepts out the event data of the resource and its child resource.
For example, still by taking the event data that tree structured resource shown in Fig. 3 and each resource shown in Fig. 4 include as an example, in advance
First obtain the list of thing information of tree structured resource are as follows:
{A1,A2,C1,C2,C3,F1,F2,G1,E1,B1,D1}。
Obtain the position Hash table information of tree structured resource in advance (initial position is call number, and 0 starts) are as follows:
{
A:[0,11],
B:[9,2],
C:[2,7],
D:[10,1],
E:[5,1],
F:[6,3],
G:[8,1]
}
When needing to inquire all events of C resource, the key assignments that resource C is obtained from the Hash table of position is [2,7], according to
The key assignments finds the position of serial number 2 in list of thing, then intercepts the value of 7 length, as C1, C2, C3, F1, F2, G1,
E1。
Wherein, the list of thing and position Hash table that tree structured resource is stored in advance include:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each sub- money
The event data in source;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, and key assignments is two
Integer array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching;
Tree structured resource is traversed by preamble ergodic algorithm;
The event data of the event data of the Current resource successively traversed out and Qi Ge child resource is added to the event
The tail portion of list;
Initial position and the event number of the Current resource are recorded in the position Hash table;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the thing of Current resource is used
Number of packages amount updates the event number of the Current resource in the position Hash table plus the event number of its each child resource.
It is appreciated that the step of list of thing and position Hash table of storage tree structured resource be not in each inquiry all
It can execute, only be changed in tree structured resource, or interval some cycles can just execute when restarting system.
Based on the method that above-mentioned tree structured resource is inquired, the embodiment of the invention also provides a kind of inquiries of tree structured resource
Device, as shown in Figure 8, comprising:
Initialization unit 80 obtains the list of thing and position Hash table of tree structured resource, wherein the event column in advance
The each resource and its each child resource successively traversed out when traversing tree structured resource by preamble ergodic algorithm is stored in table
Event data, record has initial position and event number of each resource in the list of thing in the position Hash table;
The event number is the event number of each resource itself and the sum of the event number of its each child resource;
Query unit 81, for inquiring starting of the resource to be checked in the list of thing in the position Hash table
Position and event number;
Interception unit 82, for being intercepted out in the list of thing according to the initial position and event number traversed out
The event data of the resource to be checked and its each child resource.
Wherein, the initialization unit 80 further include:
Table module 801 is built, for establishing an empty list of thing, the sequence for traversing according to preamble is successively stored respectively
The event data of a resource and its each child resource;And an empty position Hash table is established, the key name of the position Hash table is
The ID of each resource, the integer array that key assignments is two, for recording starting of each resource in the list of thing respectively
Position and event number;
Loading module 802, for the event data of tree structured resource to be loaded into caching;
Preamble spider module 803, for traversing tree structured resource by preamble ergodic algorithm;
Data adding module 804, when for preamble traversal tree structured resource, by the event of the Current resource successively traversed out
Data and the event data of Qi Ge child resource are added to the tail portion of the list of thing;
Position logging modle 805, for recording initial position and the event of the Current resource in the position Hash table
Quantity;
Quantity update module 806 is traversing its each child resource if there are child resources for the Current resource for traversing
When, it is current that this in the position Hash table is updated plus the event number of its each child resource using the event number of Current resource
The event number of resource.
It follows that the method and apparatus of tree structured resource inquiry provided in an embodiment of the present invention, by obtaining tree in advance
The list of thing and position Hash table of infrastructure resource, since the list of thing and position Hash table are by preamble ergodic algorithm
It obtains, each resource traversed out and its event data of each child resource is traversed according to preamble suitable when traversing tree structured resource
Sequence is sequentially stored in the list of thing, and records start bit of each resource in the list of thing in Hash table in the position
It sets and event number, ensure that the Coutinuous store of the event data of each resource itself and the event data of its each child resource, and
Each resource can be easily counted according to the sum of the event number of each resource itself and event number of Qi Ge child resource
Event number;To very easily traverse out resource to be checked in the Hash table of position and exist when needing query resource
Initial position and event number in list of thing, then directly intercepted out in the list of thing resource to be checked and its
The event data of each child resource, effectively improve data volume it is huge when event query speed.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all
Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention
It is interior.
Claims (8)
1. a kind of method of tree structured resource storage characterized by comprising
Tree structured resource is traversed by preamble ergodic algorithm;
The event data of each resource traversed out and its each child resource is sequentially stored in one according to the sequence that preamble traverses
In list of thing;And initial position and event number of each resource in the list of thing are recorded in a position Hash table
Amount;Wherein the event number is the event number of each resource itself and the sum of the event number of its each child resource;
Wherein, the sequence that each resource that will be traversed out and its event data of each child resource are traversed according to preamble is successively deposited
Storage is in a list of thing;And initial position of each resource in the list of thing is recorded in a position Hash table
Include: with event number
When preamble traverses tree structured resource, by the event number of the event data of the Current resource successively traversed out and Qi Ge child resource
According to the tail portion for being added to the list of thing;
Initial position and the event number of the Current resource are recorded in the position Hash table;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the event number of Current resource is used
Amount updates the event number of the Current resource in the position Hash table plus the event number of its each child resource.
2. the method according to claim 1, wherein by preamble ergodic algorithm traverse tree structured resource it
Before, the method also includes:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each child resource
Event data;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, the integer that key assignments is two
Array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching.
3. a kind of device of tree structured resource storage characterized by comprising
Preamble spider module, for traversing tree structured resource by preamble ergodic algorithm;
Storage unit, the sequence that the event data of each resource and its each child resource for that will traverse out is traversed according to preamble according to
It is secondary to be stored in a list of thing, and starting of each resource in the list of thing is recorded in a position Hash table
Position and event number;Wherein the event number is the event number of each resource itself and the event number of its each child resource
The sum of;
The storage unit includes:
Data adding module, when for preamble traversal tree structured resource, by the event data of the Current resource successively traversed out and
The event data of its each child resource is added to the tail portion of the list of thing;
Position logging modle, for recording initial position and the event number of the Current resource in the position Hash table;
Quantity update module, when having traversed its each child resource, uses if there are child resources for the Current resource for traversing
The event number of Current resource updates the Current resource in the position Hash table plus the event number of its each child resource
Event number.
4. the device according to claim 3, which is characterized in that described device further include:
Build table module, for establishing an empty list of thing, with the sequence traversed according to preamble successively store each resource and
The event data of its each child resource;And an empty position Hash table is established, the key name of the position Hash table is each resource
ID, key assignments is two integer arrays, for recording initial position and thing of each resource in the list of thing respectively
Number of packages amount;
Loading module is used for before traversing tree structured resource by preamble ergodic algorithm, by the event data of tree structured resource
It is loaded into caching.
5. a kind of method of tree structured resource inquiry characterized by comprising
Obtain the list of thing and position Hash table of pre-stored tree structured resource, wherein be stored in the list of thing
The event data of each resource and its each child resource that are successively traversed out when traversing tree structured resource by preamble ergodic algorithm, institute
Rheme sets the initial position and event number that record has each resource in the list of thing in Hash table;The event number
For the event number of each resource itself and the sum of the event number of its each child resource;
Initial position and event number of the resource to be checked in the list of thing are inquired in the position Hash table;
According to the initial position and event number inquired, the resource to be checked and its each son are intercepted out in the list of thing
The event data of resource.
6. according to the method described in claim 5, it is characterized in that, the method also includes: tree structured resource is stored in advance
List of thing and position Hash table;
The list of thing that tree structured resource is stored in advance and position Hash table include:
An empty list of thing is established, the sequence for traversing according to preamble successively stores each resource and its each child resource
Event data;
An empty position Hash table is established, the key name of the position Hash table is the ID of each resource, the integer that key assignments is two
Array, for recording initial position and event number of each resource in the list of thing respectively;
The event data of tree structured resource is loaded into caching;
Tree structured resource is traversed by preamble ergodic algorithm;
The event data of the event data of the Current resource successively traversed out and Qi Ge child resource is added to the list of thing
Tail portion;
Initial position and the event number of the Current resource are recorded in the position Hash table;
If there are child resources for the Current resource of traversal, when having traversed its each child resource, the event number of Current resource is used
Amount updates the event number of the Current resource in the position Hash table plus the event number of its each child resource.
7. a kind of device of tree structured resource inquiry characterized by comprising
Initialization unit obtains the list of thing and position Hash table of pre-stored tree structured resource, wherein the event column
The each resource and its each child resource successively traversed out when traversing tree structured resource by preamble ergodic algorithm is stored in table
Event data, record has initial position and event number of each resource in the list of thing in the position Hash table;
The event number is the event number of each resource itself and the sum of the event number of its each child resource;
Query unit, for inquired in the position Hash table initial position of the resource to be checked in the list of thing and
Event number;
Interception unit, for according to the initial position that inquires and event number, it is to be checked in the list of thing to intercept out this
Ask the event data of resource and its each child resource.
8. device according to claim 7, which is characterized in that the initialization unit further include:
Build table module, for establishing an empty list of thing, with the sequence traversed according to preamble successively store each resource and
The event data of its each child resource;And an empty position Hash table is established, the key name of the position Hash table is each resource
ID, key assignments is two integer arrays, for recording initial position and thing of each resource in the list of thing respectively
Number of packages amount;
Loading module, for the event data of tree structured resource to be loaded into caching;
Preamble spider module, for traversing tree structured resource by preamble ergodic algorithm;
Data adding module, when for preamble traversal tree structured resource, by the event data of the Current resource successively traversed out and
The event data of its each child resource is added to the tail portion of the list of thing;
Position logging modle, for recording initial position and the event number of the Current resource in the position Hash table;
Quantity update module, when having traversed its each child resource, uses if there are child resources for the Current resource for traversing
The event number of Current resource updates the Current resource in the position Hash table plus the event number of its each child resource
Event number.
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 CN105786931A (en) | 2016-07-20 |
CN105786931B true 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) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110532257B (en) * | 2019-07-12 | 2022-05-20 | 鑫火信息技术(上海)有限公司 | Method and system for visually presenting family tree data |
CN111460080B (en) * | 2020-03-25 | 2022-04-22 | 中国人民解放军国防科技大学 | Event map construction and query method and system for open source data heat analysis |
Citations (4)
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 |
-
2014
- 2014-12-26 CN CN201410834814.5A patent/CN105786931B/en active Active
Patent Citations (4)
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 |
Also Published As
Publication number | Publication date |
---|---|
CN105786931A (en) | 2016-07-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11757739B2 (en) | Aggregation of select network traffic statistics | |
CN102915347B (en) | A kind of distributed traffic clustering method and system | |
US9842132B2 (en) | Bloom filter index for device discovery | |
Leung et al. | Discovering frequent patterns from uncertain data streams with time-fading and landmark models | |
CN105574054B (en) | A kind of distributed caching range query method, apparatus and system | |
CN110196847A (en) | Data processing method and device, storage medium and electronic device | |
US10769132B1 (en) | Efficient storage and retrieval of time series data | |
CN110023925A (en) | It generates, access and display follow metadata | |
Xiao et al. | Using parallel bloom filters for multiattribute representation on network services | |
CN112148217B (en) | Method, device and medium for caching deduplication metadata of full flash memory system | |
CN109213699A (en) | A kind of metadata management method, system, equipment and computer readable storage medium | |
CN107391600A (en) | Method and apparatus for accessing time series data in internal memory | |
US20130275410A1 (en) | Live topological query | |
CN107480268A (en) | Data query method and device | |
CN110232074A (en) | Flow data and dimension table correlating method and stream calculation device | |
Huang et al. | A multi-partitioning approach to building fast and accurate counting bloom filters | |
CN105786931B (en) | A kind of method and apparatus that tree structured resource is stored, inquired | |
US20200311029A1 (en) | Key value store using generation markers | |
CN105610881B (en) | A kind of distributed caching range query method, apparatus and system | |
CN110532307A (en) | A kind of date storage method and querying method flowing sliding window | |
CN104933054A (en) | Uniform resource locator (URL) storage method and device of cache resource file, and cache server | |
US20180205790A1 (en) | Distributed data structure in a software defined networking environment | |
US10235420B2 (en) | Bucket skiplists | |
Yuan et al. | Partitioning social networks for fast retrieval of time-dependent queries | |
CN103092767A (en) | Management method for cloud computing interior physical machine information memory pool |
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. |