Data processing method and device, electronic equipment and storage medium

文档序号:168713 发布日期:2021-10-29 浏览:8次 中文

阅读说明:本技术 一种数据处理方法、装置、电子设备及存储介质 (Data processing method and device, electronic equipment and storage medium ) 是由 王永兴 于 2021-07-23 设计创作,主要内容包括:本公开关于一种数据处理方法、装置、电子设备及存储介质,涉及计算机技术领域,该方法包括:获取数据处理指令,该数据处理指令包括目标操作的类型和目标业务的标识;响应于该数据处理指令,获取与该目标操作的类型对应的方法名、该目标业务对应的待处理记录的分片键信息、该待处理记录的目标属性信息以及该目标业务对应的描述信息;基于该方法名、该描述信息以及该目标属性信息,得到初始查询语句;根据该初始查询语句和该分片键信息,生成目标查询语句;调用该目标查询语句,对该待处理记录进行该目标操作。本公开中,电子设备能够准确地确定出需要进行数据处理的记录,提升数据处理的有效性。(The present disclosure relates to a data processing method, an apparatus, an electronic device and a storage medium, and relates to the technical field of computers, wherein the method comprises: acquiring a data processing instruction, wherein the data processing instruction comprises the type of target operation and the identifier of a target service; responding to the data processing instruction, and acquiring a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service; obtaining an initial query statement based on the method name, the description information and the target attribute information; generating a target query statement according to the initial query statement and the fragment key information; and calling the target query statement, and performing the target operation on the record to be processed. According to the data processing method and device, the electronic equipment can accurately determine the record needing data processing, and the effectiveness of data processing is improved.)

1. A data processing method applied to electronic equipment is characterized by comprising the following steps:

acquiring a data processing instruction, wherein the data processing instruction comprises the type of target operation and the identifier of a target service;

responding to the data processing instruction, acquiring a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service, wherein the description information comprises a plurality of attribute information for uniquely identifying the record to be processed;

obtaining an initial query statement based on the method name, the description information and the target attribute information;

generating a target query statement according to the initial query statement and the fragment key information;

and calling the target query statement, and performing the target operation on the record to be processed.

2. The data processing method of claim 1, wherein the deriving an initial query statement based on the method name, the description information, and the target attribute information comprises:

acquiring prefix information of the original data table of the record to be processed based on the description information;

and combining the prefix information, the method name and the target attribute information according to a preset rule to generate the initial query statement.

3. The data processing method according to claim 2, wherein the generating a target query statement according to the initial query statement and the sharded key information comprises:

determining a plurality of data tables corresponding to the original data table;

determining a target data table from the plurality of data tables according to the fragment key information, wherein the target data table is a data table in which the records to be processed are stored;

and generating the target query statement according to the target data table and the initial query statement.

4. The data processing method according to claim 3, wherein after said determining a target data table from said plurality of data tables according to said shard key information, said method further comprises:

and determining the position of the record to be processed in the target data table according to the target attribute information.

5. The data processing method of claim 1, wherein the target operation is an update operation, and prior to the fetching of the data processing instruction, the method further comprises:

and clearing all attribute information of the records to be processed stored in the application program so as to execute the updating operation according to the target query statement.

6. The data processing method of claim 1, wherein the target operation is an update operation, and prior to the fetching of the received data processing instruction, the method further comprises:

and adding an annotation to the method corresponding to the type of the target operation, or adding an annotation to the method for calling the target operation, wherein the annotation is used for indicating to remove all the attribute information of the to-be-processed record stored in the application program.

7. A data processing device is characterized by comprising an acquisition module, a determination module and a processing module;

the acquisition module is configured to acquire a data processing instruction, wherein the data processing instruction comprises a type of target operation and an identifier of a target service;

the obtaining module is further configured to, in response to the data processing instruction, obtain a method name corresponding to the type of the target operation, fragment key information of a to-be-processed record corresponding to the target service, target attribute information of the to-be-processed record, and description information corresponding to the target service, where the description information includes a plurality of attribute information for uniquely identifying the to-be-processed record;

the determination module is configured to obtain an initial query statement based on the method name, the description information and the target attribute information;

the determining module is further configured to generate a target query statement according to the initial query statement and the fragment key information;

the processing module is configured to call the target query statement and perform the target operation on the record to be processed.

8. An electronic device, characterized in that the electronic device comprises:

a processor;

a memory configured to store the processor-executable instructions;

wherein the processor is configured to execute the instructions to implement the data processing method of any one of claims 1-6.

