Data processing method, device, equipment and storage medium
By processing data query and update requests according to data type consistency in the database, the data processing inaccurate problem caused by multi-type node values is solved, and higher data processing accuracy and operational reliability are achieved.
Patent Information
- Application Number
- CN202210117841.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-08
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-02-08
AI Technical Summary
In the prior art, due to the large number of node value data types stored in the database, data processing is inaccurate.
By responding to data query requests, obtain the node value and data type of the node to be queried in the preset database, and return the result value according to the consistency of the data type. Different processing methods are adopted for numeric types and non-numeric types, including summing processing and direct return to ensure the accuracy of data processing.
It improves the accuracy of data processing, reduces the phenomenon of data query and update failure, and enhances the reliability of database operations.
Smart Images

Figure CN114547142B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing, and in particular relates to a data processing method, device, equipment and storage medium. Background Art
[0002] Currently, with the continuous development of communication technology, it is usually necessary to store values of different data types in the same database.
[0003] In the above storage process, since the data types of the node values stored in the database are relatively large, in order to facilitate subsequent operations on the data in the database, it is necessary to provide a new data processing method to improve the accuracy of data processing. Summary of the Invention
[0004] In order to solve the above-mentioned problems in the prior art, that is, to solve the problem of inaccurate data processing when there are many types of node value data in the database in the prior art, the present invention provides a data processing method, device, equipment and storage medium.
[0005] According to a first aspect of an embodiment of the present application, the present invention provides a data processing method, the method comprising: responding to a data query request, the data query request including a first data type, obtaining a first node value of a node to be queried in a preset database and a second data type corresponding to the first node value; wherein the preset database includes multiple nodes; if it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type, then returning the first node value; if it is determined that the second data type is a numeric type and the second data type is consistent with the first data type, then based on the first node value and the node values of each child node under the node to be queried, obtaining and returning a result value.
[0006] In the preferred technical solution of the above-mentioned data processing method, the query request also includes a first node name, and obtaining the first node value of the node to be queried in the preset database and the second data type corresponding to the first node value includes: determining the node corresponding to the first node name in the preset database as the node to be queried, and obtaining the first node value corresponding to the first node name and the second data type corresponding to the first node value.
[0007] In a preferred technical solution of the above data processing method, the preset database includes multiple nodes stored in a tree structure, and obtaining and returning a result value based on the first node value and the node values of each child node under the node to be queried includes:
[0008] A summation process is performed based on the first node value and the node values of each child node under the node to be queried, and a summation result value is obtained and returned.
[0009] In a preferred technical solution of the above data processing method, the node value corresponding to the node in the preset database is the data to be stored sent by the hypertext markup language page.
[0010] In the preferred technical solution of the above data processing method, the node value corresponding to the node in the preset database is obtained after the native method end performs escape processing on the data to be stored sent by the hypertext markup language page.
[0011] In a preferred technical solution of the above data processing method, the method further includes: if the second data type is inconsistent with the first data type, returning a query failure notification message, wherein the query failure notification message indicates that the data query has failed.
[0012] In the preferred technical solution of the above data processing method, the data query request also includes: a failure tag, which is used to indicate the return value when the data query fails; and the query failure notification message is used to indicate the return value represented by the failure tag.
[0013] In the preferred technical solution of the above-mentioned data processing method, obtaining the first node value corresponding to the first node name in the preset database, and the second data type corresponding to the first node value, includes: if the first node name is not empty, obtaining the first node value corresponding to the first node name in the preset database, and the second data type corresponding to the first node value.
[0014] In the preferred technical solution of the above-mentioned data processing method, the method also includes: receiving a data update request, wherein the data update request includes a second node name and a second node value; obtaining a third node value corresponding to the second node name in the preset database, and a third data type corresponding to the third node value; if it is determined that the third data type is a non-numeric type, updating the node value corresponding to the second node name in the preset database to the second node value; if it is determined that the third data type is a numeric type, and the node corresponding to the second node name is a leaf node, updating the node value corresponding to the second node name in the preset database to the second node value.
[0015] In the preferred technical solution of the above-mentioned data processing method, after obtaining the third node value corresponding to the second node name in the preset database and the third data type corresponding to the third node value, it also includes: obtaining the fourth data type corresponding to the second node value; if it is determined that the third data type is consistent with the fourth data type, then executing if it is determined that the third data type is a non-numeric type, then updating the node value corresponding to the second node name in the preset database to the second node value; if it is determined that the third data type is a numeric type and the node corresponding to the second node name is a leaf node, then updating the node value corresponding to the second node name in the preset database to the second node value.
[0016] In a preferred technical solution of the above data processing method, the method further includes: if the third data type is inconsistent with the fourth data type, returning an update failure notification message, wherein the update failure notification message indicates that the data update has failed.
[0017] According to a second aspect of the embodiments of the present application, the present invention provides a data processing device, the device comprising:
[0018] A first acquisition unit is configured to respond to a data query request including a first data type, and acquire a first node value of a node to be queried in a preset database and a second data type corresponding to the first node value; wherein the preset database includes a plurality of nodes.
[0019] The first returning unit is configured to return the first node value if it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type.
[0020] The second return unit is used to obtain and return a result value based on the first node value and the node values of each child node under the node to be queried if it is determined that the second data type is a numeric type and the second data type is consistent with the first data type.
[0021] In the preferred technical solution of the above-mentioned data processing device, the query request also includes a first node name, and the first acquisition unit is specifically used to determine the node corresponding to the first node name in the preset database as the node to be queried, and obtain the first node value corresponding to the first node name and the second data type corresponding to the first node value.
[0022] In the preferred technical solution of the above-mentioned data processing device, the multiple nodes in the preset database are stored in a tree structure, and the second return unit is specifically used to perform summation based on the first node value and the node values of each child node under the node to be queried, to obtain and return the summed result value.
[0023] In a preferred technical solution of the above data processing device, the node value corresponding to the node in the preset database is the data to be stored sent by the hypertext markup language page.
[0024] In the preferred technical solution of the above data processing device, the node value corresponding to the node in the preset database is obtained after the native method end performs escape processing on the data to be stored sent by the hypertext markup language page.
[0025] In a preferred technical solution of the above-mentioned data processing device, the device further includes: a first notification unit, configured to return a query failure notification message if the second data type is inconsistent with the first data type, wherein the query failure notification message indicates a data query failure.
[0026] In a preferred technical solution of the above data processing device, the data query request also includes: a failure tag, which is used to indicate the return value when the data query fails; and the query failure notification message is used to indicate the return value represented by the failure tag.
[0027] In the preferred technical solution of the above-mentioned data processing device, the first acquisition unit is specifically used to obtain the first node value corresponding to the first node name and the second data type corresponding to the first node value in the preset database if the first node name is not empty.
[0028] In the preferred technical solution of the above-mentioned data processing device, the device also includes: a receiving unit, used to receive a data update request, wherein the data update request includes a second node name and a second node value; a second acquisition unit, used to obtain a third node value corresponding to the second node name in the preset database, and a third data type corresponding to the third node value; a first update unit, used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is a non-numeric type; and a second update unit, used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is a numeric type and the node corresponding to the second node name is a leaf node.
[0029] In the preferred technical solution of the above-mentioned data processing device, after the second acquisition unit acquires the third node value corresponding to the second node name in the preset database and the third data type corresponding to the third node value, it is also used to acquire the fourth data type corresponding to the second node value; the first update unit is specifically used to execute if it is determined that the third data type is consistent with the fourth data type, and if it is determined that the third data type is a non-numeric type, then update the node value corresponding to the second node name in the preset database to the second node value; the second update unit is specifically used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is consistent with the fourth data type, the third data type is a numeric type, and the node corresponding to the second node name is a leaf node.
[0030] In a preferred technical solution of the above-mentioned data processing device, the device further includes: a second notification unit, configured to return an update failure notification message if the third data type is inconsistent with the fourth data type, wherein the update failure notification message indicates a data update failure.
[0031] According to a third aspect of the embodiments of the present application, the present invention provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0032] The memory stores computer-executable instructions;
[0033] The processor executes the computer-executable instructions stored in the memory to implement the data processing method as described in any one of the first aspects of the embodiments of the present application.
[0034] According to the fourth aspect of the embodiments of the present application, the present invention provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, they are used to implement the data processing method as described in any one of the first aspects of the embodiments of the present application.
[0035] According to a fifth aspect of the embodiments of the present application, the present invention provides a computer program product, including a computer program, which is executed by a processor as the data processing method described in any one of the first aspects of the embodiments of the present application.
[0036] It is understandable to those skilled in the art that the data processing method, apparatus, device and storage medium provided by the present invention. The method includes: responding to a data query request, the data query request includes a first data type, obtaining a first node value of a node to be queried in a preset database and a second data type corresponding to the first node value; wherein the preset database includes multiple nodes; if it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type, then the first node value is returned; if it is determined that the second data type is a numeric type and the second data type is consistent with the first data type, then based on the first node value and the node value of each child node under the node to be queried, a result value is obtained and returned. When the first data type is consistent with the second data type, the present application adopts different methods to determine the return value for different data types to improve the accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The following describes preferred embodiments of the data processing method, apparatus, device, and storage medium of the present invention with reference to the accompanying drawings, which are as follows:
[0038] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a data storage framework provided by this application;
[0040] Figure 3 A schematic diagram of a data update process provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of a flow chart of another data update process provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0043] Figure 6 A structural diagram of another data processing device is provided for an embodiment of the present application;
[0044] Figure 7 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] First, those skilled in the art should understand that these embodiments are merely for explaining the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Those skilled in the art may adjust them as needed to suit specific applications.
[0046] Furthermore, it should be noted that, in the description of the present invention, unless otherwise expressly specified or limited, the terms "connected" and "connection" should be understood in a broad sense. For example, they can refer to fixed connection, detachable connection, or integral connection; mechanical connection or electrical connection; direct connection or indirect connection through an intermediate medium; and internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.
[0047] First, the terms involved in the present invention are explained:
[0048] 1) Smart home appliances refer to home appliances that are formed by introducing microprocessors, sensor technology, and network communication technology into home appliances. They have the characteristics of intelligent control, intelligent perception, and intelligent application. The operation of smart home appliances often relies on the application and processing of modern technologies such as the Internet of Things, the Internet, and electronic chips. For example, smart home appliances can be connected to electronic devices to enable users to remotely control and manage smart home appliances.
[0049] 2) Terminal device refers to an electronic device with wireless connection function. The terminal device can communicate with the above-mentioned smart home appliances by connecting to the Internet, or directly communicate with the above-mentioned smart home appliances through Bluetooth, WiFi, etc. In some embodiments, the terminal device is, for example, a mobile device, a computer, or a vehicle-mounted device built into a hover car, or any combination thereof. Mobile devices may include, for example, mobile phones, smart home devices, wearable devices, smart mobile devices, virtual reality devices, etc., or any combination thereof, wherein wearable devices include, for example, smart watches, smart bracelets, pedometers, etc.
[0050] 3) "Multiple" refers to two or more, and other quantifiers are similar. "And / or" describes the relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0051] 4) "Correspondence" can refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.
[0052] The following explains the application scenarios of the embodiments of the present application:
[0053] With the continuous advancement of communication technology, large amounts of data are now stored in databases within network devices. Furthermore, data stored in the same database often includes multiple formats, depending on the data source. Due to the wide variety of node value types stored in databases, a new data processing method is needed to facilitate subsequent operations on the database data and improve data processing accuracy.
[0054] The following describes in detail the technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems using specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following embodiments of the present invention are described in conjunction with the accompanying drawings.
[0055] Figure 1 A flow chart of a data processing method provided in an embodiment of the present application is shown in the figure. As shown in the figure, the method includes the following steps:
[0056] S101 : In response to a data query request including a first data type, obtain a first node value of a node to be queried and a second data type corresponding to the first node value in a preset database.
[0057] Exemplarily, in this embodiment, the preset database includes a plurality of nodes, each node corresponds to its own node value, and the data type corresponding to the node value can be one or more of the following data types: byte, char, int, long, float, double, boolean, and string. When a data query is required for the data stored in the database, a data query request sent externally to the database can be first received, and based on the data query request, the first node value corresponding to the node to be queried is obtained, and the second data type corresponding to the node value is determined. The first data type in the data query request is the data type corresponding to the node value to be queried. The second data type is the data type corresponding to the node value actually queried in the preset database.
[0058] In one example, each node in the preset database is provided with its own node name. The query request also includes a first node name, which is used to characterize the node name corresponding to the node to be queried. Therefore, when determining the node to be queried, the data query request may include the first node name, and the node corresponding to the first node name in the preset database is determined as the node to be queried, and the first node value corresponding to the first node name and the second data type corresponding to the first node value are obtained. After receiving the data query request, the first node value corresponding to the first node name is searched in the preset database based on the first node name included in the data query request, and the data type corresponding to the first node value obtained by the query is determined, that is, the second data type.
[0059] In one example, each node in the preset database corresponds to a respective storage path, and the node to be queried can be determined in the preset database based on the storage path included in the data query request.
[0060] In one example, a query interface is set on a preset database. When it is necessary to query data in the preset database, the query interface can be called and the first node name and the first data type contained in the data query request can be passed in to implement query processing on the database.
[0061] S102: If it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type, return the first node value.
[0062] Exemplarily, after determining the second data type corresponding to the first node value obtained by the query, the second data type is compared and judged. That is, the first data type included in the data query request is compared with the second node name corresponding to the first node value obtained by the query. When it is determined that the first data type is consistent with the second data type, the first node value obtained at this time is considered to be accurate. Thereafter, the second data type is further determined. When the second data type is a non-numeric type, the first node value obtained by the query is directly returned and output. For example, when the data type corresponding to the first node value obtained by the query is in the form of a string, the first node value can be directly output at this time.
[0063] S103. If it is determined that the second data type is a numeric type and the second data type is consistent with the first data type, a result value is obtained and returned based on the first node value and the node values of each child node under the node corresponding to the first node name.
[0064] Exemplarily, when the first data type is consistent with the second data type, if it is further determined that the second data type is a numeric type, then the search for the child nodes included under the node continues, and the final returned result value can be determined based on the node values corresponding to the node and each child node under the node.
[0065] In one example, when the node values corresponding to multiple nodes in a preset database are stored using a tree structure storage type, the first node value and the node values of each child node under the node to be queried can be summed up, and the summed value can be used as the final returned result value.
[0066] In one example, if it is determined that the node is a leaf node, that is, the node does not include any child nodes, then the node value, that is, the first node value, can be directly returned and outputted.
[0067] In one example, if the second data type corresponding to the first node value obtained from a database query is inconsistent with the first data type included in the query request, a query failure notification message is returned, wherein the query failure notification message indicates that the data query failed. Specifically, when returning the query failure notification message, the notification message can be generated using a preset template. For example, the preset template is "Query for a certain node name failed. Please re-enter the query request." When generating the query failure notification message based on the preset template, the node name in the preset template can be directly replaced with the first node name in the received query request.
[0068] In this embodiment, when querying data in a database, the first node value of the node to be queried is first determined in the database based on the data query request. Furthermore, in order to improve the accuracy of the data query, the second data type corresponding to the first node value is further compared with the first data type in the query request. If the comparison results are consistent, the query result of the node value is considered accurate. If the comparison results are inconsistent, it may be due to tampering with the data query request or the database being attacked. In this case, the current query is considered inaccurate and a failed query notification is returned. In addition, in this embodiment, when it is confirmed that the first node value of the query is accurate, that is, when the first data type is consistent with the second data type, for a numeric node value, it is necessary to further query the child nodes included under the node, and sum the values of the node and each child node under the node as the return value. For a non-numeric node value, the node value corresponding to the node can be directly returned. That is, by further determining whether the second data type is a numeric type or a non-numeric type, different methods are used to determine the final output return value for different types, thereby improving the accuracy of data processing.
[0069] In one embodiment, the above Figure 1 The data processing method shown is applied to the processing of the database corresponding to the client application. That is, the aforementioned preset database can be the database corresponding to the client application. Currently, client application pages are often implemented using Hypertext Markup Language (HTML) pages, and the fifth generation Hypertext Markup Language (Hypertext Markup Language 5.0, H5) pages are currently commonly used. Therefore, the node values corresponding to the nodes in the preset database can be the data to be stored sent based on the HTML page.
[0070] In another embodiment, during the development of the client application, the development is often mainly carried out by combining H5 technology with Native (native method) end technology. Figure 2 A schematic diagram of a data storage framework provided for an embodiment of the present application. When the data of an H5 page needs to be stored in the database corresponding to the client application, the data sent by the data of the H5 page can be escaped by calling the preset interface in the Native end, and the transferred data can be stored in the database. And when storing specifically, it can be stored in the database in a tree structure, and each node of the tree structure includes the node name and node value of the node. Specifically, the data query request in the above step S101 can be sent by a certain H5 page to the preset database through the Native end, or it can be sent by the Native end itself, and no specific limitation is made here.
[0071] In addition, when the received data query request is sent to the database through the Native side for an H5 page, after the database returns the result value, since the data stored in the database is escaped data, after the Native side receives the returned result value, it is also necessary to convert the first node value and then send the converted value to the H5 page.
[0072] In one possible implementation, the data query request also includes a failure tag, wherein the failure tag can be used to represent the return value when the data query fails. That is, when the data query fails, the return value represented by the failure tag can be returned as a query failure notification.
[0073] In this embodiment, by setting a failure tag in the query request, when the query fails, the return value corresponding to the failure tag can be directly returned. The return method of the query failure notification proposed in this embodiment is simple for the database to operate, eliminating the step of calling a pre-set template, and is time-saving.
[0074] In one possible implementation, when a data query request is received, the first node name included in the request can be checked. Specifically, if the node name is determined to be valid, the first node value corresponding to the first node name and the second data type corresponding to the first node value can be retrieved from a preset database. That is, in this embodiment, if the first node name is determined to be valid, a match is performed in the database, thereby reducing the number of database matches and improving data query efficiency.
[0075] In another possible implementation, when a data query request is received, the format of the first node name included in the data query request may be checked for validity. If the first node name is valid, the step of obtaining the first node value corresponding to the first node name may be continued. If the first node name is invalid, a query failure notification is returned.
[0076] For example, in some examples, the data type of the node name is set to string type. When the data type corresponding to the first node name in the received data query request is not string type, the node name is considered invalid and the query failure notification message can be directly returned.
[0077] For instance, in other examples, the data type corresponding to the node name can be pre-set to a string type, and the node name of each node is named by adding a separator ' / ' after the last character of the parent node name, and adding a string after the separator. Therefore, when judging the validity of the first node name in the query request, the format of the node name can also be judged, that is, whether the validity of the remaining characters except the preset characters and separators is included. In other words, when making a validity judgment, the validity of the node name can be judged based on the data type of the preset node name and / or the preset naming rules of the node name. Through the above judgment, the phenomenon of data query failure caused by invalid node names is avoided, and the subsequent processing efficiency of the database is improved.
[0078] Figure 3 This is a flow chart of a data update process provided in an embodiment of the present application. As shown in the figure, the method includes the following steps:
[0079] S201: Receive a data update request, where the data update request includes a second node name and a second node value.
[0080] For example, in this embodiment, data stored in the database may also be updated. Specifically, in this embodiment, the data update request received by the database includes a second node name and a second node value. The node corresponding to the second node name is the node to be updated in the database, and the second node value in the data update request is the updated value of the node corresponding to the second node name.
[0081] In one example, an update interface is provided on the database. When the database needs to be updated, the update interface can be called and the second node name and the second node value included in the data update request can be passed in to implement the update processing of the database.
[0082] S202: Obtain a third node value corresponding to the second node name and a third data type corresponding to the third node value from a preset database.
[0083] Exemplarily, after receiving a data update request, the third node value of the node corresponding to the second node name is searched in the database based on the second node name passed in the update request, and after obtaining the third node value, the third node value type is further determined.
[0084] S203: If it is determined that the third data type is a non-numeric type, the node value corresponding to the second node name in the preset database is updated to the second node value.
[0085] S204: If it is determined that the third data type is a numeric type, and the node corresponding to the second node name is a leaf node, then the node value corresponding to the second node name in the preset database is updated to the second node value.
[0086] For example, in this embodiment, when performing a database update process, different update methods are used for node values of different data types stored. Specifically, when it is determined that the third node value found is of a non-numeric type, then at this time, the node value corresponding to the second node name in the database can be directly updated to the second node value. However, if the third node value found is of a numeric type, then it is necessary to further determine whether the node is a leaf node, that is, whether the node includes other child nodes. If there are no other child nodes connected to the node, then the node is a leaf node, and the node value corresponding to the node can be directly updated to the second node value.
[0087] In a possible implementation, when the third data type is a numeric type, if the node is not a leaf node, no update operation is performed on the node, and a notification message indicating that the data update failed is returned.
[0088] In this embodiment, when updating a database, it is also necessary to determine whether to update the node value of the node after judging the data type of the node value found. Specifically, during the update operation, for non-numeric nodes, the node value can be directly updated. However, for numeric node values, it is necessary to further check whether the node is a leaf node. Only if it is a leaf node can the node value corresponding to the node be updated. This improves the accuracy of database updates by judging the numeric type of the node value.
[0089] Figure 4 A flowchart of another data update process provided in an embodiment of the present application is shown in the figure. As shown in the figure, the method includes the following steps:
[0090] S301: Receive a data update request, where the data update request includes a second node name and a second node value.
[0091] S302: Obtain a third node value corresponding to the second node name and a third data type corresponding to the third node value from a preset database.
[0092] For example, the specific principles of step S301 and step S302 in this embodiment can be found in Figure 2 Steps S201 and S202 in the above are not described in detail here.
[0093] S303: Obtain a fourth data type corresponding to the second node value.
[0094] S304: If it is determined that the third data type is consistent with the fourth data type, and the third data type is a non-numeric type, the node value corresponding to the second node name in the preset database is updated to the second node value.
[0095] S305. If it is determined that the third data type is consistent with the fourth data type, and if it is determined that the third data type is a numeric type, and the node corresponding to the second node name is a leaf node, then the node value corresponding to the second node name in the preset database is updated to the second node value.
[0096] For example, in this embodiment, to further improve the accuracy of data updates in the database, after determining the third data type corresponding to the third node value, in this embodiment, it is further necessary to determine the data type of the second node value in the data update request, i.e., the aforementioned fourth data type. After determining the fourth data type, the third data type corresponding to the original node value in the database is compared with the fourth data type corresponding to the second node value in the data update request to see if they are consistent. If they are consistent, the determination of the third data type in steps S303 and S304 can be continued, i.e., determining whether the third data type is numeric or non-numeric, and then continuing the database update process.
[0097] S306: If the third data type is inconsistent with the fourth data type, an update failure notification message is returned, wherein the update failure notification message indicates that the data update has failed.
[0098] For example, if it is determined that the third data type is inconsistent with the fourth data type, it is considered that the second node value in the current incoming update request is incorrect, or the node to be updated is not accurately found, etc., then the update processing is interrupted and a notification message of database update failure is directly generated and returned.
[0099] In this embodiment, in order to improve the accuracy of database updates, when performing data update operations, the fourth data type corresponding to the second node value in the update request and the third data type of the third node value found from the database are further compared. Only when the type comparison is consistent, the subsequent update processing steps are continued to be executed, thereby avoiding the problem of decreased database update accuracy caused by situations such as the second node value in the incoming update request being set incorrectly or being maliciously modified in the middle, thereby improving the accuracy of database updates.
[0100] Furthermore, based on the above embodiment, Figure 4 In the illustrated embodiment, before step S302, the second node name in the data update request may be subjected to a validity check. Once the second node name is determined to be valid, step S302 may be executed, thereby improving data update efficiency. It should be noted that the node name validity check described herein can be found in the relevant description of the data query embodiment and will not be further elaborated here.
[0101] In some embodiments, when data in the database needs to be deleted, the following methods can be used to perform the deletion operation:
[0102] Receive a data deletion request, wherein the data deletion request includes a third node name. Determine the validity of the third node name included in the data deletion request. If valid, search the database for the node corresponding to the third name and the child nodes under the node, and delete the nodes found above, that is, delete the node names and node values corresponding to these nodes at the same time. Specifically, when searching for child nodes under a certain node, the search can be performed based on the tree structure in the database, or when the node name is named by adding a separator ' / ' after the last character of the parent node name and adding a character string after the separator, then at this time, a fuzzy search can be performed in the database using the node name in the deletion request to obtain the child nodes under the node.
[0103] Figure 5 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application is shown in the figure. The device includes:
[0104] The first acquisition unit 41 is used to respond to a data query request including a first data type, obtain a first node value of a node to be queried in a preset database and a second data type corresponding to the first node value; wherein the preset database includes multiple nodes.
[0105] The first returning unit 42 is configured to return the first node value if it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type.
[0106] The second returning unit 43 is configured to obtain and return a result value based on the first node value and the node values of each child node under the node to be queried if it is determined that the second data type is a numeric type and the second data type is consistent with the first data type.
[0107] In the preferred technical solution of the above-mentioned data processing device, the query request also includes a first node name, and a first acquisition unit 41, which is specifically used to determine the node corresponding to the first node name in the preset database as the node to be queried, and obtain the first node value corresponding to the first node name and the second data type corresponding to the first node value.
[0108] In the preferred technical solution of the above-mentioned data processing device, multiple nodes in the preset database are stored in a tree structure, and the second return unit 43 is specifically used to perform summation based on the first node value and the node values of each child node under the node to be queried, and obtain and return the summed result value.
[0109] In a preferred technical solution of the above data processing device, the node value corresponding to the node in the preset database is the data to be stored sent by the hypertext markup language page.
[0110] In the preferred technical solution of the above data processing device, the node value corresponding to the node in the preset database is obtained after the native method end performs escape processing on the data to be stored sent by the hypertext markup language page.
[0111] For related instructions, please refer to Figure 2 The relevant descriptions and effects corresponding to the steps in the corresponding embodiments can be understood, and no further details are given here.
[0112] The data processing device provided in this embodiment can perform the following operations: Figure 2 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0113] Figure 6 A structural diagram of another data processing device is provided for the embodiment of the present application, such as Figure 6 As shown, in Figure 5 Based on the structure shown, the device also includes:
[0114] The first notification unit 44 is configured to return a query failure notification message if the second data type is inconsistent with the first data type, wherein the query failure notification message indicates that the data query has failed.
[0115] In a possible implementation, the data query request further includes: a failure tag, which is used to indicate a return value when the data query fails; and a query failure notification message which is used to indicate the return value represented by the failure tag.
[0116] In the preferred technical solution of the above-mentioned data processing device, the first acquisition unit 41 is specifically used to obtain the first node value corresponding to the first node name and the second data type corresponding to the first node value in the preset database if the first node name is not empty.
[0117] In the preferred technical solution of the above-mentioned data processing device, the device also includes: a receiving unit 45, used to receive a data update request, wherein the data update request includes a second node name and a second node value; a second acquisition unit 46, used to obtain a third node value corresponding to the second node name in a preset database, and a third data type corresponding to the third node value; a first update unit 47, used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is a non-numeric type; a second update unit 48, used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is a numeric type and the node corresponding to the second node name is a leaf node.
[0118] In the preferred technical solution of the above-mentioned data processing device, after the second acquisition unit 46 acquires the third node value corresponding to the second node name in the preset database and the third data type corresponding to the third node value, it is also used to obtain the fourth data type corresponding to the second node value; the first update unit 47 is specifically used to execute if it is determined that the third data type is consistent with the fourth data type, and if it is determined that the third data type is a non-numeric type, then the node value corresponding to the second node name in the preset database is updated to the second node value; the second update unit 48 is specifically used to update the node value corresponding to the second node name in the preset database to the second node value if it is determined that the third data type is consistent with the fourth data type, the third data type is a numeric type, and the node corresponding to the second node name is a leaf node.
[0119] In a preferred technical solution of the above data processing device, the device further includes: a second notification unit 49, configured to return an update failure notification message if the third data type is inconsistent with the fourth data type, wherein the update failure notification message indicates that the data update has failed.
[0120] For related instructions, please refer to Figure 3 and Figure 4 The relevant descriptions and effects corresponding to the steps in the corresponding embodiments can be understood, and no further details are given here.
[0121] The data processing device provided in this embodiment can perform the following operations: Figure 3 and Figure 4 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0122] Figure 7 A schematic diagram of an electronic device provided in an embodiment of the present application, such as Figure 7 As shown, the electronic device provided by this embodiment includes: a memory 701, a processor 702 and a computer program.
[0123] The computer program is stored in the memory 701 and is configured to be executed by the processor 702 to implement the present invention. Figure 2-Figure 4 The data processing method provided in any one of the corresponding embodiments.
[0124] The memory 701 and the processor 702 are connected via a bus 703 .
[0125] For related instructions, please refer to Figure 2-Figure 4 The relevant descriptions and effects corresponding to the steps in the corresponding embodiments can be understood, and no further details are given here.
[0126] One embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the present invention. Figure 7 The data processing method provided by the corresponding embodiment.
[0127] Among them, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0128] The present invention provides a computer program product, comprising a computer program, which is executed by a processor to implement the present invention. Figure 2-Figure 4 The data processing method provided in any one of the corresponding embodiments.
[0129] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0130] Other embodiments of the present invention will readily occur to those skilled in the art upon consideration of the specification and practice of the applications disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the present invention that follow from the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.
[0131] It should be understood that the present invention is not limited to the exact construction described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof, which is limited only by the appended claims.
[0132] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art may make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will fall within the scope of protection of the present invention.
[0133] Other embodiments of the present invention will readily occur to those skilled in the art upon consideration of the specification and practice of the applications disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the present invention that follow from the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.
Claims
1. A data processing method, characterized in that: The method comprises: In response to a data query request, the data query request includes a first data type and a first node name; determining a node corresponding to the first node name in a preset database as a node to be queried, and obtaining a first node value corresponding to the first node name and a second data type corresponding to the first node value; wherein the preset database includes a plurality of nodes; and the node values corresponding to the nodes in the preset database are data to be stored sent by a hypertext markup language page; If it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type, then returning the first node value; If it is determined that the second data type is a numeric type and the second data type is consistent with the first data type, a result value is obtained and returned based on the first node value and the node values of each child node under the node to be queried.
2. The data processing method according to claim 1, wherein: The plurality of nodes in the preset database are stored in a tree structure, and obtaining and returning a result value based on the first node value and the node values of each child node under the node to be queried includes: A summation process is performed based on the first node value and the node values of each child node under the node to be queried, and a summation result value is obtained and returned.
3. The data processing method according to claim 2, characterized in that: The node value corresponding to the node in the preset database is obtained after the native method end performs escape processing on the data to be stored sent by the hypertext markup language page.
4. The data processing method according to claim 1, wherein: The method further comprises: If the second data type is inconsistent with the first data type, a query failure notification message is returned, wherein the query failure notification message indicates that the data query has failed.
5. The data processing method according to claim 1, wherein: The data query request further includes: a failure tag, which is used to indicate a return value when the data query fails; and the query failure notification message is used to indicate the return value represented by the failure tag.
6. The data processing method according to claim 1, wherein: The determining the node corresponding to the first node name in the preset database as the node to be queried, and obtaining the first node value corresponding to the first node name and the second data type corresponding to the first node value, includes: If the first node name is not empty, the node corresponding to the first node name in the preset database is determined as the node to be queried, and the first node value corresponding to the first node name and the second data type corresponding to the first node value are obtained.
7. The data processing method according to any one of claims 1 to 6, characterized in that: The method further comprises: receiving a data update request, wherein the data update request includes a second node name and a second node value; Obtaining a third node value corresponding to the second node name and a third data type corresponding to the third node value in the preset database; If it is determined that the third data type is a non-numeric type, updating the node value corresponding to the second node name in the preset database to the second node value; If it is determined that the third data type is a numeric type, and the node corresponding to the second node name is a leaf node, the node value corresponding to the second node name in the preset database is updated to the second node value.
8. The data processing method according to claim 7, characterized in that: After obtaining the third node value corresponding to the second node name and the third data type corresponding to the third node value in the preset database, the method further includes: Obtain a fourth data type corresponding to the second node value; If it is determined that the third data type is consistent with the fourth data type, then if it is determined that the third data type is a non-numeric type, the node value corresponding to the second node name in the preset database is updated to the second node value; if it is determined that the third data type is a numeric type and the node corresponding to the second node name is a leaf node, then the node value corresponding to the second node name in the preset database is updated to the second node value.
9. The data processing method according to claim 8, characterized in that: The method further comprises: If the third data type is inconsistent with the fourth data type, an update failure notification message is returned, wherein the update failure notification message indicates that the data update has failed.
10. A data processing device, characterized in that: The device comprises: A first acquiring unit is configured to respond to a data query request, the data query request including a first data type and a first node name; determine a node corresponding to the first node name in a preset database as a node to be queried, and acquire a first node value corresponding to the first node name and a second data type corresponding to the first node value; wherein the preset database includes a plurality of nodes; and the node values corresponding to the nodes in the preset database are data to be stored sent by a hypertext markup language page; a first returning unit, configured to return the first node value if it is determined that the second data type is a non-numeric type and the second data type is consistent with the first data type; The second return unit is used to obtain and return a result value based on the first node value and the node values of each child node under the node to be queried if it is determined that the second data type is a numeric type and the second data type is consistent with the first data type.
11. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the data processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the data processing method according to any one of claims 1 to 9.
13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the data processing method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Data storage and query method and device and monitoring system
CN110019247A
Data storage method and system and data query method and system
CN113434587A