Structured data comparison method, data processing device and readable medium

By comparing the entity change information in the structured data and performing flattening processing, the problem of difficult to achieve structured data comparison in the prior art is solved, and structured data comparison based on entities is realized to generate easy-to-process difference information.

CN119513145APending Publication Date: 2025-02-25ZTE CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311068454.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-23
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively compare and solve entity differences in structured data, and traditional text line comparison methods cannot meet the actual needs of structured data.

Method used

By determining the change information of each evolution data relative to each entity in the original data, comparing the entity change information between any two evolution data for the same entity, obtaining the difference information of the entity, and flattening the difference information to generate a list-form comparison result.

Benefits of technology

It realizes structured data comparison based on entities, generates flat entity difference information that is easy to query, analyze and process, and solves the problem that traditional methods cannot meet the needs of structured data comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513145A_ABST
    Figure CN119513145A_ABST
Patent Text Reader

Abstract

The invention provides a structured data comparison method. The method comprises the following steps: determining change information of each evolution data relative to each entity in original data; for each entity, comparing the change information of the entity between any two pieces of evolution data to obtain difference information of the entity; flattening the difference information of each entity to obtain a comparison result in a list form; according to the entity-based structured data comparison scheme provided by the embodiment of the invention, the difference information between the structured evolution data is generated through the change information between the structured evolution data and the original data, and finally the flattened entity difference information is generated, and the flattened entity difference information is easy to query, analyze and process. The invention further provides a data processing device and a readable medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a structured data comparison method, a data processing device, and a readable medium. Background Art

[0002] With the development of software technology, many software data are stored and iterated using structured data, which also needs to be compared, conflict resolved and merged like code. In related technologies, there is no good solution for structured data comparison, conflict resolution and merging.

[0003] Traditional comparisons are generally performed based on text lines. For example, when the code developed in software engineering is submitted to a code hosting platform (such as GitHub, Gerr it, etc.) for code review and merging, the comparison is performed based on text lines. However, structured data is a description of entities with real meaning. It is concerned with entities and has no direct relationship with text lines. For example, the order of the fields of an object has changed, but in fact, the two objects are essentially the same.

[0004] Open source structured data comparison tools, such as many JSON comparison tools, can compare changes in attributes, but the results are only applicable to text display, not entity-based difference information, and therefore have no practical significance. Therefore, a meaningful comparison of structured data cannot be achieved through traditional text line comparison, nor can existing open source tools be used to obtain comparison difference information. Summary of the invention

[0005] The present disclosure provides a structured data comparison method, a data processing device and a readable medium.

[0006] In a first aspect, an embodiment of the present disclosure provides a structured data comparison method, comprising:

[0007] Determine change information of each evolved data relative to each entity in the original data, wherein the original data is structured data, and each evolved data is data obtained by evolving the original data;

[0008] For the same entity, compare the change information of the entity between any two of the evolution data to obtain difference information of the entity;

[0009] The difference information of each entity is flattened to obtain a comparison result in a list form.

[0010] On the other hand, the embodiments of the present disclosure also provide a data processing device, comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by the one or more processors, the one or more processors implement the structured data comparison method as described above; one or more I / O interfaces, connected between the processor and the storage device, configured to implement information interaction between the processor and the storage device.

[0011] On the other hand, an embodiment of the present disclosure further provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed, implements the structured data comparison method as described above.

[0012] The structured data comparison method provided by the embodiment of the present disclosure includes: determining the change information of each evolved data relative to each entity in the original data; for each entity, comparing the change information of the entity between any two evolved data to obtain the difference information of the entity; flattening the difference information of each entity to obtain the comparison result in the form of a list; the embodiment of the present disclosure provides an entity-based structured data comparison scheme, which generates the difference information between the structured evolved data through the change information between the structured evolved data and the original data, and finally generates flattened entity difference information, which is easy to query, analyze and process. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A schematic diagram of a structured data comparison process provided by an embodiment of the present disclosure;