9. A computer-readable storage medium having instructions stored thereon, wherein the instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the data processing method of any one of claims 1-6.

10. A computer program product, characterized in that it comprises computer instructions which, when run on a processor of an electronic device, enable the electronic device to perform the data processing method of any one of claims 1-6.

Technical Field

The present disclosure relates to the field of computer technologies, and in particular, to a data processing method and apparatus, an electronic device, and a storage medium.

Background

Currently, a database stores a plurality of recorded data, and each data can be uniquely identified by a value of a primary key. Therefore, when the data of a record is updated, the record can be searched according to the value of the primary key and the updating operation can be executed.

However, when one data table is split into a plurality of data tables, the value of the primary key may not identify the uniqueness of the data, i.e., there may be records in the plurality of data tables where the values of the primary keys are the same. Thus, multiple records may be found according to the value of the primary key, and the updating operation is performed on the multiple records, which may affect the accuracy of data processing.

Disclosure of Invention

The present disclosure provides a data processing method, an apparatus, an electronic device, and a storage medium, which solve the technical problem in the prior art that the accuracy of data processing is affected by searching and updating multiple records according to the value of a primary key.

The technical scheme of the embodiment of the disclosure is as follows:

according to a first aspect of embodiments of the present disclosure, a data processing method is provided. The method can comprise the following steps: acquiring a data processing instruction, wherein the data processing instruction comprises the type of target operation and the identifier of a target service; responding to the data processing instruction, acquiring a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service, wherein the description information comprises a plurality of attribute information for uniquely identifying the record to be processed; obtaining an initial query statement based on the method name, the description information and the target attribute information; generating a target query statement according to the initial query statement and the fragment key information; and calling the target query statement, and performing the target operation on the record to be processed.

Optionally, the obtaining the initial query statement based on the method name, the description information, and the target attribute information specifically includes: acquiring prefix information of the original data table of the record to be processed based on the description information; and combining the prefix information, the method name and the target attribute information according to a preset rule to generate the initial query statement.

Optionally, the generating a target query statement according to the initial query statement and the fragment key information specifically includes: determining a plurality of data tables corresponding to the original data table; determining a target data table from the plurality of data tables according to the fragment key information, wherein the target data table is a data table in which the record to be processed is stored; and generating the target query statement according to the target data table and the initial query statement.

Optionally, the data processing method further includes: and determining the position of the record to be processed in the target data table according to the target attribute information.

Optionally, the target operation is an update operation, and before the data processing instruction is obtained, the data processing method further includes: and clearing all attribute information of the record to be processed stored in the application program so as to execute the updating operation according to the target query statement.

Optionally, the target operation is an update operation, and before the data processing instruction is obtained, the data processing method further includes: and adding an annotation to the method corresponding to the type of the target operation, or adding an annotation to the method for calling the target operation, wherein the annotation is used for indicating that all attribute information of the to-be-processed record stored in the application program is cleared.

Optionally, the all data information of the to-be-processed record includes primary key information of the to-be-processed record, and the clearing all attribute information of the to-be-processed record stored in the application program specifically includes: and clearing the primary key information of the record to be processed stored in the application program.

Optionally, before the data processing instruction is obtained, the data processing method further includes: obtaining the types of a plurality of operations, wherein the target operation is one of the plurality of operations; and naming the methods corresponding to the types of the multiple operations according to a preset naming rule, so that the method name corresponding to the type of the target operation is obtained under the condition of obtaining the type of the target operation.

According to a second aspect of the embodiments of the present disclosure, there is provided a data processing apparatus. The apparatus may include: the device comprises an acquisition module, a determination module and a processing module; the acquisition module is configured to acquire a data processing instruction, wherein the data processing instruction comprises a type of target operation and an identifier of a target service; the obtaining module is further configured to, in response to the data processing instruction, obtain a method name corresponding to the type of the target operation, fragment key information of a to-be-processed record corresponding to the target service, target attribute information of the to-be-processed record, and description information corresponding to the target service, where the description information includes a plurality of attribute information for uniquely identifying the to-be-processed record; the determining module is configured to obtain an initial query statement based on the method name, the description information and the target attribute information; the determining module is further configured to generate a target query statement according to the initial query statement and the fragment key information; the processing module is configured to invoke the target query statement and perform the target operation on the record to be processed.

Optionally, the obtaining module is specifically configured to obtain prefix information of the original data table of the record to be processed based on the description information; the determining module is specifically configured to combine the prefix information, the method name, and the target attribute information according to a preset rule to generate the initial query statement.

