Data storage method and device

By generating data objects and converting them into structured query statements, efficient persistent storage of topological relational data is achieved, solving the problems of high database access pressure and communication quality dependence, and improving the success rate of data persistence.

CN114490651BActive Publication Date: 2025-08-12ALIBABA CLOUD COMPUTING CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210062579.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-19
Publication Date
2025-08-12
Estimated Expiration
2042-01-19

AI Technical Summary

Technical Problem

In the prior art, in the persistent storage process of topological relational data, excessive database access times lead to high access pressure, and may lead to failure of data persistence in an unstable environment.

Method used

By generating the data object corresponding to the data element and converting it into a structured query statement containing topological information fields, the database needs to be accessed once for persistent storage.

Benefits of technology

Reduces database access pressure, increases the probability of success of data persistence operations, and gets rid of the dependence on communication quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490651B_ABST
    Figure CN114490651B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a data storage method and device, including: obtaining data to be stored; generating data objects corresponding to the data elements based on the data content of the data elements and the topological relationship between the data elements; traversing the data objects and generating structured query statements corresponding to the data elements based on the data content and topological information in the data objects; and sending the structured query statements to the database for execution to store the data elements and the topological relationship between the data elements. The entire persistent storage process of the present application only requires accessing the database once, which reduces the access pressure on the database, frees the data persistence operation from the requirement for communication quality during the access process, and improves the success probability of the data persistence operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data storage method and device, an electronic device, and a machine-readable medium. Background Art

[0002] The process of storing data with topological relationships in a database is called persistence of topological relationship data.

[0003] In the process of persisting topological relationship data, it is necessary to maintain the topological relationship of each piece of data. In related technologies, recursive insertion into the database can be used to insert each piece of data into the database, and the topological information of the next piece of data to be inserted is determined based on the information returned by the database after the data is inserted. In this way, the persistent storage of data and topological relationships is completed by accessing the database multiple times.

[0004] However, in the current solution, due to excessive number of database accesses, the database access pressure will be high, and in an unstable access environment, data persistence may fail. Summary of the Invention

[0005] An embodiment of the present application provides a data storage method to solve the problem of excessive number of database accesses in the related art.

[0006] Correspondingly, the embodiments of the present application also provide a data storage device, an electronic device, and a storage medium to ensure the implementation and application of the above method.

[0007] In order to solve the above problems, an embodiment of the present application discloses a data storage method, the method comprising:

[0008] Acquire data to be stored; the data to be stored includes at least two data elements having a topological relationship;

[0009] Generate a data object corresponding to the data element according to the data content of the data element and the topological relationship between the data elements; the data object includes the data content of the data element and the topological information of other data elements that have a topological relationship with the data element;

[0010] Traversing the data objects and generating structured query statements corresponding to the data elements based on the data content and topology information in the data objects;

[0011] The structured query statement is sent to a database for execution to store the data elements and the topological relationships between the data elements.

[0012] The present application discloses a data storage device, comprising:

[0013] An acquisition module, configured to acquire data to be stored; the data to be stored includes at least two data elements having a topological relationship;

[0014] A first generating module is configured to generate a data object corresponding to the data element according to the data content of the data element and the topological relationship between the data elements; the data object includes the data content of the data element and the topological information of other data elements having a topological relationship with the data element;

[0015] A second generating module is used to traverse the data object and generate a structured query statement corresponding to the data element according to the data content and topology information in the data object;

[0016] The storage module is used to send the structured query statement to the database for execution, so as to store the data elements and the topological relationships between the data elements.

[0017] An embodiment of the present application further discloses an electronic device, comprising: a processor; and a memory on which executable code is stored. When the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.

[0018] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes one or more methods described in the embodiments of the present application.

[0019] Compared with the related art, the embodiments of the present application have the following advantages:

[0020] In an embodiment of the present application, there is a topological relationship between the data elements in the data to be stored, which requires maintaining the topological relationship of each data element in the process of persistently storing the data to be stored in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database for execution to achieve persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirement of communication quality during the access process, thereby improving the success probability of the data persistence operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is an architectural diagram of a template data storage method according to an embodiment of the present application;

[0022] Figure 2 This is a structural diagram of a data object set according to an embodiment of the present application;

[0023] Figure 3 This is an interface diagram of an application scenario of an embodiment of the present application;

[0024] Figure 4 This is an architectural diagram of a data storage method in an office scenario according to an embodiment of the present application;

[0025] Figure 5 This is an interface diagram of another application scenario of an embodiment of the present application;

[0026] Figure 6 This is an architectural diagram of a data storage method in a map scenario according to an embodiment of the present application;

[0027] Figure 7 This is an interface diagram of another application scenario of an embodiment of the present application;

[0028] Figure 8 This is a flowchart of the steps of a data storage method according to an embodiment of the present application;

[0029] Figure 9 This is a flowchart of another data storage method embodiment of the present application;

[0030] Figure 10 This is a schematic diagram of the identification value of a structured query statement in an embodiment of the present application;

[0031] Figure 11 This is a structural block diagram of a data storage device according to an embodiment of the present application;

[0032] Figure 12 It is a structural diagram of a device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0034] To help those skilled in the art better understand this application, the concepts involved in this application are explained below:

[0035] Data to be stored: data used to be stored in the data table of the database. After the data to be stored is stored in the corresponding data table of the database, the data to be stored is permanent. Thereafter, the data content of the data to be stored can be obtained by accessing and querying the data table of the database.

[0036] Data element: An independent piece of data to be stored. For example, for a table, a piece of data in a row or column is a data element.

[0037] Topological relationships: Topological relationships refer to the relationships between spatial data that satisfy the principles of topological geometry. The topological relationships between data elements in the data to be stored refer to the relationships between these data elements that satisfy the principles of topological geometry. One type of topological relationship is tree-structured data, which has hierarchical relationships and parent-child relationships between adjacent levels. Topological relationships can also include star structures, ring structures, bus structures, mesh structures, hybrid topologies, and cellular topologies.

[0038] Data object: An entity class constructed by data elements through data content and topological relationships. In a database storage scenario, a data object is an object of a class mapped to the data table structure in the database.

[0039] Structured Query Language (SQL): is a database query and programming language used to access data and query, update and manage relational database systems. It has the functions of data definition, data manipulation, and data control.

[0040] Auto-increment flag: An flag used to implement auto-increment operations. For example, if the value of the auto-increment flag is n at the previous operation, the value of the auto-increment flag will automatically be incremented by one at the next operation, so that the value of the auto-increment flag becomes n+1.

[0041] Reflection mechanism: refers to the fact that in the running state of the Java environment, for any class, all the properties and methods of this class can be known; for any object, any of its methods and properties can be called; this function of dynamically obtaining information and dynamically calling object methods is called the reflection mechanism of the Java language.

[0042] In one implementation of an embodiment of the present application, the data storage method can be applied to the storage scenario of template data, with the purpose of realizing persistent storage of template data in a database so as to provide subsequent access query of the template data content. In an embodiment of the present application, there is a topological relationship between the data elements in the template data, which requires maintaining the topological relationship of each data element in the process of persistently storing the template data in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database. The database will import the structured query statements into the data table to realize persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirements of communication quality during the access process, thereby improving the success probability of the data persistence operation.