[0014] Figure 2 A schematic diagram of a process for determining change information of a first target entity relative to a second target entity provided in an embodiment of the present disclosure;

[0015] Figure 3a-3c A schematic diagram of comparing entities in a tree structure provided in an embodiment of the present disclosure;

[0016] Figure 3d A schematic diagram of comparing entities of an unordered list structure provided in an embodiment of the present disclosure;

[0017] Figure 3e-3f A schematic diagram of comparing entities of an ordered list structure provided in an embodiment of the present disclosure;

[0018] Figure 3g-3h A schematic diagram of comparing entities in an unordered list in the form of a keyword-key value provided in an embodiment of the present disclosure;

[0019] Figure 4a A schematic diagram of configuring a personalized aligner provided in an embodiment of the present disclosure;

[0020] Figure 4b A schematic diagram of comparison by a comparator provided in an embodiment of the present disclosure;

[0021] Figure 4c A schematic diagram of a universal comparator for determining entity attributes corresponding to a first target entity provided by an embodiment of the present disclosure;

[0022] Figure 5a A schematic diagram of determining change information of each evolved data relative to each entity in the original data provided by an embodiment of the present disclosure;

[0023] Figure 5b A schematic diagram of the principle of comparing and generating entity difference information provided by an embodiment of the present disclosure;

[0024] Figure 6 A schematic diagram of flattening difference information of entities provided in an embodiment of the present disclosure;

[0025] Figure 7a-7k A schematic diagram of structured data comparison provided for a specific example of the present disclosure, wherein: Figure 7e Schematic diagram of the data structure of the original node O, branch A and branch B;

[0026] Figure 8a-8g A schematic diagram of a structured data comparison process provided for another specific example of the present disclosure, wherein: Figure 8a It is a schematic diagram of the tree structure of the original node O, branch A and branch B;

[0027] Fig. 9 A schematic diagram of the structure of a data processing device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] Example embodiments will be described more fully below with reference to the accompanying drawings, but the example embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. On the contrary, the purpose of providing these embodiments is to make the present disclosure thorough and complete and to enable those skilled in the art to fully understand the scope of the present disclosure.

[0029] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0030] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a", "an" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded.

[0031] The embodiments described herein may be described with reference to plan views and / or cross-sectional views by means of idealized schematic diagrams of the present disclosure. Therefore, the example illustrations may be modified according to manufacturing techniques and / or tolerances. Therefore, the embodiments are not limited to the embodiments shown in the accompanying drawings, but include modifications of the configurations formed based on the manufacturing process. Therefore, the regions illustrated in the accompanying drawings have schematic properties, and the shapes of the regions shown in the figures illustrate the specific shapes of the regions of the elements, but are not intended to be limiting.

[0032] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.

[0033] like Figure 1 As shown, the present disclosure provides a structured data comparison method, the method comprising the following steps:

[0034] Step S11, determining the change information of each evolved data relative to each entity in the original data, wherein the original data is structured data, and each evolved data is data obtained by evolving the original data.

[0035] The original data can evolve into at least two evolved data. In the embodiment of the present disclosure, the original data is structured data. Accordingly, each evolved data obtained based on the evolution of the original data has the same data structure as the original data and is also structured data. In this step, for each entity in the original data, the change information of each evolved data relative to the original data for the entity is determined.

[0036] For example, the data of an entity is constantly evolving, and at a node O, it evolves in two directions, called branch A and branch B. After a period of evolution, branch A and branch B are different, and the difference between the two needs to be compared. In this step, the change information A' of A relative to O and the change information B' of B relative to O are determined respectively.

[0037] Step S12: for the same entity, compare the entity change information between any two evolution data to obtain the entity difference information.

[0038] For each entity, the change information of the entity between any two evolution data is compared to obtain the difference information of each entity. For example, for a certain entity, the change information A' of A relative to O and the change information B' of B relative to O are compared to obtain the difference information of the entity.

[0039] Step S13, flattening the difference information of each entity to obtain a comparison result in a list form.