Optionally, the determining module is specifically configured to determine a plurality of data tables corresponding to the original data table; the determining module is specifically configured to determine a target data table from the multiple data tables according to the fragment key information, where the target data table is a data table in which the record to be processed is stored; the determining module is further specifically configured to generate the target query statement according to the target data table and the initial query statement.

Optionally, the determining module is further configured to determine a position of the to-be-processed record in the target data table according to the target attribute information.

Optionally, the target operation is an update operation, and the data processing apparatus further includes a clearing module; the clearing module is configured to clear all attribute information of the to-be-processed record stored in the application program so as to execute the updating operation according to the target query statement.

Optionally, the target operation is an update operation, and the data processing apparatus further includes an annotation adding module; the annotation adding module is configured to add an annotation to the method corresponding to the type of the target operation, or add an annotation to the method calling the target operation, where the annotation is used to indicate that all attribute information of the to-be-processed record stored in the application program is cleared.

Optionally, the clearing module is specifically configured to clear the primary key information of the to-be-processed record stored in the application program.

Optionally, the obtaining module is further configured to obtain a type of a plurality of operations, the target operation being one of the plurality of operations; the processing module is further configured to name the methods corresponding to the types of the multiple operations according to a preset naming rule, so that the method name corresponding to the type of the target operation is obtained when the type of the target operation is obtained.

According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, which may include: a processor and a memory configured to store processor-executable instructions; wherein the processor is configured to execute the instructions to implement any of the above-described optional data processing methods of the first aspect.

According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having instructions stored thereon, which, when executed by an electronic device, enable the electronic device to perform any one of the above-mentioned optional data processing methods of the first aspect.

According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the optional data processing method of any one of the first aspects.

The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:

based on any one of the above aspects, in the present disclosure, the electronic device may obtain a data processing instruction, where the data processing instruction includes a type of the target operation and an identifier of the target service; responding to the data processing instruction, the electronic equipment acquires a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service; the electronic equipment obtains an initial query statement based on the method name, the description information and the target attribute information, and generates a target query statement according to the initial query statement and the fragment key information; and then the electronic equipment calls the target query statement to perform the target operation on the record to be processed. In the embodiment of the disclosure, the electronic device may determine a unique record (i.e., a to-be-processed record corresponding to a target service) in the target data table based on the method name, the description information, the target attribute information, and the fragment key information, and obtain a corresponding query statement, so as to perform a target operation on the to-be-processed record, thereby accurately determining a record that needs to be subjected to data processing, and improving the effectiveness of data processing.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.

Fig. 1 is a schematic flow chart illustrating a data processing method provided by an embodiment of the present disclosure;

FIG. 2 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 3 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 4 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 5 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 6 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 7 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

FIG. 8 is a flow chart illustrating a further data processing method provided by an embodiment of the present disclosure;

fig. 9 is a schematic structural diagram of a data processing apparatus provided in an embodiment of the present disclosure;

fig. 10 is a schematic structural diagram of another data processing apparatus provided in the embodiment of the present disclosure.

Detailed Description

In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, and/or components.

The data to which the present disclosure relates may be data that is authorized by a user or sufficiently authorized by parties.

As described in the background, since in the related art, when one data table is split into a plurality of data tables, the value of the primary key may not identify the uniqueness of a certain data. Thus, multiple records may be looked up and updated based on the value of the primary key. If the user only needs to update one record at this time, it indicates that the update (or data processing) of the record in the prior art is inaccurate, and user experience is affected.

Based on this, the embodiments of the present disclosure provide a data processing method, where an electronic device may obtain a data processing instruction, where the data processing instruction includes a type of a target operation and an identifier of a target service; responding to the data processing instruction, the electronic equipment acquires a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service; the electronic equipment obtains an initial query statement based on the method name, the description information and the target attribute information, and generates a target query statement according to the initial query statement and the fragment key information; and then the electronic equipment calls the target query statement to perform the target operation on the record to be processed. In the embodiment of the disclosure, the electronic device may determine a unique record (i.e., a to-be-processed record corresponding to a target service) in the target data table based on the method name, the description information, the target attribute information, and the fragment key information, and obtain a corresponding query statement, so as to perform a target operation on the to-be-processed record, thereby accurately determining a record that needs to be subjected to data processing, and improving the effectiveness of data processing.

The data processing method, the data processing device, the electronic device and the storage medium provided by the embodiment of the disclosure are applied to a scene in which a target operation (for example, an update operation) needs to be performed on a certain record in a database. When a data processing instruction is obtained, a target query statement may be called according to the method provided by the embodiment of the present disclosure, and a target operation is performed on a record to be processed.