[0043] Reference Figure 1 , which shows an architectural diagram of a template data storage method provided in an embodiment of the present application, including a template server and a database server. In this scenario, the template server can maintain template data, and the template can be a classification and grading template. The classification and grading template can divide the data into several different data elements according to the classification and grading of the data. The topological structure composed of the data elements in the classification and grading template can be a tree structure.

[0044] Specifically, Figure 1 The classification and grading template shown can be a financial classification and grading template in the financial field, which includes 4 levels, level 1 has data element services; level 2 has data element transaction information and data element contract agreements; level 3 has data element transaction general information, data element contract general information and data element credit card service information; level 4 has data element risk level S3, data element risk level S2 and data element risk level S2. It should be noted that all template data shown in the embodiment of the present application are data that have been desensitized and publicly released on the Internet, and the reading of the data has been agreed upon by the customer and all parties' platforms. In addition, the templates that support persistent storage operations in the embodiment of the present application can also include customized classification and grading templates and templates in other fields, such as industrial classification and grading templates, energy classification and grading templates, etc.

[0045] In the embodiment of the present application, in order to facilitate the template server to process the template data, the financial classification and grading template can be converted into an Excel spreadsheet file according to the topological structure of the data elements in the financial classification and grading template, so as to maintain the topological relationship through the row and column relationship. The specific converted Excel spreadsheet file is shown in Table 1 below:

[0046] Level 1 Level 2 Level 3 Level 4 Serve Transaction Information General transaction information Risk Level S3 Serve Contract Agreement General contract information Risk Level S2 Serve Contract Agreement Credit card service information Risk Level S2

[0047] Table 1

[0048] Furthermore, the template server can convert the data elements in the converted Excel spreadsheet file into data objects to obtain a data object collection. The data object can specifically be an entity class, which defines the data content and topological relationship of the data element. In one implementation, the data object can specifically be an entity class in the form of a map. The key in the map can define the name of the data element (such as "service"), and the value in the map includes the topological information of all child node data elements of the data element. The topological information can specifically be a list of child node objects containing child node data elements, wherein a map is an object that maps keys to values. The Map object stores key / value pairs and is a collection of key / value pairs. Any value (object or primitive value) can be used as a key or a value. The embodiment of the present application is based on an entity class in the form of a map to reflect the data elements to be inserted into the data table, which is more in line with the access requirements in the database scenario, that is, the requirement to obtain the value of the data by accessing the database and querying the key.

[0049] The embodiment of the present application defines a set of descendant node data objects of the data object based on the data content definition of the data element in the converted data object, thereby realizing the maintenance of the topological relationship of the data object in the data object. Figure 2 , which shows a structural diagram of a data object set provided by an embodiment of the present application, Figure 2 That reflects the Figure 1 The structure of the data object set obtained after conversion from the financial classification and grading template shows that, in addition to its own attributes (data content), each data object also includes a child node object list (topology information). According to the topological relationship in Table 1, the child node object list of the data object service contains data object transaction information and data object contract information; the child node object list of the data object transaction information contains data object transaction general information; the child node object list of the data object transaction general information contains data object risk level S3; the child node object list of the data object contract agreement contains data object transaction contract information and data object credit card service information; the child node object list of the data object transaction contract information contains data object risk level S2; and the child node object list of the data object credit card service information contains data object risk level S2. Since data object risk level S3, data object risk level S2, and data object risk level S2 have no child nodes, the child node object lists of these three are empty.

[0050] Reference Figure 1 , in getting Figure 2After the data object set is shown, you can traverse each data object from level 1, and build each data object into a structured query statement (SQL) based on the data content and topology information to obtain a set of structured query statements corresponding to the data object. When building a structured query statement, you can use Java's reflection mechanism to obtain the attributes and attribute values of the data object, and obtain the table name by parsing the annotation. The attributes, attribute values and table name are the three key parameters for building a structured query statement. Finally, according to the construction format of the structured query statement, these three key parameters can be assembled into a structured query statement. This process can be implemented through a structured query statement conversion tool.

[0051] It should be noted that the set of structured query statements corresponding to the data object is constructed based on the dimension of the data element. The embodiment of the present application can also construct a template structured query statement for the dimension of the financial classification and grading template to characterize the descriptive information of the financial classification and grading template. The template structured query statement is used to define the template's identification, creation time, modification time, template name, enabled status, maximum supported classification level, deletion status, template category and other fields.

[0052] Finally, the embodiment of the present application can access the database once and send the set of structured query statements corresponding to the data objects of the financial classification and grading template, as well as the template structured query statements used to represent the descriptive information of the financial classification and grading template, to the database for execution. The database can store the descriptive information of the financial classification and grading template in a first data table based on the template structured query statements, and store the data elements included in the financial classification and grading template in a second data table based on the set of structured query statements, thereby completing the persistent storage of the financial classification and grading template. In addition, to reflect the association between the template structured query statements and the structured query statements corresponding to the data objects, the structured query statements corresponding to the data objects use the field that identifies the financial classification and grading template in the first data table.

[0053] Reference Figure 1 The template server can also communicate and interact with the client to provide the client with services based on the financial classification and grading template. After the financial classification and grading template is persistently stored in the database of the database server, the template server can respond to the client's query request for the financial classification and grading template, extract the data content of the financial classification and grading template from the database of the database server according to the query request and feed it back to the client. In addition, when the user of the client is a user with development authority, the template server can also respond to the processing request of adding / deleting / modifying / querying sent by the client, and perform the processing of adding / deleting / modifying / querying on the financial classification and grading template stored in the database by accessing the database of the database server.

[0054] Regarding the communication interaction between the template server and the client, several scenarios based on classification and grading templates can be implemented as follows:

[0055] In one scenario, refer to Figure 3 , which shows an interface diagram of an application scenario provided by an embodiment of the present application. When a user applies for financial services on the client's interface 11, the client can apply to the template server through the background to use the financial classification and grading template. The client can extract and return the data content of the financial classification and grading template from the database through the template server, identify the data of the current interface 11, and thus determine the financial category, risk level and related suggestions corresponding to the credit card application service, and display and mark them accordingly on the interface 11.

[0056] In another scenario, refer to Figure 3 The client can apply to the template server for the use of the financial classification and grading template. The client can extract and return the data content of the financial classification and grading template from the database through the template server to identify metadata 1 and metadata 2 in the metadata screening interface 12, thereby determining the financial category, risk level and related suggestions corresponding to the metadata, so that the metadata can be subsequently desensitized based on the financial category, risk level and related suggestions corresponding to the metadata.

[0057] In the embodiment of the present application, the data storage method can also be applied to the persistent storage of organizational structure data in office scenarios, referring to Figure 4 , which shows an architectural diagram of a data storage method in an office scenario provided by an embodiment of the present application, including an organizational structure server and a database server. In this scenario, the organizational structure server can be used to maintain the company's organizational structure.