[0040] In this step, the difference information of each entity of the original data is summarized and flattened to obtain a comparison result in a list form. Flattening the difference information means simplifying the hierarchical structure of the difference information and converting the difference information into a "flat" list-style comparison result.

[0041] The structured data comparison method provided by the embodiment of the present disclosure includes: determining the change information of each evolved data relative to each entity in the original data; for each entity, comparing the change information of the entity between any two evolved data to obtain the difference information of the entity; flattening the difference information of each entity to obtain the comparison result in the form of a list; the embodiment of the present disclosure provides an entity-based structured data comparison scheme, which generates the difference information between the structured evolved data through the change information between the structured evolved data and the original data, and finally generates flattened entity difference information, which is easy to query, analyze and process.

[0042] In some embodiments, Figure 2 As shown, the change information of the first target entity in the target evolution data relative to the second target entity in the original data is determined in the following manner, wherein the target evolution data is one of the evolution data, and the first target entity and the second target entity are one of the entities:

[0043] Step S21 : determining a comparator corresponding to the entity attribute of the first target entity according to a preset mapping relationship between the entity attribute and the comparator.

[0044] In the disclosed embodiment, a comparator is pre-configured, and a mapping relationship between entity attributes of each entity in the original data and the comparator is configured. The mapping relationship is queried according to the entity attributes of the first target entity to determine the comparator corresponding to the entity attributes of the first target entity.

[0045] Step S22: using a comparator, obtaining change information of the first target entity relative to the second target entity according to the first target entity, the second target entity and the data types of the first target entity and the second target entity.

[0046] In some embodiments, the first target entity, the second target entity, and the data types of the first target entity and the second target entity are input into a comparator, so that the comparator determines a corresponding comparison strategy according to the data type, and compares the first target entity with the second target entity according to the comparison strategy to obtain change information of the first target entity relative to the second target entity. In other words, the first target entity, the second target entity, and the data type are used as input parameters of the comparator, and the comparator automatically generates change information of the first target entity relative to the second target entity according to these three input parameters, and the change information is the evolution information of the first target entity in the target evolution data.

[0047] The data types include tree structures, unordered lists, ordered lists, and unordered lists in the form of keywords and key values. The following describes in detail the comparison strategies for structured data of each data type.

[0048] (1) When the data type is a tree structure, the tree structure is flattened, a path of each entity in the tree structure is generated and the path is used as an entity identifier, and the first target entity is compared with the second target entity according to the entity identifier.

[0049] Tree-structured data such as Figure 3a As shown in , the tree structure includes the following two types: same-level attention order and same-level non-attention order. For the tree structure of the same-level attention order, the tree structure is flattened to obtain Figure 3b The flattened ordered list shown in the figure shows the hierarchy through the path composed of the subscripts of the nodes (i.e. entities). The path shows the subscripts of the list. path: "root / children / 0 / children / 1". For the tree structure that does not care about the order at the same level, the tree structure is flattened to obtain Figure 3c The flattened unordered list shown in the figure has a hierarchy represented by a path composed of the identifiers (such as id) of each node. Figure 3c As shown, the path does not need to reflect the subscript of the list. path: "node1 / node1-2 / node1-2-1". It should be noted that the information of the child level should be removed during flattening. After flattening, the target evolution data and the original data are found according to the entity identifier (such as id) for comparison. Among them, the hierarchical changes are compared through the path, and the internal differences of the entity are compared through other attributes of the entity.

[0050] (2) When the data type is an unordered list, the first target entity is compared with the second target entity according to the identifier of the first target entity and the identifier of the second target entity. The target evolution data has the same data structure as the original data, and the identification attribute can be confirmed. Figure 3d As shown, the property attribute can be used as an identifier, and the first target entity is found and compared with the second target entity through the identifier.

[0051] (3) When the data type is an ordered list, the first target entity and the second target entity are converted into character strings respectively, and the two character strings corresponding to the first target entity and the second target entity obtained by the conversion are compared.

