Dynamic digital object-oriented subscription tree reconstruction method and system
By constructing subtrees in the subscription tree and decentrally storing subscription data, the problem of reduced event matching efficiency caused by unbalanced subscription trees in heterogeneous systems is solved, and the event matching efficiency of data interconnection applications is improved.
Patent Information
- Application Number
- CN202410608046.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2024-08-23
AI Technical Summary
In the interconnection of heterogeneous systems, the imbalance of the subscription tree in the existing publish-subscribe system leads to a reduction in event matching efficiency. Especially when the subscription content changes, the matching efficiency of nodes with large storage capacity drops significantly.
By determining the subtree of the target storage node in the subscription tree, constructing the subtree based on subscription attributes, decentrally storing subscription data, reducing matching paths, and improving event matching efficiency.
Through subtree construction and decentralized data storage, the event matching time is reduced, the event matching efficiency in data interconnection applications is improved, and the efficiency reduction problem caused by the imbalance of the subscription tree is solved.
Smart Images

Figure CN118535767A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of big data, and in particular, to a subscription tree reconstruction method and system for dynamic digital objects. Background Art
[0002] With the development of science and technology, heterogeneous system interconnection technology has begun to be widely used in production activities. For example, in smart agriculture, data is collected from the agricultural production environment, including soil moisture, temperature, light, water quality and other information, and then data analysis and artificial intelligence technology are used to manage agricultural production more accurately, thereby improving agricultural production efficiency and quality and reducing costs and risks; smart manufacturing applications can realize intelligent control of product manufacturing by collecting and recording various data in the production and manufacturing process, such as production equipment status, product quality inspection data, etc. Heterogeneous system interconnection applications usually include a variety of information systems with multi-source heterogeneous characteristics. Therefore, realizing data interaction between multiple multi-source heterogeneous systems is a key issue.
[0003] Digital objects mainly include data entities, metadata and data status information. Digital object metadata is the descriptive information of digital objects, which is used for retrieval and discovery of digital objects. Digital objects can realize data interconnection and interoperability between multi-source heterogeneous systems. At the same time, in order to meet the communication needs between various subjects, a publish-subscribe system with loose coupling, multi-point communication and asynchronous transmission is used as an intermediate system.
[0004] In the existing publish-subscribe system, subscribers generate subscriptions based on their needs for digital object metadata. When a publisher publishes an event, the event matching the subscription can be published to the corresponding subscriber through event matching, thereby realizing communication between multi-source heterogeneous systems.
[0005] The storage method of subscriptions affects the efficiency of event matching. Compared with centrally storing all subscriptions and then comparing the published events with all the centrally stored subscriptions one by one, storing subscriptions in a tree structure and then selecting paths between nodes in the tree structure during event matching can reduce a large number of unnecessary matches. However, when the content of the subscription changes significantly, the difference in the amount of subscription data stored in each node of the subscription tree will become larger, resulting in an unbalanced subscription tree. The efficiency of event matching of subscription tree nodes with larger storage capacity will also decrease accordingly. Summary of the invention
[0006] The embodiments of the present application provide a subscription tree reconstruction method and system for dynamic digital objects, aiming to improve the efficiency of event matching in data interconnection applications.
[0007] In a first aspect, an embodiment of the present application provides a subscription tree reconstruction method for dynamic digital objects, the method comprising:
[0008] In response to a subscription adding operation of a subject, obtaining a subscription to be added, wherein the subscription represents a demand of the corresponding subject for digital object metadata, and the subscription includes one or more subscription attributes;
[0009] Determining a target storage node for the subscription to be added in the subscription tree, and determining the number of subscriptions stored in the target storage node;
[0010] When the number of subscriptions stored in the target storage node is greater than the subscription storage threshold, constructing a subtree of the target storage node according to all subscriptions stored in the target storage node and the subscription attributes corresponding to each of the subscriptions to be added, wherein constructing the subtree of the target storage node includes determining node attributes of each node of the subtree and determining paths between nodes at different levels;
[0011] All subscriptions stored in the target storage node and the subscription to be added are dispersedly stored in a subtree of the target storage node to reconstruct the subscription tree, wherein each node in the subtree of the target storage node can be used to store different subscriptions.
[0012] Optionally, constructing a subtree of the target storage node according to all subscriptions stored in the target storage node and subscription attributes corresponding to each of the subscriptions to be added includes:
[0013] Among all subscriptions stored in the target storage node and the subscription to be added, sort the number of occurrences of each subscription attribute in descending order, and use the subscription attributes ranked in the top N1 positions as multiple candidate index attributes of the subtree;
[0014] According to the number of times that the width of the constraint range of the multiple candidate index attributes does not exceed the upper bound threshold, the multiple candidate index attributes are sorted in descending order, and the candidate index attributes ranked in the first N2 positions are selected as the index attributes of the subtree;
[0015] According to the index attribute of the subtree, the node attributes corresponding to the nodes at different levels of the subtree are determined, and according to the value range of the index attribute of the subtree, the paths between the nodes at different levels in the subtree are determined to construct the subtree of the target storage node.
[0016] Optionally, all subscriptions stored in the target storage node and the subscription to be added are stored in a subtree of the target storage node in a dispersed manner, including:
[0017] For all subscriptions stored in the target storage node and any subscription in the subscription to be added, judging the type of the current node in the order from the root node to the child node of the subtree;
[0018] If the current node is a non-leaf node and the subscription contains the node attribute corresponding to the current node, the subscription attribute consistent with the node attribute is deleted in the subscription, and the arrival path from the current node to the next-level child node is determined according to the attribute type of the subscription attribute;
[0019] If the current node is a leaf node, or the subscription attribute in the subscription under the current node is empty, the subscription is stored in the subscription list of the current node.
[0020] Optionally, for all subscriptions stored in the target storage node and any subscription in the subscription to be added, after determining the type of the current node in the order from the root node to the child node of the subtree, the method further includes:
[0021] If the current node is a non-leaf node and the subscription does not contain the node attribute corresponding to the current node, the rightmost path is selected as the path from the current node to the next-level child node.
[0022] Optionally, when any non-leaf node in the subscription tree is used to aggregate all subscriptions of the next layer of nodes connected thereto, the target storage node is any leaf node of the subscription tree.
[0023] Optionally, when each node in the subscription tree stores different subscriptions, the target storage node is any node in the subscription tree.
[0024] Optionally, all subscriptions stored in the target storage node and the subscription to be added are stored in a subtree of the target storage node in a dispersed manner, including:
[0025] storing all subscriptions stored in the target storage node and the subscription to be added in a subscription table;
[0026] The subject identifiers corresponding to all the subscriptions and the subscriptions to be added are stored in a dispersed manner in a subtree of the target storage node.
[0027] In a second aspect, an embodiment of the present application provides a subscription tree reconstruction system for dynamic digital objects, the system comprising:
[0028] An acquisition module, configured to acquire a subscription to be added in response to a subscription adding operation of a subject, wherein the subscription represents a demand of the corresponding subject for digital object metadata, and the subscription includes one or more subscription attributes;
[0029] A quantity determination module, used to determine the target storage node of the subscription to be added in the subscription tree, and determine the number of subscriptions stored in the target storage node;
[0030] A subtree construction module, configured to construct a subtree of the target storage node according to subscription attributes corresponding to all subscriptions stored in the target storage node and the subscriptions to be added when the number of subscriptions stored in the target storage node is greater than a subscription storage threshold, wherein constructing the subtree of the target storage node includes determining node attributes of each node of the subtree and determining paths between nodes at different levels;
[0031] A reconstruction module is used to disperse and store all subscriptions stored in the target storage node and the subscription to be added in a subtree of the target storage node to reconstruct the subscription tree, wherein each node in the subtree of the target storage node can be used to store different subscriptions.
[0032] Beneficial effects:
[0033] When the subject adds a subscription, first determine the target storage node corresponding to the subscription to be added in the subscription tree, and determine the number of subscriptions stored in the target storage node. When the number of subscriptions is greater than the subscription storage threshold, build a subtree of the target storage node based on all subscriptions stored in the target storage node and the subscription attributes corresponding to each subscription to be added.
[0034] For the target storage node with a large storage volume, a subtree is constructed. According to the subscription properties corresponding to the subscriptions stored therein and the subscriptions to be added, the node properties of each node of the subtree and the paths between nodes of different levels are determined. Then, all the subscriptions previously stored in the target storage node and the subscriptions to be added are dispersedly stored in the subtree of the target storage node. The subscription tree after reconstruction based on the node with a large subscription storage volume can reduce the amount of subscriptions to be matched through the path between the nodes of the subtree and the nodes of the same level when the event is matched to the target storage node. It is not necessary to match all the subscriptions stored in the target storage node with the events one by one, thereby reducing the matching time and improving the efficiency of event matching in data interconnection applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0036] Figure 1is a flowchart of the steps of a subscription tree reconstruction method for dynamic digital objects proposed in one embodiment of the present application;
[0037] Figure 2 It is a schematic diagram of the structure of a subtree provided in an embodiment of the present application;
[0038] Figure 3 This is a schematic diagram of a result of subscribing to and storing in a subtree proposed in an embodiment of the present application;
[0039] Figure 4 This is a schematic diagram of matching candidate subscriptions proposed in an embodiment of the present application;
[0040] Figure 5 This is a schematic diagram of matching candidate subscriptions proposed in an embodiment of the present application;
[0041] Figure 6 This is a schematic diagram of the reconstruction of a new subscription tree proposed in an embodiment of the present application;
[0042] Figure 7 It is a functional module diagram of a subscription tree reconstruction system for dynamic digital objects proposed in one embodiment of the present application. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] Digital objects mainly include data entities, metadata and data status information. Digital object metadata is the description information of digital objects, which is used for retrieval and discovery of digital objects. In heterogeneous system interconnection technology, digital objects can be used to achieve data interconnection and interoperability between multi-source heterogeneous systems.
[0045] The publish-subscribe mechanism is widely used in multi-source heterogeneous systems. Each subject is both a publisher and a subscriber. The biggest advantage of the publish-subscribe mechanism is that it reduces the coupling of the system. Publishers and subscribers do not need to be online at the same time, nor do they need to know each other's information. The production and consumption of messages do not have to be carried out at the same time. Subscribers can pull time through asynchronous callbacks.
[0046] Subscribers can subscribe to the digital object metadata of interest through subscription conditions. When new digital object metadata is generated or updated, it is published as an event. Then, through event matching, the event is published to subscribers who have subscribed. In the entire process of event subscription, event matching and event distribution, the efficiency of event matching affects the efficiency of the entire system operation.
[0047] The storage method of subscriptions affects the efficiency of event matching. Compared with centrally storing all subscriptions and then comparing the published events with all the centrally stored subscriptions one by one, storing subscriptions in a tree structure and then selecting paths between nodes in the tree structure during event matching can reduce a large number of unnecessary matches. However, when the content of the subscription changes significantly, the difference in the amount of subscription data stored in each node of the subscription tree will become larger, resulting in an unbalanced subscription tree. The efficiency of event matching of subscription tree nodes with larger storage capacity will also decrease accordingly.
[0048] In order to improve the efficiency of event matching in data interconnection applications, an embodiment of the present application provides a subscription tree reconstruction method for dynamic digital objects.
[0049] Reference Figure 1 , shows a flowchart of the steps of a subscription tree reconstruction method for dynamic digital objects in an embodiment of the present application, and the method may specifically include the following steps:
[0050] S101: In response to a subscription adding operation of a subject, a subscription to be added is obtained.
[0051] Subscription describes the needs of the subject as a subscriber for digital object metadata. When any subject's needs for digital object metadata change, a subscription corresponding to the subject's new needs can be added.
[0052] The format of subscription can be recorded as S = {SubID, C1, C2, C3, ..., C m}, where m is the number of subscription attributes in the subscription, SubID is the subject identifier of the subscription, Ci represents the subscription constraint of the i-th subscription attribute in the subscription, i∈m, C i ={T, a i , L i , U i}, T is the attribute type, a i is the attribute name, Li is the lower boundary of the constrained attribute, and Ui is the upper boundary of the constrained attribute. A subscription can contain one or more subscription attributes. Each subscription attribute only appears once in a subscription. The subscription constraint is the condition that the subscription attribute needs to meet.
[0053] S102: Determine a target storage node for the subscription to be added in a subscription tree, and determine the number of subscriptions stored in the target storage node.
[0054] A subscription tree refers to a pre-built tree structure that stores subscriptions of multiple subjects. Based on the nodes of the tree structure and the paths between nodes at different levels, when a subject generates newly published digital object metadata or modified digital object metadata, the newly published or modified digital object is mapped to a new publishing event, and then the new publishing event is matched with the subscription stored in the subscription tree. Based on the tree structure of the subscription tree, the subscriptions stored in the path can be matched only on one path, without matching the newly published event with all subscriptions one by one, which can improve the efficiency of event matching.
[0055] The subscription tree can store subscriptions in different ways. The existing subscription tree stores subscriptions only on leaf nodes, and then any non-leaf node is used to aggregate all subscriptions of the next layer of nodes connected to it. At this time, when adding a subscription in this subscription tree, the target storage node of the subscription to be added is any leaf node of the subscription tree.
[0056] Regardless of the storage method of the subscription tree, after determining the target storage node corresponding to the subscription to be added, for example, locating the leaf node corresponding to the subscription to be added, taking the leaf node as the target storage node, and then counting the number of all subscriptions stored in the target storage node.
[0057] S103: When the number of subscriptions stored in the target storage node is greater than the subscription storage threshold, a subtree of the target storage node is constructed according to subscription attributes corresponding to all subscriptions stored in the target storage node and the subscriptions to be added.
[0058] The setting of the subscription storage threshold can be customized according to the needs of the actual implementation process. When the number of subscriptions is greater than the subscription storage threshold, it indicates that the number of subscriptions stored in the target storage node is already large. If the newly published event is matched one by one with all subscriptions in the target storage node, the event matching time will also increase. Therefore, this embodiment establishes a subtree for the target storage node, and uses the subtree to disperse the storage of all subscriptions in the target storage node and the subscriptions to be added.
[0059] For example, in a subscription tree, each leaf node is used to store multiple subscriptions, and any non-leaf node is used to aggregate all subscriptions of the next layer node connected to it. After determining the leaf node corresponding to the subscription to be added, all subscriptions currently stored in the leaf node are counted. When the number of subscriptions currently stored in the leaf node is greater than the subscription storage threshold, in the event matching process, in order to reduce the one-to-one matching of the newly published event with all subscriptions in the leaf node, a subtree can be generated for the leaf node. Specifically, the process of constructing the subtree corresponding to the target storage node includes:
[0060] A1: among all subscriptions stored in the target storage node and the subscriptions to be added, sort the number of occurrences of each subscription attribute from high to low, and use the subscription attributes ranked in the top N1 positions as multiple candidate index attributes of the subtree.
[0061] The index attribute determines the height of the subtree, so the index attribute should select the subscription attribute that appears more frequently in these subscriptions, which can make the subtree more balanced.
[0062] Therefore, it is first necessary to count the number of times any subscription attribute appears in all subscriptions already stored in the target storage node and the subscriptions to be added, and then sort the subscription attributes in descending order according to the number of times, and use the first N1 subscription attributes as multiple candidate index attributes of the subtree. The specific value of N1 can be customized according to needs during actual implementation.
[0063] A2: sort the multiple candidate index attributes in descending order according to the number of times the constraint range widths of the multiple candidate index attributes do not exceed the upper bound threshold, and select the candidate index attributes ranked in the top N2 positions as the index attributes of the subtree.
[0064] In addition, the width of the range constraint of the index attribute should be as small as possible, so as to reduce redundant storage of subscriptions. Therefore, the number of times that the constraint range width of multiple candidate index attributes does not exceed the upper bound threshold ω1 can be counted, and then the multiple candidate index attributes are sorted in descending order according to the number of times, and finally the candidate index attributes ranked in the top N2 positions are selected as the index attributes of the subtree; wherein, the value of ω1 is related to the value range of the attribute, and the specific value of N2 can be customized according to needs during actual implementation. For example, the relationship between N1 and N2 can be: N1=2*N2.
[0065] Since the index attribute determines the height of the subtree, the number of index attributes of the subtree should not be too large, otherwise the number of nodes in the subtree will increase exponentially with the number of index attributes. For example, less than 10 index attributes can be selected.
[0066] A3: According to the index attribute of the subtree, determine the node attributes corresponding to the nodes at different levels of the subtree, and according to the value range of the index attribute of the subtree, determine the paths between the nodes at different levels in the subtree to construct the subtree of the target storage node.
[0067] First, according to the number of index attributes, the first index attribute is determined as the node attribute of the root node of the subtree, the second index attribute is determined as the node attribute of the node at the next level, and so on.
[0068] Then determine the number of paths from each node to the nodes of the next level, that is, for the node division cells, for example, if each node has m cells, then each node has m paths to the nodes of the next level.
[0069] In an optional implementation, the cells can be divided into granularities based on the center point of the constraint range of the subscription attribute. Specifically, since the value domain of the attribute is a range and the width of the constraint range is infinite, it is not possible to directly hash the constraint range. The constraint range can be limited to an upper and lower bound, and then hashing can be implemented at the center of the constraint range. For example, each node can be divided into three cells c1, c2 and c3, where the range of c1 is 0-0.5, the range of c2 is 0.5-1.0, and the range of c3 is 0-1.0. Then, the corresponding cell is selected according to the center point of the constraint range of each subscription attribute.
[0070] For example, if the center of the range constraint is in the interval [0, 0.5], cell c1 is selected; if the center of the range constraint is in the interval [0.5, 1.0], cell c2 is selected; if the index attribute has no constrained range or the center of the constrained range is 0.5, cell c3 is selected.
[0071] Reference Figure 2 , showing a schematic diagram of the structure of the subtree provided in an embodiment of the present application, assuming that the number of index attributes is 3, all candidate index attributes are sorted from high to low according to the number of times the constraint range width does not exceed the upper bound ω1 of the range constraint width, and the top 3 candidate index attributes are used as index attributes, namely J1, J2 and J3. The node attribute of the root node of the subtree corresponds to J1, the node attribute of the next-level non-leaf node corresponds to J2, and the node attribute corresponding to the leaf node is J3; assuming that the cell of each node is divided into 2, then except for the leaf node with attribute J3, each of the remaining nodes has 2 paths to the next-level node.
[0072] At this point, the subtree of the target storage node has been constructed.
[0073] S104: All subscriptions stored in the target storage node and the subscription to be added are dispersedly stored in a subtree of the target storage node to reconstruct the subscription tree.
[0074] After the subtree of the target storage node is constructed, all subscriptions stored in the target storage node and subscriptions to be added need to be stored in the subtree. Specifically, the subscriptions are stored in order from the root node to the child nodes of the subtree.
[0075] For all subscriptions stored in the target storage node and any subscription in the subscription to be added, the type of the current node is determined.
[0076] If the current node is a non-leaf node and the subscription contains node attributes corresponding to the current node, the subscription attributes consistent with the node attributes are deleted in the subscription, and the arrival path from the current node to the next level child node is determined based on the subscription attributes.
[0077] If the current node is not a leaf node and the subscription does not contain the node attribute corresponding to the current node, the rightmost path is selected as the path from the current node to the next level of child nodes;
[0078] If the current node is a leaf node, or the subscription attribute in the subscription under the current node is empty, the subscription is stored in the subscription list of the current node.
[0079] In a feasible implementation manner, five subscriptions stored in the target storage node are taken as an example to illustrate the process of storing subscriptions in a subtree. The ten subscriptions are shown in Table 1.
[0080] Table 1 Subscription instance
[0081]
[0082]
[0083] Reference Figure 3 , showing a schematic diagram of subscription storage results in a subtree provided by an embodiment of the present application. First, the index attribute is selected according to the above 5 subscriptions. According to the selection rule of the index attribute, it can be determined that the index attributes include a1, a2 and a3, that is, the height of the subtree is 3 layers, where the node attribute of the first layer node is a1, the node attribute of the second layer node is a2, and the node attribute of the third layer node is a3; still taking the 3 cells c1, c2 and c3 of each node as an example.
[0084] For subscription S1, the subscription constraints for subscription S1 include:<double a10.1 0.5> ,<double a20 0.4> ,<double a30.8 0.9> , starting from the root node, subscription S1 includes the node attribute a1 of the root node, so the subscription attribute a1 in subscription S1 is deleted, indicating that the subscription attribute a1 in subscription S1 has been added to the subtree, and then the path to the next layer of child nodes is determined according to the constraint range of the subscription attribute a1 in subscription S1. Specifically, the constraint range of the subscription attribute a1 in S1 is [0.1, 0.5], and the center of the constraint range belongs to the interval [0, 0.5]. Select cell c1, that is, select the first path to the child node with node attribute a2.
[0085] Subscription S1 includes subscription attribute a2, so subscription attribute a2 in subscription S1 is deleted, and based on the constraint range of subscription attribute a2 being [0, 0.4], the center of its constraint range belongs to the interval [0, 0.5], cell c1 is selected, that is, the first path to the child node with node attribute a3 is selected.
[0086] Since the node with the node attribute a3 is already a leaf node, the process of storing the subscription S1 in the subscription tree can be completed by directly storing the subject identifier SubID of the subscription S1 in the subscription list of the current node.
[0087] For subscription S2, the subscription constraints for subscription S2 include:<double a10.5 0.6> , starting from the root node, subscription S2 includes the node attribute a1 of the root node, so the subscription attribute a1 in subscription S2 is deleted, indicating that the subscription attribute a1 in subscription S2 has been added to the subtree, and then the path to the next layer of child nodes is determined according to the constraint range of subscription attribute a1 in subscription S2. Specifically, the constraint range of subscription attribute a1 in S2 is [0.5, 0.6], and the center of the constraint range belongs to [0.5, 1]. Select cell c2, that is, select the second path to the child node with node attribute a2.
[0088] Since the subscription attribute in subscription S2 has been deleted and is empty at this time, the child node with attribute a2 reached by the second path from the node with node attribute a1 is selected as the storage node of subscription S2, that is, the subject identifier SubID of subscription S2 is directly stored in the subscription list of the current node to complete the process of storing subscription S2 in the subscription tree.
[0089] For subscription to S3, the subscription constraints for subscription to S3 include:<double a10.6 0.9> and<double a20.30.5> , starting from the root node, subscription S3 includes the node attribute a1 of the root node, so the subscription attribute a1 in subscription S3 is deleted, indicating that the subscription attribute a1 in subscription S3 has been added to the subtree, and then the path to the next layer of child nodes is determined according to the constraint range of subscription attribute a1 in subscription S3. Specifically, the constraint range of subscription attribute a1 in S3 is [0.6, 0.9], and the center of the constraint range belongs to the interval [0.5, 1]. Select cell c2, that is, select the second path to the child node with attribute a2.
[0090] Subscription S3 includes subscription attribute a2, so subscription attribute a2 in subscription S3 is deleted, and based on the constraint range of subscription attribute a2 being [0.3, 0.5], the center of its constraint range belongs to the interval [0, 0.5], cell c1 is selected, that is, the first path to the child node with node attribute a3 is selected.
[0091] Since the node with the node attribute a3 is already a leaf node, the process of storing the subscription S3 in the subscription tree can be completed by directly storing the subject identifier SubID of the subscription S3 in the subscription list of the current node.
[0092] For subscription S4, the subscription constraints for subscription S4 include:<double a20.6 0.7> , starting from the root node, since subscription S4 does not include the node attribute a1 of the root node, the cell c3 of the root node is selected, that is, the third path to the child node with the node attribute a2 is selected; subscription S4 includes subscription attribute a2, so the subscription attribute a2 in subscription S4 is deleted, and according to the constraint range of subscription attribute a2 is [0.6, 0.7], the center of its constraint range is 0.5, so the cell c2 is selected, that is, the second path to the child node with the node attribute a3 is selected.
[0093] Since the node with the node attribute a3 is already a leaf node, the process of storing the subscription S4 in the subscription tree can be completed by directly storing the subject identifier SubID of the subscription S4 in the subscription list of the current node.
[0094] For subscription S5, the subscription constraints for subscription S5 include:<double a30.5 0.8> , starting from the root node, subscription S5 does not include the node attribute a1 of the root node, so the cell c3 of the root node is selected, that is, the third path to the child node with the node attribute a2 is selected; at the same time, subscription S5 does not include the node attribute a2 of the root node, and the cell c3 is selected, that is, the third path to the child node with the node attribute a3 is selected. Since the node with the node attribute a3 is already a leaf node, the subject identifier SubID of subscription S5 can be directly stored in the subscription list of the current node to complete the process of storing subscription S5 in the subscription tree.
[0095] In a feasible implementation, all subscriptions stored in the target storage node and subscriptions to be added can also be stored in a subscription table, for example, the subscriptions are stored in a Map, the key is the subject identifier SubID of the subscription, and the value is the subscription attribute of the subscription; when storing subscriptions in a subtree, it is only necessary to store the subject identifier of each subscription in the subscription list of the subtree node. Compared with storing the entire subscription, storing only the subject identifier of the subscription can reduce the storage pressure of the entire subscription tree.
[0096] In the process of adding the subject identifier of a subscription to the subscription tree, the subject identifier and all subscription attributes contained in a subscription can be copied from the Map. The deletion of any subscription attribute of any subscription mentioned in the process of adding the subscription tree is performed in the copied subscription, and the subscription attributes of the subscription are not deleted from the Map.
[0097] By building a subtree for nodes whose number of stored subscriptions is greater than the subscription storage threshold, and storing the subscriptions of the node in the subtree, during the event matching process, a path matching subscription can be determined in the subtree according to the event attributes of the newly published event, without matching all subscriptions one by one, thereby improving the efficiency of event matching.
[0098] In a feasible implementation, when a new event is published, the event is matched with the subscription through the subscription tree, and the subscription tree is indexed according to the type. According to the storage range of the root node and non-leaf nodes of the subscription tree, the paths between nodes of different levels are continuously selected. When a leaf node is reached, the leaf node corresponds to a subtree that stores multiple subscription subject identifiers, and event matching continues in the subtree.
[0099] When matching events in a subtree and determining the target subscription corresponding to the newly published event, the following process can be included:
[0100] C1: Based on the event attributes of the newly published event, the candidate subscription that satisfies the attribute matching is indexed in the subtree.
[0101] For example, an event is a combination of one or more attribute-key-value pairs, that is, a newly published event may include one or more event attributes; for example, a newly published event is recorded as:
[0102] E = {e1, e2, e3, ..., e n}
[0103] Where n is the number of event attributes in the newly published event, and e j is the jth (j≦n) attribute-value pair in the event, e j ={T, a j , v j}, T represents the attribute type, a j represents the jth attribute name, and v j represents the jth attribute a j The corresponding value, and in an event, each event attribute appears at most once.
[0104] For example, the process of determining candidate subscriptions may be:
[0105] C11: Assign the node attribute of the root node of the subtree to the variable node.
[0106] C12: Determine whether the variable node is a leaf node and whether the event attribute of the newly released event is empty.
[0107] When the variable node is a leaf node, or the event attribute of the newly published event is empty, step C13 is executed: the subscription corresponding to the subject identifier stored in the subscription list of the node is taken as a candidate subscription, and the execution process ends.
[0108] When the variable node is not a leaf node and the event attribute of the newly released event is not empty, step C14 is executed.
[0109] C14: Determine whether the newly released event contains the node attribute of the variable node.
[0110] If the newly published event does not contain the node attribute of the variable node, execute step C16.
[0111] If the newly published event contains node attributes of the variable node, execute steps C15-C16.
[0112] C15: Delete event attributes that are consistent with node attributes in the newly published event.
[0113] C16: Select the path to the next level child node and update the variable node.
[0114] Among them, if the newly published event does not contain the node attribute of the variable node, the rightmost path is selected as the path to the next-level child node from the current node; if the newly published event contains the node attribute of the variable node, the path to the child node is determined according to the type of event attribute deleted in the newly published event. For example, for event attributes of string type, the path to the child node is determined according to the value of the string; for event attributes of numeric type, the path to the child node is determined according to the constraint range of the subscription attribute.
[0115] The next-level child node corresponding to the path is used as the updated current node, and the node attribute of the updated current node is assigned to the variable node. Then C12 is executed until C13 is executed. After the subscription corresponding to the subject identifier stored in the subscription list of the node is used as a candidate subscription, the loop is exited.
[0116] C2: According to the subject identifier of the candidate subscription in the subtree, the corresponding candidate subscription is called in the Map, and then the final target subscription is determined according to the event attributes of the newly published event and the subscription attributes of the candidate subscription.
[0117] Then, according to the identifier corresponding to the candidate subscription, each candidate subscription is called out from the Map, and according to the event attributes of the newly published event and the subscription attributes of the candidate subscription, it is determined whether each candidate subscription is the target subscription.
[0118] For example, if the newly published event E and subscription S meet the conditions:
[0119] And L i ≤v j ≤U i
[0120] Then the event E and subscription S are considered to match.
[0121] In a feasible implementation manner, the newly released events include E1 and E2, wherein the event attributes of E1 are: double a1 0.55 0.55, and the event attributes of E2 are double a1 0.2 0.2, double a2 0.1 0.1, doublea3 0.7 0.7.
[0122] Reference Figure 4 , showing a matching schematic diagram of the candidate subscription provided by an embodiment of the present application. In this embodiment, when determining the candidate subscription of E1 in the subtree storing subscriptions S1-S5, the newly published event E1 has only one event attribute a1 and is of numeric type. The node attribute a1 of the root node exists in the newly published event E1, so the event attribute a1 in the newly published event E1 is deleted, and according to the value of the event attribute a1 in the newly published event E1 being 0.55, it is assigned to the cell c2 corresponding to the node, that is, the second path to the next level of child nodes is selected. The arrows in the figure represent the paths searched during matching. Although the leaf nodes of the subtree have not been matched at this time, the attributes in the newly published event E1 are empty, so the loop can be exited, and the subject identifier of the subscription S2 stored in the subscription list of the corresponding node is taken out, and the subscription S2 is used as the candidate subscription for the newly published event E1.
[0123] Reference Figure 5 , showing a matching schematic diagram of candidate subscriptions provided by an embodiment of the present application. In this embodiment, when determining the candidate subscription of E2 in a subtree storing subscriptions S1-S5, the node attribute a1 of the root node exists in the newly published event E2, so the event attribute a1 in the newly published event E2 is deleted, and according to the value of the event attribute a1 in the newly published event E2 being 0.2, the cell c1 is allocated, that is, the first path is selected to reach the node with the node attribute a2 in the subtree; the event attribute a2 exists in the newly published event E2, so the event attribute a2 in the newly published event E2 is deleted, and according to the value of the event attribute a2 in the newly published event E2 being 0.1, the cell c1 is allocated, that is, the first path is selected to reach the node with the node attribute a3 in the subtree, so the node with the node attribute a3 is the leaf node of the subtree, so the matching is stopped, the subject identifier of the subscription S1 stored in the subscription list of the current node is taken out, and the subscription S1 is used as the candidate subscription for the newly published event E2.
[0124] For the new release event E1<double a10.55 0.55> For example, the subscription condition of candidate subscription S2 is doublea10.5 0.6, 0.5≤0.55≤0.6, so subscription S2 is the target subscription of the newly published event E1.
[0125] For the new release event E2<double a10.2 0.2> ,<double a20.1 0.1> ,<double a30.70.7> For example, the subscription condition of candidate subscription S1 is<double a10.1 0.5> ,<double a20 0.4> ,<doublea30.8 0.9> , where 0.1≤0.2≤0.5, 0≤0.1≤0.4, but 0.7≤0.8≤0.9, so subscription S1 is not the target subscription for the newly published event E1.
[0126] After determining the target subscription for each newly published event, the newly published event is distributed to one or more entities corresponding to the target subscription.
[0127] In another feasible implementation, the construction process of the new subscription tree provided in the embodiment of the present application is consistent with steps A1-A3 of the subtree, that is, based on the subscription attributes of all subscriptions of multiple subjects, the index attribute of the subscription tree is determined, and the path between nodes of different levels is determined based on the value range of the index attribute, and then the subscription tree is constructed, and all subscriptions are stored in the subscription tree according to steps B1-B6, or only the subject identifier of the subscription can be stored in the subscription tree.
[0128] In the new subscription tree provided in this embodiment, each node can store subscriptions. If the number of subscriptions stored in any node is greater than the subscription storage threshold when a new subscription is added to the node, a subtree can be constructed for the node, and then all subscriptions stored in the node are called in the Map according to the subject identifiers of all subscriptions stored in the node. Then, all subscriptions stored in the node are further dispersedly stored in the subtree according to steps A1-A3, thereby reconstructing the subscription tree.
[0129] It is worth noting that in the new subscription tree provided in this embodiment, when a subtree is established for any node, the index attributes of the subtree should be different from the index attributes from the root node of the subscription tree to the node. If these attributes are still selected as the index attributes of the subtree, the entire subscription tree may be unbalanced.
[0130] Reference Figure 6, showing a schematic diagram of the reconstruction of the new subscription tree provided in an embodiment of the present application. By constructing a subtree for any node, only the storage method of the node is changed, and the storage method and indexing method of other nodes in the subscription tree are not affected. That is, the subtree of any node is reconstructed in the subscription tree constructed according to steps A1-A3, and the process of event matching in the subscription tree and event matching in the subtree of any node is consistent, such as steps C1-C2.
[0131] In addition to adding new subscriptions, you can also delete subscriptions in subtrees and new subscription trees. Specifically, in response to a subscription deletion operation of any subject, determine the subscription to be deleted, first delete the subscription to be deleted in the Map, and then delete the subject identifier of the subscription to be deleted in the subtree or subscription tree. The most important thing is to find the location where the subject identifier of the subscription to be deleted is stored in the subtree or subscription tree. The process is consistent with the process of storing the subject identifier of the subscription in the subtree or subscription tree. Finally, locate the node in the subtree or subscription tree that stores the subscription to be deleted, and delete the subject identifier SubID of the subscription to be deleted in the subscription list of the node.
[0132] The subject may also be allowed to modify the subscription. Specifically, in response to a subscription modification operation of any subject, the subscription before the modification and the subscription after the modification are obtained, and then the subscription before the modification is deleted, and then the subscription after the modification is added.
[0133] Reference Figure 7 , shows a functional module diagram of a subscription tree reconstruction system for dynamic digital objects provided by an embodiment of the present application, the system comprising:
[0134] The acquisition module 100 is used to acquire a subscription to be added in response to a subscription adding operation of a subject, wherein the subscription represents the demand of the corresponding subject for digital object metadata, and the subscription includes one or more subscription attributes;
[0135] The quantity determination module 200 is used to determine the target storage node of the subscription to be added in the subscription tree, and determine the number of subscriptions stored in the target storage node;
[0136] The subtree construction module 300 is used to construct a subtree of the target storage node according to all subscriptions stored in the target storage node and the subscription attributes corresponding to each of the subscriptions to be added when the number of subscriptions stored in the target storage node is greater than the subscription storage threshold, wherein constructing the subtree of the target storage node includes determining the node attributes of each node of the subtree and determining the paths between nodes at different levels;
[0137] The reconstruction module 400 is used to disperse and store all subscriptions stored in the target storage node and the subscription to be added in a subtree of the target storage node to reconstruct the subscription tree, wherein each node in the subtree of the target storage node can be used to store different subscriptions.
[0138] Optionally, the subtree construction module includes:
[0139] A first sorting unit is used to sort the number of occurrences of each subscription attribute in all subscriptions stored in the target storage node and the subscription to be added in descending order, and use the subscription attributes ranked in the first N1 positions as multiple candidate index attributes of the subtree;
[0140] A second sorting unit is used to sort the multiple candidate index attributes in descending order according to the number of times the constraint range widths of the multiple candidate index attributes do not exceed the upper bound threshold, and select the candidate index attributes ranked in the first N2 positions as the index attributes of the subtree;
[0141] A construction subunit is used to determine the node attributes corresponding to the nodes at different levels of the subtree according to the index attributes of the subtree, and to determine the paths between the nodes at different levels in the subtree according to the value range of the index attributes of the subtree, so as to construct the subtree of the target storage node.
[0142] Optionally, the reconstruction module includes:
[0143] a judging unit, configured to judge the type of a current node in the order from the root node to the child node of the subtree for all subscriptions stored in the target storage node and any subscription in the subscription to be added;
[0144] A first path determination unit is configured to, when the current node is a non-leaf node and the subscription contains a node attribute corresponding to the current node, delete a subscription attribute consistent with the node attribute in the subscription, and determine an arrival path from the current node to a next-level child node according to the subscription attribute;
[0145] The storage unit is used to store the subscription in the subscription list of the current node if the current node is a leaf node or the subscription attribute in the subscription under the current node is empty.
[0146] Optionally, the reconstruction module further includes:
[0147] The first path determination unit is used to select the rightmost path as the arrival path from the current node to the next-level child node when the current node is a non-leaf node and the subscription does not contain the node attribute corresponding to the current node.
[0148] Optionally, the reconstruction module includes:
[0149] A subscription table storage unit, used to store all subscriptions stored in the target storage node and the subscription to be added in a subscription table;
[0150] The subtree storage unit is used to disperse and store the subject identifiers corresponding to all the subscriptions and the subscriptions to be added in the subtree of the target storage node.
[0151] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for reconstructing a subscription tree for dynamic digital objects described in the embodiment is implemented.
[0152] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0153] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices or computer program products. Therefore, the present application can be implemented in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can be implemented in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0154] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0155] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0157] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0158] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0159] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A subscription tree reconstruction method for dynamic digital objects, It is characterized in that The method comprises: In response to a subscription adding operation of a subject, obtaining a subscription to be added, wherein the subscription represents a demand of the corresponding subject for digital object metadata, and the subscription includes one or more subscription attributes; Determining a target storage node for the subscription to be added in the subscription tree, and determining the number of subscriptions stored in the target storage node; When the number of subscriptions stored in the target storage node is greater than the subscription storage threshold, constructing a subtree of the target storage node according to all subscriptions stored in the target storage node and the subscription attributes corresponding to each of the subscriptions to be added, wherein constructing the subtree of the target storage node includes determining node attributes of each node of the subtree and determining paths between nodes at different levels; All subscriptions stored in the target storage node and the subscription to be added are dispersedly stored in a subtree of the target storage node to reconstruct the subscription tree, wherein each node in the subtree of the target storage node can be used to store different subscriptions.
2. The method according to claim 1, It is characterized in that Constructing a subtree of the target storage node according to all subscriptions stored in the target storage node and the subscription attributes corresponding to the subscriptions to be added, including: Among all subscriptions stored in the target storage node and the subscription to be added, sort the number of occurrences of each subscription attribute in descending order, and use the subscription attributes ranked in the top N1 positions as multiple candidate index attributes of the subtree; According to the number of times that the width of the constraint range of the multiple candidate index attributes does not exceed the upper bound threshold, the multiple candidate index attributes are sorted in descending order, and the candidate index attributes ranked in the first N2 positions are selected as the index attributes of the subtree; According to the index attribute of the subtree, the node attributes corresponding to the nodes at different levels of the subtree are determined, and according to the value range of the index attribute of the subtree, the paths between the nodes at different levels in the subtree are determined to construct the subtree of the target storage node.
3. The method according to claim 2, It is characterized in that Distributing and storing all subscriptions stored in the target storage node and the subscription to be added in a subtree of the target storage node includes: For all subscriptions stored in the target storage node and any subscription in the subscription to be added, judging the type of the current node in the order from the root node to the child node of the subtree; If the current node is a non-leaf node and the subscription contains the node attribute corresponding to the current node, the subscription attribute consistent with the node attribute is deleted in the subscription, and the arrival path from the current node to the next-level child node is determined according to the attribute type of the subscription attribute; If the current node is a leaf node, or the subscription attribute in the subscription under the current node is empty, the subscription is stored in the subscription list of the current node.
4. The method according to claim 3, It is characterized in that For all subscriptions stored in the target storage node and any subscription in the subscription to be added, after determining the type of the current node in the order from the root node to the child node of the subtree, the method further includes: If the current node is a non-leaf node and the subscription does not contain the node attribute corresponding to the current node, the rightmost path is selected as the path from the current node to the next-level child node.
5. The method according to claim 1, It is characterized in that When any non-leaf node in the subscription tree is used to aggregate all subscriptions of the next layer of nodes connected to it, the target storage node is any leaf node of the subscription tree.
6. The method according to claim 1, It is characterized in that When each node in the subscription tree stores different subscriptions, the target storage node is any node in the subscription tree.
7. The method according to any one of claims 1 to 6, It is characterized in that Distributing and storing all subscriptions stored in the target storage node and the subscription to be added in a subtree of the target storage node includes: storing all subscriptions stored in the target storage node and the subscription to be added in a subscription table; The subject identifiers corresponding to all the subscriptions and the subscriptions to be added are stored in a dispersed manner in a subtree of the target storage node.
8. A subscription tree reconstruction system for dynamic digital objects. It is characterized in that The system comprises: An acquisition module, configured to acquire a subscription to be added in response to a subscription adding operation of a subject, wherein the subscription represents a demand of the corresponding subject for digital object metadata, and the subscription includes one or more subscription attributes; A quantity determination module, used to determine the target storage node of the subscription to be added in the subscription tree, and determine the number of subscriptions stored in the target storage node; A subtree construction module, configured to construct a subtree of the target storage node according to subscription attributes corresponding to all subscriptions stored in the target storage node and the subscriptions to be added when the number of subscriptions stored in the target storage node is greater than a subscription storage threshold, wherein constructing the subtree of the target storage node includes determining node attributes of each node of the subtree and determining paths between nodes at different levels; A reconstruction module is used to disperse and store all subscriptions stored in the target storage node and the subscription to be added in a subtree of the target storage node to reconstruct the subscription tree, wherein each node in the subtree of the target storage node can be used to store different subscriptions.