[0058] It should be emphasized that in the embodiments of the present application, all customer-related data can only be obtained and used after the consent of the customer and all parties.

[0059] Specifically, Figure 4 The organizational structure data shown may include three levels: Level 1 includes the data element headquarters; Level 2 includes the data element branch 1 and data element branch 2; and Level 3 includes data element network point 11, data element network point 21, and data element network point 22. It should be noted that all organizational structure data shown in the embodiments of this application are anonymized and publicly released on the Internet, and the access to the data has been approved by the client and all platforms.

[0060] In an embodiment of the present application, the organizational structure server can convert the organizational structure data into an Excel spreadsheet file based on the topological structure of the data elements in the organizational structure data, and then convert the data elements in the Excel spreadsheet file into data objects to obtain a data object set, and traverse each data object from level 1, and construct each data object into a structured query statement based on the data content and topological information to obtain a structured query statement set corresponding to the data object. Finally, by accessing the database once, the structured query statement set corresponding to the data object can be sent to the database for execution.

[0061] Reference Figure 4 The organizational structure server can also communicate and interact with the client to provide services based on the organizational structure data to the client. After the organizational structure data is persistently stored in the database of the database server, the organizational structure server can respond to the client's query request for the organizational structure data, extract the data content of the organizational structure data from the database of the database server according to the query request and feed it back to the client. In addition, when the user of the client is a user with development permissions, the organizational structure server can also respond to the processing request of adding / deleting / modifying / querying sent by the client, and perform adding / deleting / modifying / querying on the organizational structure data stored in the database by accessing the database of the database server.

[0062] For example, refer to Figure 5 , which shows an interface diagram of another application scenario provided by an embodiment of the present application. For the communication interaction between the organizational structure server and the client, a scenario based on organizational structure data can be realized as follows: when the user handles the onboarding process in the client interface 13, he needs to authorize multiple managers under the organizational structure. The client can apply to the organizational structure server for the use of organizational structure data. The client can identify the data on the current page through the organizational structure data content extracted and returned from the database by the organizational structure server, thereby determining the specific organizational structure display and labeling of each manager, and obtaining a process of first approval by the branch 2 manager and then approval by the outlet 21 manager, so as to help users complete the service processing more clearly.

[0063] In the embodiment of the present application, the data storage method can also be applied to the persistent storage of map block data in the map scene, referring to Figure 6 , which shows an architectural diagram of a data storage method in a map scenario provided by an embodiment of the present application, including a map server and a database server. In this scenario, the map server can be used to maintain the topological relationship between map blocks in the map, and this topological relationship includes the ownership relationship and hierarchical relationship between map blocks.

[0064] Specifically, Figure 6The map block data shown may include three levels: Level 1 includes the data element "East China"; Level 2 includes the data element "Jiangzhou Province" and the data element "Jingzhou Province"; and Level 3 includes the data element "Jiangcheng City", the data element "Jingcheng City", and the data element "Yezhou City". It should be noted that all map block data shown in the embodiments of this application is anonymized and publicly released on the internet, and the access to the data has been approved by the client and all platforms.

[0065] In an embodiment of the present application, the map server can convert the map block data into an Excel spreadsheet file based on the topological structure of the data elements in the map block data, and then convert the data elements in the Excel spreadsheet file into data objects to obtain a data object set, and traverse each data object from level 1, and construct each data object into a structured query statement based on the data content and topological information to obtain a structured query statement set corresponding to the data object. Finally, by accessing the database once, the structured query statement set corresponding to the data object can be sent to the database for execution.

[0066] Reference Figure 6 The map server can also communicate and interact with the client to provide services based on map block data to the client. After persistently storing the map block data in the database of the database server, the map server can respond to the client's query request for map block data, extract the data content of the map block data from the database of the database server according to the query request and feed it back to the client.

[0067] For example, refer to Figure 7 , which shows an interface diagram of another application scenario provided by an embodiment of the present application. For the communication interaction between the map server and the client, a scenario based on map block data that can be implemented is specifically: when the user performs navigation service on the client interface 14, the initial route calculated by the map server is: location A-location B-location C. The client can apply to the map server for the use of map block data. The client can identify the initial route through the data content of the map block data extracted and returned by the map server from the database, thereby determining a more accurate navigation path: location A in Jingcheng City, Jingzhou Province-location B in Yezhou City, Jingzhou Province-location C in Jiangcheng City, Jingzhou Province.

[0068] In an embodiment of the present application, there is a topological relationship between the data elements in the data to be stored, which requires maintaining the topological relationship of each data element in the process of persistently storing the data to be stored in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database for execution to achieve persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirement of communication quality during the access process, thereby improving the success probability of the data persistence operation.

[0069] Reference Figure 8 , which shows a flowchart of the steps of a data storage method provided by an embodiment of the present application, including:

[0070] Step 101: Acquire data to be stored; the data to be stored includes at least two data elements having a topological relationship.

[0071] In the embodiment of the present application, the data to be stored is data for storage in a data table of a database. After the data to be stored is stored in the corresponding data table of the database, the data to be stored is permanent. Thereafter, the data content of the data to be stored can be obtained by accessing and querying the data table of the database. A data element is an independent piece of data in the data to be stored. The topological relationship between the data elements in the data to be stored refers to the relationship between these data elements that satisfies the principles of topological geometry. Figure 1 、 Figure 4 、 Figure 6 The financial classification and grading template, organizational structure data, and map block data shown respectively are all data to be stored with topological relationships between data elements. The topological relationships of these three types of data are all tree structures. The topological relationships can also include star structures, ring structures, bus structures, mesh structures, hybrid topological structures, cellular topological structures, etc. The embodiments of this application do not limit the specific structure of the topological relationship.

[0072] Step 102: Generate a data object corresponding to the data element according to the data content of the data element and the topological relationship between the data elements.

[0073] The data object includes the data content of the data element and the topological information of other data elements that have a topological relationship with the data element.

[0074] In an embodiment of the present application, data elements are converted into data objects based on the data content of the data elements and the topological relationship between the data elements to obtain a data object set. The data object can specifically be an entity class, in which the data content and topological relationship of the data elements are defined. When the topological relationship is a tree structure with a hierarchical relationship and a parent-child node relationship, on the basis of the definition of the data content of the data element in the data object, the topological information is specifically taken as a list of child node objects of a data object containing other data elements, thereby realizing the definition of a set of descendant node data objects of the data object, thereby achieving the purpose of maintaining the topological relationship of the data object in the data object.

[0075] Step 103: traverse the data objects and generate structured query statements corresponding to the data elements according to the data content and topology information in the data objects.

[0076] After obtaining the data object set, each data object can be traversed, and each data object is constructed into a structured query statement based on the data content and topology information to obtain a structured query statement set corresponding to the data object.