[0052] There are two types of ordered lists: those with the same structure but requiring order and those with different structures. For ordered lists with the same structure but requiring order, such as Figure 3e As shown in the figure, for a cell operation item, it is required to display update first and then delete. For ordered lists with different structures, such as Figure 3f As shown, the identification attribute cannot be confirmed. When the first target entity is compared with the second target entity, the comparison is performed by converting the entity data into a string, that is, the ordered list is compared and processed as a black box.

[0053] (4) When the data type is an unordered list in the form of keyword-key value, the unordered list is flattened, the keyword is used as an identifier, and the first target entity is compared with the second target entity.

[0054] An unordered list of keyword-value pairs such as Figure 3g As shown, the keywords are used as identifiers to flatten the list, and the following is obtained: Figure 3h When comparing the first target entity with the second target entity, the first target entity and the second target entity are found by using the keyword, and the key value of each item is compared.

[0055] The step of determining the comparator corresponding to the entity attribute of the first target entity according to the mapping relationship between the entity attribute and the comparator set in advance (i.e., step S21) includes the following steps: when the comparator corresponding to the entity attribute of the first target entity cannot be determined according to the mapping relationship between the entity attribute and the comparator set in advance, selecting a universal comparator corresponding to the entity attribute of the first target entity according to a preset rule. In other words, the comparator is selected based on the mapping relationship between the entity attribute and the comparator first, and when there is no matching comparator, the comparator is selected according to the preset rule.

[0056] It should be noted that four general comparators can be configured for the entity attributes of the above four data types respectively. That is, the data type of tree structure corresponds to the general tree structure comparator, the data type of unordered list corresponds to the general unordered list comparator, the data type of ordered list corresponds to the general ordered list comparator, and the data type of keyword-key value unordered list corresponds to the general keyword-key value unordered list comparator.

[0057] The comparer may include a general comparer and a personalized comparer. For special entity attributes, a corresponding personalized comparer needs to be configured for it.

[0058] Figure 4a The following is a schematic diagram for configuring a personalized aligner: Figure 4a As shown, multiple aligners can be pre-configured. For example, a file-level aligner, an entity-level aligner, a text attribute-level aligner, and an entity attribute-level aligner can be configured, and a mapping relationship between each aligner and an entity attribute can be established. Figure 4b As shown, when performing data comparison, type data corresponding to the structured data is input, and the corresponding comparer is selected to perform recursive comparison.

[0059] Typically, general recursive general matchers also include: general typed structured data matcher, general untyped structured data matcher, general array matcher and general text matcher. The general text matcher is generally used as the default matcher.

[0060] In some embodiments, Figure 4c As shown, the selecting a comparator corresponding to the entity attribute of the first target entity according to a preset rule comprises the following steps:

[0061] In the case where the attributes of the first target entity have a custom type, select the general typed structured data matcher;

[0062] In the case where the attribute of the first target entity has no custom type and the attribute of the first target entity is not text, selecting a general typeless structured data matcher;

[0063] In the case where the attribute of the first target entity has no custom type and the attribute of the first target entity is text, a general text matcher is selected.

[0064] In some embodiments, Figure 5a As shown, the original data is divided into the following levels: file level, entity level, entity attribute level, and text attribute level; the step of determining the change information of each evolved data relative to each entity in the original data (i.e., step S11) includes the following steps: determining the change information of each evolved data relative to each entity in the original data according to the level.

[0065] Determine the change information of each entity in the evolved data relative to the original data from the following aspects:

[0066] (1) Addition, deletion and modification at the file level;

[0067] (2) Addition, deletion, and modification at the entity level;

[0068] (3) Addition, deletion, and modification at the entity attribute level;

[0069] (4) Addition, deletion, and modification at the text attribute level, where the modified line number can be extracted for multiple lines of text;

[0070] (5) Entity path change: Among them, entities that do not care about the order of the same level can collect path changes and adopt the comparison strategy corresponding to the tree structure that does not care about the order of the same level;

[0071] (6) Changes in entity structure

[0072] ① Pay attention to entities of the same level and need to collect structural changes. You can use the comparison strategy corresponding to the tree structure of the same level;