The data processing method provided by the embodiment of the disclosure is exemplarily described below with reference to the accompanying drawings:

as shown in fig. 1, a data processing method provided by the embodiment of the present disclosure may include S101-S105.

S101, the electronic equipment acquires a data processing instruction.

Wherein the data processing instruction comprises a type of the target operation and an identification of the target service.

It should be understood that the types of target operations include query operations, update operations, delete operations, and the like, which can perform relevant processing on records (particularly, recorded data) in the database. The identification of the target service is used to identify the uniqueness of the target service.

S102, responding to a data processing instruction, the electronic equipment acquires a method name corresponding to the type of target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service.

Wherein the description information includes a plurality of attribute information uniquely identifying the record to be processed.

It is understood that different operation types may correspond to different method names, and the electronic device may determine and acquire a method name corresponding to a type of a target operation based on the type of the target operation.

In an implementation manner of the embodiment of the present disclosure, the fragment key information of different records corresponding to the target service may be different, and different fragment key information may correspond to different data tables. When the electronic device is capable of determining a plurality of data tables corresponding to (divided) a certain original data table, the divided data table corresponding to (or belonging to) a record in the original data table may be determined based on the fragment key information of the record, and then a target operation may be performed on the record in the divided data table.

It is understood that the pending record may correspond to a plurality of attributes, and one attribute may correspond to a column in the target data table. When the electronic device acquires certain attribute information (e.g., target attribute information) of a record to be processed, the position of the record to be processed in the target data table may be determined based on the attribute information.

Optionally, the fragment key information may be represented in the form of a fragment key value, that is, the fragment key information of a record is a value of a fragment key corresponding to the record; similarly, the attribute information may also be represented in the form of an attribute value, for example, the target attribute information of a record is the value of the target attribute corresponding to the record.

Optionally, the description information corresponding to the target service may be Java class description information, and the Java class description information may include a table name of a data table (which may be understood as an original data table of the record to be processed) corresponding to the Java class and a plurality of fields for describing attributes. Specifically, an attribute may correspond to a column in the original data table.

It can be understood that a Java class is the most basic unit in an object-oriented language, and can be used to describe data of a certain record (for example, a record to be processed) corresponding to a target service.

In one implementation, when data of a certain service (e.g., a video service) needs to be acquired (or queried), the description information corresponding to the target service may be understood as Java class description information corresponding to the video service.

S103, the electronic equipment obtains an initial query statement based on the method name, the description information and the target attribute information.

It should be understood that the method name is a method name of the target operation, the description information is description information corresponding to the target, and the target attribute information is target attribute information of a record to be processed corresponding to the target service.

It should be noted that the initial query statement and the target query statement in the embodiments of the present disclosure are not limited to the query operation statement. In the embodiment of the present disclosure, the electronic device may generate or obtain multiple statements used for performing relevant operations (for example, query operations, update operations, deletion operations, and the like) on a certain record (specifically, data of the record), and all the multiple statements are referred to as query statements, and a description in the following embodiment is not repeated.

Alternatively, the query statement (including the initial query statement and the target query statement) may be a Structured Query Language (SQL) statement.

And S104, the electronic equipment generates a target query statement according to the initial query statement and the fragment key information.

In connection with the above description of the embodiments, it should be understood that the slice key information is used to characterize the target data table in which the record to be processed is stored. That is, the electronic device may determine the target data table based on the fragment key information, and may further perform a target operation on the record to be processed in the target data table.

And S105, the electronic equipment calls a target query statement and performs target operation on the record to be processed.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as known from S101 to S105, the electronic device may obtain a data processing instruction, where the data processing instruction includes a type of a target operation and an identifier of a target service; responding to the data processing instruction, the electronic equipment acquires a method name corresponding to the type of the target operation, fragment key information of a record to be processed corresponding to the target service, target attribute information of the record to be processed and description information corresponding to the target service; the electronic equipment obtains an initial query statement based on the method name, the description information and the target attribute information, and generates a target query statement according to the initial query statement and the fragment key information; and then the electronic equipment calls the target query statement to perform the target operation on the record to be processed. In the embodiment of the disclosure, the electronic device may determine a unique record (i.e., a to-be-processed record corresponding to a target service) in the target data table based on the method name, the description information, the target attribute information, and the fragment key information, and obtain a corresponding query statement, so as to perform a target operation on the to-be-processed record, thereby accurately determining a record that needs to be subjected to data processing, and improving the effectiveness of data processing.

