Data processing method and device, electronic equipment and computer readable storage medium
By obtaining configuration information to generate target deletion execution instructions and using pre-compiled interfaces for data processing, the problem of low efficiency and poor flexibility caused by manual hard coding in existing technologies is solved, and automated and fast data deletion processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MASHANG CONSUMER FINANCE CO LTD
- Filing Date
- 2022-09-08
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies rely on manual hard coding for data deletion, which makes it difficult to respond to business changes in a timely manner, resulting in low efficiency, inflexibility, and difficulty in dynamically controlling data processing logic.
The system generates a target deletion execution command by obtaining configuration information and pre-compiles it using preset data operation interfaces such as PreparedStatement to automate data deletion processing. It also supports placeholder functionality to improve execution efficiency.
It enables automated data deletion without manual intervention when business needs change, improving the speed and efficiency of data processing and supporting flexible business logic control.
Smart Images

Figure CN116150131B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a data processing method and apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] Since software systems often generate a large amount of data during operation, it is generally necessary to periodically delete some unimportant business data from the database in order to reduce the storage pressure on the database.
[0003] Currently, data deletion is typically handled by developers who hard-code the deletion of different business data based on the deletion requirements of different business operations. This method is inconvenient because it relies on manual intervention, and it may also lead to low data processing efficiency due to the inability to respond to business changes in a timely manner and the lack of dynamic control over business deletion logic. Summary of the Invention
[0004] This disclosure provides a data processing method and apparatus, an electronic device, and a computer-readable storage medium.
[0005] In a first aspect, this disclosure provides a data processing method, which includes:
[0006] Obtain configuration information to be processed, wherein the configuration information is information used to indicate the target data to be deleted;
[0007] Based on the configuration information, generate a target deletion execution command;
[0008] The target deletion execution instruction is sent to the database storing the target data based on a preset data operation interface. The database is used to pre-compile the target deletion execution instruction. The preset data operation interface supports placeholders and supports pre-compiling the target deletion execution instruction.
[0009] According to the target deletion execution instruction, the target data in the database is deleted.
[0010] Secondly, this disclosure provides a data processing apparatus, which includes:
[0011] An acquisition unit is used to acquire configuration information to be processed, wherein the configuration information is information used to indicate target data to be deleted;
[0012] The generation unit is used to generate a target deletion execution instruction based on the configuration information;
[0013] A pre-compilation unit is used to send the target deletion execution instruction to a database storing the target data based on a preset data operation interface. The database is used to pre-compile the target deletion execution instruction. The preset data operation interface supports placeholders and supports pre-compiling the target deletion execution instruction.
[0014] An execution unit is used to delete the target data in the database according to the target deletion execution instruction.
[0015] Thirdly, this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the data processing method described above.
[0016] Fourthly, this disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data processing method of the first aspect described above.
[0017] The embodiments provided in this disclosure eliminate the need for manual hard-coding to adapt to changed business requirements each time a deletion occurs. Instead, the electronic device can automatically acquire configuration information indicating the target data to be deleted and automatically delete the target data based on this configuration information. Furthermore, after generating the target deletion execution command based on the configuration information, the command is pre-compiled by sending it to the database through a preset data operation interface that supports placeholders. This saves compilation time when the placeholders of the target deletion command are filled with actual values and executed by the database, thereby improving the execution speed and efficiency of the target deletion execution command. Since the configuration information can be manually changed in a timely manner according to business needs, and the preset database operation interface's support for placeholders better supports the configurable function of the deletion execution command, the embodiments provided in this disclosure enable the electronic device to conveniently and efficiently respond to business needs and delete target data in the database.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0019] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the embodiments of the present disclosure to explain the disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed description of exemplary embodiments with reference to the accompanying drawings, in which:
[0020] Figure 1 A flowchart of a data processing method provided in an embodiment of this disclosure;
[0021] Figure 2 This is a flowchart for obtaining configuration information provided in an embodiment of the present disclosure;
[0022] Figure 3 A flowchart for generating deletion execution instructions is provided for embodiments of this disclosure;
[0023] Figure 4 A first flowchart of the deletion process provided in this embodiment of the disclosure;
[0024] Figure 5 This is a second flowchart of the deletion process provided in an embodiment of the present disclosure;
[0025] Figure 6 A flowchart for storing target deletion records provided in this embodiment of the disclosure;
[0026] Figure 7 A flowchart of the query processing provided in this embodiment of the disclosure;
[0027] Figure 8 This is a processing block diagram illustrating the data processing method provided in the embodiments of this disclosure;
[0028] Figure 9 A block diagram of a data processing apparatus provided in an embodiment of this disclosure;
[0029] Figure 10 This is a block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0030] To enable those skilled in the art to better understand the technical solutions of this disclosure, exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments of this disclosure to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0031] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.
[0032] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.
[0033] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Words such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.
[0034] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.
[0035] In related technologies, to alleviate database storage pressure, when deleting business data generated by software systems stored in the database, developers typically collect data deletion requirements in advance. Then, they develop a data deletion application through hard coding and run it on electronic devices to delete unimportant business data from the database. However, due to different business types or changes in business processes, data deletion requirements often vary and may change at any time. In such scenarios, developers usually need to perform targeted data deletion for different business needs through hard coding. Furthermore, when the deletion requirements for a particular business change, developers need to modify the hard coding again and restart the data deletion application to complete the data deletion process in the database.
[0036] The data processing method in this related technology relies too heavily on manual intervention, which is inconvenient. Furthermore, each time the business deletion request changes, the corresponding changes to the data deletion process are implemented by modifying the hard-coded code, which often fails to respond to business needs in a timely manner. Moreover, the data deletion logic is not dynamically controlled enough. Therefore, it can be seen that this data processing method in this related technology may be inconvenient and inefficient.
[0037] To address the aforementioned problems and facilitate convenient and efficient data deletion in the database, this disclosure provides a data processing method, please refer to the following embodiments. Figure 1 This is a flowchart of a data processing method provided in an embodiment of this disclosure. The method can be applied to an electronic device, which can be a server, a physical server, or a virtual server. Of course, with the continuous advancement of technology, the electronic device can also be a terminal device; that is, the method can also be applied independently to a terminal device, for example, to an edge terminal device in an edge computing scenario. No special limitation is made here. In this embodiment of the disclosure, unless otherwise specified, the application of the method to a server is used as an example for explanation.
[0038] like Figure 1 As shown, the data processing method provided in this embodiment may include the following steps S101-S104, which will be described in detail below.
[0039] Step S101: Obtain configuration information to be processed, wherein the configuration information is information used to indicate the target data to be deleted.
[0040] In this embodiment of the disclosure, the target data may be business data stored in a database that corresponds to any business. The business may be one or more businesses in an e-commerce system, and / or one or more businesses in a financial lending system, a financial intelligent outbound calling system, or other similar systems.
[0041] For example, in a financial intelligent outbound calling system, business data such as log data and customer data of customers with low activity levels can be deleted periodically to reduce the storage pressure on the database.
[0042] Configuration information can be pre-configured information used to indicate the target data to be deleted. Configuration information may include database name, table name, data field name, target boundary values, and enabling instructions.
[0043] The database name can be the name of the database that stores the target data corresponding to this configuration information.
[0044] The data table name can be the name of the data table in the database used to store the target data.
[0045] The data field name can be the name of the data field corresponding to the target data in this data table;
[0046] The target boundary value, i.e., the numerical boundary of the target data to be deleted, can be used to filter the target data from multiple data corresponding to the data field;
[0047] Enable indication information can be used to indicate whether the configuration information is enabled, that is, whether the configuration information is valid.
[0048] That is, business data is usually stored in one or more tables in a database. Therefore, in order to enable electronic devices to easily identify the target data to be deleted, in this embodiment of the disclosure, the user can indicate the target data by pre-configuring the database, table, data field and corresponding target boundary value of the target data in the configuration information. At the same time, in order to enable electronic devices to respond to business needs in a timely manner and realize dynamic control of business logic, an enable indication can be used as a flag to indicate whether the configuration information is enabled, so that the electronic device can quickly determine whether the target data needs to be deleted according to the configuration information based on the enable indication.
[0049] In one embodiment, taking the configuration information as an example that simultaneously includes the database name, table name, data field name, target boundary value, and activation instruction information, the configuration information can be {database1,tbl1,amount,100 yuan,enabled}, to instruct the electronic device to delete the data with the database name "database1", the table name "tbl1", and the amount of 100, so as to reduce the storage pressure of the database.
[0050] In this embodiment of the disclosure, the configuration information can be stored in a configuration file or in a configuration database. To enable the electronic device to dynamically control business logic and respond promptly to business changes, in this embodiment of the disclosure, the configuration information stored in the configuration file or configuration database can be dynamically configured by the user; that is, the user can dynamically configure the configuration information through the front-end interface during the operation of the electronic device.
[0051] Step S102: Generate a target deletion execution instruction based on the configuration information; and Step S103: Send the target deletion execution instruction to the database storing the target data based on the preset data operation interface. The database is used to pre-compile the target deletion execution instruction. The preset data operation interface supports placeholders and supports pre-compiling the target deletion execution instruction.
[0052] The target deletion command can be a Structured Query Language (SQL) statement that can be executed by the database to delete target data from the database. For example, the target deletion command could be "delete from database1 where amount = ?".
[0053] It should be noted that, unless otherwise specified, in this embodiment, the programming language for implementing the data deletion application is Java. The preset data operation interface can be the PreparedStatement interface in Java used for performing database operations; however, with the continuous advancement of technology, this preset data operation interface can also be other interfaces or interfaces in other programming languages that support placeholders and pre-compile execution instructions, without special limitations here.
[0054] In related technologies, data deletion is typically implemented using the Statement interface in Java, which is used to perform database operations. This involves dynamically concatenating SQL statements to perform the deletion. However, this method requires real-time compilation of the SQL statements to be executed each time, resulting in slow SQL execution speed. Furthermore, it may lead to SQL injection vulnerabilities and poor code readability, making code maintenance difficult.
[0055] In this embodiment of the disclosure, considering that the PreparedStatement interface enables the database to pre-compile the execution instructions to be executed, i.e., SQL statements, and also supports using placeholders for variables in SQL statements, in order to increase the flexibility of coding so that the electronic device can configure the target deletion execution instructions more flexibly based on the configuration information obtained in step S101, in this embodiment of the disclosure, after obtaining the configuration information, the target deletion execution instructions can be generated by first using placeholders for variables in the deletion statement, and then the target deletion execution instructions can be sent to the database for pre-compilation through the PreparedStatement interface to improve the execution speed when the target deletion statement is actually executed by the database with the variables substituted.
[0056] Step S104: Delete the target data in the database according to the target deletion execution instruction.
[0057] After generating the target deletion execution instruction in step S102 and precompiling the target deletion execution instruction in step S103, the target data in the database can be deleted according to the target deletion execution instruction.
[0058] As can be seen from the above description, the data processing method provided in this disclosure does not require manual hard coding for each deletion business change. Instead, the electronic device can automatically obtain the configuration information indicating the target data to be deleted and automatically delete the target data based on the configuration information. Simultaneously, after generating the target deletion execution instruction based on the configuration information, the instruction is pre-compiled by sending it to the database through a preset data operation interface that supports placeholders. This saves compilation time when the placeholders of the target deletion instruction are filled with actual values and executed by the database, thereby improving the execution speed and efficiency of the target deletion statement. Since the configuration information can be changed manually according to business needs, and the preset database operation interface's support for placeholders better supports the configurable function of the deletion execution instruction, the embodiments provided in this disclosure enable the electronic device to conveniently and efficiently respond to business needs and delete target data in the database.
[0059] Please refer to Figure 2 This is a flowchart for obtaining configuration information provided in an embodiment of this disclosure. For example... Figure 2 As shown in the present embodiment, the configuration information in step S101 can be obtained through the following steps S201-S203, which will be described in detail below.
[0060] Step S201: Obtain at least one piece of configuration information from the configuration database used to store configuration information, wherein the configuration database stores at least one piece of configuration information, which is information used to indicate the deletion of data in different databases.
[0061] The database for this configuration can be any database, such as a MySQL database; no special restrictions are imposed here.
[0062] That is, in this embodiment of the disclosure, in order to enable users to flexibly set the configuration information and for electronic devices to easily obtain the configuration information, the configuration information can be stored in a configuration database. The configuration information in the configuration database can be generated by the user through the front-end interface; it should be noted that, in this embodiment of the disclosure, the configuration database used to store the configuration information and the database used to store the business data can be the same database or different databases, without any special limitation here.
[0063] In addition, in order to enable electronic devices to simultaneously delete business data corresponding to different services in different databases, in this embodiment of the disclosure, the configuration database may include at least one piece of configuration information, which may correspond to different databases, that is, it may be information used to instruct the deletion of business data stored in data tables in different databases.
[0064] For example, the configuration database can contain 1-6 configuration entries simultaneously. The first and second configuration entries can be used to indicate the deletion of different business data in database "database1", the third and fourth configuration entries can be used to indicate the deletion of different business data in database "database2", the fifth configuration entry can be used to indicate the deletion of business data in database "database3", and the sixth configuration entry can be used to indicate the deletion of business data in database "database4".
[0065] Understandably, in some embodiments, obtaining at least one piece of configuration information from the configuration database used to store configuration information can be: obtaining the at least one piece of configuration information from the configuration database at preset time intervals. For example, configuration information can be obtained from the configuration database and data deletion can be performed every 24 hours.
[0066] Step S202: Based on the database name corresponding to each configuration information, group the at least one configuration information to obtain at least one configuration information set, wherein the configuration information in each configuration information set corresponds to a database.
[0067] For example, if the configuration database stores the 6 configuration information items mentioned in the example above, grouping these 6 configuration information items according to the database name will yield 4 sets of configuration information, namely {1,2,}, {3,4}, {5}, and {6}.
[0068] Step S203: Obtain a configuration information from at least one set of configuration information as the configuration information to be processed.
[0069] That is, in this embodiment of the disclosure, in order to improve data processing efficiency, after obtaining at least one piece of configuration information from the configuration database at a preset time interval, the deletion of different business data in different databases or the same database can be completed by sequentially obtaining a piece of configuration information and performing data deletion processing on the business data corresponding to the configuration information.
[0070] Since deleting data from different databases requires establishing a database connection first and then deleting the target data based on that database connection, in this embodiment of the disclosure, the configuration information in the configuration information set can be processed sequentially in groups according to the configuration information set obtained above. This avoids the need to frequently switch database connections and cause efficiency loss when two adjacent configuration information sets indicate that business data in different databases should be deleted.
[0071] Using the example above, after obtaining the four configuration information sets through step S202, the configuration information in the first configuration information set, namely {1,2}, can be processed first; then, the configuration information in the second, third, and fourth configuration information sets can be processed.
[0072] In some embodiments, to improve data processing efficiency, after obtaining the above-mentioned configuration information set, a corresponding number of threads can be created simultaneously according to the number of configuration information sets, and different configuration information sets can be processed by the newly created threads simultaneously to concurrently delete business data in different databases. That is, in this embodiment of the present disclosure, after step S202, step S203 can be skipped directly, and instead: the number of sets of the at least one configuration information set is obtained; a preset number of threads are created, the preset number being greater than 0 and less than or equal to the number of sets; the at least one configuration information set is assigned to the preset number of threads; and the preset number of threads delete business data in the database corresponding to the assigned configuration information set according to the configuration information in the assigned configuration information set.
[0073] For example, for the above four sets of configuration information, threads 1 to 4 can be created simultaneously, and the four sets of configuration information can be processed by the four threads one by one to improve data processing efficiency.
[0074] In this embodiment of the disclosure, the configuration information may include enable indication information, which can be used to indicate whether the configuration information is enabled; before performing the above step S102, the method further includes: determining whether the configuration information is enabled according to the enable indication information; if the enable indication information indicates that the configuration information is enabled, performing the step of generating a target deletion execution instruction according to the configuration information.
[0075] That is, considering that business needs may change at any time in practice, the configuration information in the configuration database may be deactivated. Therefore, the configuration information in the configuration database may include activation indication information indicating whether it is enabled. In this way, after the electronic device obtains the configuration information through the above step S101, it can first determine whether the configuration information is enabled based on the activation indication information. If the configuration information is not enabled, the subsequent steps do not need to be performed, so as to further improve data processing efficiency.
[0076] Furthermore, as can be seen from the above description, in this embodiment of the disclosure, the configuration information obtained in step S101 may include the data table name, data field name, and target boundary value. In this embodiment, the step S102 above, which describes generating a target deletion execution instruction based on the configuration information, may include: generating a target deletion execution instruction based on the data table name and data field name, wherein the target deletion execution instruction includes a first placeholder, which is a position reserved for the target boundary value.
[0077] For example, if the configuration information is {database1,tbl1,amount,100 yuan,enabled}, the target deletion statement can be "delete from database1 where amount=?", that is, set String sql1=delete from database1 where amount=?.
[0078] In this implementation, such as Figure 3 As shown, the step S103, which involves sending the target deletion execution command to the database storing the target data based on the preset data operation interface, may include the following steps S301-S302.
[0079] Step S301: Set the target deletion execution command to the parameters of the preset data operation interface.
[0080] In step S302, the target deletion execution command is sent to the database through the preset data operation interface after setting the parameters.
[0081] After receiving the target deletion execution command, in order to improve the execution speed of the command when it is actually executed by the database, the target deletion execution command can be sent to the database for pre-compilation through the preset data operation interface via a pre-established database connection.
[0082] The database connection can be a connection established in advance with the database before the electronic device needs to operate on the database. For example, the database connection "conn1" can be obtained through the following encoded instructions:
[0083] dataSource=getDataSource();
[0084] Connection conn1=dataSource.getConnection();
[0085] After obtaining the database connection, the target deletion execution command can be sent to the database for pre-compilation by setting the parameter of the preset data operation interface, namely the PreparedStatement interface.
[0086] For example, the target deletion command can be pre-compiled by sending it to the database using PreparedStatement ps1 = conn1.prepareStatement(sql1) to improve the execution speed when finally deleting data.
[0087] Please refer to Figure 4 This is a first flowchart of the deletion process provided in an embodiment of this disclosure. For example... Figure 4 As shown, the process of deleting target data in the database according to the target deletion execution instruction in step S104 above includes the following steps: step S401, filling the target boundary value into the position indicated by the first placeholder in the target deletion execution instruction; and step S402, sending a control instruction to the database, wherein the control instruction is used to instruct the database to execute the target deletion execution instruction that fills the target boundary value in order to delete the target data.
[0088] Taking the target deletion execution command as sql1 above as an example, the target boundary value of 100 can be filled into the target deletion statement by using ps1.setInt(1, 100). After the filling process is completed, the database can be instructed to execute the target deletion statement with the filled target boundary value by sending a control command.
[0089] This example demonstrates how to delete a data record with an amount of 100 yuan in database tbl1 of database1. In practice, the database can be instructed to execute a target deletion statement that fills the boundary values by sending the control command "ps1.executeUpdate()" to delete the data record with an amount of 100 yuan in tbl1.
[0090] Please refer to Figure 5 This is a second flowchart illustrating the deletion process provided in an embodiment of this disclosure. For example... Figure 5As shown, in this embodiment, the step S103 above, which involves deleting target data in the database according to the target deletion execution instruction, includes the following steps S501-S503:
[0091] Step S501: Obtain policy information from the configuration information, wherein the policy information includes information for indicating a limit on the number of data to be deleted, and / or information for indicating that data backup should be performed before data deletion.
[0092] Step S502: Select the corresponding strategy execution function according to the strategy information. The strategy execution function is used to perform the function enhancement processing corresponding to the strategy information when deleting target data in the database based on the target deletion execution instruction.
[0093] Step S502: Based on the selected strategy execution interface and target deletion execution instruction, the target data in the database is deleted.
[0094] The strategy execution function, also known as the strategy class, can be a method class based on the Strategy Pattern in software design patterns. It can flexibly perform deletion processing on target data to enhance the deletion processing functionality.
[0095] In other words, to further enhance the flexibility of electronic devices in data deletion processing, the configuration information may also include policy information. This policy information is used to indicate the deletion policy for the target data. The deletion policy is a corresponding function enhancement process when deleting the target data. The deletion policy can correspond to a policy class so that while performing data deletion processing, targeted function enhancement processing can be performed according to business needs, thereby fulfilling special business needs and increasing the compatibility and scalability of the code.
[0096] For example, in some scenarios, although the instruction is to delete target data, the number of data records to be deleted is limited to a certain threshold; in other scenarios, it may be necessary to back up the target data while deleting it. In such scenarios, related technologies typically implement this through hard coding, which is quite complex. However, in this embodiment of the present disclosure, by adding policy information for instructing the execution of deletion processing to the configuration information, the electronic device, upon obtaining the configuration information to delete target data, can select the corresponding policy execution interface based on the policy information and perform the deletion processing on the target data based on the policy execution interface.
[0097] Please refer to Figure 6 This is a flowchart illustrating the storage target deletion of records provided in an embodiment of this disclosure. For example... Figure 6As shown, in some embodiments, after performing the above step S104, the method further includes: step S601, obtaining the target deletion record returned by the database after the deletion process, wherein the target deletion record includes the data record corresponding to the target data deleted in the deletion process; and step S602, storing the target deletion record.
[0098] That is, in this embodiment of the disclosure, when performing deletion processing, the target data can be deleted based on the target deletion statement by means of ResultSet resultSet1 = ps.executeUpdate(), and the target deletion record after database processing can be obtained into resultSet1. Then, the target deletion record can be stored so that data can be recovered based on the target deletion record in the event of accidental deletion.
[0099] Please refer to Figure 7 This is a flowchart of the query processing provided in the embodiments of this disclosure. For example... Figure 7 As shown, in some embodiments, before performing step S104 above, the method may further include the following steps S701-S704:
[0100] Step S701: Based on the configuration information, generate a target query execution instruction corresponding to the target deletion execution instruction;
[0101] Step S702: The target query execution instruction is sent to the database based on the preset data operation interface. The database is also used to pre-compile the target query execution instruction. The target query execution instruction is used to query the number of data records in the database that contain the target data. The target query execution instruction includes a second placeholder that has the same function as the first placeholder.
[0102] The target query execution command can be an SQL statement corresponding to the target deletion execution command mentioned above, used to confirm whether the target data in the database meets the deletion conditions.
[0103] For example, the target query execution command could be String sql2 = select count(*) from database1 where amount = ?.
[0104] The second placeholder functions similarly to the first placeholder mentioned above. Both can be characters used to place the target boundary value in the SQL statement to be executed, so that the database can pre-compile the SQL statement to be executed.
[0105] After obtaining the target query execution instruction, it can be sent to the database for pre-compilation using PreparedStatement ps2 = conn1.prepareStatement(sql2).
[0106] Step S703: Obtain the target quantity based on the configuration information and the target query execution command.
[0107] After precompiling the target query execution instruction, the target boundary condition of limiting the amount to 100 can be filled into the target query execution instruction using the form ps2.setInt(1, 100). After completing this filling process, another control instruction, ps2.executeQuery(), can be used to instruct the database to execute the target query execution instruction that fills the target boundary value, so as to obtain the number of data records with an amount of 100 yuan in tbl1 of database1 as the target quantity.
[0108] Step S704: If the number of targets exceeds a preset threshold, execute the target deletion instruction to delete the target data in the database.
[0109] Considering that if the target data does not exist in the database, there is no need to perform data deletion processing, and since the execution speed of SQL query execution instructions is usually much faster than that of SQL delete execution instructions, in this embodiment of the disclosure, before performing data deletion processing, the target query execution instruction corresponding to the target delete execution instruction can be obtained in advance, and the target number of target data in the database can be queried based on the target query execution instruction. After obtaining the target number, the target number can be compared with a preset threshold to determine whether it is necessary to perform data deletion processing.
[0110] For example, if the preset threshold can be 0, then data deletion can be performed when the target quantity is greater than 0, that is, when the target data is not empty; or, the preset threshold can also be a value such as 10 or 100, without special limitation here.
[0111] Please refer to Figure 8 This is a processing block diagram illustrating the data processing method provided in the embodiments of this disclosure. The following is in conjunction with... Figure 8 The data processing method provided in the embodiments of this disclosure will be illustrated by examples. For instance... Figure 8As shown, in actual implementation, the electronic device can execute the data processing method by executing a scheduled task. Specifically, after the scheduled task starts, step S801 is executed first to query at least one piece of configuration information from the configuration database; then, step S802 is executed to group the at least one piece of configuration information according to the database name corresponding to the at least one piece of configuration information to obtain at least one set of configuration information; after obtaining the at least one set of configuration information, step S803 can be executed to create a database connection for each set of configuration information; then, step S804 is executed to traverse the configuration information in each set of configuration information in groups, that is, to sequentially obtain one piece of configuration information to be processed from each set of configuration information, so as to perform deletion processing on the corresponding target data based on the configuration information.
[0112] like Figure 8 As shown, after obtaining configuration information, it can first be determined whether the configuration information is enabled based on the enable instruction information in the configuration information. If the configuration information is not enabled, the next configuration information is processed. If the configuration information is enabled, step S805 is executed, generating a target query execution instruction based on the configuration information, and obtaining the target quantity corresponding to the target data based on the target query execution instruction. Then, it is determined whether the target data in the database meets the data deletion conditions based on the target quantity, for example, whether the target quantity is greater than a preset threshold, which can be, for example, 100. If the target quantity is greater than the preset threshold, that is, the data deletion conditions are met, step S806 is executed, generating and filling the target deletion execution instruction, and selecting a strategy execution function based on the strategy information in the configuration information. Then, the target data in the database is deleted according to the selected strategy execution function and the target deletion statement.
[0113] After step S806, it is determined whether the configuration information in each configuration information set has been processed. If not, the next configuration information is traversed to continue the corresponding data deletion process. If the processing is completed, step S807 is executed to obtain the operation record result returned by the database after the deletion process and store the operation record result. After that, the current scheduled task is terminated.
[0114] As described above, the data processing method provided in this embodiment allows users to dynamically change the configuration information indicating the target data to be deleted according to business needs during the operation of the data deletion application by setting a configuration database. The electronic device executes the task by retrieving the configuration information from the configuration database. In order to improve data processing efficiency, the pre-compilation of the pre-generated target deletion execution instruction and target query execution instruction by using a preset data operation interface can improve the execution speed when the placeholders contained in the corresponding execution instruction are set as target boundary conditions and sent to the database for execution. In addition, by determining whether data clearing is required based on the target query execution instruction, unnecessary deletion processing can be avoided, thereby enabling the electronic device to perform data deletion processing conveniently and efficiently.
[0115] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.
[0116] In addition, this disclosure also provides a data processing apparatus, an electronic device, and a computer-readable storage medium, all of which can be used to implement any of the data processing methods provided in this disclosure. The corresponding technical solutions and descriptions are described in the corresponding section of the method and will not be repeated here.
[0117] Figure 9 This is a block diagram of a data processing apparatus provided in an embodiment of the present disclosure.
[0118] Reference Figure 9 This disclosure provides a data processing apparatus 900, which includes an acquisition unit 901, a generation unit 902, a pre-compilation unit 903, and an execution unit 904.
[0119] The acquisition unit 901 is used to acquire configuration information to be processed, wherein the configuration information is information used to indicate the target data to be deleted.
[0120] In some embodiments, when acquiring configuration information to be processed, the acquisition unit 901 may be used to: obtain at least one piece of configuration information from a configuration database used to store configuration information, wherein the configuration database stores at least one piece of configuration information, and the at least one piece of configuration information is information used to indicate the deletion of data in different databases; group the at least one piece of configuration information according to the database names corresponding to the at least one piece of configuration information to obtain at least one set of configuration information, wherein the configuration information in each set of configuration information corresponds to a database; and acquire a piece of configuration information from the at least one set of configuration information as configuration information to be processed.
[0121] The generation unit 902 is used to generate a target deletion execution instruction based on the configuration information.
[0122] The pre-compilation unit 903 is used to send the target deletion execution instruction to the database storing the target data based on the preset data operation interface. The database is used to pre-compile the target deletion execution instruction. The preset data operation interface supports placeholders and supports the pre-compilation of the target deletion execution instruction.
[0123] In some embodiments, the configuration information includes a data table name, a data field name, and a target boundary value. The data table name is the name of the data table in the database used to store the target data, the data field name is the name of the data field corresponding to the target data in the data table, and the target boundary value is used to filter the target data from multiple data entries corresponding to the data field. When generating a target deletion execution instruction based on the configuration information, the generation unit 902 can be used to: generate a target deletion execution instruction based on the data table name and the data field name, wherein the target deletion execution instruction includes a first placeholder, which is a reserved position for the target boundary condition. In this embodiment, when the pre-compilation unit 903 sends the target deletion execution instruction to the database storing the target data based on a preset data operation interface, it can be used to: set the target deletion execution instruction as a parameter of the preset data operation interface; and send the target deletion execution instruction to the database through the preset data operation interface with the set parameters.
[0124] The execution unit 904 is used to delete target data in the database according to the target deletion execution instruction.
[0125] In some embodiments, when the execution unit 903 performs target data deletion processing on the database according to the target deletion statement, it can be used to: fill the target boundary conditions to the position indicated by the first placeholder in the target deletion execution instruction; and send a control instruction to the database, wherein the control instruction is used to instruct the database to execute the target deletion execution instruction that fills the target boundary conditions in order to perform target data deletion processing.
[0126] In some embodiments, the configuration information includes policy information, which is used to indicate a deletion policy for the target data. When the execution unit 904 performs deletion processing on the target data in the database according to the target deletion execution instruction, it can be used to: obtain the policy information from the configuration information, wherein the policy information includes information for indicating a limit on the number of data to be deleted, and / or information for indicating that data backup should be performed before data deletion; select a corresponding policy execution function according to the policy information, wherein the policy execution function is used to perform functional enhancement processing corresponding to the policy information when the target data in the database is deleted according to the target deletion execution instruction; and perform deletion processing on the target data in the database based on the selected policy execution function and the target deletion execution statement.
[0127] In some embodiments, the device 900 further includes a storage unit for: acquiring a target deletion record returned by the database after deletion processing, wherein the target deletion record includes a data record corresponding to the target data that was deleted during the deletion processing; and storing the target deletion record.
[0128] In some embodiments, the device 900 further includes a query judgment unit, configured to: generate a target query execution instruction corresponding to a target deletion execution instruction based on configuration information; send the target query execution instruction to a database based on a preset data operation interface, wherein the database is also configured to pre-compile the target query execution instruction, wherein the target query execution instruction is used to query the number of data records in the database containing target data, and the target query execution instruction includes a second placeholder that functions the same as the first placeholder; obtain the target quantity based on the configuration information and the target query execution instruction; and, if the target quantity is greater than a preset threshold, perform a step of deleting the target data in the database according to the target deletion execution instruction.
[0129] In some embodiments, the device 900 further includes an enable determination unit, configured to: determine whether the configuration information is enabled based on the enable indication information in the configuration information; and, if the enable indication information indicates that the configuration information is enabled, execute a step of generating a target deletion execution instruction based on the configuration information.
[0130] Figure 10 This is a block diagram of an electronic device provided in an embodiment of the present disclosure.
[0131] Reference Figure 10This disclosure provides an electronic device 1000, comprising: at least one processor 1001; at least one memory 1002; and one or more I / O interfaces 1003 connected between the processor 1001 and the memory 1002; wherein the memory 1002 stores one or more computer programs executable by the at least one processor 1001, and the one or more computer programs are executed by the at least one processor 1001 to enable the at least one processor 1001 to perform the above-described data processing method.
[0132] This disclosure also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the data processing method described above. The computer-readable storage medium may be volatile or non-volatile.
[0133] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the data processing method described above.
[0134] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).
[0135] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0136] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0137] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.
[0138] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0139] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0140] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0141] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0143] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.
Claims
1. A data processing method, characterized by, The method comprises: obtaining configuration information to be processed, wherein the configuration information is information used for indicating target data to be deleted, the configuration information comprises a data table name, a data field name and a target boundary value, and the target boundary value is used for screening the target data from a plurality of data corresponding to the data field; generating a target deletion execution instruction according to the configuration information, wherein the target deletion execution instruction comprises a first placeholder, and the first placeholder is a position reserved for the target boundary value; sending the target deletion execution instruction to a database storing the target data based on a preset data operation interface, wherein the database is used for pre-compiling the target deletion execution instruction, the preset data operation interface supports placeholders and pre-compiling the target deletion execution instruction; and performing deletion processing on the target data in the database according to the target deletion execution instruction.
2. The method of claim 1, wherein, The data table name is the name of a data table in the database used for storing the target data, and the data field name is the name of a data field in the data table corresponding to the target data. The generating of the target deletion execution instruction according to the configuration information comprises: generating the target deletion execution instruction according to the data table name and the data field name. The sending of the target deletion execution instruction to the database based on the preset data operation interface comprises: setting the target deletion execution instruction as a parameter of the preset data operation interface; and sending the target deletion execution instruction to the database through the preset data operation interface after the parameter is set.
3. The method of claim 2, wherein, The performing of the deletion processing on the target data in the database according to the target deletion execution instruction comprises: filling the target boundary value into a position indicated by the first placeholder in the target deletion execution instruction; and sending a control instruction to the database, wherein the control instruction is used for instructing the database to execute the target deletion execution instruction filled with the target boundary value to perform the deletion processing on the target data.
4. The method of claim 1, wherein, The configuration information comprises policy information used for indicating a deletion policy for the target data. The performing of the deletion processing on the target data in the database according to the target deletion execution instruction comprises: obtaining the policy information from the configuration information, wherein the policy information comprises information used for indicating a limit on the number of data deletions and / or information used for indicating data backup before data deletion; and selecting a corresponding policy execution function according to the policy information, wherein the policy execution function is used for performing a function enhancement processing corresponding to the policy information when the deletion processing on the target data in the database is performed based on the target deletion execution instruction; and performing the deletion processing on the target data in the database based on the selected policy execution function and the target deletion execution instruction.
5. The method of claim 2, wherein, Before the step of deleting the target data in the database according to the target deletion execution instruction, the method further includes: Based on the configuration information, a target query execution instruction corresponding to the target deletion execution instruction is generated; Based on the preset data operation interface, the target query execution instruction is sent to the database. The database is also used to pre-compile the target query execution instruction. The target query execution instruction is used to query the number of data records in the database that contain the target data. The target query execution instruction includes a second placeholder that has the same function as the first placeholder. Based on the configuration information and the target query execution instruction, the target quantity is obtained; If the number of targets exceeds a preset threshold, the step of deleting the target data in the database according to the target deletion execution instruction is executed.
6. The method of claim 1, wherein, The process of obtaining the configuration information to be processed includes: Obtain at least one piece of configuration information from the configuration database used to store configuration information, wherein the configuration database stores at least one piece of configuration information, and the at least one piece of configuration information is information used to indicate the deletion of data in different databases; Based on the database names corresponding to each of the at least one configuration information, the at least one configuration information is grouped to obtain at least one set of configuration information, wherein the configuration information in each set of configuration information corresponds to a database; Obtain a configuration information from the at least one set of configuration information as the configuration information to be processed.
7. The method according to any one of claims 1 to 6, characterized in that, The configuration information includes an enable indication, which indicates whether the configuration information is enabled. Before the step of generating the target deletion execution instruction based on the configuration information, the method further includes: Based on the activation instruction information, determine whether the configuration information is enabled; If the enable indication information indicates that the configuration information is enabled, the step of generating the target deletion execution instruction based on the configuration information is executed.
8. A data processing apparatus, characterized by, include: An acquisition unit is used to acquire configuration information to be processed, wherein the configuration information is information used to indicate target data to be deleted, and the configuration information includes a data table name, a data field name, and a target boundary value, wherein the target boundary value is used to filter the target data from multiple data corresponding to the data field; The generation unit is configured to generate a target deletion execution instruction based on the configuration information. The target deletion execution instruction includes a first placeholder, which is a reserved position for the target boundary value. A pre-compilation unit is used to send the target deletion execution instruction to a database storing the target data based on a preset data operation interface. The database is used to pre-compile the target deletion execution instruction. The preset data operation interface supports placeholders and supports pre-compiling the target deletion execution instruction. An execution unit is used to delete the target data in the database according to the target deletion execution instruction.
9. An electronic device, comprising: include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the data processing method as described in any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed by a processor, it implements the data processing method as described in any one of claims 1-7.