[0073] ②Entities can have both structural changes and path changes.

[0074] (7) Ordered lists, that is, lists without identification attributes, are compared by converting them into strings, which means that the ordered lists are compared and processed as black boxes.

[0075] Figure 5b The schematic diagram of the principle of comparing and generating entity difference information provided by the embodiment of the present disclosure is as follows: Figure 5b As shown, since the original data corresponding to each evolved data is the same, the structure of the change information obtained by comparing any two evolved data with the original data is the same. The corresponding attributes can be found at the same position in the data structure (that is, the same entity) for comparison, and the comparison result is still a data structure with nested attributes.

[0076] In some embodiments, the difference information of the entity is the difference information between the entity of the second evolution data and the entity of the first evolution data, and the step of comparing the change information of the entity between any two evolution data to obtain the difference information of the entity (i.e., step S12) includes the following steps:

[0077] In the case where the entity of the first evolution data has not changed and the entity of the second evolution data has changed, the difference information of the entity is determined to be the change information of the entity of the second evolution data relative to the entity of the first evolution data; in the case where the entity of the first evolution data has changed and the entity of the second evolution data has changed, the difference information of the entity is determined to be the conflict information between the entity of the second evolution data and the entity of the first evolution data. It should be noted that, in the case where the entity of the first evolution data has changed and the entity of the second evolution data has not changed, the difference information between the entity of the second evolution data and the entity of the first evolution data is not recorded. Not recording the difference information means not generating the difference information, that is, in the case where the entity of the first evolution data has changed and the entity of the second evolution data has not changed, the difference information between the entity of the second evolution data and the entity of the first evolution data cannot be obtained.

[0078] Compare the change information of the same entity between any two evolution data to obtain the comparison rule of the difference information of the entity. Take the difference information of branch B relative to branch A as an example, the comparison rule of determining the difference information of the entity is as follows:

[0079] (1) Changes at the file level

[0080] ① If the same file is added at the same time, the conflict information is recorded as the difference information;

[0081] ② If one evolution data modifies a file and another evolution data deletes the file, the conflict information is recorded as the difference information;

[0082] ③ If branch A has not changed, the change information of branch B is directly retained as the difference information, including addition, deletion, and modification information;

[0083] ④ If branch A has changed and branch B has not changed, the changed data will not be saved, that is, the difference information will not be recorded;

[0084] ⑤ If both branch A and branch B have changed, continue to compare;

[0085] (2) The rules at the entity level and entity attribute level are the same as above

[0086] (3) Changes in the same attribute

[0087] ① If branch A has not changed, the change information of branch B will be retained directly, including addition, deletion, and modification information;

[0088] ② If branch A has changed and branch B has not changed, the transformation data will not be saved, that is, the difference information will not be recorded;

[0089] (4) Conflicts of the same attribute include the following situations:

[0090] ①Add at the same time;

[0091] ②Single-line text can be modified simultaneously;

[0092] ③ Black box attributes (such as ordered lists) are modified simultaneously;

[0093] ④ One evolutionary data is used to delete data, and the other evolutionary data is used to modify data;

[0094] ⑤ If the parent attribute of one evolving data is deleted and the child attribute of another evolving data is modified, the conflict information of the parent attribute will be saved;

[0095] ⑥ Two evolving data are deleted at the same time without recording conflicting information;

[0096] (5) For multiple lines of text, judge based on the line numbers of the two evolution data modifications

[0097] ① Two evolution data modify the same line, which is saved as a multi-line text conflict as difference information;

[0098] ② If both evolution data are modified but the same line is not modified, the text modified at the same time is saved as the difference information;

[0099] ③ If only branch B is modified, the attribute modification information is saved as the difference information;

[0100] ④ If only branch A is modified, the modification information will not be saved;

[0101] (6) Entity path changes (when the order of the same level is not taken into account, the comparison strategy corresponding to the tree structure that does not pay attention to the order of the same level is adopted)

[0102] ① If only branch B modifies the path, the path modification is saved;