With reference to fig. 1, as shown in fig. 2, before the electronic device obtains the data processing instruction, the data processing method provided in the embodiment of the present disclosure may further include S106 to S107.

S106, the electronic equipment acquires a plurality of operation types.

Wherein the target operation is one of the plurality of operations.

In conjunction with the description of the above embodiments, it should be understood that the types of target operations include operations such as query operations, update operations, and delete operations, which can perform relevant processing on records (specifically, data of the records) in the database. I.e., the types of the plurality of operations may include a query operation, an update operation, a delete operation, and the like.

S107, the electronic equipment names the methods corresponding to the operation types respectively according to a preset naming rule, so that the electronic equipment obtains the method names corresponding to the types of the target operation under the condition that the types of the target operation are obtained.

It is understood that each operation type (i.e., each operation type) may correspond to a method, and the electronic device may name each method according to the preset naming rule (i.e., configure a method name for each method). Further, when the electronic device acquires a type of a certain operation (for example, a target operation), the electronic device may acquire a method name corresponding to the type of the target operation.

In an implementation manner of the embodiment of the present disclosure, the electronic device may name a method corresponding to each operation type according to a naming rule of the Spring-data-jpa (or configure a method name for each operation type), and further, after the type of the target operation is obtained by the Spring-data-jpa, the method name may be obtained based on the type of the target operation, and further, a generation process of a related query statement is completed based on the method name and the like.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as known from S106 to S107, the electronic device may obtain a plurality of operation types, and name the methods corresponding to the operation types according to the preset naming rules. In the embodiment of the present disclosure, the electronic device names the methods corresponding to the types of multiple operations (including the target operation), so that when the electronic device acquires the data processing instruction (specifically, acquires the type of the target operation), the method name can be acquired based on the type of the target operation, the method name corresponding to the type of the target operation can be accurately acquired, and then the related query statement can be accurately determined.

With reference to fig. 1, as shown in fig. 3, in an implementation manner of the embodiment of the present disclosure, the electronic device obtains an initial query statement based on the method name, the description information, and the target attribute information, and specifically includes S1031 to S1032.

And S1031, the electronic equipment acquires prefix information of the original data table of the record to be processed based on the description information.

With reference to the description of the foregoing embodiment, it should be understood that the description information corresponding to the target service may include a table name of an original data table of the record to be processed (that is, a data table before the record to be processed is divided), and the table name may also be understood as prefix information of the original data table, that is, may be used to characterize to which original data table the record to be processed belongs. After the electronic device acquires the description information, the electronic device may acquire prefix information of the original data table. In this manner, the electronic device can determine to which raw data table the pending record belongs.

S1032, the electronic equipment combines the prefix information, the method name and the target attribute information according to a preset rule to generate an initial query statement.

In an implementation manner of the embodiment of the present disclosure, the spring-data-jpa may generate an initial SQL statement according to prefix information (i.e., name) of an original data table included in the Java class description information, a method name corresponding to a type of a target operation, and target attribute information.

Exemplarily, assuming that prefix information of the original data table is user, and target attribute information is user _ id ═ 2, a method name of the target operation is: findbyugerid, the type of target operation, is a query operation, and the semantics of the method of the query operation can be understood as querying the information of the user according to userid. At this time, the electronic device (specifically, spring-data-jpa) may generate an initial SQL statement: select from user where user id is 2.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as can be seen from S1031-S1032, the electronic device may obtain prefix information of the original data table of the record to be processed (i.e. the data table before being divided that includes the record to be processed) based on the description information corresponding to the target, and combine the prefix information, the method name, and the target attribute information according to a preset rule to generate the initial query statement. In the embodiment of the disclosure, the electronic device may determine the original data table of the record to be processed based on the prefix information, and generate the query statement capable of operating the record to be processed from the original data table in combination with the method name and the target attribute information, so that generation efficiency of the initial query statement can be improved, and generation efficiency of the target query statement can be improved.

With reference to fig. 3, as shown in fig. 4, in an implementation manner of the embodiment of the present disclosure, the electronic device generates a target query statement according to the initial query statement and the fragment key information, which specifically includes S1041-S1043.

S1041, the electronic device determines a plurality of data tables corresponding to the original data tables.

It should be understood that the electronic device may split the original data table into a plurality of data tables based on a preset table splitting rule, and specifically, allocate different records to the plurality of data tables.

Alternatively, the preset table partitioning rule may be a modular operation, that is, different records are partitioned into different data tables by taking the remainder.

S1042, the electronic device determines a target data table from the multiple data tables according to the fragment key information.

The target data table is a data table in which the record to be processed is stored.