[0077] When constructing a structured query statement, you can use Java's reflection mechanism to obtain the attributes and attribute values of the data object, and obtain the table name by parsing the annotation. The attributes, attribute values, and table name are the three key parameters for constructing a structured query statement. Finally, according to the construction format of the structured query statement, these three key parameters are assembled into a structured query statement. This process can be implemented using a structured query statement conversion tool. It should be noted that this application can also obtain the attributes, attribute values, and table name of the data object through other methods, such as extracting or defining the specific values of these three key parameters by yourself.

[0078] Step 104: Send the structured query statement to a database for execution, so as to store the data elements and the topological relationships between the data elements.

[0079] The embodiment of the present application can access the database server once and send the set of structured query statements corresponding to the data object to the database for execution. The database can store the structured query statements corresponding to the data object in the data table to complete the persistent storage of the data to be stored.

[0080] To sum up, in the embodiment of the present application, there is a topological relationship between the data elements in the data to be stored, which requires maintaining the topological relationship of each data element in the process of persistently storing the data to be stored in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database for execution to achieve persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirements of communication quality during the access process, thereby improving the success probability of the data persistence operation.

[0081] Reference Figure 9 , shows a flowchart of another data storage method embodiment of the present application. It includes:

[0082] Step 201: Acquire data to be stored; the data to be stored includes at least two data elements having a topological relationship.

[0083] This step may be specifically referred to the above step 101 and will not be described again here.

[0084] Step 202: Generate the data object in the form of a map according to the data content of the data elements and the topological relationship between the data elements.

[0085] In the embodiment of the present application, in order to facilitate the processing of the stored data, the data to be stored can be converted into an Excel spreadsheet file according to the topological structure of the data elements in the data to be stored, so as to maintain the topological relationship through the row and column relationship. When reading the data content of the Excel spreadsheet file, the List<T> can be obtained. <List <string>>list object, each element in the list is each row of data in Excel, each element is List <string>In this format, the data in the index position 0-N in this element is the data from the 0th to the Nth column in each row of Excel.

[0086] by Figure 1 Take the financial classification and grading template in Table 1 as an example, List <List <string>>The specific data format of the list object is as follows:

[0087]

[0088] Next, for each element in the list, that is, each row of data in Excel, the topological relationship between each data element can be obtained. Then, according to the data content of the data element and the topological relationship between the data elements, in the process of generating a data object in the form of a map, the key and value of the map can be constructed. The key can be the data name of the data element, and the value includes the data content of the child node data object of the data object, that is, the value can be Figure 2 After traversing all data elements, we can get the following: Figure 2 As shown in the data object set, it can be seen that the data object of the child node exists in the child node object list of its parent node data object, forming a multi-layer nested structure, so that the parent-child node topological relationship between each level is associated through the child node object list. Subsequently, by obtaining the entity object of level 1, traversing the entity object of level 1 and its child node object list, the subsequent operation of generating a structured query statement can be completed.

[0089] Optionally, the topological relationship includes: a hierarchical relationship between the data elements, and a parent-child node relationship between the data elements at adjacent levels; the key of the data object in map form includes the name of the data object, and the value of the data object in map form includes the data content of the child node data object of the data object.

[0090] In an embodiment of the present application, the value of a data object in the form of a map is a list of child node objects of a data object containing other data elements. Based on the data content definition of the data elements in the converted data object, the embodiment of the present application defines a set of descendant node data objects of the data object, thereby realizing the maintenance of the topological relationship of the data object in the data object.

[0091] Step 203: traverse the data objects and generate structured query statements corresponding to the data elements according to the data content and topology information in the data objects.

[0092] This step may be specifically referred to the above step 101 and will not be described again here.

[0093] Optionally, in one implementation, the topological relationship includes: a hierarchical relationship between the data elements, and a parent-child node relationship between the data elements at adjacent levels; the topological information includes data objects corresponding to all child node data elements of the data elements; and step 203 may specifically include:

[0094] Sub-step 2031: traverse the data objects in the order of the levels, and generate a structured query statement with an auto-increment identification field and a parent node identification field according to the data content and topology information in the data objects.

[0095] In the embodiment of the present application, the order of the levels can be as follows: Figure 1 The data objects are traversed in the order from level 1 to level 4, and before the traversal, the two identification parameters of the self-increment identifier and the parent node identifier are set to participate in the subsequent traversal process, wherein, based on the characteristic that when traversing two data elements with a parent-child node relationship in the topological relationship, the traversal order of the latter data element is incremented by one, the established self-increment identifier is used to implement the self-increment operation. For example, if the value of the self-increment identifier is n at the previous operation moment, then at the next operation moment, the value of the self-increment identifier will automatically be incremented by one, so that the value of the self-increment identifier becomes n+1; in this embodiment of the present application, the self-increment identifier of a data object can be used to represent its own identifier, and can also be used as the parent node identifier in its child node data object.

[0096] Since, except for the data elements at level 1, each other data element has a corresponding parent node data element, the parent node identifier maintained for the data element is used to reflect the identifier of the data element of the parent node of the data element, thereby maintaining the topological relationship of the data elements.

[0097] Specifically, the auto-increment identifier and parent node identifier finally determined for each data object can be used as the auto-increment identifier field and parent node identifier field in the structured query statement of the data element corresponding to the data object, thereby achieving the purpose of maintaining the topological relationship of the data elements in the structured query statement.

[0098] Optionally, sub-step 2031 may specifically include:

[0099] Sub-step A1: when traversing the root node data object at the first level, obtain the first initial value of the self-increment identifier and the second initial value of the parent node identifier.

[0100] In the embodiment of the present application, since the auto-increment flag is a global variable parameter when the database inserts data, when the process of inserting the data to be stored is a new insertion process started by the database, the auto-increment flag can be set to a first initial value, such as 1 or an integer value greater than 1, and for the root node data object at the first level, such as Figure 2 Since the data object service in the data object service has no parent node, the parent node identifier can be set to the second initial value, which can be a null value. In addition, before the operation of inserting the data to be stored begins, there is a historical insert operation using the auto-increment identifier in the database, so that the value of the auto-increment identifier is not the first initial value. In this case, the current maximum value of the auto-increment identifier plus one can be used as the starting value of the auto-increment identifier when inserting the data to be stored. This allows the current operation of inserting the data to be stored to continue from the historical insert operation, avoiding blank rows in the data table and preventing the currently inserted data from overwriting rows in the data table where data has already been inserted, causing data confusion.

[0101] Optionally, when the structured query statements are sent to different databases for execution, sub-step A1 may specifically include:

[0102] Sub-step A11: obtaining the current maximum value of the auto-increment flag when executing the structured query statement in each data table in different databases.

[0103] Sub-step A12: adding one to the current maximum value of all current self-increment flags is used as the first initial value.

[0104] In actual applications, there may be multiple different operating environments. These operating environments all have databases and all have the need to persistently store the same data to be stored in the database. However, for the auto-increment identifier, which is a global parameter for the data table in the database, the current maximum values of the auto-increment identifiers of the data tables in the databases of different environments may be different. This is because the data tables in different databases store different historical insertion operations. At this time, the embodiment of the present application uses the result of adding one to the current maximum value of all current auto-increment identifiers as the first initial value, so that when the same structured query statement set is inserted into the data tables in the databases of different environments, the insertion operation can be started based on the starting value of the same auto-increment identifier, thereby ensuring the consistency of the inserted data and achieving the purpose of reusing the structured query statement set in different database environments, so that the same set of execution codes can be adapted to different environments, which brings convenience to subsequent unified maintenance.