[0103] ② If only branch A modifies the path, the data will not be saved;

[0104] ③ If both parties modify the path, the saved path conflicts;

[0105] (7) Changes in entity structure (focusing on the same level order, using the tree structure comparison strategy corresponding to the same level focus order)

[0106] ① If only branch B adds, deletes nodes, or changes node positions, the structural changes are saved;

[0107] ② If only branch A adds, deletes nodes, or changes node positions, the data will not be saved;

[0108] ③ If both parties add, delete nodes or change node positions at the same time, it will be regarded as a data structure conflict;

[0109] ④ If one party deletes a node and the other party modifies the sub-attributes of this node, it will rise to a data structure conflict and be handled. The data structure is the same as above.

[0110] In some embodiments, Figure 6 As shown, the flattening of the difference information of each entity to obtain a comparison result in a list form (i.e., step S13) includes the following steps: converting the hierarchically nested difference information into a list form, converting the hierarchy into a change path, and obtaining a comparison result in a list form. The comparison result in the list form includes an addition list, a deletion list, a modification list, and a conflict list.

[0111] In order to clearly illustrate the solution of the embodiment of the present disclosure, the following Figure 7a-7f , through a specific example, taking the structured data of a tree structure where the order between the same levels does not need to be concerned about as an example, the comparison process of the structured data is explained.

[0112] The router.json file is a structured data file, such as Figure 7a As shown, the data includes the original node O, branch A and branch B. Branch A and branch B are evolved based on the original node O. Now it is necessary to compare the difference between branch A and branch B, and the difference between branch B and branch A.

[0113] The data structure requirements are as follows:

[0114] (1) Attribute routers: The tree-shaped routing configuration must reflect the hierarchical relationship, and there is no need to pay attention to the order between the same levels;

[0115] (2) Attribute guards: guard configuration list. The order does not need to be concerned. Type and name are used as identifiers for each item.

[0116] The comparison result requirements are as follows:

[0117] (1) Addition, deletion, and modification of a single route, resulting in path changes;

[0118] (2) Addition, deletion and modification of a single routing guard.

[0119] The comparison can be done in the following steps:

[0120] 1. If Figure 7b As shown, define the data type of the entity that matches the data structure;

[0121] 2. If Figure 7c As shown, a general comparer is defined;

[0122] 3. If Figure 7d As shown, define a personalized matcher, that is, add a matcher corresponding to the entity attribute;

[0123] 4. Implementation of routing comparator

[0124] The routing entity is a tree structure that does not care about the order of the same level. According to the previous statement, the tree structure needs to be flattened, and the hierarchy is reflected by the path composed of the identifiers (path attributes) of each node. The output structure is as follows Figure 7e As shown, the urlPath attribute is a synthetic path, so the tree structure is converted into an array for comparison.

[0125] 5. Implementation of the universal comparer diffArray

[0126] The order of the array is not important, but a unique identifier must be specified to identify each item. When comparing, the data to be compared is found by the unique identifier, and then the diffObject comparer is called.

[0127] 6. Call the general comparator diffObject as the entry comparator

[0128] objectDiff(compareRouterJson,rawRouterJson,RouterConfig)

[0129] (1) Determine the _diffInfo_ attribute based on type;

[0130] (2) If the _diffInfo_ attribute is found, determine the corresponding comparator and perform data comparison;

[0131] (3) If the _diffInfo_ attribute is not found, if it is a primitive type, the generic diffLines comparer is used for comparison; if it is an object, the diffJson comparer is used for comparison;

[0132] 7. If Figure 7f and Figure 7g As shown, Figure 7f is the change information of A relative to O, Figure 7g This is the change information of B relative to O. It can be seen that the structure of the change information is generated according to the structure of the data.

[0133] 8. The change information of A relative to O and the change information of B relative to O shall be as follows: Figure 5b The comparison is performed in the following way to obtain the comparison result. Figure 7h As shown, this is the difference information between A and B, such as Figure 7i As shown, this is the difference information between B and A.