It should be understood that the pending record may be assigned to one of the plurality of data tables (i.e., the target data table).

Specifically, the electronic device may determine the number of the plurality of data tables, determine a remainder corresponding to the shard key information according to the shard key information, and determine that the target data table is a fourth data table of the plurality of data tables based on the remainder.

Exemplarily, it is assumed that the original data table corresponds to 3 data tables, which are the first data table, the second data table, and the third data table. Further, suppose that the fragment key information of the record to be processed is 11,11/3 and 2, which indicates that the record to be processed is a record included in the second data table, the electronic device determines that the second data table is the target data table.

S1043, the electronic device generates a target query statement according to the target data table and the initial query statement.

In one implementation of the disclosed embodiments, ShardingSphere (the software that is open source on the GitHub) may generate the target query statement based on the name of the target data table and the initial query statement.

Illustratively, in conjunction with the example in S1032, the target SQL statement generated by the electronic device (specifically, ShardingSphere) is select from _ user _2 _ user _ id ═ 2. Wherein, user _2 is the name of the target data table.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: from S1041-S1042, the electronic device may determine a plurality of data tables corresponding to the original data table, then determine a target data table from the plurality of data tables according to the shard key information, and generate a target query statement according to the target data table and the initial query statement. In the embodiment of the present disclosure, the electronic device may determine, according to the fragment key information, a unique data table (i.e., a target data table) corresponding to the record to be processed, and may generate the target query statement in combination with the initial query statement. The target data table can be conveniently and quickly determined, and accurate and effective target query sentences can be generated.

With reference to fig. 4, as shown in fig. 5, after the electronic device determines the target data table from the multiple data tables according to the fragment key information, the data processing method provided by the embodiment of the present disclosure may further include S108.

And S108, the electronic equipment determines the position of the record to be processed in the target data table according to the target attribute information.

With reference to the description of the foregoing embodiment, it should be understood that the fragment key information of the record to be processed may be used to determine a target data table (that is, a data table corresponding to the record to be processed is included), and the description information corresponding to the target service includes a plurality of attribute information that can uniquely identify the record to be processed. In the embodiment of the disclosure, the electronic device may determine (or select) target attribute information from a plurality of attribute information corresponding to the record to be processed, and then determine the position of the record to be processed in the target data table based on the target attribute information.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as can be seen from S108, the electronic device may determine the position of the to-be-processed record in the target data table according to the target attribute information. In the embodiment of the present disclosure, the electronic device determines the position of the record to be processed in the target data table according to the target attribute information, that is, may determine a unique record (that is, the record to be processed) from the target data table, and further perform the target operation on the record to be processed. The position of the record to be processed in the target data table can be accurately determined, and the accuracy of data processing is further improved.

With reference to fig. 1, as shown in fig. 6, in an implementation manner of the embodiment of the present disclosure, the target operation is an update operation, and before the electronic device obtains the data processing instruction, the data processing method provided by the embodiment of the present disclosure further includes S109.

And S109, the electronic equipment clears all attribute information of the records to be processed stored in the application program so as to execute updating operation according to the target query statement.

It should be understood that for an update operation, two cases can be distinguished. In one case, the data corresponding to the record is updated directly without reading (i.e. querying), and this time, the updating can be performed according to the method described in the above embodiment.

In another case, it is necessary to perform a query operation on the record to be processed, that is, query and read data of the record to be processed, and then store the data in a cache (or a memory) of the application program, where the data includes the primary key information of the record to be processed. When the electronic device obtains the data processing instruction, if the primary key information is not cleared, the electronic device (specifically, the spring-data-jpa) may perform an update operation on the record to be processed according to the primary key information, and based on the description in the background art, it should be understood that the primary key information may not identify the uniqueness of the record, that is, at this time, the electronic device may perform an update operation on multiple records in multiple data tables, which may still affect the accuracy of data processing.

In this embodiment of the present disclosure, before the electronic device obtains the data processing instruction, all attribute information of the to-be-processed record stored in the application program (that is, the attribute information includes the primary key information of the to-be-processed record) is cleared, so that the electronic device cannot perform an update operation based on the primary key information, that is, the to-be-processed record may be updated based on the target query statement generated in the above embodiment.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as can be seen from S109, the electronic device may clear all attribute information of the to-be-processed records stored in the application program, so as to perform the update operation according to the target query statement. In the embodiment of the disclosure, since all the attribute information includes the primary key information of the record to be processed, the electronic device cannot execute the update operation of the record to be processed based on the primary key information, and can reasonably call the target query statement generated in the disclosure to complete the update operation of the record to be processed, the update operation of the record to be processed can be accurately performed, and the user experience is improved.