[0105] For example, for two different environments, a public cloud and a private cloud (proprietary cloud), both of which have their own databases deployed. Assume that due to historical insert operations on the data table in the public cloud database, the current auto-increment flag used by the public cloud is 10, and due to historical insert operations on the data table in the private cloud database, the current auto-increment flag used by the private cloud is 20. Then, you can execute the following command on the data table in the public cloud database and the data table in the private cloud database respectively:

[0106] SELECT max(id)from`industry_template;

[0107] The purpose of this operation is to take the current maximum value of the auto-increment identifier used by the data table in the public cloud database and the data table in the private cloud database, thereby obtaining a value of 20. Then, the value 20 is added by one to obtain the starting value 21 of the auto-increment identifier when inserting the data to be stored. Subsequently, when inserting, the data table in the public cloud database and the data table in the private cloud database use the same value as the starting value of the auto-increment identifier, which ensures the consistency of the inserted data and avoids data confusion in the data table. In addition, the execution code also achieves the purpose of being reused in the public cloud environment and the private cloud environment, improving the convenience of maintenance and development. It should be noted that for the value range of 10-20 for the auto-increment identifier of the data table in the public cloud database, the corresponding row in the data table can be left as a null value to be used for other insert operations.

[0108] It should be noted that the data storage method of the embodiment of the present application can be deployed in a private cloud scenario. Since the resources used for security deployment in the private cloud scenario are limited, and the topological relationship involved in the security deployment may be very complex, if the security deployment occupies too many resources, it will increase the cost of using the customer's private cloud, and the query pressure on the database will be relatively large. The application of the above-mentioned scheme of the embodiment of the present application is conducive to reducing the resource consumption of the private cloud data security center, and achieving the effect of smooth deployment of the data security center with fewer resources.

[0109] Among them, a private cloud is established for a specific user / institution and can achieve resource optimization within a small range.

[0110] Of course, for proprietary clouds, the principles are similar to those of private clouds. The application of the above-mentioned scheme of the embodiment of the present application in proprietary clouds is conducive to reducing the resource consumption of the proprietary cloud data security center, thereby achieving the effect of smooth deployment of the data security center with fewer resources.

[0111] A dedicated cloud (Dedicated Cloud, or DeC) is a dedicated virtualized resource pool isolated from a public cloud. Within a Dedicated Cloud, users can apply for exclusive use of physical devices, computing and network resources, and access reliable distributed storage. Users can centrally manage resources from a management console, providing the same flexibility as using a private cloud.

[0112] Sub-step A2: determining that the auto-increment identification field in the structured query statement corresponding to the root node data object includes an auto-increment identification with a first initial value, and determining that the parent node identification field includes a parent node identification with a second initial value.

[0113] In this step, when constructing a structured query statement corresponding to the root node data object through a structured query statement construction tool, based on the determined first initial value and second initial value, the auto-increment identifier of the first initial value can be set in the auto-increment identifier field of the structured query statement, and the parent node identifier of the second initial value can be set in the parent node identifier field.

[0114] Optionally, sub-step 2031 may specifically include:

[0115] Sub-step A3: When traversing descendant node data objects that are not at the first level, determine that the value of the auto-increment identifier included in the auto-increment identifier field in the structured query statement corresponding to the descendant node data object is: the result of adding 1 to the value of the auto-increment identifier of the last traversed data object, and determine that the value of the parent node identifier included in the parent node identifier field is: the value of the auto-increment identifier of the parent node data object of the descendant node data object.

[0116] When traversing descendant node data objects that are not at the first level, since the topological information of the data object includes the data objects corresponding to all child node data elements of the data element, the parent-child node topological relationship between the data objects is maintained. Therefore, the value of the auto-increment identifier of the descendant node data object currently traversed can be set to: the value of the auto-increment identifier of the last traversed data object plus 1, and the value of the parent node identifier can be set to: the value of the auto-increment identifier of the parent node data object of the descendant node data object. Thus, through the coordination of the auto-increment identifier and the parent node identifier, the topological relationship of the data elements inserted into the database is maintained.

[0117] For example, for Figure 2 The data object set shown in the figure is traversed in the order of data object service - data object transaction information - data object transaction general information - data object risk level S3 - data object contract agreement - data object transaction contract information - data object risk level S2 - data object credit card service information - data object risk level S2. Finally, the following is obtained: Figure 10 The results shown, Figure 10 A schematic diagram of the identification values of a structured query statement of the present application is shown, wherein, after executing the self-increment identification self-increment operation of each structured query statement in the above-mentioned traversal order, the results obtained include: the self-increment identification of the service SQL is 1; the parent node identification is null—the self-increment identification of the transaction information SQL is 2; the parent node identification is 1—the self-increment identification of the transaction general information SQL is 3; the parent node identification is 2—the self-increment identification of the risk level S3 SQL is 4; the parent node identification is 3—the self-increment identification of the contract agreement SQL is 5; the parent node identification is 1—the self-increment identification of the transaction contract information SQL is 6; the parent node identification is 5—the self-increment identification of the risk level S2 SQL is 7; the parent node identification is 6—the self-increment identification of the credit card service information SQL is 8; the parent node identification is 5—the self-increment identification of the risk level S2 SQL is 9; the parent node identification is 8.

[0118] Optionally, in another implementation, step 203 may specifically include:

[0119] Sub-step 2032: Acquire the data content and topology information of the data object by calling the reflection mechanism function.

[0120] Sub-step 2033: Generate a structured query statement corresponding to the data element according to the data content and topology information of the data object.

[0121] In the embodiment of the present application, the basic form of a structured query statement is as follows:

[0122] insert into table_name(column_1,column_2,column_3)values(value_1,value_2,value_3)

[0123] Among them, the structured query statement has three key parts: the table name tablename; the inserted data column and the specific value value of the corresponding data column. In order to avoid code duplication in generating structured query statements, the embodiment of the present application can abstract a general processing method, that is, using Java's reflection mechanism to obtain the attributes of the data object and the values corresponding to the attributes, and parsing the annotations to obtain the table name, so as to obtain the three key parts of the structured query statement, and then assemble the table name, attribute list, and the values corresponding to the attribute list into a structured query statement. This abstract method can process any entity object. If other types of entity objects also need to generate structured query statements in the future, they can be used directly without the need for re-development, which reduces the difficulty of development. In addition, the topological relationship stored in the above manner can occupy less storage resources.

[0124] The specific process of obtaining a structured query statement for a data object through the Java reflection mechanism is as follows:

[0125] The first step is to parse the incoming data object, traverse all the attributes defined by the class and parent class, and add them to the fieldList.

[0126] The second step is to parse the @Table annotation of the data object and get the table name tableName.

[0127] Step 3: Initialize the attribute string StringBuilder fieldSb = new StringBuilder("("); and initialize the attribute value string StringBuilder valueSb = new StringBuilder("values(");

[0128] Step 4: Traverse and process the fieldList list;

[0129] Step 5. Get the name of the field, skip the ignored attributes, such as serialVersionUID and attributes annotated with @Transient, convert the attribute name to lowercase and underline the attribute name, and add the separator and the attribute name to fieldSb.

[0130] Step 6. Use the Java reflection mechanism to call the get method of the attribute to obtain the value of the attribute. Add the separator and this attribute value to valueSb, and process the next field attribute of filedList. If the filed attribute is not empty, repeat steps 5 and 6. If the filed attribute is empty, jump out of the loop traversal and execute step 7.

[0131] Step 7. Concatenate tableName, fieldSb, and valueSb to obtain a complete structured query statement.

[0132] Step 204: Send the structured query statement to a database for execution, so as to store the data elements and the topological relationships between the data elements.

[0133] This step may be specifically referred to step 104 and will not be described in detail here.

[0134] Optionally, the method further includes:

[0135] Step 205: Obtain description information of the data to be stored.

[0136] Step 206: Generate a structured query statement corresponding to the data to be stored according to the description information of the data to be stored.

[0137] Step 207: Send the structured query statement corresponding to the data to be stored to the database for execution, so as to store the description information of the data to be stored.

[0138] Optionally, the descriptive information of the data to be stored is stored in the first data table of the database, and the first data table is used to store one or more of the data identification field, first creation time field, first modification time field, data name field, enable status field, data category field, deletion status field, and maximum topology level field in the descriptive information of the data to be stored.

[0139] Optionally, the data elements of the data to be stored are stored in a second data table of the database, and the second data table is associated with the first data table corresponding to the data to be stored. The second data table is used to store one or more of an element identification field for the data element, a second creation time field, a second modification time field, a field for identifying the data to be stored in the first data table, a parent node identification field, a display sort number field, a risk level field, a scan range field, an association model field, and an element category field.

[0140] In combination with steps 205 to 207, there may be at least two data tables in the database: a first data table and a second data table. If the data to be stored with a topological relationship is considered to be a type of industry or template, then based on the structured query statement generated by the description information of the data to be stored, the first data table is used to store the basic summary information of the industry or template, that is, the fields defined in the description information of the data to be stored; the second data table stores the topological classification data objects of each industry or template, that is, the various fields defined for the data elements of the data to be stored. The topological classification data objects can be associated with the first data table through industry or template attribute flags.

[0141] For example, when the data to be stored is a classification template, the first data table is the template table, which is used to store the descriptive information of each classification template. Specifically, the structured query statement used to reflect the descriptive information of each classification template is executed, so that the descriptive information of each classification template is stored in the first data table; the second data table is the template classification table, which is used to store the classification data of each template. Specifically, the structured query statement used to reflect the classification data is executed, so that the classification data is stored in the second data table. The classification data in the template classification table is associated with the auto-increment identifier in the template table through template_id, indicating which template each classification data belongs to.

[0142] Further, referring specifically to Table 2, it shows the necessary fields stored in the first data table industry_template when the data to be stored is classified and graded template data:

[0143]

[0144] Table 2 shows an example of the data object format constructed for the classification and grading template:

[0145]

[0146] It can be seen that the required fields in the first data table are defined, and the structured query statement obtained for the data object is as follows:

[0147] insertintoindustry_template:

[0148] (name, status, max_category_level, is_delete, type, id, gmt_create, gmt_modified) values ('${built_in_finance_template_simplify_name}',0,5,0,2,3,'xxxx-xx-xx 20:51:06.83','xxxx-xx-xx 20:51:06.83').

[0149] For example, referring specifically to Table 3, it shows the necessary fields stored in the first data table industry_template when the data to be stored is classified and graded template data:

[0150] Table 3

[0151] An example of the data object format constructed for the data elements of the classification and grading template is as follows:

[0152]

[0153] It can be seen that the required fields in the second data table are defined, and the child node data object list List <industrycategory>children, maintains the topological relationship of data elements. The structured query statement obtained for this data object is as follows:

[0154] insert into industry_category:

[0155] (name,category_level,template_id,order_num,id,gmt_create,gmt_modified)values('${finance_template_simplify_001000000000000}',1,3,1,627,'xxxx-xx-xx 20:51:06.847','xxxx-xx-xx20:51:06.847');.

[0156] In an embodiment of the present application, a database may be accessed once, and the structured query statements corresponding to the data objects contained in the data to be stored and the structured query statements corresponding to the description information of the data to be stored may be sent to the database for execution. The database may store the description information of the data to be stored in a first data table and the data elements of the data to be stored in a second data table, thereby completing the persistent storage of the entire data to be stored.

[0157] It should be noted that the above code is only an example to illustrate the principle. Using other forms of code and the same logic to execute the process of the embodiment of the present application is within the scope of protection of the embodiment of the present application.

[0158] Optionally, the method further includes:

[0159] Step 208, in response to a query request for a target data element, based on the query request, when it is determined that the enabled status field corresponding to the target data to be stored in the first data table is in an enabled state, obtain the data content of the target data element from the second data table associated with the first data table in the database, and the target data to be stored includes the target data element.

[0160] Specifically, in an embodiment of the present application, when responding to a query request from a client for a target data element, the database can first check in accordance with the query request whether the data to be stored to which the target data element to be queried belongs exists in the first data table of the database. If so, the database further determines whether the enable field of the data to be stored in the first data table is enabled. If so, the data content of the target data element is obtained from the second data table associated with the first data table in the database, and the data content of the target data element is sent to the client. In an embodiment of the present application, the database administrator can control whether the data to be stored is enabled and accepts access queries based on actual needs through the enable field of the data to be stored, thereby increasing management flexibility.

[0161] Optionally, the method further includes:

[0162] Step 209: Obtain a query request for the target data element, wherein the query request includes a query key of the target language environment.

[0163] Step 210: According to the query request including the query key of the target language environment, the data content of the target data element in the target language environment is obtained from the database.

[0164] In an embodiment of the present application, the database can be applied to application scenarios in different language environments. For example, the database can provide an English query page for an English language environment, and can also provide a Chinese query page for a Chinese language environment. According to the user's page query language, such as Chinese or English, when converting data elements into data objects in the form of a map, a unique name identification key is set and stored persistently. When querying, the English prefix of the language environment plus the unique name identifier is used as a unique internationalization key, and the translation result corresponding to the unique international key in the query cache is queried, so that the query results of data elements in different query environments can be obtained.

[0165] Specifically, in the process of constructing the internationalization key, the specific translation content of the internationalization key in different languages is constructed, and the internationalization keys and corresponding translation languages of different language environments are stored in the cache. When the application is started, the internationalization keys and corresponding translations of each language environment in the cache are loaded into the memory. When the visitor obtains the data content of the data to be stored, the application reads the data from the database, and adds the corresponding language environment, such as zh_cn_ (Chinese) or en_us_ (English), before the variable of the internationalization key read according to the visitor's language environment. Then, the internationalization key of the corresponding language environment in the memory is read. The data content of the data to be stored in different language environments can be obtained, which is used for page display in different language environments.

[0166] To sum up, in the embodiment of the present application, there is a topological relationship between the data elements in the data to be stored, which requires maintaining the topological relationship of each data element in the process of persistently storing the data to be stored in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database for execution to achieve persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirements of communication quality during the access process, thereby improving the success probability of the data persistence operation.

[0167] Reference Figure 11 , which shows a block diagram of a data storage device provided in an embodiment of the present application, including:

[0168] The acquisition module 301 is configured to acquire data to be stored; the data to be stored includes at least two data elements having a topological relationship;

[0169] A first generating module 302 is configured to generate a data object corresponding to the data element according to the data content of the data element and the topological relationship between the data elements; the data object includes the data content of the data element and the topological information of other data elements having a topological relationship with the data element;

[0170] The second generating module 303 is used to traverse the data object and generate a structured query statement corresponding to the data element according to the data content and topology information in the data object;

[0171] The storage module 304 is configured to send the structured query statement to a database for execution, so as to store the data elements and the topological relationships between the data elements.

[0172] Optionally, the topological relationship includes: a hierarchical relationship between the data elements, and a parent-child node relationship between the data elements at adjacent levels; the topological information includes data objects corresponding to all child node data elements of the data element;

[0173] The second generating module 303 includes:

[0174] The traversal submodule is used to traverse the data objects in the order of the levels, and generate a structured query statement with an auto-increment identification field and a parent node identification field according to the data content and topology information in the data objects.

[0175] Optionally, the traversal submodule includes:

[0176] A first traversal unit is used to obtain a first initial value of the self-increment identifier and a second initial value of the parent node identifier when traversing the root node data object at the first level;

[0177] The determining unit is configured to determine that the auto-increment identification field in the structured query statement corresponding to the root node data object includes an auto-increment identification with a first initial value, and to determine that the parent node identification field includes a parent node identification with a second initial value.

[0178] Optionally, the traversal submodule includes:

[0179] The second traversal unit is used to determine, when traversing a descendant node data object that is not at the first level, that the value of the auto-increment identifier included in the auto-increment identifier field in the structured query statement corresponding to the descendant node data object is: the result of adding 1 to the value of the auto-increment identifier of the last traversed data object, and to determine that the value of the parent node identifier included in the parent node identifier field is: the value of the auto-increment identifier of the parent node data object of the descendant node data object.

[0180] Optionally, when the structured query statements are sent to different databases for execution, the first traversal unit includes:

[0181] The acquisition subunit is used to obtain the current maximum value of the auto-increment identifier when executing the structured query statement in each data table in different databases;

[0182] The auto-increment sub-unit is used to take the result of adding one to the current maximum value of all current auto-increment identifiers as the first initial value.

[0183] Optionally, the first generating module 302 includes:

[0184] The generating submodule is used to generate the data object in the form of a map according to the data content of the data elements and the topological relationship between the data elements.

[0185] Optionally, the topological relationship includes: a hierarchical relationship between the data elements, and a parent-child node relationship between the data elements at adjacent levels;

[0186] The key of the data object in the map form includes the name of the data object, and the value of the data object in the map form includes the data content of the child node data object of the data object.

[0187] Optionally, the second generating module 303 includes:

[0188] A calling submodule, configured to obtain the data content and topology information of the data object by calling a reflection mechanism function;

[0189] The generating submodule is used to generate a structured query statement corresponding to the data element according to the data content and topology information of the data object.

[0190] Optionally, the device further includes:

[0191] An attribute information module, used to obtain description information of the data to be stored;

[0192] A third generating module is used to generate a structured query statement corresponding to the data to be stored according to the description information of the data to be stored;

[0193] The storage module is used to send the structured query statement corresponding to the data to be stored to the database for execution, so as to store the description information of the data to be stored.

[0194] Optionally, the description information of the data to be stored is stored in a first data table of the database, and the first data table is used to store one or more of a data identification field, a first creation time field, a first modification time field, a data name field, an enabled status field, a data category field, a deletion status field, and a maximum topology level field in the description information of the data to be stored;

[0195] The data elements of the data to be stored are stored in a second data table of the database, and the second data table is associated with the first data table corresponding to the data to be stored;

[0196] The second data table is used to store one or more of the following: an element identification field for storing the data element, a second creation time field, a second modification time field, a field for identifying the data to be stored in the first data table, a parent node identification field, a display sort number field, a risk level field, a scan range field, an association model field, and an element category field.

[0197] Optionally, the device further includes:

[0198] A query module is used to respond to a query request for a target data element. According to the query request, when it is determined that the enabled status field corresponding to the target data to be stored in the first data table is in the enabled state, obtain the data content of the target data element from the second data table associated with the first data table in the database, and the target data to be stored includes the target data element.

[0199] Optionally, the device further includes:

[0200] A response module, configured to obtain a query request for a target data element, wherein the query request includes a query key of a target language environment;

[0201] The language environment module is configured to obtain data content of a target data element in the target language environment from the database according to the query request including a query key of the target language environment.

[0202] In summary, in the embodiment of the present application, there is a topological relationship between the data elements in the data to be stored, which requires maintaining the topological relationship of each data element in the process of persistently storing the data to be stored in the database. The embodiment of the present application generates a data object corresponding to the data element based on the data content and topological relationship of the data element, and converts the data object of the data element into a structured query statement containing the topological information field of the data element through a traversal operation. Finally, by accessing the database once, the structured query statements corresponding to all data elements are sent to the database for execution to achieve persistent storage. The entire persistent storage process only needs to access the database once, which reduces the access pressure of the database, and makes the data persistence operation free from the requirements of communication quality during the access process, thereby improving the success probability of the data persistence operation.

[0203] An embodiment of the present application further provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.

[0204] The present application provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In the present application, the electronic device includes various types of devices such as terminal devices and server (cluster).

[0205] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices and server (clusters). Figure 12 An exemplary apparatus 1000 that can be used to implement various embodiments described in the embodiments of this application is schematically shown.

[0206] For one embodiment, Figure 12 An exemplary apparatus 1000 is shown having one or more processors 1002, a control module (chip set) 1004 coupled to at least one of the processor(s) 1002, a memory 1006 coupled to the control module 1004, a non-volatile memory (NVM) / storage device 1008 coupled to the control module 1004, one or more input / output devices 1010 coupled to the control module 1004, and a network interface 1012 coupled to the control module 1004.

[0207] The processor 1002 may include one or more single-core or multi-core processors, and the processor 1002 may include any combination of general-purpose processors or dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, the apparatus 1000 can serve as a terminal device, a server (cluster), or other device described in the embodiments of the present application.

[0208] In some embodiments, the apparatus 1000 may include one or more computer-readable media (e.g., memory 1006 or NVM / storage 1008) having instructions 1014 and one or more processors 1002 configured in conjunction with the one or more computer-readable media to execute the instructions 1014 to implement a module to perform the actions described in the present disclosure.

[0209] For one embodiment, the control module 1004 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1002 and / or any suitable device or component in communication with the control module 1004 .

[0210] The control module 1004 may include a memory controller module to provide an interface to the memory 1006. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0211] The memory 1006 can be used, for example, to load and store data and / or instructions 1014 for the device 1000. For one embodiment, the memory 1006 can include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 1006 can include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0212] For one embodiment, the control module 1004 may include one or more input / output controllers to provide an interface to the NVM / storage device 1008 and the input / output device(s) 1010 .

[0213] For example, NVM / storage 1008 may be used to store data and / or instructions 1014. NVM / storage 1008 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0214] NVM / storage device 1008 may include storage resources that are physically part of the device on which apparatus 1000 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 1008 may be accessible over a network via input / output device(s) 1010.

[0215] (One or more) input / output devices 1010 may provide an interface for apparatus 1000 to communicate with any other appropriate device. Input / output devices 1010 may include communication components, audio components, sensor components, etc. Network interface 1012 may provide an interface for apparatus 1000 to communicate via one or more networks. Apparatus 1000 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.

[0216] For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers of the control module 1004 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004 to form a system-on-chip (SoC).

[0217] In various embodiments, the apparatus 1000 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the apparatus 1000 may have more or fewer components and / or a different architecture. For example, in some embodiments, the apparatus 1000 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0218] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in the memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.

[0219] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0220] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0221] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0222] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0223] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0224] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0225] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0226] The above is a detailed introduction to a data storage method, device, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.< / industrycategory> < / string> < / string> < / string>

Claims

1. A data storage method, characterized in that: include: Get the data to be stored; The data to be stored includes at least two data elements having a topological relationship; Generate data objects corresponding to the data elements according to the data content of the data elements and the topological relationship between the data elements to obtain a data object set; the data objects include the data content of the data elements and the topological information of other data elements that have a topological relationship with the data elements; After obtaining the data object set, traversing the data objects and generating structured query statements corresponding to the data elements according to the data content and topology information in the data objects, thereby obtaining a structured query statement set corresponding to the data objects; The structured query statement set is sent to a database for execution, so as to store the data elements and the topological relationships between the data elements.

2. The method according to claim 1, characterized in that The topological relationship includes: the hierarchical relationship between the data elements, and the parent-child node relationship between the data elements at adjacent levels; the topological information includes the data objects corresponding to all child node data elements of the data elements; The traversing of the data object and generating a structured query statement corresponding to the data element according to the data content and topology information in the data object includes: The data objects are traversed in the order of the levels, and a structured query statement having a self-increment identification field and a parent node identification field is generated according to the data content and topology information in the data objects.

3. The method according to claim 2, characterized in that The traversing of the data objects in the order of the levels and generating a structured query statement having an auto-increment identification field and a parent node identification field according to the data content and topology information in the data objects includes: When traversing the root node data object at the first level, obtaining the first initial value of the self-increment identifier and the second initial value of the parent node identifier; It is determined that the auto-increment identification field in the structured query statement corresponding to the root node data object includes an auto-increment identification with a first initial value, and it is determined that the parent node identification field includes a parent node identification with a second initial value.

4. The method according to claim 2, characterized in that The traversing of the data objects in the order of the levels and generating a structured query statement having an auto-increment identification field and a parent node identification field according to the data content and topology information in the data objects includes: When traversing descendant node data objects at a non-first level, determine that the value of the auto-increment identifier included in the auto-increment identifier field in the structured query statement corresponding to the descendant node data object is: the result of adding 1 to the value of the auto-increment identifier of the last traversed data object, and determine that the value of the parent node identifier included in the parent node identifier field is: the value of the auto-increment identifier of the parent node data object of the descendant node data object.

5. The method according to claim 3, characterized in that When the structured query statements are sent to different databases for execution, obtaining the first initial value of the auto-increment identifier includes: Get the current maximum value of the auto-increment identifier when executing structured query statements in data tables in different databases; The result of adding one to the maximum value of the current maximum values of all current self-increment flags is used as the first initial value.

6. The method according to claim 1, characterized in that Generating a data object corresponding to the data element according to the data content of the data element and the topological relationship between the data elements includes: The data object in the form of a map is generated according to the data content of the data elements and the topological relationship between the data elements.

7. The method according to claim 6, characterized in that The topological relationship includes: a hierarchical relationship between the data elements, and a parent-child node relationship between the data elements at adjacent levels; The key of the data object in the map form includes the name of the data object, and the value of the data object in the map form includes the data content of the child node data object of the data object.

8. The method according to claim 1, characterized in that The traversing of the data object and generating a structured query statement corresponding to the data element according to the data content and topology information in the data object includes: Obtaining the data content and topology information of the data object by calling the reflection mechanism function; A structured query statement corresponding to the data element is generated according to the data content and topology information of the data object.

9. The method according to claim 1, characterized in that The method further comprises: Obtaining description information of the data to be stored; generating a structured query statement corresponding to the data to be stored according to the description information of the data to be stored; The structured query statement corresponding to the data to be stored is sent to the database for execution, so as to store the description information of the data to be stored.

10. The method according to claim 9, characterized in that The description information of the data to be stored is stored in a first data table of the database, and the first data table is used to store one or more of a data identification field, a first creation time field, a first modification time field, a data name field, an enabled status field, a data category field, a deleted status field, and a maximum topology level field in the description information of the data to be stored; The data elements of the data to be stored are stored in a second data table of the database, and the second data table is associated with the first data table corresponding to the data to be stored; The second data table is used to store one or more of the following: an element identification field for storing the data element, a second creation time field, a second modification time field, a field for identifying the data to be stored in the first data table, a parent node identification field, a display sort number field, a risk level field, a scan range field, an association model field, and an element category field.

11. The method according to claim 10, characterized in that The method further comprises: In response to a query request for a target data element, based on the query request, when it is determined that the enabled status field corresponding to the target data to be stored in the first data table is in an enabled state, the data content of the target data element is obtained from the second data table associated with the first data table in the database, and the target data to be stored includes the target data element.

12. The method according to claim 1, characterized in that The method further comprises: Obtaining a query request for a target data element, the query request including a query key for a target language environment; According to the query request including the query key of the target language environment, data content of the target data element in the target language environment is acquired from the database.

13. A data storage device, characterized in that: include: An acquisition module, used to acquire data to be stored; The data to be stored includes at least two data elements having a topological relationship; A first generating module is configured to generate data objects corresponding to the data elements according to the data contents of the data elements and the topological relationships between the data elements, thereby obtaining a data object set; the data objects include the data contents of the data elements and the topological information of other data elements having a topological relationship with the data elements; A second generating module is configured to, after obtaining the data object set, traverse the data objects and generate structured query statements corresponding to the data elements based on the data content and topology information in the data objects, thereby obtaining a set of structured query statements corresponding to the data objects; The storage module is used to send the structured query statement set to the database for execution, so as to store the data elements and the topological relationships between the data elements.

14. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to execute the data storage method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Method and device for realizing tree structure

    CN110704420A