[0134] 9. Flatten the difference information between A and B and between B and A, concatenate the paths of each layer to generate the final change path, and obtain the comparison results in the form of a list, such as Figure 7j As shown in the figure, it is the difference information of the flattened A relative to B, such as Figure 7k As shown, this is the difference information of the flattened B relative to A.

[0135] In order to clearly illustrate the solution of the embodiment of the present disclosure, the following Figure 8a-8e , through a specific example, taking the tree-structured data that needs to pay attention to the order between the same levels as an example, the comparison process of the structured data is explained.

[0136] The module.json file is a component layout information file, which contains nodes of various components and presents a tree-like data structure, including layout components and functional components. The comparison results require the comparison of layout changes between functional components and attribute configuration changes within functional components. The module.json file includes data of the original node O, branch A, and branch B. Branch A and branch B are evolved based on the original node O. The node information of the above three data tree structures is as follows: Figure 8a shown.

[0137] The data comparison process is as follows:

[0138] 1. If Figure 8b As shown, define the type that matches the data structure;

[0139] 2. Define a universal comparator. Universal comparators are all the same, such as Figure 7c As shown;

[0140] 3. If Figure 8c As shown, define a personalized matcher, that is, add a matcher corresponding to the entity attribute;

[0141] 4. Implementation of component comparer

[0142] The component entity is a tree structure with the same level of attention order. According to the previous statement, the tree structure needs to be flattened, and the hierarchy is reflected by the path composed of the identifiers (agent attributes) of each node. The result of flattening the component tree structure is as follows Figure 8d As shown, the layoutPath attribute is a synthetic path, so the tree structure is converted into an array for comparison.

[0143] 5. Call the general comparer diffObject as the entry comparer. The specific process is the same as the previous specific example and will not be repeated here.

[0144] 6. The comparison process is similar to Example 1. The comparison results are as follows: Figure 8e The comparison results are shown in Figure 8f As shown in the figure, the difference information after flattening is as follows Figure 8g shown.

[0145] The embodiments of the present disclosure can be applied to the following scenarios: structured data comparison and merging scenarios, multi-person synchronous development scenarios, code repository comparison and merging scenarios. The embodiments of the present disclosure can be applied to Windows or Linux systems, and the software running environment can be a node or java development environment, which needs to have file storage, reading and writing functions.

[0146] The disclosed embodiment provides a solution for comparing differences in structured data of arbitrary complexity, generating structured difference information through structured change information, and finally generating flat entity change information, which can realize the split comparison of arbitrarily complex structured data, and can generate entity-based, practically meaningful, easy-to-query, analyze and process difference information. The disclosed embodiment also provides a solution for personalized comparison, defining an attribute comparer through structured data types, and realizing personalized comparison.

[0147] The present disclosure also provides a data processing device, such as Fig. 9 As shown, the data processing device includes: one or more processors 901, a storage device 902 and one or more I / O interfaces 903; wherein, one or more programs are stored on the storage device 902, and when the one or more programs are executed by the one or more processors, the one or more processors 901 implement the structured data comparison method provided in the aforementioned embodiments; the I / O interface 903 is connected between the processor 901 and the storage device 901, and is configured to implement information interaction between the processor 901 and the storage device 902.

[0148] Among them, the processor 901 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the storage device 902 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 903 is connected between the processor 901 and the storage device 902, and can realize information interaction between the processor 901 and the storage device 902, including but not limited to a data bus (Bus), etc.

[0149] The embodiments of the present disclosure further provide a computer-readable medium on which a computer program is stored, wherein when the computer program is executed, the structured data comparison method provided in the aforementioned embodiments is implemented.

[0150] It will be appreciated by those skilled in the art that all or some of the steps in the method disclosed above, the functional modules / units in the device may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0151] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly stated, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, it will be understood by those skilled in the art that various changes in form and detail may be made without departing from the scope of the invention as set forth in the appended claims.

Claims

