A data processing method and device
By preprocessing, extracting and rendering JSON data, generating original node manifests and editing, the problem of JSONEditor's inefficiency in modifying JSON data is solved, and more efficient data processing and search efficiency is achieved.
Patent Information
- Application Number
- CN202411139567.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-20
AI Technical Summary
When JSONEditor modifys JSON data, it is unable to effectively separate the view interface and logical functions, resulting in low data processing efficiency, especially when processing large-scale metadata trees, the search efficiency is low.
By obtaining the metadata tree, preprocessing, extracting and rendering, generating the original node inventory, editing and rendering again according to the modification requirements, and finally generating the target metadata tree, using the inventory data structure to improve data processing efficiency.
It improves the work efficiency of data processing, especially for modifying large-scale metadata trees. By converting the tree structure into a inventory structure, the efficiency of data search is improved.
Smart Images

Figure CN118656533B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and also to a data processing method and device. Background Art
[0002] JSON data is a lightweight data exchange format. JSONEditor is a dependency library for online editing of JSON data. The JSON online editing function of some websites needs to use this dependency library. JSONEditor provides five editing and viewing modes: code, tree, text, form, and view. However, its view interface cannot be separated from the logical function, making it difficult to modify. Moreover, its goal is to modify the attributes and values of JSON data. Every time a key-value pair needs to be updated, it may involve the addition, deletion, or modification of multiple nodes. The amount of data to be processed is relatively large, and the data processing efficiency is low. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a data processing method and device to improve the data processing efficiency.
[0004] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0005] A first aspect of the present invention provides a data processing method, comprising:
[0006] Get the metadata tree;
[0007] Preprocessing the metadata tree to obtain a preprocessed metadata tree;
[0008] Extracting the preprocessed metadata tree to obtain an original node list;
[0009] Rendering the original node list to obtain a rendered original node list;
[0010] Editing the rendered original node list according to the received modification requirements to obtain an edited node list;
[0011] Rendering the edited node list to obtain a rendered edited node list;
[0012] A target metadata tree is generated according to the rendered edited node list.
[0013] Optionally, preprocessing the metadata tree to obtain a preprocessed metadata tree includes:
[0014] Get preset inspection standards;
[0015] Checking the metadata tree according to the preset checking standard to obtain a checking result;
[0016] The metadata tree is adjusted according to the inspection result to obtain a preprocessed metadata tree.
[0017] Optionally, the preprocessed metadata tree is extracted to obtain an original node list, including:
[0018] Extract the preprocessed metadata tree according to a preset extraction method to obtain metadata nodes;
[0019] Modifying the node information of the metadata node to obtain a modified metadata node;
[0020] According to the modified metadata nodes, an original node list is obtained.
[0021] Optionally, the original node list is rendered to obtain a rendered original node list, including:
[0022] Traversing the metadata nodes in the original node list to obtain metadata nodes;
[0023] Determine a node component according to the metadata node;
[0024] The metadata nodes in the original node list are rendered using the node component to obtain a rendered original node list.
[0025] Optionally, the rendered original node list is edited according to the received modification requirements to obtain an edited node list, including:
[0026] Receive metadata modification requests;
[0027] The rendered original node list is edited according to a preset modification method and the metadata modification requirement to obtain an edited node list.
[0028] Optionally, the preset modification method includes:
[0029] If the metadata modification requirement is to delete an existing metadata node, then find the position index of the existing metadata node in the original node list, and delete the existing metadata node according to the position index;
[0030] If the metadata modification requirement is to add a new metadata node, then find the position index of the preset metadata node in the original node list, and add the metadata node according to the position index;
[0031] If the metadata modification requirement is to modify the information of an existing metadata node, then the position index of the preset metadata node in the original node list is searched, and the information of the existing metadata node is modified according to the position index.
[0032] Optionally, generating a target metadata tree according to the rendered edited node list includes:
[0033] Determine a root node according to the rendered edited node list;
[0034] Dividing the rendered edited node list according to the root node to obtain a divided node list;
[0035] The divided node list is converted using a preset conversion function to generate a target metadata tree.
[0036] A second aspect of the present invention provides a data processing device, comprising:
[0037] The acquisition module is used to obtain the metadata tree;
[0038] A preprocessing module, used for preprocessing the metadata tree to obtain a preprocessed metadata tree;
[0039] An extraction module, used for extracting the preprocessed metadata tree to obtain an original node list;
[0040] A rendering module, used for rendering the original node list to obtain a rendered original node list;
[0041] An editing module, used for editing the rendered original node list according to the received modification requirements to obtain an edited node list;
[0042] A processing module, used for rendering the edited node list to obtain a rendered edited node list;
[0043] A generating module is used to generate a target metadata tree according to the rendered edited node list.
[0044] According to a third aspect of the present invention, a computing device is provided, comprising: a processor and a memory storing a computer program, wherein when the computer program is executed by the processor, the method according to the first aspect is executed.
[0045] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions, which, when executed on a computer, causes the computer to execute the method described in the first aspect.
[0046] The above solution of the present invention includes at least the following beneficial effects:
[0047] The above scheme of the present invention obtains the original node list by preprocessing, extracting and rendering the acquired metadata tree, edits the rendered original node list according to the modification requirements, and then renders the edited node list, and then generates the target metadata tree, flattens the metadata tree, and when editing the metadata tree, focuses on the metadata nodes rather than all the attributes of the metadata tree, which is conducive to improving the work efficiency of data processing; in addition, the above scheme converts the data structure from a tree to a list, which is more efficient in data search, and is particularly suitable for modifying metadata trees with larger scales. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flow chart of a data processing method in an embodiment of the present invention;
[0049] Figure 2 It is a structural schematic diagram of a data processing device in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0051] like Figure 1 As shown, an embodiment of the present invention provides a data processing method, comprising the following steps:
[0052] Step 101, obtaining a metadata tree;
[0053] Step 102, preprocessing the metadata tree to obtain a preprocessed metadata tree;
[0054] Step 103, extracting the preprocessed metadata tree to obtain an original node list;
[0055] Step 104, rendering the original node list to obtain a rendered original node list;
[0056] Step 105, editing the rendered original node list according to the received modification requirements to obtain an edited node list;
[0057] Step 106, rendering the edited node list to obtain a rendered edited node list;
[0058] Step 107: Generate a target metadata tree according to the rendered edited node list.
[0059] The data processing method proposed in the embodiment of the present invention obtains an original node list by preprocessing, extracting and rendering the acquired metadata tree, edits the rendered original node list according to the modification requirements, and then renders the edited node list, and then generates a target metadata tree, flattens the metadata tree, and when editing the metadata tree, focuses on the metadata nodes rather than all the attributes of the metadata tree, which is conducive to improving the work efficiency of data processing; in addition, the data processing method proposed in the embodiment of the present invention converts the data structure from a tree (tree data structure) to a list (list data structure), which is more efficient in data search and is particularly suitable for modifying metadata trees with larger scales.
[0060] In an optional embodiment of the present invention, the structure of the metadata tree obtained in step 101 is a JSON data structure. The metadata tree structure is a data used to describe data, which can clearly show the hierarchical structure and attribute relationship of the data. JSON is a text-based data exchange format. This embodiment mainly processes the metadata tree of the JSON data structure.
[0061] In an optional embodiment of the present invention, step 102 includes:
[0062] Step 1021, obtaining a preset inspection standard;
[0063] Specifically, the preset check standard is a reference standard for checking whether the obtained metadata tree meets the requirements. Only metadata trees that meet the preset check standard will enter the subsequent processing steps to improve work efficiency. Here, the preset check standard can be one or more of: data is not empty, data has no missing key attributes, data key attribute values are correct, etc., where the key attributes can be set according to actual conditions, such as one or more of the source of the data, the structure of the data, the creation date of the data, the type of the data, etc.
[0064] Step 1022, checking the metadata tree according to the preset checking standard to obtain a checking result;
[0065] Specifically, you can traverse each node in the metadata tree to check whether each node is empty (null or empty string, etc.); check whether the data in each node conforms to the value range or format in the preset inspection standard (such as date, number, enumeration value, etc.); check whether the attribute type of each node data conforms to the corresponding attribute type in the preset inspection standard, such as date fields should be date types, number fields should be integers or floating point numbers, etc.; check whether there are logical inconsistencies in the content of the node data (you can check whether the foreign key reference is valid, whether the value of the calculated field matches the basic data, etc.). Here, you can use XML (Extensible Markup Language), JSON or other data format processing libraries to traverse and verify each node data.
[0066] It should be noted that the inspection results include the inspection results of each node in the metadata tree. For example, the inspection result of node A may include multiple items, such as: whether there is a vacancy, whether it complies with the value range or format in the preset inspection standard, whether the attribute type complies with the corresponding attribute type in the preset inspection standard, etc.
[0067] Step 1023: Adjust the metadata tree according to the inspection result to obtain a preprocessed metadata tree.
[0068] Specifically, if the check result contains nodes or data in the metadata tree that do not meet one or more of the preset check criteria, here, the pass standard can be formulated according to the actual situation. For example, if the data in n nodes in the metadata tree do not meet the preset check criteria, the metadata tree needs to be adjusted. The adjustment method can be to re-acquire the metadata tree until its check result meets the preset check criteria.
[0069] In an optional embodiment of the present invention, step 103 includes:
[0070] Step 1031, extracting the preprocessed metadata tree according to a preset extraction method to obtain metadata nodes;
[0071] Specifically, the preset extraction method can be an in-order traversal, which is a binary tree traversal method. The traversal order is to first traverse the left subtree, then traverse the root node, and finally traverse the right subtree. Through this traversal method, all nodes in the metadata tree are extracted. Here, a recursive function can be used to traverse the metadata tree and extract node data.
[0072] Step 1032, modifying the node information of the metadata node to obtain a modified metadata node;
[0073] Specifically, after the metadata node is extracted, a new identifier (Id) and a parent node identifier (parentId) need to be assigned to the metadata node, so as to facilitate the composition of the list and subsequent editing, modification, etc. according to the new identifier. When the target metadata tree is finally generated, these identifiers and parent node identifiers will be deleted.
[0074] Step 1033, obtaining the original node list according to the modified metadata node.
[0075] Specifically, the modified metadata node is added to the node list in a set format to form the original node list.
[0076] In an optional embodiment of the present invention, step 104 includes:
[0077] Step 1041, traverse the metadata nodes in the original node list to obtain metadata nodes;
[0078] Specifically, the metadata nodes in the original node list can be traversed in a loop to obtain all metadata nodes (including nodes and subnodes of nodes) in the original node list, which serves as a basis for subsequently determining the corresponding node component according to each metadata node.
[0079] Step 1042, determining a node component according to the metadata node;
[0080] Specifically, the node and its corresponding child nodes can be taken as an array, and a node component can be determined for each array to render the entire array.
[0081] Step 1043: Use the node component to render the metadata nodes in the original node list to obtain a rendered original node list.
[0082] Specifically, the node component is used to render the nodes and sub-nodes in the corresponding array. The purpose of rendering is to let the user see the nodes and prepare for editing and modification. Among them, the node component renders the attributes and values of the nodes and sub-nodes. For example, there are two standards for rendering: interface and data. Rendering is to display the attributes in the interface, and the data is the attribute value. In this embodiment, when the attribute value is a string, an input box is rendered, and when the attribute value is a date, a date selection panel is rendered.
[0083] In an optional embodiment of the present invention, step 105 includes:
[0084] Step 1051, receiving a metadata modification request;
[0085] Specifically, the metadata modification requirement may include at least one of deleting a node, adding a node, editing data, etc. These requirements are generated by the user according to actual needs. The nodes or data are edited according to these requirements to meet the user's needs.
[0086] Step 1052: edit the rendered original node list according to a preset modification method and the metadata modification requirement to obtain an edited node list.
[0087] In an optional embodiment of the present invention, the preset modification method in step 1052 includes:
[0088] If the metadata modification requirement is to delete an existing metadata node, then find the position index of the existing metadata node in the original node list, and delete the existing metadata node according to the position index;
[0089] If the metadata modification requirement is to add a new metadata node, then find the position index of the preset metadata node in the original node list, and add the metadata node according to the position index;
[0090] If the metadata modification requirement is to modify the information of an existing metadata node, then the position index of the preset metadata node in the original node list is searched, and the information of the existing metadata node is modified according to the position index.
[0091] Specifically, when deleting an existing metadata node, find the position index of the metadata node in the original node list and delete the existing metadata node. When adding a new metadata node, search for existing metadata nodes in order, compare the information of each node one by one, until a node matching the new metadata node is found, find the position index of the matching node in the original node list, append the new metadata node after the matching node, and if no node matching the new metadata node is found, append the new metadata node to the end of the original node list. When modifying the information of an existing metadata node, only the specific content and the corresponding node components can be modified, and the original identifier and position index remain unchanged.
[0092] In an optional embodiment of the present invention, step 107 includes:
[0093] Step 1071, determining a root node according to the rendered edited node list;
[0094] Specifically, traverse each node in the rendered edited node list and check the "parent node" attribute of each node. If a node has no parent node (that is, its parent node attribute is null or a specific value indicating that there is no parent node), it can be considered as a root node.
[0095] Step 1072, dividing the rendered edited node list according to the root node to obtain a divided node list;
[0096] Specifically, traverse all nodes. If the node is a child node, merge it into the array of the parent node. Taking the root node as the boundary, traverse the array of all nodes (the array contains the child nodes of the node) and generate the right subtree. The same-level nodes generate the left subtree. Finally, delete the assigned new identifier (Id) and the parent node identifier (parentId).
[0097] Step 1073: Use a preset conversion function to convert the divided node list to generate a target metadata tree.
[0098] Specifically, the preset conversion function may be a listToTree function, which constructs a tree by recursively finding the child nodes of each node. Specifically, the root node is used as the boundary, the same-level nodes generate the left subtree, the array of all nodes generates the right subtree, and the target metadata tree is obtained according to the root node, the left subtree and the right subtree.
[0099] A specific embodiment of the data processing method proposed in the embodiment of the present invention is:
[0100] Step 111, initialize the editor. The editor can be a JSON data editor component, calling the interface provided by the editor to convert the predefined container element into an editor instance, that is, the width, height, toolbar options, etc. of the editor, so as to personalize the editor. When initializing the editor, generate an instance that assigns an ID to the node for storing and generating the ID.
[0101] Step 112, obtain data. Obtain the metadata tree. In this embodiment, metadata is data that describes data. In this embodiment, metadata is described using a JSON data structure. A metadata node refers to a certain metadata. Modifying a metadata node is to modify the value of a metadata attribute. Check and confirm whether the format of the metadata tree meets the preset inspection standard (such as the preset inspection standard that the data is not empty, the data does not lose key attributes, the data key attribute values are correct, etc.). If the format is wrong, end editing or re-acquire the metadata tree.
[0102] An example of a metadata tree is:
[0103] {
[0104] "leftNode":{
[0105] "leftNode":{
[0106] "leftNode":null,
[0107] "rightNode": null,
[0108] "leaf": true,
[0109] "logicalOperation": "",
[0110] "metadata": {
[0111] "metadataId": 0,
[0112] "metadataValue": "Province H"
[0113] }
[0114] },
[0115] "rightNode": {
[0116] "leftNode": null,
[0117] "rightNode": null,
[0118] "leaf": true,
[0119] "logicalOperation": "",
[0120] "metadata": {
[0121] "metadataId": 1,
[0122] "metadataValue": "City B"
[0123] }
[0124] },
[0125] "leaf": true,
[0126] "logicalOperation": "AND",
[0127] "metadata": null
[0128] },
[0129] "rightNode": {
[0130] "leftNode": null,
[0131] "rightNode": null,
[0132] "leaf": true,
[0133] "logicalOperation":"",
[0134] "metadata":{
[0135] "metadataId":2,
[0136] "metadataValue":"J Province"
[0137] }
[0138] },
[0139] "leaf":false,
[0140] "logicalOperation":"AND",
[0141] "metadata":null
[0142] }
[0143] Step 113, data flattening. After the data check is passed, the nodes in the tree structure are extracted. In this embodiment, the in-order traversal method is adopted to search for nodes in the tree and assign new identifiers and associated parent node identifiers. The nodes are added to the node list (list), and the node list is output to prepare for rendering the nodes in the tree component. The steps of extracting nodes in the tree structure include: first, it is necessary to define the data structure of the tree node. This usually includes attributes such as the node identifier, parent node identifier, and child node list. For example, a Node class can be defined, including attributes such as item_id (node identifier), item_pid (parent node identifier), checked (checked) and children (child nodes). Using a recursive function to traverse the tree structure, the data of the node can be extracted as needed. If there is a JSON data tree as follows, data A, its left node L and right node R1, then list=A, L1, R1 is obtained.
[0144] Step 114, render the tree component. Loop through the nodes in the node list, use the node component to render each node, and monitor the changes of each node. The purpose of rendering is to let the user see the node and prepare for modification. The node component is an editing tool used to render nodes. Multiple such node components constitute a node component tree. The monitored events include deletion, addition and modification. Deletion includes deleting nodes (leaf nodes) and deleting parent nodes (non-leaf nodes). Addition includes adding nodes (adding from the root node) and adding child nodes (adding under a certain node). Different monitoring will have different data processing logic. When modifying, update the current node; when deleting the parent node, delete its child nodes together; when adding a node, if no node matching the newly added node is found, add one at the end of the node list. When adding a child node, add one after the last child node of the node matching the newly added node.
[0145] Step 115, modify the data according to the modification requirements. The modification requirements and corresponding operations include the following:
[0146] Delete / add nodes: Implement the functions of deleting and adding nodes in the tree component. When deleting a node, find the position index of the node in the node list and delete it; when adding a node, find a node that matches the newly added node as the current node, find the position index of the current node in the node list, add the sibling node to the last node in the node list, and add the child node to the index+1 position; after deleting and adding a node, the node list data changes, triggering a component update and re-rendering the component.
[0147] Edit metadata: When metadata is modified, change is triggered and a new node is output. The node identifier remains unchanged, and the tree component change listener is triggered to replace the node in the node list. When the node data in the node list changes, the node component update is triggered, that is, the corresponding node component is re-determined, and the node is re-rendered using the new node component. The extension component checks whether the metadata value is legal.
[0148] When node metadata is deleted, added, or modified, an update event is triggered, which in turn triggers the update of the node component and re-renders the node.
[0149] Step 116, rendering the node component. The node component renders the attributes and values of the metadata. There are two standards for rendering: interface and data. Rendering is to display the attributes in the interface. The data is the attribute value. If the attribute value is a string, an input box is rendered. When the attribute value is a date, a date selection panel is rendered.
[0150] Step 117, generate and output the metadata tree. After editing the metadata node, the metadata tree can be generated using the construction method. In this embodiment, the listToTree method is used to convert the node list into a tree structure at the time of initialization. First, traverse all the nodes in the node list. If the current node during traversal is a child node, merge it into the child node array of the parent node; secondly, traverse the child node array of all nodes and generate the right subtree, and the same-level nodes generate the left subtree. Finally, delete the id (identifier), parentId (parent node identifier), and children (array) added during the editing process. Output the new metadata tree, which is the target metadata tree after modifying the acquired metadata tree according to user needs. Users can use the target metadata tree to understand the detailed description and retrieval of the data.
[0151] The flattened metadata nodes in this embodiment add parent node identifiers to child nodes to maintain complete node relationships, which can also save costs. After the data is flattened, the data is sent to the tree component for rendering. Processing Array (a data structure consisting of a fixed number of elements with the same data type, such as the node list list in this embodiment) type data in the VueJS (front-end framework) component template is simpler than processing Object data (object data type, such as the metadata tree tree), and the template is more readable. In addition, the Array type performs better when processing large amounts of data. Finally, the node component is called to render the metadata type and metadata value. After modifying the metadata information, the metadata at the corresponding position in the Array is updated. At this point, the metadata modification is complete. The flattened data cannot be directly used as output, so it is necessary to restore the data structure (converted from the node list to the metadata tree) and output the edited metadata tree.
[0152] The data processing method of the embodiment of the present invention improves the efficiency of adding, deleting and modifying data by flattening the metadata tree (converting the metadata tree into a node list), and reduces the complexity of searching for nodes in the tree structure, that is, traversing a node relationship tree in the tree is simplified to comparing the relationship between a node and two adjacent nodes. In addition, when editing the metadata tree, attention is paid to the metadata nodes rather than all the attributes of the metadata tree, and emphasis is placed on adding, deleting and modifying the metadata tree nodes rather than modifying the attributes in the nodes, so as to simplify the modification of the metadata tree and improve data processing efficiency. The data structure Object (tree) is converted to Array (list), which is more efficient in node traversal and search, and performs better when the scale of the metadata tree modification is larger.
[0153] like Figure 2 As shown, an embodiment of the present invention provides a data processing device 200, including:
[0154] The acquisition module 201 is used to acquire a metadata tree; the structure of the metadata tree is JSON data;
[0155] A preprocessing module 202, used to preprocess the metadata tree to obtain a preprocessed metadata tree;
[0156] An extraction module 203 is used to extract the preprocessed metadata tree to obtain an original node list;
[0157] A rendering module 204, used for rendering the original node list to obtain a rendered original node list;
[0158] An editing module 205, configured to edit the rendered original node list according to the received modification requirements to obtain an edited node list;
[0159] A processing module 206 is used to render the edited node list to obtain a rendered edited node list;
[0160] The generating module 207 is used to generate a target metadata tree according to the rendered edited node list.
[0161] Optionally, preprocessing the metadata tree to obtain a preprocessed metadata tree includes:
[0162] Get preset inspection standards;
[0163] Checking the metadata tree according to the preset checking standard to obtain a checking result;
[0164] The metadata tree is adjusted according to the inspection result to obtain a preprocessed metadata tree.
[0165] Optionally, the preprocessed metadata tree is extracted to obtain an original node list, including:
[0166] Extract the preprocessed metadata tree according to a preset extraction method to obtain metadata nodes;
[0167] Modifying the node information of the metadata node to obtain a modified metadata node;
[0168] According to the modified metadata nodes, an original node list is obtained.
[0169] Optionally, the original node list is rendered to obtain a rendered original node list, including:
[0170] Traversing the metadata nodes in the original node list to obtain metadata nodes;
[0171] Determine a node component according to the metadata node;
[0172] The metadata nodes in the original node list are rendered using the node component to obtain a rendered original node list.
[0173] Optionally, the rendered original node list is edited according to the received modification requirements to obtain an edited node list, including:
[0174] Receive metadata modification requests;
[0175] The rendered original node list is edited according to a preset modification method and the metadata modification requirement to obtain an edited node list.
[0176] Optionally, the preset modification method includes:
[0177] If the metadata modification requirement is to delete an existing metadata node, then find the position index of the existing metadata node in the original node list, and delete the existing metadata node according to the position index;
[0178] If the metadata modification requirement is to add a new metadata node, then find the position index of the preset metadata node in the original node list, and add the metadata node according to the position index;
[0179] If the metadata modification requirement is to modify the information of an existing metadata node, then the position index of the preset metadata node in the original node list is searched, and the information of the existing metadata node is modified according to the position index.
[0180] Optionally, generating a target metadata tree according to the rendered edited node list includes:
[0181] Determine a root node according to the rendered edited node list;
[0182] Dividing the rendered edited node list according to the root node to obtain a divided node list;
[0183] The divided node list is converted using a preset conversion function to generate a target metadata tree.
[0184] It should be noted that the device is a device corresponding to the above method, and all implementations in the above method embodiment are applicable to the embodiment of the device and can achieve the same technical effect. This embodiment will not be repeated.
[0185] The embodiment of the present invention further provides a computing device, comprising: a processor, and a memory storing a computer program, wherein when the computer program is executed by the processor, the method described in any one of the above embodiments is executed. All implementations in the above method embodiments are applicable to the embodiments of the device, and can achieve the same technical effects. They will not be described in detail in this embodiment.
[0186] The embodiment of the present invention further provides a computer-readable storage medium on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the above embodiments. All implementations in the above method embodiments are applicable to the embodiments of the device and can achieve the same technical effects. They will not be described in detail in this embodiment.
[0187] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data processing method, characterized in that: include: Get the metadata tree; Preprocessing the metadata tree to obtain a preprocessed metadata tree; Extracting the preprocessed metadata tree to obtain an original node list; Rendering the original node list to obtain a rendered original node list; Editing the rendered original node list according to the received modification requirements to obtain an edited node list; Rendering the edited node list to obtain a rendered edited node list; generating a target metadata tree according to the rendered edited node list; The step of preprocessing the metadata tree to obtain a preprocessed metadata tree includes: Obtaining preset inspection criteria; the preset inspection criteria include one or more of the following: data is not empty, data has no missing key attributes, and data key attribute values are correct; the key attributes are one or more of the following: data source, data structure, data creation date, and data type; The metadata tree is checked according to the preset check standard to obtain a check result; wherein the metadata tree is checked in the following manner: traversing each node of the metadata tree to check whether each node has a null value; checking whether the data in each node conforms to the value range or format in the preset check standard; checking whether the attribute type of each node data conforms to the corresponding attribute type in the preset check standard; checking whether the content of the node data has logical inconsistencies by checking whether the foreign key reference is valid and whether the value of the calculated field matches the basic data; Adjusting the metadata tree according to the inspection result to obtain a preprocessed metadata tree; The preprocessed metadata tree is extracted to obtain an original node list, including: Extract the preprocessed metadata tree according to a preset extraction method to obtain a metadata node; the preset extraction method is an in-order traversal, and the traversal order of the in-order traversal is traversing the left subtree, traversing the root node, and traversing the right subtree; Modifying the node information of the metadata node to obtain a modified metadata node; wherein the specific manner of modifying the node information of the metadata node is: assigning a new identifier and a parent node identifier to the metadata node; Obtaining an original node list according to the modified metadata node; The original node list is rendered to obtain a rendered original node list, including: Traversing the metadata nodes in the original node list to obtain metadata nodes; traversing the metadata nodes in the original node list in a loop traversal manner; Determine a node component according to the metadata node; take the metadata node and its corresponding child nodes as an array, determine a node component for each array, and use the node component to render the attributes and values of the entire array; Using the node component to render the metadata nodes in the original node list, to obtain a rendered original node list; The rendered original node list is edited according to the received modification requirements to obtain an edited node list, including: Receive metadata modification requests; Editing the rendered original node list according to a preset modification method and the metadata modification requirement to obtain an edited node list; The preset modification method includes: If the metadata modification requirement is to delete an existing metadata node, then find the position index of the existing metadata node in the original node list, and delete the existing metadata node according to the position index; If the metadata modification requirement is to add a new metadata node, then the position index of the preset metadata node in the original node list is searched, and the metadata node is added according to the position index; when adding a new metadata node, the existing metadata nodes are searched in order, and the information of each metadata node is compared one by one until a metadata node matching the new metadata node is found, and the position index of the matching metadata node in the original node list is searched, and the new metadata node is appended after the matching metadata node. If a metadata node matching the new metadata node is not found, the new metadata node is appended to the end of the original node list; If the metadata modification requirement is to modify the information of an existing metadata node, then find the position index of the preset metadata node in the original node list, and modify the information of the existing metadata node according to the position index; The step of generating a target metadata tree according to the rendered edited node list includes: Determine a root node according to the rendered edited node list; Divide the rendered edited node list according to the root node to obtain a divided node list; traverse all metadata nodes, if the metadata node is a child node, merge it into the array of the parent node, take the root node as the boundary, traverse the array of all metadata nodes and generate a right subtree, and generate a left subtree for the same-level nodes, and finally, delete the assigned new identifier and the parent node identifier; The node list after the division is converted using a preset conversion function to generate a target metadata tree; the preset conversion function is a listToTree function, which constructs a tree by recursively finding the child nodes of each metadata node. The tree is constructed in such a way that the root node is used as a boundary, the metadata nodes at the same level generate a left subtree, and the array of all metadata nodes generates a right subtree, and the target metadata tree is obtained according to the root node, the left subtree and the right subtree.
2. A data processing device, characterized in that: include: The acquisition module is used to obtain the metadata tree; A preprocessing module, used for preprocessing the metadata tree to obtain a preprocessed metadata tree; An extraction module, used for extracting the preprocessed metadata tree to obtain an original node list; A rendering module, used for rendering the original node list to obtain a rendered original node list; An editing module, used for editing the rendered original node list according to the received modification requirements to obtain an edited node list; A processing module, used for rendering the edited node list to obtain a rendered edited node list; A generating module, used for generating a target metadata tree according to the rendered edited node list; The step of preprocessing the metadata tree to obtain a preprocessed metadata tree includes: Obtaining preset inspection criteria; the preset inspection criteria include one or more of the following: data is not empty, data has no missing key attributes, and data key attribute values are correct; the key attributes are one or more of the following: data source, data structure, data creation date, and data type; The metadata tree is checked according to the preset check standard to obtain a check result; wherein the metadata tree is checked in the following manner: traversing each node of the metadata tree to check whether each node has a null value; checking whether the data in each node conforms to the value range or format in the preset check standard; checking whether the attribute type of each node data conforms to the corresponding attribute type in the preset check standard; checking whether the content of the node data has logical inconsistencies by checking whether the foreign key reference is valid and whether the value of the calculated field matches the basic data; Adjusting the metadata tree according to the inspection result to obtain a preprocessed metadata tree; The preprocessed metadata tree is extracted to obtain an original node list, including: Extract the preprocessed metadata tree according to a preset extraction method to obtain a metadata node; the preset extraction method is an in-order traversal, and the traversal order of the in-order traversal is traversing the left subtree, traversing the root node, and traversing the right subtree; Modifying the node information of the metadata node to obtain a modified metadata node; wherein the specific manner of modifying the node information of the metadata node is: assigning a new identifier and a parent node identifier to the metadata node; Obtaining an original node list according to the modified metadata node; The original node list is rendered to obtain a rendered original node list, including: Traversing the metadata nodes in the original node list to obtain metadata nodes; traversing the metadata nodes in the original node list in a loop traversal manner; Determine a node component according to the metadata node; take the metadata node and its corresponding child nodes as an array, determine a node component for each array, and use the node component to render the attributes and values of the entire array; Using the node component to render the metadata nodes in the original node list, to obtain a rendered original node list; The rendered original node list is edited according to the received modification requirements to obtain an edited node list, including: Receive metadata modification requests; Editing the rendered original node list according to a preset modification method and the metadata modification requirement to obtain an edited node list; The preset modification method includes: If the metadata modification requirement is to delete an existing metadata node, then find the position index of the existing metadata node in the original node list, and delete the existing metadata node according to the position index; If the metadata modification requirement is to add a new metadata node, then the position index of the preset metadata node in the original node list is searched, and the metadata node is added according to the position index; when adding a new metadata node, the existing metadata nodes are searched in order, and the information of each metadata node is compared one by one until a metadata node matching the new metadata node is found, and the position index of the matching metadata node in the original node list is searched, and the new metadata node is appended after the matching metadata node. If a metadata node matching the new metadata node is not found, the new metadata node is appended to the end of the original node list; If the metadata modification requirement is to modify the information of an existing metadata node, then find the position index of the preset metadata node in the original node list, and modify the information of the existing metadata node according to the position index; The step of generating a target metadata tree according to the rendered edited node list includes: Determine a root node according to the rendered edited node list; Divide the rendered edited node list according to the root node to obtain a divided node list; traverse all metadata nodes, if the metadata node is a child node, merge it into the array of the parent node, take the root node as the boundary, traverse the array of all metadata nodes and generate a right subtree, and generate a left subtree for the same-level nodes, and finally, delete the assigned new identifier and the parent node identifier; The node list after the division is converted using a preset conversion function to generate a target metadata tree; the preset conversion function is a listToTree function, which constructs a tree by recursively finding the child nodes of each metadata node. The tree is constructed in such a way that the root node is used as a boundary, the metadata nodes at the same level generate a left subtree, and the array of all metadata nodes generates a right subtree, and the target metadata tree is obtained according to the root node, the left subtree and the right subtree.
3. A computing device, characterized in that: include: A processor and a memory storing a computer program, wherein when the computer program is executed by the processor, the method according to claim 1 is performed.
4. A computer-readable storage medium, characterized in that: Instructions are stored, which, when executed on a computer, cause the computer to execute the method as claimed in claim 1.