With reference to fig. 1 and as shown in fig. 7, in an implementation manner of the embodiment of the present disclosure, the target operation is an update operation, and before the electronic device obtains the data processing instruction, the data processing method provided by the embodiment of the present disclosure further includes S110.

S110, adding annotations to the method corresponding to the type of the target operation by the electronic equipment, or adding annotations to the method for calling the target operation.

Wherein the annotation is used for indicating that all attribute information of the to-be-processed record stored in the application program is cleared.

It can be understood that when an operation is executed, a method corresponding to the type of another operation is required to call a method corresponding to the type of the operation, for example, method a calls method B, so as to implement the operation corresponding to method B. When the target operation is an update operation, a comment may be added to a method of the update operation or a method calling the update operation, and the comment may be understood as a tag.

When the electronic device detects the annotation, all attribute information of the pending record stored in the application may be cleared.

In an implementation manner of the embodiment of the present disclosure, the annotation may be @ ClearCacheBeforeUpdate, and when the electronic device detects the annotation, the method entity manager.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as known from S110, the electronic device may add an annotation to the method corresponding to the type of the target operation, or add an annotation to the method calling the target operation, where the annotation is used to indicate that all attribute information of the to-be-processed record stored in the application program is to be cleared. In the embodiment of the present disclosure, since all the attribute information includes the primary key information of the record to be processed, the electronic device cannot execute the update operation of the record to be processed based on the primary key information, and can reasonably call the target query statement generated in the present disclosure to complete the update operation of the record to be processed, and can accurately perform the update operation on the only record to be processed, thereby improving the accuracy of data processing.

With reference to fig. 6 and as shown in fig. 8, in an implementation manner of the embodiment of the present disclosure, the clearing, by the electronic device, all attribute information of the to-be-processed record stored in the application program may specifically include S1091.

S1091, the electronic equipment clears the primary key information of the record to be processed stored in the application program.

It should be understood that the above-mentioned electronic device has a main role of clearing all attribute information of the to-be-processed record stored in the application program, that is, clearing the primary key information included in the all attribute information. In the embodiment of the present disclosure, the electronic device may directly clear the primary key information of the to-be-processed record stored in the application program, so that the electronic device cannot execute the update operation based on the primary key information, and may perform the update operation on the to-be-processed record based on the target query statement generated in the above embodiment.

The technical scheme provided by the embodiment can at least bring the following beneficial effects: as known from S1091, the electronic device may clear the primary key information of the pending record stored in the application. In the embodiment of the disclosure, the electronic device clears the primary key information of the record to be processed, so that the electronic device cannot execute the updating operation of the record to be processed based on the primary key information, and can reasonably call the target query statement generated in the disclosure to complete the updating operation of the record to be processed, thereby accurately and effectively updating the record to be processed and improving the effectiveness of data processing.

It is understood that, in practical implementation, the electronic device according to the embodiments of the present disclosure may include one or more hardware structures and/or software modules for implementing the corresponding data processing methods, and these hardware structures and/or software modules may constitute an electronic device. Those of skill in the art will readily appreciate that the present disclosure can be implemented in hardware or a combination of hardware and computer software for implementing the exemplary algorithm steps described in connection with the embodiments disclosed herein. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.

Based on such understanding, the embodiment of the present disclosure also provides a data processing apparatus, and fig. 9 shows a schematic structural diagram of the data processing apparatus provided by the embodiment of the present disclosure. As shown in fig. 9, the data processing apparatus 10 may include: an acquisition module 101, a determination module 102 and a processing module 103.

The obtaining module 101 is configured to obtain a data processing instruction, where the data processing instruction includes a type of a target operation and an identifier of a target service.

The obtaining module 101 is further configured to, in response to the data processing instruction, obtain a method name corresponding to the type of the target operation, fragment key information of a to-be-processed record corresponding to the target service, target attribute information of the to-be-processed record, and description information corresponding to the target service, where the description information includes a plurality of attribute information for uniquely identifying the to-be-processed record.

A determining module 102 configured to obtain an initial query statement based on the method name, the description information, and the target attribute information.

The determining module 102 is further configured to generate a target query statement according to the initial query statement and the sharding key information.

And the processing module 103 is configured to call the target query statement and perform the target operation on the record to be processed.

Optionally, the obtaining module 101 is specifically configured to obtain prefix information of the original data table of the record to be processed based on the description information.

The determining module 102 is specifically configured to combine the prefix information, the method name, and the target attribute information according to a preset rule to generate the initial query statement.

