A method, device, equipment and storage medium for converting original access data
By using the YANG model's associated tags in the software-defined network controller to automate data conversion and database table structure design, the problem of low data access efficiency is solved, and manual processing costs and repetitive development are reduced.
Patent Information
- Application Number
- CN202311146679.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-06
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-09-06
AI Technical Summary
In existing software-defined network controllers, data access is inefficient and requires manual processing of access data and design of database table structures, resulting in high labor costs and a large amount of repetitive development.
By obtaining the original access data, traversing and cleaning special characters, determining key-value pair information, and converting data according to the associated tags in the YANG model, the database table structure is automatically constructed, reducing manual processing costs.
It realizes automated data conversion and database table structure design, reduces repetitive development and improves project development efficiency.
Smart Images

Figure CN117033496B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for converting original access data. Background Art
[0002] In existing Software Defined Network (SDN) controller development, lightweight JSON (JavaScript Object Notation) access data based on the YANG (Yet Another Next Generation) data model is the foundation of the entire project. The corresponding business logic relies on access data, and the database table structure is also designed and defined based on access data.
[0003] In existing methods, manual processing of access data, manual design of database table structure, and manual persistence of access data to the database are usually required.
[0004] However, existing methods have the problem of low efficiency when accessing data. Summary of the Invention
[0005] The present application provides a method, apparatus, device and storage medium for converting original access data to solve the problem of low efficiency in data access in existing methods.
[0006] In a first aspect, the present application provides a method for converting original access data, the method comprising:
[0007] Acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node;
[0008] Traversing the original access data, determining first key-value pair information of the first data and second key-value pair information of the second data;
[0009] If the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, determining a first association tag between the first key-value pair information and the second key-value pair information;
[0010] The original access data is converted according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
[0011] In an embodiment of the present application, the method for obtaining original access data includes:
[0012] Determine the target YANG model;
[0013] Obtain raw access data based on the target YANG model.
[0014] In an embodiment of the present application, traversing the original access data to determine the first key-value pair information of the first data and the second key-value pair information of the second data includes:
[0015] According to the original access data, special characters in the original access data are cleaned to obtain the cleaned original access data;
[0016] According to the cleaned original access data, first key-value pair information of the first data and second key-value pair information of the second data are determined.
[0017] In an embodiment of the present application, special characters in the original access data are cleaned according to the original access data to obtain the cleaned original access data, including:
[0018] Determine a special character and a target character in the original access data, wherein the target character is the first character after the special character;
[0019] Deleting special characters from the original access data to obtain the original access data after initial cleaning;
[0020] The target characters in the original access data after the initial cleaning process are marked to obtain the original access data after the cleaning process.
[0021] In an embodiment of the present application, when the target character is a letter, the target character in the original access data after the initial cleaning process is marked to obtain the cleaned original access data, including:
[0022] Determining target characters in the raw access data after initial cleaning;
[0023] The target characters in the original access data after the initial cleaning process are format-converted to obtain the cleaned original access data, wherein the format-converted process is used to convert the lowercase format of the letters into uppercase format.
[0024] In an embodiment of the present application, if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, determining the first association tag between the first key-value pair information and the second key-value pair information includes:
[0025] Determine preset comparison key-value pair information, wherein the comparison key-value pair information is key-value pair information preset in the YANG model;
[0026] According to the node relationship between the first data and the second data, a first association relationship between the first key-value pair information and the second key-value pair information, and a first association label of the first association relationship are determined.
[0027] In an embodiment of the present application, if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, after determining the first association tag between the first key-value pair information and the second key-value pair information, the method further includes:
[0028] Traversing the original access data, determining whether the second data belongs to underlying data, where the underlying data is used to represent the level of the second data in the node relationship;
[0029] If the second data does not belong to the bottom layer data, determining third data and third key-value pair information of the third data, wherein the third data is data of a child node of the second data;
[0030] If the third key-value pair information is key-value pair information in the preset comparison key-value pair information, determining a second association tag between the second key-value pair information and the third key-value pair information;
[0031] The original access data is converted according to the first key-value pair information, the second key-value pair information, the third key-value pair information, the first association tag, and the second association tag to obtain converted data.
[0032] In an embodiment of the present application, after converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes:
[0033] Obtaining a first initial data table and first key-value pair data of first key-value pair information in the converted data;
[0034] If the data volume of the first key-value pair data meets the preset data volume requirement, the field name and attribute information of the first key-value pair data are written into the first initial data table to obtain the first data table.
[0035] In an embodiment of the present application, after obtaining the first initial data table and the first key-value pair data of the first key-value pair information in the conversion data, the method further includes:
[0036] If the number of first key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each first key-value pair data;
[0037] The field name and attribute information of each first key-value pair data are respectively written into the first initial data table to obtain a first data table.
[0038] In an embodiment of the present application, after converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes:
[0039] Acquire a second initial data table and second key-value pair data of second key-value pair information in the converted data;
[0040] If the data volume of the second key-value pair data meets the preset data volume requirement, the field name and attribute information of the second key-value pair data are written into the second initial data table to obtain a second data table.
[0041] In an embodiment of the present application, after obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the conversion data, the method further includes:
[0042] If the number of the second key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each second key-value pair data;
[0043] The field name and attribute information of each second key-value pair data are respectively written into the second initial data table to obtain a second data table.
[0044] In an embodiment of the present application, after obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the conversion data, the method further includes:
[0045] Traversing the converted data to determine whether the second key-value pair data belongs to underlying data, where the underlying data is used to represent the level of the second key-value pair data in the converted data node relationship;
[0046] If the second key-value pair data does not belong to the underlying data, determining the third key-value pair information in the converted data, obtaining the third initial data table, and the third key-value pair data of the third key-value pair information;
[0047] If the data volume of the third key-value pair data meets the preset data volume requirement, the field name and attribute information of the third key-value pair data are written into the third initial data table to obtain a third data table.
[0048] In a second aspect, the present application provides a device for converting original access data, comprising:
[0049] An acquisition module, configured to acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node;
[0050] a determination module, configured to traverse the original access data and determine first key-value pair information of the first data and second key-value pair information of the second data;
[0051] a comparison module, configured to determine a first association tag between the first key-value pair information and the second key-value pair information if both the first key-value pair information of the first data and the second key-value pair information of the second data are key-value pair information in preset comparison key-value pair information;
[0052] The conversion module is configured to convert the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
[0053] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0054] The memory stores computer-executable instructions;
[0055] The processor executes the computer-executable instructions stored in the memory to implement the method of the embodiment of the present application.
[0056] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method of the embodiment of the present application.
[0057] The present application provides a method, apparatus, device and storage medium for converting original access data, which obtains original access data, wherein the original access data includes first data of a first node and second data of a second node, and the first node is the parent node of the second node; traverses the original access data to determine first key-value pair information of the first data and second key-value pair information of the second data; if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in preset comparison key-value pair information, then determine a first association tag of the first key-value pair information and the second key-value pair information; according to the first key-value pair information, the second key-value pair information, and the first association tag, The means for converting the original access data to obtain converted data can, when converting the original access data of the layer structure, mark and associate the nodes of each layer in the original access data through key-value pair information and the first association tag, so that when the first data and the second data in the original access data are converted, the marked data of each layer can be extracted, and the extracted data can be stored in a database table structure for data storage automatically constructed by the first association tag according to the relationship between the layers, thereby obtaining converted data. This reduces the cost of manually processing the original access data and designing the database table structure. At the same time, the target data can be directly located based on the association tag, reducing the development of repetitive data and improving the development efficiency of the project. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0059] Figure 1 A flowchart of a method for converting raw access data provided in an embodiment of the present application;
[0060] Figure 2 A flowchart of another method for converting original access data provided in an embodiment of the present application;
[0061] Figure 2A A schematic diagram of the process flow of the data conversion module provided in an embodiment of the present application;
[0062] Figure 2B A schematic diagram of the process flow of the library table generation module provided in an embodiment of the present application;
[0063] Figure 2C A flowchart of the code processing module provided in an embodiment of the present application;
[0064] Figure 3 A schematic diagram of the structure of a device for converting raw access data provided in an embodiment of the present application;
[0065] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0066] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0067] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0068] In the existing technology, the access data structure is complex, and in the past, manual design was required to implement the basic library-table relationship before subsequent business development could proceed. However, the complex structure will greatly increase the difficulty of design, and the library-table relationship will change due to business changes. The labor cost of maintaining the library-table relationship is high, and it also affects the upper-level business development and is not conducive to the stability of the back-end project. The access data of the SDN controller needs to be persisted to the database, which previously required manual execution. In addition, each business layer is independent, with a large amount of repeated development and a lack of a unified persistence device.
[0069] In order to solve the above problems, the conversion method of original access data provided in this application can automatically convert the original access data into converted data containing inter-hierarchical association information based on the original access data structure and the hierarchical primary key information defined by the YANG model. The converted data is embedded with association tags based on the original access data. According to the association tags, the data of each level that meets the preset requirements can be directly extracted from the data, and the database table structure can be automatically designed based on the data of each level, thereby reducing the cost of manually processing the original access data and designing the database table structure. At the same time, the target data can be directly located based on the association tags, reducing the development of repetitive data and improving the development efficiency of the project.
[0070] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0071] The execution subject of the method for converting the original access data provided in the embodiment of the present application can be a server. The server can be a computer or other device. This embodiment does not impose any special restrictions on the implementation method of the execution subject, as long as the execution subject can obtain the original access data, the original access data includes the first data of the first node and the second data of the second node, and the first node is the parent node of the second node; traverse the original access data to determine the first key-value pair information of the first data and the second key-value pair information of the second data; if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, then determine the first association tag of the first key-value pair information and the second key-value pair information; according to the first key-value pair information, the second key-value pair information, and the first association tag, convert the original access data to obtain the converted data.
[0072] The key-value pair information may refer to data corresponding to a primary key value, and the primary key value may refer to an index of the data in the key-value pair information.
[0073] The preset comparison key-value pair information may refer to the key-value pair information defined in the YANG model. The basic principle is as follows: the key-value pair information defined in the YANG model is set as the comparison key-value pair information that meets the data conversion requirements of the original access data, and the key-value pair information in the original access data is compared with the comparison key-value pair information to determine the key-value pair information in the original access data that meets the preset comparison key-value pair information.
[0074] Association tags act as identifiers in the conversion data. Based on the association tags, the location of the target key-value pair information in the conversion data can be directly determined, thereby improving the efficiency of project development.
[0075] Figure 1 The flowchart of the method for converting the original access data provided in the embodiment of the present application is shown in FIG. The execution subject of the method can be a computer, and this embodiment is not particularly limited here. Figure 1 As shown, the method may include:
[0076] S101: Acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node.
[0077] The original access data may refer to basic data in a data conversion system. For example, in SDN controller development, the access data JSON based on the YANG model definition may be the original access data used for project development. The original access data may include at least two levels. For example, when the original access data includes 10 levels, the first level may be the level of the N-1th level, and the second level may be the level of the Nth level, where N is an integer less than or equal to 10. In the embodiment of the present application, the data of the first level is the first data, and the data of the second level is the second data.
[0078] In this embodiment of the present application, the method for obtaining original access data further includes:
[0079] Determine the target YANG model;
[0080] Obtain raw access data based on the target YANG model.
[0081] The target YANG model may refer to setting the key-value pair information defined in the YANG model as the target model, that is, the key-value pair information defined in the YANG model is the comparison key-value pair information that meets the data conversion requirements of the original access data.
[0082] S102: traverse the original access data to determine first key-value pair information of the first data and second key-value pair information of the second data.
[0083] The first key-value pair information refers to all key-value pair information at the level where the first data is located.
[0084] The second key-value pair information refers to all key-value pair information at the level where the second data is located.
[0085] In the embodiment of the present application, the method for determining the first key-value pair information of the first data and the second key-value pair information of the second data further includes:
[0086] According to the original access data, special characters in the original access data are cleaned to obtain the cleaned original access data;
[0087] According to the cleaned original access data, first key-value pair information of the first data and second key-value pair information of the second data are determined.
[0088] Special characters include underscores, brackets, and other characters with special meanings.
[0089] Cleaning processing may refer to removing special characters from the original access data by means of deletion.
[0090] In the embodiment of the present application, special characters in the original access data are cleaned to obtain the cleaned original access data. The method further includes:
[0091] Determine the special character and the target character in the original access data, where the target character is the first character after the special character;
[0092] Deleting special characters from the original access data to obtain the original access data after initial cleaning;
[0093] The target characters in the original access data after the initial cleaning process are marked to obtain the original access data after the cleaning process.
[0094] The target character is the first character after the special character. For example, when the original access data is a_bc, the special character is the underscore "_" and the target character is "b".
[0095] In this embodiment of the present application, when the target character is a letter, the target character in the original access data after the initial cleaning process is marked to obtain the original access data after the cleaning process, and the method further includes:
[0096] Determining target characters in the raw access data after initial cleaning;
[0097] The target characters in the original access data after the initial cleaning process are format-converted to obtain the cleaned original access data, wherein the format-converted process is used to convert the lowercase format of the letters into uppercase format.
[0098] The format conversion may mean that when the original access data is a_bc, the data obtained after the format processing is aBc.
[0099] S103: If the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, determine a first association tag between the first key-value pair information and the second key-value pair information.
[0100] The preset comparison key-value pair information refers to a preset set of key-value pair information that meets the data conversion requirements. For example, the preset comparison key-value pair information may be key-value pair information defined in a YANG model.
[0101] The first association tag may refer to a tag that can determine that a hierarchy where the first key-value pair information is located and a hierarchy where the second key-value pair information is located exist in a superior-subordinate relationship.
[0102] In this embodiment of the present application, if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, then determining a first association tag between the first key-value pair information and the second key-value pair information, the method further includes:
[0103] Determine preset comparison key-value pair information, wherein the comparison key-value pair information is key-value pair information preset in the YANG model;
[0104] According to the node relationship between the first data and the second data, a first association relationship between the first key-value pair information and the second key-value pair information, and a first association label of the first association relationship are determined.
[0105] The first association relationship refers to a relationship in which the level where the first key-value pair information is located and the level where the second key-value pair is located are upper and lower levels.
[0106] For example, when the node where the first data is located is the parent node of the node where the second data is located, the first label relationship between the first key-value pair information corresponding to the first data and the second key-value pair information corresponding to the second data can be determined, that is, the level where the first key-value pair information is located is the upper level of the level where the second key-value pair information is located. According to the first association relationship, the first association label can be named, and the first key-value pair information and the second key-value pair information can be directly located through the first association label.
[0107] S104: Convert the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
[0108] The converted data refers to data obtained by placing the first key-value pair information, the second key-value pair information, and the first association tag into the original access data.
[0109] In this embodiment of the present application, if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, then after determining the first association tag between the first key-value pair information and the second key-value pair information, the method further includes:
[0110] Traversing the original access data to determine whether the second data belongs to underlying data, where the underlying data is used to represent the level of the second data in the node relationship;
[0111] If the second data does not belong to the bottom layer data, determining third data and third key-value pair information of the third data, wherein the third data is data of a child node of the second data;
[0112] If the third key-value pair information is key-value pair information in the preset comparison key-value pair information, determining a second association tag between the second key-value pair information and the third key-value pair information;
[0113] The original access data is converted according to the first key-value pair information, the second key-value pair information, the third key-value pair information, the first association tag, and the second association tag to obtain converted data.
[0114] Among them, the underlying data can refer to the lowest level data in the JSON type original access data. By analyzing the original access data layer by layer, it is determined whether each layer of data contains child nodes. If it contains child nodes, it is determined that the layer data is not the underlying data of the original access data. Otherwise, the layer data is the underlying data of the original access data.
[0115] The third data refers to data at a level below the level where the second data is located.
[0116] Among them, when the original access data contains third data, the third key-value pair information and the second associated tag corresponding to the third data can be determined, and the first key-value pair information, the second key-value pair information and the third key-value pair information, as well as the first associated tag and the second associated tag are placed into the original access data to obtain the converted data.
[0117] In this embodiment of the present application, after converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes:
[0118] Obtaining a first initial data table and first key-value pair data of first key-value pair information in the converted data;
[0119] If the data volume of the first key-value pair data meets the preset data volume requirement, the field name and attribute information of the first key-value pair data are written into the first initial data table to obtain the first data table.
[0120] The first initial data table is a data table corresponding to the data in the first key-value pair information, and is obtained by writing all the data in the first key-value pair information into a table.
[0121] The preset data volume requirement means that the data in the first key-value pair information cannot contain a field set.
[0122] The field name of the first key-value pair data refers to the name that can identify the position of the field in the data table, and the attribute information refers to the attributes of the field, such as the data type, length, default value, etc. of the field.
[0123] The first data table refers to the data table corresponding to the first key-value pair data in the converted data.
[0124] In an embodiment of the present application, after obtaining the first initial data table and the first key-value pair data of the first key-value pair information in the conversion data, the method further includes:
[0125] If the number of first key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each first key-value pair data;
[0126] The field name and attribute information of each first key-value pair data are respectively written into the first initial data table to obtain a first data table.
[0127] The fact that the number of entries of the first key-value pair data does not meet the preset entry requirement means that the first key-value pair data contains a field set.
[0128] Determining the field name and attribute information of each first key-value pair data refers to splitting the field set in the first key-value pair data to obtain individual field information, and writing the name and attribute information of the individual fields into the first initial data table respectively, thereby obtaining the first data table.
[0129] In an embodiment of the present application, after converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes:
[0130] Acquire a second initial data table and second key-value pair data of second key-value pair information in the converted data;
[0131] If the data volume of the second key-value pair data meets the preset data volume requirement, the field name and attribute information of the second key-value pair data are written into the second initial data table to obtain a second data table.
[0132] The second initial data table is a data table corresponding to the data in the second key-value pair information, and is obtained by writing all the data in the second key-value pair information into one table.
[0133] The second data table refers to the data table corresponding to the second key-value pair data in the converted data.
[0134] In an embodiment of the present application, after obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the conversion data, the method further includes:
[0135] If the number of the second key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each second key-value pair data;
[0136] The field name and attribute information of each second key-value pair data are respectively written into the second initial data table to obtain a second data table.
[0137] In an embodiment of the present application, after obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the conversion data, the method further includes:
[0138] Traversing the transformed data, determining whether the second key-value pair data belongs to underlying data, where the underlying data is used to represent the level of the second key-value pair data in the transformed data node relationship;
[0139] If the second key-value pair data does not belong to the underlying data, determining the third key-value pair information in the converted data, obtaining the third initial data table, and the third key-value pair data of the third key-value pair information;
[0140] If the data volume of the third key-value pair data meets the preset data volume requirement, the field name and attribute information of the third key-value pair data are written into the third initial data table to obtain a third data table.
[0141] The third data table refers to the data table corresponding to the third key-value pair data in the converted data.
[0142] The method for converting original access data provided in the present application can obtain original access data, including first data of a first node and second data of a second node; determine first key-value pair information of the first data and second key-value pair information of the second data based on the original access data; if the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in preset comparison key-value pair information, determine the first association tag of the first key-value pair information and the second key-value pair information; convert the original access data based on the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, thereby solving the problems in the prior art of high data duplication processing rate and high labor cost caused by the complex access data structure.
[0143] Figure 2 Another method for converting original access data provided in the embodiment of the present application is as follows: Figure 2 As shown, the overall process of the data conversion method is as follows:
[0144] S201, the data conversion module processes the original access data based on the primary key information in the YANG model for subsequent association of the library table structure and automatic storage of the access data;
[0145] The requirement for the subsequent associated library table structure is that the access data cannot contain special characters.
[0146] S202, a library table generation module generates corresponding library table information based on the converted data, including table structure, field names, attributes, etc.;
[0147] The library table information refers to a first data table corresponding to the first key-value pair information and a second data table corresponding to the second key-value pair information.
[0148] S203, the code processing module can generate the basic DAO layer code according to the library table information, and at the same time, the data is converted and entered into the library according to the corresponding data conversion module;
[0149] Figure 2A The data conversion module processing flow is provided for the embodiment of the present application, and the steps are as follows:
[0150] S204. Obtain the primary key set keyM defined in the YANG model;
[0151] S205. Based on the given original access data dataO, the keys in all key-value pairs are processed into camelCase format to obtain formatted data dataF.
[0152] The camel case data refers to data obtained by cleaning special characters in the original access data.
[0153] S206: Process data layer by layer starting from the top layer of dataF to obtain all key-value pair information of the current layer;
[0154] S207: Determine whether the current level contains any value in keyM. If so, proceed to step S208; otherwise, proceed directly to step S210.
[0155] S208: Place the associated field set into the current level as the associated information of the previous level, and add a special identifier before the field;
[0156] The special identifier refers to the associated tag.
[0157] S209: There is only one keyM at each level. Extract the key-value pair of this field and temporarily store it in the associated field set.
[0158] S210, parse all key-value pair attributes of the current level and temporarily store them;
[0159] S211: Determine whether the current layer is the bottom layer of dataF. If so, proceed to step S213; otherwise, proceed to step S212.
[0160] S212: Go to the next data. If the number of levels increases, the associated field set is not updated. If the number of levels decreases, the level is returned and the primary key information in the current level is removed from the associated field set.
[0161] S213: Output the converted data dataC after all processing is completed.
[0162] Figure 2B The library table generation module processing flow is provided for the embodiment of this application, and the steps are as follows:
[0163] S214, obtaining processed data dataC through the data conversion module;
[0164] S215, process data layer by layer starting from the top layer of dataC, and obtain all key-value pair information of the current layer;
[0165] S216. Use the current level tag name to indicate the name of the new table and generate the basic structure of the table;
[0166] S217: Loop through all data at the current level to determine whether the field is a set. If so, proceed to step S218; otherwise, proceed to step S219.
[0167] S218, placing the collection into the dataC to-be-processed level;
[0168] S219, adding field names and attribute information to the current table based on the attributes;
[0169] S220, enter the next processing level;
[0170] S221, determine whether it is the bottom layer of dataC, if so, go to step S222, otherwise go to step S220;
[0171] S222. Output the complete library table structure.
[0172] Figure 2C The code processing module process is provided for the embodiment of this application, and the steps are as follows:
[0173] S223, converting dataO into dataC according to the data conversion module;
[0174] S224, starting from the top layer of dataC, process the data layer by layer to obtain all key-value pair information of the current layer;
[0175] S225. Extract all the set fields of the current level. This part is table data and should be placed in the pending level for new storage processing.
[0176] S226. Process the non-aggregate field information as a storage operation;
[0177] S227, storing the current level field information in the database;
[0178] S228, enter the next processing level;
[0179] S229: Determine whether it is the bottom layer of dataC. If so, output the complete library table structure. Otherwise, go to step S228.
[0180] Another method for converting original access data provided in an embodiment of the present application can obtain conversion data with inter-hierarchical correlation information, and the conversion data can be used for library table structure generation and automatic conversion. It can automatically design complex library table structures and provide an external interface. It can be converted into corresponding library table structure data with one click and stored in the library for processing. It can greatly reduce the manual maintenance cost of library table relationships, reduce the impact of business layer development, reduce repetitive code development, and improve project development efficiency.
[0181] Figure 3 This is a schematic diagram of the structure of the device for converting the original access data provided in the embodiment of the present application. Figure 3 As shown, the original access data conversion device 30 includes: an acquisition module 301, a determination module 302, a comparison module 303, and a conversion module 304.
[0182] An acquisition module 301 is configured to acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node;
[0183] A determination module 302 is configured to traverse the original access data and determine first key-value pair information of the first data and second key-value pair information of the second data;
[0184] a comparison module 303 configured to determine a first association tag between the first key-value pair information and the second key-value pair information if both the first key-value pair information of the first data and the second key-value pair information of the second data are key-value pair information in preset comparison key-value pair information;
[0185] The conversion module 304 is configured to convert the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
[0186] In the embodiment of the present application, the acquisition module 301 may also be specifically used to:
[0187] Determine the target YANG model;
[0188] Obtain raw access data based on the target YANG model.
[0189] In the embodiment of the present application, the determination module 302 may also be specifically configured to:
[0190] According to the original access data, special characters in the original access data are cleaned to obtain the cleaned original access data;
[0191] According to the cleaned original access data, first key-value pair information of the first data and second key-value pair information of the second data are determined.
[0192] In the embodiment of the present application, the determination module 302 may also be specifically configured to:
[0193] Determine the special character and the target character in the original access data, where the target character is the first character after the special character;
[0194] Deleting special characters from the original access data to obtain the original access data after initial cleaning;
[0195] The target characters in the original access data after the initial cleaning process are marked to obtain the original access data after the cleaning process.
[0196] In the embodiment of the present application, the determination module 302 may also be specifically configured to:
[0197] Determining target characters in the raw access data after initial cleaning;
[0198] The target characters in the original access data after the initial cleaning process are format-converted to obtain the cleaned original access data, wherein the format-converted process is used to convert the lowercase format of the letters into uppercase format.
[0199] In the embodiment of the present application, the comparison module 303 may also be specifically used to:
[0200] Determine preset comparison key-value pair information, wherein the comparison key-value pair information is key-value pair information preset in the YANG model;
[0201] According to the node relationship between the first data and the second data, a first association relationship between the first key-value pair information and the second key-value pair information, and a first association label of the first association relationship are determined.
[0202] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0203] Traversing the original access data to determine whether the second data belongs to underlying data, where the underlying data is used to represent the level of the second data in the node relationship;
[0204] If the second data does not belong to the bottom layer data, determining third data and third key-value pair information of the third data, wherein the third data is data of a child node of the second data;
[0205] If the third key-value pair information is key-value pair information in the preset comparison key-value pair information, determining a second association tag between the second key-value pair information and the third key-value pair information;
[0206] The original access data is converted according to the first key-value pair information, the second key-value pair information, the third key-value pair information, the first association tag, and the second association tag to obtain converted data.
[0207] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0208] Obtaining a first initial data table and first key-value pair data of first key-value pair information in the converted data;
[0209] If the data volume of the first key-value pair data meets the preset data volume requirement, the field name and attribute information of the first key-value pair data are written into the first initial data table to obtain the first data table.
[0210] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0211] If the number of first key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each first key-value pair data;
[0212] The field name and attribute information of each first key-value pair data are respectively written into the first initial data table to obtain a first data table.
[0213] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0214] Acquire a second initial data table and second key-value pair data of second key-value pair information in the converted data;
[0215] If the data volume of the second key-value pair data meets the preset data volume requirement, the field name and attribute information of the second key-value pair data are written into the second initial data table to obtain a second data table.
[0216] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0217] If the number of the second key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each second key-value pair data;
[0218] The field name and attribute information of each second key-value pair data are respectively written into the second initial data table to obtain a second data table.
[0219] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0220] Traversing the transformed data, determining whether the second key-value pair data belongs to underlying data, where the underlying data is used to represent the level of the second key-value pair data in the transformed data node relationship;
[0221] If the second key-value pair data does not belong to the underlying data, determining the third key-value pair information in the converted data, obtaining the third initial data table, and the third key-value pair data of the third key-value pair information;
[0222] If the data volume of the third key-value pair data meets the preset data volume requirement, the field name and attribute information of the third key-value pair data are written into the third initial data table to obtain a third data table.
[0223] In the embodiment of the present application, the conversion module 304 may also be specifically configured to:
[0224] If the number of the third key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each third key-value pair data;
[0225] The field name and attribute information of each third key-value pair data are respectively written into the third initial data table to obtain a third data table.
[0226] As can be seen from the above, the conversion device 30 of the original access data of the embodiment of the present application is composed of an acquisition module 301, which is used to obtain the original access data, wherein the original access data includes the first data of the first node and the second data of the second node, and the first node is the parent node of the second node; a determination module 302, which is used to determine the first key-value pair information of the first data and the second key-value pair information of the second data based on the original access data; a comparison module 303, which is used to compare the first key-value pair information of the first data and the second key-value pair information of the second data with the key-value pair information in the preset comparison key-value pair information to determine the first association label of the first key-value pair information and the second key-value pair information; and a conversion module 304, which is used to convert the original access data according to the first key-value pair information, the second key-value pair information, and the first association label to obtain converted data. Therefore, by converting the original access data, determining the associated tags in the converted data, directly extracting the data at each level that meets the preset data requirements based on the associated tags, and automatically designing the database table structure based on the data at each level, the cost of manually processing the original access data and designing the database table structure is reduced, the development of repetitive data is reduced, and the project development efficiency is improved.
[0227] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 4 As shown, the electronic device 40 includes:
[0228] The electronic device 40 may include one or more processors 401 , one or more computer-readable storage media memories 402 , a communication component 403 , and other components. The processor 401 , the memory 402 , and the communication component 403 are connected via a bus 404 .
[0229] In a specific implementation process, at least one processor 401 executes the computer-executable instructions stored in the memory 402, so that the at least one processor 401 executes the above-mentioned method for converting the original access data.
[0230] The specific implementation process of the processor 401 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.
[0231] In the above Figure 4In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASICs), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present invention may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0232] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory.
[0233] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be classified into address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.
[0234] In some embodiments, a computer program product is further proposed, including a computer program or instructions, which implement the steps in any of the above-mentioned methods for converting original access data when executed by a processor.
[0235] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0236] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0237] To this end, an embodiment of the present application provides a computer-readable storage medium, which stores multiple instructions. The instructions can be loaded by a processor to execute the steps of any data processing method provided in the embodiment of the present application.
[0238] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0239] According to one aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program comprises computer instructions stored in a computer-readable storage medium.
[0240] Since the instructions stored in the storage medium can execute the steps in any data processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data processing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0241] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0242] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for converting original access data, characterized in that: The method is applied to a data conversion system, and the method includes: Acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node; Traversing the original access data, determining first key-value pair information of the first data and second key-value pair information of the second data; If the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, determining a first association tag between the first key-value pair information and the second key-value pair information; The original access data is converted according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
2. The method according to claim 1, characterized in that The method for obtaining original access data includes: Determine the target YANG model; According to the target YANG model, original access data is obtained.
3. The method according to claim 1, characterized in that The traversing the original access data to determine first key-value pair information of the first data and second key-value pair information of the second data includes: cleaning the special characters in the original access data according to the original access data to obtain cleaned original access data; According to the cleaned original access data, first key-value pair information of the first data and second key-value pair information of the second data are determined.
4. The method according to claim 3, characterized in that The step of cleaning the special characters in the original access data according to the original access data to obtain the cleaned original access data includes: Determining a special character and a target character in the original access data, where the target character is the first character after the special character; Deleting special characters from the original access data to obtain the original access data after initial cleaning; Marking is performed on the target characters in the original access data after the initial cleaning process to obtain the original access data after the cleaning process.
5. The method according to claim 4, characterized in that When the target character is a letter, marking the target character in the original access data after the initial cleaning process to obtain the cleaned original access data includes: Determining target characters in the original access data after the initial cleaning process; Performing format conversion processing on the target characters in the original access data after the initial cleaning processing to obtain the original access data after the cleaning processing, wherein the format conversion processing is used to convert the lowercase format of the letters into uppercase format.
6. The method according to claim 1, characterized in that If the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, determining a first association tag between the first key-value pair information and the second key-value pair information includes: Determining preset comparison key-value pair information, wherein the comparison key-value pair information is key-value pair information preset in the YANG model; According to the node relationship between the first data and the second data, a first association relationship between the first key-value pair information and the second key-value pair information, and a first association label of the first association relationship are determined.
7. The method according to claim 1, characterized in that If the first key-value pair information of the first data and the second key-value pair information of the second data are both key-value pair information in the preset comparison key-value pair information, after determining the first association tag between the first key-value pair information and the second key-value pair information, the method further includes: Traversing the original access data, determining whether the second data belongs to underlying data, the underlying data being used to represent a level of the second data in a node relationship; If the second data does not belong to the underlying data, determining third data and third key-value pair information of the third data, wherein the third data is data of a child node of the second data; If the third key-value pair information is key-value pair information in the preset comparison key-value pair information, determining a second association tag between the second key-value pair information and the third key-value pair information; The original access data is converted according to the first key-value pair information, the second key-value pair information, the third key-value pair information, and the first association tag and the second association tag to obtain converted data.
8. The method according to claim 1, characterized in that After converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes: Acquire a first initial data table and first key-value pair data of the first key-value pair information in the converted data; If the data volume of the first key-value pair data meets the preset data volume requirement, the field name and attribute information of the first key-value pair data are written into the first initial data table to obtain a first data table.
9. The method according to claim 8, characterized in that After obtaining the first initial data table and the first key-value pair data of the first key-value pair information in the converted data, the method further includes: If the number of the first key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each of the first key-value pair data; The field name and attribute information of each piece of the first key-value pair data are written into the first initial data table to obtain a first data table.
10. The method according to claim 1, characterized in that After converting the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data, the method further includes: Acquire a second initial data table and second key-value pair data of the second key-value pair information in the converted data; If the data volume of the second key-value pair data meets the preset data volume requirement, the field name and attribute information of the second key-value pair data are written into the second initial data table to obtain a second data table.
11. The method according to claim 10, characterized in that After obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the converted data, the method further includes: If the number of the second key-value pair data does not meet the preset number requirement, determining the field name and attribute information of each piece of the second key-value pair data; The field name and attribute information of each piece of the second key-value pair data are written into the second initial data table to obtain a second data table.
12. The method according to claim 11, characterized in that After obtaining the second initial data table and the second key-value pair data of the second key-value pair information in the converted data, the method further includes: Traversing the converted data, determining whether the second key-value pair data belongs to underlying data, the underlying data being used to represent the level of the second key-value pair data in the node relationship of the converted data; If the second key-value pair data does not belong to the underlying data, determining third key-value pair information in the converted data, obtaining a third initial data table, and third key-value pair data of the third key-value pair information; If the data volume of the third key-value pair data meets the preset data volume requirement, the field name and attribute information of the third key-value pair data are written into the third initial data table to obtain a third data table.
13. A device for converting original access data, characterized in that: include: an acquisition module, configured to acquire original access data, where the original access data includes first data of a first node and second data of a second node, where the first node is a parent node of the second node; a determination module, configured to traverse the original access data and determine first key-value pair information of the first data and second key-value pair information of the second data; a comparison module, configured to determine a first association tag between the first key-value pair information and the second key-value pair information if both the first key-value pair information of the first data and the second key-value pair information of the second data are key-value pair information in preset comparison key-value pair information; The conversion module is configured to convert the original access data according to the first key-value pair information, the second key-value pair information, and the first association tag to obtain converted data.
14. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 12 when executed by a processor.
Citation Information
Patent Citations
JSON-to-SQL method and device, terminal and storage medium
CN115577032A
Smart view generation for payloads
US20230214401A1