1. A structured data comparison method, characterized in that: include: Determine change information of each evolved data relative to each entity in the original data, wherein the original data is structured data, and each evolved data is data obtained by evolving the original data; For the same entity, compare the change information of the entity between any two of the evolution data to obtain difference information of the entity; The difference information of each entity is flattened to obtain a comparison result in a list form.

2. The method according to claim 1, characterized in that Determine change information of a first target entity in the target evolution data relative to a second target entity in the original data in the following manner, wherein the target evolution data is one of the evolution data, and the first target entity and the second target entity are one of the entities: Determining the comparator corresponding to the entity attribute of the first target entity according to a preset mapping relationship between the entity attribute and the comparator; The comparer is used to obtain change information of the first target entity relative to the second target entity according to the first target entity, the second target entity and the data types of the first target entity and the second target entity.

3. The method according to claim 2, characterized in that The using the comparer to obtain the change information of the first target entity relative to the second target entity according to the first target entity, the second target entity and the data types of the first target entity and the second target entity, comprises: The first target entity, the second target entity and the data types of the first target entity and the second target entity are input into the comparator, so that the comparator determines a corresponding comparison strategy according to the data types, and compares the first target entity with the second target entity according to the comparison strategy to obtain change information of the first target entity relative to the second target entity.

4. The method according to claim 3, characterized in that The data type includes a tree structure, an unordered list, an ordered list, and an unordered list in the form of a keyword-key value; determining a corresponding comparison strategy according to the data type, and comparing the first target entity with the second target entity according to the comparison strategy, including: In the case where the data type is a tree structure, flattening the tree structure, generating a path of each entity in the tree structure and using the path as an entity identifier, and comparing the first target entity with the second target entity according to the entity identifier; When the data type is an unordered list, comparing the first target entity with the second target entity according to the identifier of the first target entity and the identifier of the second target entity; In the case where the data type is an ordered list, the first target entity and the second target entity are converted into character strings respectively, and the two converted character strings corresponding to the first target entity and the second target entity are compared; When the data type is an unordered list in the form of a keyword-key value, the unordered list is flattened, the keyword is used as an identifier, and the first target entity is compared with the second target entity.

5. The method according to claim 2, characterized in that The determining the comparator corresponding to the entity attribute of the first target entity according to the preset mapping relationship between the entity attribute and the comparator includes: When the comparator corresponding to the entity attribute of the first target entity cannot be determined according to the preset mapping relationship between the entity attribute and the comparator, the comparator corresponding to the entity attribute of the first target entity is selected according to a preset rule.

6. The method according to claim 5, characterized in that The selecting a comparator corresponding to the entity attribute of the first target entity according to a preset rule includes: In the case where the attribute of the first target entity has a user-defined type, selecting a general typed structured data matcher; In a case where the attribute of the first target entity has no custom type and the attribute of the first target entity is not text, selecting a general typeless structured data matcher; When the attribute of the first target entity has no custom type and the attribute of the first target entity is text, a general text matcher is selected.

7. The method according to claim 1, characterized in that The original data is divided into the following levels: file level, entity level, entity attribute level, and text attribute level; the step of determining the change information of each evolution data relative to each entity in the original data includes: According to the level, change information of each evolved data relative to each entity in the original data is determined.

8. The method according to claim 1, characterized in that The difference information of the entity is difference information between the entity of the second evolution data and the entity of the first evolution data, and the comparing the change information of the entity between any two evolution data to obtain the difference information of the entity includes: In a case where the entity of the first evolution data has not changed and the entity of the second evolution data has changed, determining the difference information of the entity as change information of the entity of the second evolution data relative to the entity of the first evolution data; When the entity of the first evolution data changes and the entity of the second evolution data changes, the difference information of the entity is determined to be conflict information between the entity of the second evolution data and the entity of the first evolution data.

9. A data processing device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the structured data comparison method according to any one of claims 1 to 8; One or more I / O interfaces are connected between the processor and the storage device and are configured to implement information interaction between the processor and the storage device.

10. A computer readable medium having a computer program stored thereon, wherein: When the program is executed, the structured data comparison method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Remote multi-source industrial data real-time analysis processing system and method

    CN121166786A