Optionally, the determining module 102 is specifically further configured to determine a plurality of data tables corresponding to the original data table.

The determining module 102 is specifically further configured to determine a target data table from the plurality of data tables according to the fragment key information, where the target data table is a data table in which records to be processed are stored.

The determining module 102 is further specifically configured to generate the target query statement according to the target data table and the initial query statement.

Optionally, the determining module 102 is further configured to determine, according to the target attribute information, a position of the record to be processed in the target data table.

Optionally, the target operation is an update operation, and the data processing apparatus 10 further includes a clearing module 104.

A clearing module 104 configured to clear all attribute information of the to-be-processed record stored in the application program so as to execute the updating operation according to the target query statement.

Optionally, the target operation is an update operation, and the data processing apparatus 10 further includes an annotation adding module 105.

And the annotation adding module 105 is configured to add an annotation to the method corresponding to the type of the target operation, or add an annotation to the method calling the target operation, where the annotation is used to indicate that all the attribute information of the to-be-processed record stored in the application program is cleared.

Optionally, the clearing module 104 is specifically configured to clear the primary key information of the to-be-processed record stored in the application program.

Optionally, the obtaining module 101 is further configured to obtain types of a plurality of operations, where the target operation is one of the plurality of operations.

The processing module 103 is further configured to name the methods corresponding to the types of the multiple operations according to a preset naming rule, so that when the type of the target operation is obtained, the method name corresponding to the type of the target operation is obtained.

As described above, the embodiments of the present disclosure may perform division of functional modules on a data processing apparatus according to the above method example. The integrated module can be realized in a hardware form, and can also be realized in a software functional module form. In addition, it should be further noted that the division of the modules in the embodiments of the present disclosure is schematic, and is only a logic function division, and there may be another division manner in actual implementation. For example, the functional blocks may be divided for the respective functions, or two or more functions may be integrated into one processing block.

With regard to the data processing apparatus in the foregoing embodiments, the specific manner in which each module performs operations and the beneficial effects thereof have been described in detail in the foregoing method embodiments, and are not described herein again.

Fig. 10 is a schematic structural diagram of another data processing apparatus provided by the present disclosure. As shown in fig. 10, the data processing apparatus 20 may include at least one processor 201 and a memory 203 for storing processor-executable instructions. Wherein the processor 201 is configured to execute the instructions in the memory 203 to implement the data processing method in the above-described embodiments.

In addition, the data processing device 20 may also include a communication bus 202 and at least one communication interface 204.

The processor 201 may be a Central Processing Unit (CPU), a micro-processing unit, an ASIC, or one or more integrated circuits for controlling the execution of programs according to the present disclosure.

The communication bus 202 may include a path that conveys information between the aforementioned components.

The communication interface 204 may be any device, such as a transceiver, for communicating with other devices or communication networks, such as an ethernet, a Radio Access Network (RAN), a Wireless Local Area Network (WLAN), etc.

The memory 203 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these. The memory may be self-contained and connected to the processing unit by a bus. The memory may also be integrated with the processing unit.

The memory 203 is used for storing instructions for executing the disclosed solution, and is controlled by the processor 201. The processor 201 is configured to execute instructions stored in the memory 203 to implement the functions of the disclosed method.

In particular implementations, processor 201 may include one or more CPUs such as CPU0 and CPU1 in fig. 10 for one embodiment.

In particular implementations, data processing apparatus 20 may include a plurality of processors, such as processor 201 and processor 207 in FIG. 10, for example, as an example. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).

In one embodiment, the data processing apparatus 20 may further include an output device 205 and an input device 206. The output device 205 is in communication with the processor 201 and may display information in a variety of ways. For example, the output device 205 may be a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display device, a Cathode Ray Tube (CRT) display device, a projector (projector), or the like. The input device 206 is in communication with the processor 201 and can accept user input in a variety of ways. For example, the input device 206 may be a mouse, a keyboard, a touch screen device, or a sensing device, among others.

Those skilled in the art will appreciate that the configuration shown in fig. 10 does not constitute a limitation of the data processing apparatus 20, and may include more or fewer components than those shown, or combine certain components, or employ a different arrangement of components.

In addition, the present disclosure also provides a computer-readable storage medium including instructions, which when executed by a processor, cause the processor to perform the data processing method provided as the above embodiment.

In addition, the present disclosure also provides a computer program product comprising instructions which, when executed by a processor, cause the processor to perform the data processing method as provided in the above embodiments.

Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

24页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种报文数据的转换方法、装置、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!