Data migration method and device, electronic equipment and storage medium
By acquiring and utilizing field mapping information for data migration, the problems of low database resource utilization and high data reading complexity are solved, achieving efficient utilization of database resources and improved data reading performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-11-22
- Publication Date
- 2026-05-22
AI Technical Summary
In database scenarios, the same target business may correspond to multiple data tables, resulting in low database resource utilization, high complexity of data reading code, and poor performance.
By obtaining the field mapping information corresponding to the target data migration type, the correspondence between the source data table and the target data table is determined. The target fields are traversed to obtain the missing field values, and the data is assembled and written based on the associated fields, thus realizing the migration of data from the source data table to the target data table.
It improves the utilization of database resources, reduces the code complexity of data reading, improves data reading performance, and ensures the integrity of field values of target data entries.
Smart Images

Figure CN122072622A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data migration method, apparatus, electronic device, and storage medium. Background Technology
[0002] In database scenarios, the same target business may correspond to multiple data tables, which in turn require multiple database instances, resulting in low database resource utilization. Furthermore, when it is necessary to read business data for the target business, it is usually necessary to read from multiple data tables separately and then perform data aggregation, which leads to high code complexity and poor performance in data reading. Summary of the Invention
[0003] The technical problem to be solved by this application is to provide a data migration method, apparatus, electronic device and storage medium that can improve the utilization rate of database resources, reduce the code complexity of data reading and improve data reading performance.
[0004] To address the aforementioned technical problems, this application provides a data migration method, comprising:
[0005] Obtain field mapping information corresponding to the target data migration type; when the target data migration type is a first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business; each source data table includes at least one source data entry, each source data entry includes the source field values corresponding to the multiple source fields respectively, and the multiple source fields include at least some of the fields in the multiple target fields;
[0006] The plurality of target fields are traversed. If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, the field value of the first target field is obtained based on the field value of the first associated field. The first target field is at least one of the plurality of target fields, and the plurality of source fields do not include the first target field.
[0007] Data is assembled based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field to obtain the first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field;
[0008] Write the first target data entry into the target data table.
[0009] On the other hand, this application provides a data migration apparatus, including:
[0010] The mapping information acquisition module is used to acquire field mapping information corresponding to the target data migration type. When the target data migration type is a first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business. Each source data table includes at least one source data entry, and each source data entry includes the source field values corresponding to the multiple source fields respectively. The multiple source fields include at least some of the fields in the multiple target fields.
[0011] The first field traversal module is used to traverse the plurality of target fields. If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, the field value of the first target field is obtained based on the field value of the first associated field. The first target field is at least one of the plurality of target fields, and the plurality of source fields do not include the first target field.
[0012] The first data assembly module is used to assemble data based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field, to obtain the first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field;
[0013] The first writing module is used to write the first target data entry into the target data table.
[0014] On the other hand, this application provides an electronic device including a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data migration method as described above.
[0015] On the other hand, this application provides a computer storage medium storing at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded by a processor and executed as described above in the data migration method.
[0016] On the other hand, this application provides a computer program product including computer instructions stored in a computer-readable storage medium; a processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions to cause the electronic device to perform the data migration method described above.
[0017] Implementing the embodiments of this application has the following beneficial effects:
[0018] In this application, given the source data table corresponding to the target business and the target data table corresponding to the target business, the corresponding target data migration type can be determined. Based on the field mapping information corresponding to the target data migration type, data in the source data table can be migrated to the target data table, releasing the database resources of the source data table and improving the utilization rate of database resources. Furthermore, when it is necessary to read business data of the target business, data can be read directly from the target data table without having to read from multiple data tables, thereby reducing the code complexity of data reading and improving data reading performance. Furthermore, when the target data migration type is the first heterogeneous migration type, it can be determined that the data of a source data table is migrated to a target data table, and the source data table and the target data table are heterogeneous data tables. During the traversal of multiple target fields, if each source data entry in the source data table does not have a source field corresponding to the first target field, and each source data entry has a first associated field of the first target field, the field value of the first target field can be obtained based on the first associated field, thereby enabling the supplementation of field values for missing fields, improving the completeness of field values in each target data entry, that is, improving the completeness of field value filling during the data migration process. Attached Figure Description
[0019] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the implementation environment provided in the embodiments of this application;
[0021] Figure 2 This is a flowchart of the data migration method corresponding to the first heterogeneous migration type provided in the embodiments of this application;
[0022] Figure 3 This is a flowchart of the data migration method corresponding to the second heterogeneous migration type provided in the embodiments of this application;
[0023] Figure 4 This is a flowchart of the data migration method corresponding to the isomorphic migration type provided in the embodiments of this application;
[0024] Figure 5 This is a flowchart illustrating the data migration method corresponding to the isomorphic migration type provided in the embodiments of this application;
[0025] Figure 6 This is a flowchart illustrating the data migration method corresponding to the first heterogeneous migration type provided in the embodiments of this application;
[0026] Figure 7 This is a flowchart illustrating the data migration method corresponding to the second heterogeneous migration type provided in the embodiments of this application;
[0027] Figure 8 This is a schematic diagram of a data migration device provided in an embodiment of this application;
[0028] Figure 9 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0031] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0032] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0033] Please see Figure 1 The illustration shows an implementation environment provided in the embodiments of this application. The implementation environment may include at least one source database server 110, a target database server 120, and a data migration server 130. The source database server 110 and the data migration server 130 can communicate with each other via a network, and the target database server 120 and the data migration server 130 can communicate with each other via a network.
[0034] Specifically, the data migration server 130 can obtain the corresponding field mapping information based on the target data migration type, and then read the field values of the source fields from the source database server 110 based on the field mapping information and assemble the data to obtain the corresponding target data entries, and write the target data entries to the target database server 120. The target database server 120 and the data migration server 130 can be different service modules on the same server, or they can be different servers; this embodiment does not impose specific limitations.
[0035] In this embodiment, the source database server 110, the target database server 120, and the data migration server 130 can each include an independently running server, a distributed server, or a server cluster composed of multiple servers, wherein the server can be a cloud server.
[0036] To address the technical problems of low database resource utilization, high code complexity for data reading, and poor performance in existing technologies, this application provides a data migration method corresponding to a first heterogeneous migration type. The execution entity of this method can be the aforementioned data migration server; please refer to... Figure 2 The method may include:
[0037] S210. Obtain field mapping information corresponding to the target data migration type; when the target data migration type is a first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business; each source data table includes at least one source data entry, each source data entry includes the source field values corresponding to the multiple source fields respectively, and the multiple source fields include at least some of the fields in the multiple target fields.
[0038] Before data migration, the source data table to be migrated and the target data table to be migrated can be determined in advance. Then, the target data migration type can be determined based on the table structure of the source data table to be migrated and the table structure of the target data table. In this embodiment, the table structure can be multiple fields contained in each data entry in the data table. The table structure can also be multiple fields contained in each data entry in the data table, as well as the field order of the multiple fields, etc.
[0039] When the target data migration type is the first heterogeneous migration type, it can be determined that the data migration task is to migrate data from a source data table to a target data table, and the table structure of the source data table is different from that of the target data table. Specifically, multiple source fields contained in each data entry in the source data table may be different from multiple target fields contained in each data entry in the target data table. In one example, multiple source fields may be some of the target fields among multiple target fields, for example, multiple source fields are field 1, field 2, and field 3, and multiple target fields are field 1, field 2, field 3, field 4, field 5, and field 6. In another example, multiple source fields may also partially overlap with multiple target fields, that is, some of the source fields exist in the target fields, for example, multiple source fields are field 1, field 2, and field 3, and multiple target fields are field 1, field 2, field 4, field 5, and field 6, wherein field 1 and field 2 in the source fields overlap with field 1 and field 2 in the target fields. In a specific embodiment, the number of multiple source fields contained in each source data entry may be less than or equal to the number of multiple target fields.
[0040] The field mapping information corresponding to the first heterogeneous migration type can represent the correspondence between each source field in a source data table and each target field in a target data table. Multiple source fields include at least some fields from multiple target fields. The field mapping information can include field correspondence information, field matching information, and field supplementary information. For field correspondence information, at least some fields in multiple source fields are the same as some target fields in multiple target fields. For example, if multiple source fields are field 1, field 2, and field 3, and multiple target fields are field 1, field 2, field 3, field 4, field 5, and field 6, the corresponding field mapping information can include field 1 in the source data table corresponding to field 1 in the target data table, field 2 in the source data table corresponding to field 2 in the target data table, and field 3 in the source data table corresponding to field 3 in the target data table. For field matching information, at least some fields in multiple source fields match some target fields in multiple target fields. The source and target fields with matching relationships have different field names but the same meaning and value. For example, if the source fields are field1, field2, and field3, and the target fields are field1', field2, field3, field4, field5, and field6, then field1 in the source fields matches field1' in the target fields. Field1 in the source fields and field1' in the target fields are fields with the same meaning, only different names, and their values are the same. For example, if field1 is user_id and field1' is user_uin, although user_id and user_uin have different fields, they both correspond to object identifiers, and their respective field values are object identifier information.
[0041] S220. Traverse the plurality of target fields. If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, obtain the field value of the first target field based on the field value of the first associated field; the first target field is at least one of the plurality of target fields, and the plurality of source fields does not include the first target field.
[0042] The field mapping information corresponding to the first heterogeneous migration type can represent the correspondence between each source field in a source data table and each target field in a target data table. The field mapping information can also include field association information, which can represent the association between at least one target field and at least one source field. Specifically, it can be that the field value of at least one target field can be obtained based on the field value of at least one source field, i.e., field supplementary information. For field supplementary information, if multiple source fields are field 1, field 2, and field 3, and multiple target fields are field 1, field 2, field 3, field 4, field 5, and field 6, the corresponding field mapping information can include field 1 in the source data table corresponding to field 1 in the target data table, field 2 in the source data table corresponding to field 2 in the target data table, and field 3 in the source data table corresponding to field 3 in the target data table. Where field 4, field 5, and field 6 in the target fields do not have corresponding source fields, if field 4 in the target fields is the first target field, the field value of field 4 cannot be directly obtained from the source fields. Field 1 in the source fields is the first associated field of field 4 in the target fields, and correspondingly, data can be obtained based on the field value of field 1 in the source fields to obtain the field value of field 4. For example, if the first associated field is user_id (object identifier) and the first target field is appid (application identifier), then the value of appid can be obtained based on the value of user_id.
[0043] It should be noted that each first target field may not correspond to a first associated field, or it may correspond to at least one first associated field. That is, the field value of each first target field can be obtained by data acquisition based on the field values of one or more first associated fields.
[0044] S230. Data assembly is performed based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field to obtain the first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field.
[0045] Multiple target fields may include a first target field and a second target field. The first target field does not exist in the multiple source fields and cannot be directly obtained from the field values of the multiple source fields in the source data entry, but it can be obtained from the field values of the first associated field in the multiple source fields. The second target field in the multiple target fields has the same or matching source fields in the multiple source fields, so the field value of the second target field can be directly obtained from the field values of the multiple source fields in the source data entry. Based on the source field values of the multiple source fields contained in each source data entry, the field values of the corresponding target fields can be obtained. By assembling the field values of the target fields, the first target data entry corresponding to each source data entry can be obtained. Furthermore, if there is a field order among the multiple target fields, the field values of the corresponding target fields can be assembled based on the field order of the multiple target fields to obtain the first target data entry corresponding to each source data entry.
[0046] S240. Write the first target data entry into the target data table.
[0047] The writing operation for the first target data entry can be a single write operation or a batch write operation. Specifically, it can be that each first target data entry is written to the target data table as soon as it is generated, or it can be that when the number of first target data entries reaches a preset number, the preset number of first target data entries are written to the target data table in batches, or it can be that the first target data entries generated in each preset writing cycle are written to the target data table. The specific implementation situation can be determined, and it will not be elaborated here.
[0048] In this application, given the source data table corresponding to the target business and the target data table corresponding to the target business, the corresponding target data migration type can be determined. Based on the field mapping information corresponding to the target data migration type, data in the source data table is migrated to the target data table, releasing the database resources of the source data table and improving the utilization rate of database resources. Furthermore, when it is necessary to read business data of the target business, data can be read directly from the target data table without reading from multiple data tables, thereby reducing the code complexity of data reading and improving data reading performance. Further, when the target data migration type is the first heterogeneous migration type, it can be determined that data from one source data table is migrated to one target data table, and the source data table and the target data table are heterogeneous data tables. During the traversal of multiple target fields, if each source data entry in the source data table does not have a source field corresponding to the first target field, and each source data entry has a first associated field of the first target field, the field value of the first target field can be obtained based on the first associated field, thereby supplementing the field value of the missing field and improving the completeness of the field values in each target data entry.
[0049] Furthermore, as can be seen from the above, the field value of the first target field can be obtained based on the field value of the first associated field. Specific methods for obtaining this value may include:
[0050] Call the target data retrieval function;
[0051] The field value of the first associated field is used as the input parameter of the target data acquisition function, so that the target data acquisition function can obtain the field value of the first target field in the business data based on the field value of the first associated field; the business data is the business data corresponding to the target business or the business data corresponding to the associated business.
[0052] The target data retrieval function can be a pre-built function for retrieving the field value of the target field. When retrieving the field value by calling the target data retrieval function, the field value of the first associated field can be used as the input parameter. Thus, the target data retrieval function can retrieve the corresponding field value from the business data.
[0053] Specifically, the business data includes at least one business data entry, and each business data entry includes the field value of the first associated field and the field value of the first target field. Therefore, the target data retrieval function can determine the business data entry to be searched based on the field value of the first associated field (input parameter), and search for the field value of the first target field within that business data entry. For example, the business data entry to be searched corresponding to object identifier ×× can be determined based on the field value of the user_id field, and the field value of the appid field can be retrieved from business data entry A.
[0054] When the business data corresponds to the target business, the business data can be stored in a data table other than the source data table and the target data table corresponding to the target business; when the business data corresponds to a related business, the business data can be stored in a data table corresponding to the related business; the related business can be a business that is related to the target business, and the business data of the related business and the business data of the target business partially overlap.
[0055] In this embodiment, when the first target field is not present among multiple source fields, the field value of the first target field can be obtained based on the field value of the first associated field that is associated with the first target field among multiple source fields. Specifically, it can be obtained from business data through a preset target data retrieval function. Obtaining field values through a preset function improves the convenience of field value retrieval. Furthermore, field values can be obtained from the business data of the target business or the business data of the associated business. If the corresponding field value cannot be obtained from the business data of the target business, it can be obtained from the business data of the associated business, thereby maximizing the field value retrieval rate and improving the comprehensiveness of field value filling.
[0056] In this embodiment, during the data migration method corresponding to the first heterogeneous migration type, there may be situations where the source field and the target field are the same, but the data format of the source field's field value may be different from that of the target field's field value. Therefore, when reading the field value of the source field, further data format conversion is required to obtain a field value that meets the field value format requirements of the target field. Specifically, the step of assembling data based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field to obtain the first target data entry corresponding to each source data entry includes:
[0057] If there is a field whose format needs to be converted in both the source field corresponding to the second target field and the first target field, the field value of the field whose format needs to be converted is converted to obtain the field value of the target data format; the field value of the field whose format needs to be converted is the source data format, and the source data format is different from the target data format.
[0058] Data is assembled based on the field values of the target data format corresponding to the field to be converted, and the field values of other fields, to obtain the first target data entry corresponding to each source data entry; the other fields are the second target field and the fields in the first target field other than the field to be converted.
[0059] In this embodiment, the field to be formatted is at least one of multiple source fields, and the multiple target fields include this at least one source field. In the source data table, the field value of this at least one source field is in the source data format, and in the target data table, the field value of the corresponding target field is in the target data format. Therefore, during data assembly, the extracted source field values can be converted to obtain the target data format field values. For other non-formatted fields to be formatted, the field values of the corresponding source fields can be directly used as the field values of the corresponding target fields.
[0060] For example, if the field to be converted is field 3, the field value corresponding to field 3 in the source data table may be TRUE or FALSE, meaning the source data format may be a character type, and the field value corresponding to field 3 in the target data table may be 1 or 0, meaning the target data format may be a numeric type. Accordingly, when the field value corresponding to field 3 in the source data table is TRUE, it can be converted to 1 and used as the field value of field 3 in the target data table; when the field value corresponding to field 3 in the source data table is FALSE, it can be converted to 0 and used as the field value of field 3 in the target data table.
[0061] In this embodiment, if the data format of any field value in the source data table is different from the data format of the corresponding target field value in the target data table, the data format of the source field value can be converted so that the field value of the source field can meet the target data format, thereby improving the data compatibility between the source data table and the target data table.
[0062] Furthermore, the data migration method corresponding to the first heterogeneous migration type in this embodiment may also include:
[0063] If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is no first associated field of the first target field in each source data entry, the field value of the first target field is determined as the default field value.
[0064] If there is no source field corresponding to the first target field in each source data entry (i.e., there is no source field corresponding to the first target field among multiple source fields), and there is no first associated field of the first target field in each source data entry (i.e., there is no first associated field of the first target field among multiple source fields), then a default field value can be used to assign a value to the first target field. For example, the default field value can be default_value. The default field values corresponding to different first target fields can be the same or different.
[0065] In this embodiment, for a first target field that does not have a corresponding source field or an associated field, it cannot directly obtain its own field value based on the field value of the source field and the field value of the associated field. Therefore, a default field value can be used to assign a value to the first target field, thereby further ensuring the integrity of the field values of each target field in each target data entry in the target data table.
[0066] When the target data migration type is the second heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields contained in multiple source data tables corresponding to the target service and multiple target fields in the target data table; each source data table includes at least one source data entry, and each source data entry includes source field values corresponding to multiple source fields, wherein the multiple source fields include at least some of the fields in the multiple target fields; the multiple source data tables contain source data entries for the same data object, and the source fields in the source data entries for the same data object in the multiple source data tables partially overlap; accordingly, please refer to Figure 3 This embodiment also provides a data migration method corresponding to the second heterogeneous migration type. The execution subject of this method can be the aforementioned data migration server, and specifically may include:
[0067] S310. Traverse the plurality of target fields. For each data object, if it is determined based on the field mapping information that at least one source data table contains a source field corresponding to the third target field, obtain the field value of the source field corresponding to the third target field from the source data entries corresponding to each data object in the at least one source data table; the third target field is at least one of the plurality of target fields.
[0068] Multiple source data tables contain source data entries for the same data object. These source data tables have different source fields, and some source fields overlap in the source data entries for the same data object. In other words, the source data tables are heterogeneous, and the source and target data tables are also heterogeneous. For example, multiple source data tables include source table a and source table b. Source table a contains source data entry a1 for data object 1, and source table b contains source data entry b1 for data object 1. Source data entry a1 includes fields 1, 2, and 3, while source data entry b1 includes fields 1, 5, and 6. Field 1 in source data entry a1 and source data entry b1 overlaps. The target fields are field 1, field 2, field 3, field 4, field 5, and field 6.
[0069] Field mapping information may include field correspondence information, field matching information, and field supplementary information. When migrating data for each data object across multiple source data tables, multiple target fields can be traversed. For the current target field, if a corresponding source field exists in at least one source data table, the field value of the source field corresponding to the current target field can be obtained from the source data entry corresponding to the data object in the corresponding source data table. Regarding field correspondence information, when the current target field is field 1 in the target fields, the field mapping information may include the correspondence between field 1 in the target fields and field 1 in source data table a. It may also include the correspondence between field 1 in the target fields and field 2 in source data table b. Alternatively, it may include both the correspondence between field 1 in the target fields and field 1 in source data table a, and the correspondence between field 1 in the target fields and field 2 in source data table b. When the current target field is field 2, the field mapping information for field 2 may include the correspondence between field 1 in the target field and field 2 in the source data table a. Therefore, the field value of field 2 can be obtained from the source data entry corresponding to each data object in the source data table a. For field matching information, for example, if multiple source fields in the source data table a are field 1, field 2, and field 3, and multiple target fields are field 1', field 2, field 3, field 4, field 5, and field 6, then field 1 in the source field and field 1' in the target field have a matching relationship. Field 1 in the source field and field 1' in the target field are fields with the same meaning, only different field names, and the field values of field 1 in the source field and field 1' in the target field are the same. The relevant implementation details of step S210 in this embodiment will not be repeated here.
[0070] S320. Data assembly is performed based on the field values of the source fields corresponding to the third target field to obtain the second target data entry corresponding to each data object.
[0071] For each data object, the field values of different source fields are obtained from multiple source data tables as the field values of the corresponding target fields. The field values of the target fields corresponding to each data object are then assembled to obtain the second target data entry corresponding to each data object. Furthermore, if there is a field order among the multiple target fields, the field values of the corresponding target fields can be assembled based on the field order of the multiple target fields to obtain the second target data entry corresponding to each source data entry.
[0072] For example, multiple source data tables include source data table a and source data table b. Source data table a includes source data entry a1 of data object 1, and source data table b includes source data entry b1 of data object 1. Source data entry a1 includes fields 1, 2, and 3, and source data entry b1 includes fields 1, 5, and 6. Multiple target fields are field 1, field 2, field 3, field 4, field 5, and field 6. Based on field mapping information, the field values of field 1, field 2, and field 3 of the target fields can be obtained from source data table a, and the field values of field 5 and field 6 of the target fields can be obtained from source data table b.
[0073] S330. Write the second target data entry into the target data table.
[0074] The writing operation for the second target data entry can be a single write operation or a batch write operation. Specifically, it can be that every two second target data entries are generated and written to the target data table, or that a preset number of second target data entries are written to the target data table in batches when the number of second target data entries reaches a preset number, or that the second target data entries generated in each cycle are written to the target data table according to a preset writing cycle. The specific implementation situation can be determined, and will not be elaborated here.
[0075] In this embodiment, during the data migration process from multiple heterogeneous source data tables to a heterogeneous target data table, the source data entry corresponding to each data object is used as the migration dimension. Based on the field mapping information, the source field corresponding to each target field and the source data table where the corresponding source field is located can be determined sequentially. Then, the field value of the corresponding source field is obtained from the source data entry corresponding to each data object in the source data table as the field value of the target field, which improves the convenience and accuracy of data migration from multiple heterogeneous source data tables to a heterogeneous target data table.
[0076] Furthermore, the data migration method corresponding to the second heterogeneous migration type in this embodiment may also include:
[0077] If, based on the field mapping information, it is determined that there is no source field corresponding to the fourth target field in the plurality of source data tables, and at least one source data table contains a second associated field of the fourth target field, the field value of the fourth target field is obtained based on the field value of the second associated field; the fourth target field is at least one of the plurality of target fields.
[0078] The data assembly based on the field values of the source field corresponding to the third target field to obtain the second target data entry corresponding to each data object includes:
[0079] Data is assembled based on the field values of the source field corresponding to the third target field and the field values of the fourth target field to obtain the second target data entry corresponding to each data object.
[0080] For example, multiple source data tables include source data table a and source data table b. Source data table a includes source data entry a1 of data object 1, and source data table b includes source data entry b1 of data object 1. Source data entry a1 includes fields 1, 2, and 3, and source data entry b1 includes fields 1, 5, and 6. Multiple target fields are field 1, field 2, field 3, field 4, field 5, and field 6. Among the multiple target fields, field 4 is the fourth target field. The second associated field of the fourth target field can be field 2 in source data table a, thus enabling the retrieval of the field value of field 4 based on the field value of field 2 in source data table a.
[0081] Specifically, the method for obtaining the field value of the fourth target field based on the field value of the second associated field may include:
[0082] Call the target data retrieval function;
[0083] The field value of the second associated field is used as the input parameter of the target data acquisition function, so that the target data acquisition function can obtain the field value of the fourth target field in the business data based on the field value of the second associated field; the business data is the business data corresponding to the target business or the business data corresponding to the associated business.
[0084] The target data retrieval function can be a pre-built function for retrieving the field value of the target field. When retrieving the field value by calling the target data retrieval function, the field value of the second associated field can be used as an input parameter. Thus, the target data retrieval function can retrieve the corresponding field value from the business data.
[0085] For details on obtaining the value of the fourth target field from the value of the second associated field, please refer to the method described above for obtaining the value of the first target field based on the value of the first associated field in this embodiment, which will not be repeated here. Furthermore, after obtaining the values of the third and fourth target fields, the obtained field values can be assembled to obtain the second target data entry corresponding to each data object.
[0086] In this embodiment, when the fourth target field is not present among multiple source fields, the field value of the fourth target field can be obtained based on the field value of the second associated field among the multiple source fields that is associated with the fourth target field. Specifically, it can be obtained from business data through a preset target data retrieval function. Obtaining the field value through a preset function improves the convenience of field value retrieval. Furthermore, the field value can be obtained from the business data of the target business or the business data of the associated business. If the corresponding field value cannot be obtained from the business data of the target business, it can be obtained from the business data of the associated business, thereby maximizing the field value retrieval rate and improving the comprehensiveness of field value filling.
[0087] In this embodiment, during the data migration method corresponding to the second heterogeneous migration type, there may be situations where the source field and the target field are the same, but the data format of the field value of the source field may be different from that of the field value of the target field. Therefore, when reading the field value of the source field, further data format conversion is required to obtain a field value that meets the field value format requirements of the target field. Specifically, the data assembly based on the field value of the source field corresponding to the third target field to obtain the second target data entry corresponding to each data object includes:
[0088] If the third target field contains a field whose format needs to be converted, the field value of the field whose format needs to be converted is converted to obtain the field value of the target data format; the field value of the field whose format needs to be converted is the source data format, and the source data format is different from the target data format.
[0089] Data is assembled based on the field values of the target data format corresponding to the field to be converted, and the field values of other fields, to obtain the second target data entry corresponding to each source data entry; the other fields are fields in multiple source data tables other than the field to be converted.
[0090] In this embodiment, the field to be formatted is at least one of multiple source fields, and the multiple target fields include this at least one source field. In the source data table, the field value of this at least one source field is in the source data format, and in the target data table, the field value of the corresponding target field is in the target data format. Therefore, during data assembly, the extracted source field values can be converted to obtain the target data format field values. For other non-formatted fields to be formatted, the field values of the corresponding source fields can be directly used as the field values of the corresponding target fields.
[0091] For example, if the field to be converted is field 3, the field value corresponding to field 3 in the source data table may be TRUE or FALSE, meaning the source data format may be a character type, and the field value corresponding to field 3 in the target data table may be 1 or 0, meaning the target data format may be a numeric type. Accordingly, when the field value corresponding to field 3 in the source data table is TRUE, it can be converted to 1 and used as the field value of field 3 in the target data table; when the field value corresponding to field 3 in the source data table is FALSE, it can be converted to 0 and used as the field value of field 3 in the target data table.
[0092] In this embodiment, if the data format of any field value in the source data table is different from the data format of the corresponding target field value in the target data table, the data format of the source field value can be converted so that the field value of the source field can meet the target data format, thereby improving the data compatibility between the source data table and the target data table.
[0093] Furthermore, the data migration method corresponding to the second heterogeneous migration type in this embodiment may also include:
[0094] If, based on the field mapping information, it is determined that there is no source field corresponding to the fourth target field in each source data entry, and there is no second associated field of the fourth target field in each source data entry, the field value of the fourth target field is determined as the default field value.
[0095] If there is no source field corresponding to the fourth target field in each source data entry, that is, there is no source field corresponding to the fourth target field among multiple source fields, and there is no second associated field of the fourth target field in each source data entry, that is, there is no second associated field of the fourth target field among multiple source fields, then the default field value can be used to assign a value to the fourth target field. For example, the default field value can be default_value. The default field values corresponding to different fourth target fields can be the same or different.
[0096] In this embodiment, for a fourth target field that does not have a corresponding source field or an associated field, it cannot directly obtain its own field value based on the field value of the source field and the field value of the associated field. Therefore, a default field value can be used to assign a value to the fourth target field, thereby further ensuring the integrity of the field values of each target field in each target data entry in the target data table.
[0097] When the target data migration type is a homogeneous migration type, the field mapping information represents the one-to-one correspondence between multiple source fields in the source data table corresponding to the target service and multiple target fields in the target data table; the source data table includes at least one source data entry, and each source data entry includes the source field values corresponding to the multiple source fields respectively; correspondingly, this embodiment also provides a data migration method corresponding to the homogeneous migration type, and the execution subject of this method can be the aforementioned data migration server. Please refer to [link to relevant documentation]. Figure 4 The method may include:
[0098] S410. Traverse the plurality of target fields and obtain the field values of the source fields corresponding to the plurality of target fields from the source data table.
[0099] Isomorphic migration refers to data migration between a source table and a target table that have the same table structure, where multiple source fields in the source table correspond one-to-one with multiple target fields in the target table. For example, the source table might contain fields 1, 2, 3, 4, 5, and 6, and the target table might contain fields 1, 2, 3, 4, 5, and 6, with each field corresponding to the other. When a source field has an empty value, a default value can be assigned to the corresponding target field.
[0100] S420. Data assembly is performed based on the field values of the source fields corresponding to the plurality of target fields respectively, to obtain a third target data entry corresponding to each source data entry.
[0101] During the data migration process, multiple target fields can be traversed to obtain the field value of the source field corresponding to the current target field from the source data table, which is then used as the field value of the current target field. By assembling the field values corresponding to multiple target fields, the corresponding third target data entry can be obtained.
[0102] S430. Write the third target data entry into the target data table.
[0103] The writing operation for the third target data entry can be a single write operation or a batch write operation. Specifically, it can be that each third target data entry is written to the target data table as soon as it is generated, or it can be that a preset number of third target data entries are written to the target data table in batches when the number of third target data entries reaches a preset number, or it can be that the third target data entries generated in each cycle are written to the target data table according to a preset writing cycle. The specific implementation situation can be determined, and it will not be elaborated here.
[0104] In this embodiment, when migrating data between a source data table and a target data table with the same table structure, the field value of each target field can be obtained based on the one-to-one correspondence between multiple source fields and multiple target fields. Then, the data is assembled to generate the corresponding first target data entry and written into the target data table, thereby realizing data migration between homogeneous data tables and improving the efficiency and accuracy of homogeneous data table migration.
[0105] In this embodiment, since there may be incremental data in the source data table, the incremental data can be migrated separately. The incremental data migration may include at least one source data entry, and each source data entry includes field values corresponding to multiple source fields. In the specific data migration process, the corresponding data migration method can be determined based on different data migration types. For details, please refer to the relevant implementation details of the data migration method corresponding to the first heterogeneous migration type, the data migration method corresponding to the second heterogeneous migration type, and the data migration method corresponding to the homogeneous migration type mentioned above in this embodiment, which will not be repeated here.
[0106] It should be noted that any of the methods in this embodiment can be combined based on the actual situation and have corresponding beneficial effects, which will not be elaborated here.
[0107] The following uses a domain name registration scenario as an example to illustrate the implementation process of this application. The corresponding data object is the registration object for the registered domain name:
[0108] 1. Homogeneous migration type: Migration from source data table to target data table. The source data table and the target data table have the same table structure, and multiple source fields in the source data table correspond one-to-one with multiple target fields in the target data table.
[0109] Please refer to Table 1, which shows the field correspondence for isomorphic migration types:
[0110] Table 1
[0111] Source field illustrate target field illustrate id Primary key id Primary key user_uin User uin user_uin User uin domain_id The domains table contains the id. domain_id The domains table contains the id. action Operation, Chinese description action Operation, Chinese description created_on Creation time created_on Creation time action_type Types of operational behaviors action_type Types of operational behaviors operator_user_uin uin of the operation initiator operator_user_uin uin of the operation initiator …… …… …… ……
[0112] The field mapping information corresponding to the isomorphic migration type can include field correspondence information, and the migration relationship model can be configured using JSON language; the configuration of the corresponding migration relationship model can include:
[0113]
[0114]
[0115] Wherein, source_table: source data table
[0116] object_table: The target data table
[0117] table_relationship: Table relationship, key is the target field.
[0118] relation_field: Source field
[0119] default_value: The default value, filled in by default when the source field does not exist.
[0120] relationship_type: Relationship type: 1 indicates migration between two isomorphic tables.
[0121] Please refer to the relevant section. Figure 5 It illustrates a flowchart of the data migration method corresponding to the isomorphic migration type, which may include:
[0122] S510. Load the migration relationship model.
[0123] S520. Determine the data migration type based on relationship_type, relationship_type = 1.
[0124] S530. Traverse multiple target fields and read the field value of the current source field corresponding to the current target field based on the table relationship table_relationship and the source field relationship_field.
[0125] S540. Determine if the current source field value is empty; if yes, proceed to step S570; if no, proceed to step S550.
[0126] S550. Determine whether it is necessary to check whether the data format of the current source field value and the corresponding target field value are consistent; if yes, proceed to step S580; if no, proceed to step S560.
[0127] S560. Convert the data format of the current source field value to obtain the target data format field value.
[0128] S570. Assign a default field value to the current target field.
[0129] S580. Assemble the field values corresponding to multiple target fields to obtain target data entries, and write the target data entries into the target data table.
[0130] For incremental data migration in the source data table, the newly added data can be separated based on the subscription data update information, and then the incremental data migration can be realized according to the flowchart above.
[0131] 2. First type of heterogeneous migration: A source data table is migrated to a target data table. The source data table and the target data table have different table structures. Multiple source fields in the source data table include at least some of the target fields in the target data table.
[0132] Please refer to Table 2, which shows the field mapping for the first heterogeneous migration type:
[0133] Table 2
[0134] Source field illustrate target field illustrate id Primary key id Primary key domain_id Domain ID domain domain name domain domain name user_id User uin user_uin User uin app_id appid journal_id Billing Sub-Order Number journal_id Billing Sub-order Number template_id Template ID …… …… …… ……
[0135] The field mapping information corresponding to the first heterogeneous migration type may include field correspondence information, field matching information, and field supplementary information, and the migration relationship model can be configured using JSON language; the configuration of the corresponding migration relationship model may include:
[0136]
[0137]
[0138] source_table: Source data table
[0139] object_table: The target data table
[0140] table_relationship: Table relationship, key is the target field.
[0141] relation_field: Source field
[0142] default_value: The default value, filled in by default when the source field does not exist.
[0143] `method_change`: A user-defined function that performs parameter conversion; `method_param` represents the function parameters.
[0144] relationship_type: Relationship type: 2 indicates migration between two heterogeneous tables.
[0145] Please refer to the relevant section. Figure 6 It illustrates a flowchart of the data migration method corresponding to the first heterogeneous migration type, which may include:
[0146] S610. Load the migration relationship model.
[0147] S612. Determine the data migration type based on relationship_type, relationship_type = 2.
[0148] S614. For each source data entry, iterate through multiple target fields and read the field value of the current source field corresponding to the current target field based on the table relationship table_relationship and the source field relationship_field.
[0149] S616. Determine if the current target field has a corresponding current source field; if yes, proceed to step S618; otherwise, proceed to step S624.
[0150] S618. Determine if the current source field value is empty; if yes, proceed to step S628; if no, proceed to step S620.
[0151] S620. Determine whether it is necessary to check whether the data format of the current source field value and the corresponding target field value are consistent; if yes, proceed to step S630; if no, proceed to step S622.
[0152] S622. Convert the data format of the current source field to obtain the field value in the target data format.
[0153] S624. Determine whether the current target field has a first associated field; if yes, proceed to step S626; otherwise, proceed to step S628.
[0154] S626. Obtain the field value of the current target field based on the field value of the first associated field.
[0155] S628. Assign a default field value to the current target field.
[0156] S630. Assemble the field values corresponding to multiple target fields to obtain target data entries, and write the target data entries into the target data table.
[0157] For incremental data migration in the source data table, the newly added data can be separated based on the subscription data update information, and then the incremental data migration can be realized according to the flowchart above.
[0158] 3. Second type of heterogeneous migration: Migration from multiple source data tables to a target data table. The table structures of the multiple source data tables and the target data table are different. The multiple source data tables contain source data entries for the same data object, and the source fields of the source data entries for the same data object in the multiple source data tables partially overlap.
[0159] Please refer to Table 3, which shows the field mapping for the second heterogeneous migration type:
[0160] Table 3
[0161]
[0162]
[0163] "source_table1": "wss_db.domains",
[0164] "source_table2": "epp_db.epp_domain",
[0165] "object_table": "cgw_db.do_reg_tasks",
[0166] "table_relationship":{
[0167] "cgw_db.domain_id": {"relation_field": "", "default_value": "", "method_change": "get_domain_id", "method_param": "wss_db.id"},
[0168] / / Retrieve the value of the domain_id field in the target data table based on the id field value in the source data table wss.
[0169] "cgw_db.domain": {"relation_field": "wss_db.domain", "default_value": "", "is_unique": "1"},
[0170] / / The domain field in the source data table (wss) corresponds to the domain field in the target data table.
[0171] "cgw_db.password": {"relation_field": "", "default_value": ""},
[0172] / / The field "password" does not exist in either of the source tables, so it is assigned a default value.
[0173] "cgw_db.user_uin": {"relation_field": "wss_db.uin", "default_value": ""},
[0174] / / The field 'uin' in the source data table 'wss' corresponds to the field 'user_uin' in the target data table.
[0175] "cgw_db.period": {"relation_field": "wss_db.years", "default_value": "1"},
[0176] "cgw_db.dnvc_task_id": {"relation_field": "epp_db.dnvc_task_id", "default_value": ""},
[0177] / / The field dnvc_task_id in the source data table epp corresponds to the field dnvc_task_id in the target data table.
[0178] ... / / Correspondence of other fields
[0179] },
[0180] "relationship_type": "3"
[0181] }
[0182] source_table1: Source data table a
[0183] source_table2: Source data table b
[0184] object_table: The target data table
[0185] table_relationship: Table relationship, key is the target field.
[0186] relation_field: Source field
[0187] default_value: The default value, filled in by default when the source field does not exist.
[0188] `method_change`: A user-defined function that performs parameter conversion; `method_param` represents the function parameters.
[0189] relationship_type: Relationship type: 3 indicates data migration from multiple source heterogeneous tables to a single target heterogeneous table.
[0190] Please refer to the relevant section. Figure 7 It illustrates a flowchart of the data migration method corresponding to the second heterogeneous migration type, which may include:
[0191] S710. Load the migration relationship model.
[0192] S712. Determine the data migration type based on relationship_type, relationship_type = 3.
[0193] S714. For each data object in multiple source data tables, traverse multiple target fields and read the field value of the current source field corresponding to the current target field based on the table relationship (table_relationship) and the source field (relation_field).
[0194] S717. Determine if the current target field has a corresponding current source field; if yes, proceed to step S718; otherwise, proceed to step S724.
[0195] S718. Determine if the current source field value is empty; if yes, proceed to step S728; if no, proceed to step S720.
[0196] S720. Determine whether it is necessary to check whether the data format of the current source field value and the corresponding target field value are consistent; if yes, proceed to step S730; if no, proceed to step S722.
[0197] S722. Convert the data format of the current source field to obtain the field value in the target data format.
[0198] S724. Determine whether the current target field has a second associated field; if yes, proceed to step S727; otherwise, proceed to step S728.
[0199] S727. Obtain the field value of the current target field based on the field value of the second associated field.
[0200] S728. Assign a default field value to the current target field.
[0201] S730. Assemble the field values corresponding to multiple target fields to obtain target data entries, and write the target data entries into the target data table.
[0202] For incremental data migration in the source data table, the newly added data can be separated based on the subscription data update information, and then the incremental data migration can be realized according to the flowchart above.
[0203] Please see Figure 8 This embodiment also provides a data migration apparatus, including:
[0204] The mapping information acquisition module 810 is used to acquire field mapping information corresponding to the target data migration type; when the target data migration type is a first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business; each source data table includes at least one source data entry, each source data entry includes the source field values corresponding to the multiple source fields respectively, and the multiple source fields include at least some of the fields in the multiple target fields;
[0205] The first field traversal module 820 is used to traverse the plurality of target fields. When it is determined based on the field mapping information that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, the field value of the first target field is obtained based on the field value of the first associated field. The first target field is at least one of the plurality of target fields, and the plurality of source fields do not include the first target field.
[0206] The first data assembly module 830 is used to assemble data based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field, to obtain a first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field;
[0207] The first writing module 840 is used to write the first target data entry into the target data table.
[0208] Furthermore, the first field traversal module is also used for:
[0209] Call the target data retrieval function;
[0210] The field value of the first associated field is used as the input parameter of the target data acquisition function, so that the target data acquisition function can obtain the field value of the first target field in the business data based on the field value of the first associated field; the business data is the business data corresponding to the target business or the business data corresponding to the associated business.
[0211] Furthermore, the first data assembly module is also used for:
[0212] If there is a field whose format needs to be converted in both the source field corresponding to the second target field and the first target field, the field value of the field whose format needs to be converted is converted to obtain the field value of the target data format; the field value of the field whose format needs to be converted is the source data format, and the source data format is different from the target data format.
[0213] Data is assembled based on the field values of the target data format corresponding to the field to be converted, and the field values of other fields, to obtain the first target data entry corresponding to each source data entry; the other fields are the second target field and the fields in the first target field other than the field to be converted.
[0214] Furthermore, the device also includes:
[0215] The default assignment module is used to determine the field value of the first target field as the default field value when it is determined based on the field mapping information that there is no source field corresponding to the first target field in each source data entry and there is no first associated field of the first target field in each source data entry.
[0216] Furthermore, when the target data migration type is the second heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields contained in multiple source data tables corresponding to the target service and multiple target fields in the target data table; each source data table includes at least one source data entry, each source data entry includes source field values corresponding to multiple source fields, and the multiple source fields include at least some of the fields in the multiple target fields; the multiple source data tables contain source data entries for the same data object, and the source fields in the source data entries for the same data object in the multiple source data tables partially overlap;
[0217] The device further includes:
[0218] The second field traversal module is used to traverse the plurality of target fields. For each data object, if it is determined based on the field mapping information that at least one source data table exists with a source field corresponding to the third target field, the field value of the source field corresponding to the third target field is obtained from the source data entries corresponding to each data object in the at least one source data table; the third target field is at least one of the plurality of target fields.
[0219] The second data assembly module is used to assemble data based on the field value of the source field corresponding to the third target field to obtain the second target data entry corresponding to each data object;
[0220] The second writing module is used to write the second target data entry into the target data table.
[0221] Furthermore, the device also includes:
[0222] The first acquisition module is used to acquire the field value of the fourth target field based on the field value of the second associated field when it is determined from the field mapping information that there is no source field corresponding to the fourth target field in the plurality of source data tables, and at least one source data table has a second associated field of the fourth target field; the fourth target field is at least one target field among the plurality of target fields.
[0223] The second data assembly module is also used for:
[0224] Data is assembled based on the field values of the source field corresponding to the third target field and the field values of the fourth target field to obtain the second target data entry corresponding to each data object.
[0225] Furthermore, when the target data migration type is a homogeneous migration type, the field mapping information represents the one-to-one correspondence between multiple source fields in the source data table corresponding to the target business and multiple target fields in the target data table; the source data table includes at least one source data entry, and each source data entry includes the source field values corresponding to the multiple source fields respectively;
[0226] The device further includes:
[0227] The third field traversal module is used to traverse the multiple target fields and obtain the field values of the source fields corresponding to the multiple target fields from the source data table.
[0228] The third data assembly module is used to assemble data based on the field values of the source fields corresponding to the multiple target fields respectively, so as to obtain a third target data entry corresponding to each source data entry;
[0229] The third writing module is used to write the third target data entry into the target data table.
[0230] The apparatus provided in the above embodiments can execute the methods provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.
[0231] This embodiment also provides a computer-readable storage medium storing at least one instruction or at least one program, which is loaded by a processor and executed as any of the methods described above in this embodiment.
[0232] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described above.
[0233] Figure 9 This is a block diagram illustrating an electronic device for data migration according to an exemplary embodiment. The electronic device may be a server, and its internal structure diagram may be as follows: Figure 9 As shown, the electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a data migration method.
[0234] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the electronic device to which the present disclosure is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0235] This specification provides the operational steps of the methods described in the embodiments or flowcharts, but more or fewer operational steps may be included based on conventional or non-inventive labor. The steps and order listed in the embodiments are merely one possible execution order among many steps and do not represent the only execution order. In actual system or interrupt product execution, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment).
[0236] The structure shown in this embodiment is only a partial structure related to the solution of this application and does not constitute a limitation on the device to which the solution of this application is applied. Specific devices may include more or fewer components than shown, or combinations of certain components, or arrangements of different components. It should be understood that the methods, apparatuses, etc., disclosed in this embodiment can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or unit modules through some interfaces.
[0237] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0238] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0239] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data migration method, characterized in that, include: Obtain the field mapping information corresponding to the target data migration type; When the target data migration type is the first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business; each source data table includes at least one source data entry, each source data entry includes the source field values corresponding to the multiple source fields respectively, and the multiple source fields include at least some of the fields in the multiple target fields; Traverse the multiple target fields, and if it is determined based on the field mapping information that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, obtain the field value of the first target field based on the field value of the first associated field; The first target field is at least one of the plurality of target fields, and the plurality of source fields does not include the first target field; Data is assembled based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field to obtain the first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field; Write the first target data entry into the target data table.
2. The method according to claim 1, characterized in that, The step of obtaining the field value of the first target field based on the field value of the first associated field includes: Call the target data retrieval function; The field value of the first associated field is used as the input parameter of the target data acquisition function, so that the target data acquisition function can obtain the field value of the first target field in the business data based on the field value of the first associated field; the business data is the business data corresponding to the target business or the business data corresponding to the associated business.
3. The method according to claim 1, characterized in that, The step of assembling data based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field to obtain the first target data entry corresponding to each source data entry includes: If there is a field whose format needs to be converted in both the source field corresponding to the second target field and the first target field, the field value of the field whose format needs to be converted is converted to obtain the field value of the target data format; the field value of the field whose format needs to be converted is the source data format, and the source data format is different from the target data format. Data is assembled based on the field values of the target data format corresponding to the field to be converted, and the field values of other fields, to obtain the first target data entry corresponding to each source data entry; the other fields are the second target field and the fields in the first target field other than the field to be converted.
4. The method according to claim 1 or 3, characterized in that, The method further includes: If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is no first associated field of the first target field in each source data entry, the field value of the first target field is determined as the default field value.
5. The method according to claim 1, characterized in that, When the target data migration type is the second heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields contained in multiple source data tables corresponding to the target business and multiple target fields in the target data table; each source data table includes at least one source data entry, each source data entry includes source field values corresponding to multiple source fields, and the multiple source fields include at least some of the fields in the multiple target fields; The multiple source data tables contain source data entries for the same data object, and the source fields in the source data entries for the same data object in the multiple source data tables partially overlap. The method further includes: The plurality of target fields are traversed. For each data object, if it is determined based on the field mapping information that at least one source data table exists that corresponds to the third target field, the field value of the source field corresponding to the third target field is obtained from the source data entries corresponding to each data object in the at least one source data table; the third target field is at least one of the plurality of target fields. Data is assembled based on the field values of the source fields corresponding to the third target field to obtain the second target data entry corresponding to each data object; Write the second target data entry into the target data table.
6. The method according to claim 5, characterized in that, The method further includes: If, based on the field mapping information, it is determined that there is no source field corresponding to the fourth target field in the plurality of source data tables, and at least one source data table contains a second associated field of the fourth target field, the field value of the fourth target field is obtained based on the field value of the second associated field; the fourth target field is at least one of the plurality of target fields. The data assembly based on the field values of the source field corresponding to the third target field to obtain the second target data entry corresponding to each data object includes: Data is assembled based on the field values of the source field corresponding to the third target field and the field values of the fourth target field to obtain the second target data entry corresponding to each data object.
7. The method according to claim 1, characterized in that, When the target data migration type is a homogeneous migration type, the field mapping information represents the one-to-one correspondence between multiple source fields in the source data table corresponding to the target business and multiple target fields in the target data table; The source data table includes at least one source data entry, and each source data entry includes the source field values corresponding to the plurality of source fields respectively; The method further includes: Iterate through the multiple target fields and obtain the field values of the source fields corresponding to the multiple target fields from the source data table; Data is assembled based on the field values of the source fields corresponding to the multiple target fields to obtain a third target data entry corresponding to each source data entry; Write the third target data entry into the target data table.
8. A data migration device, characterized in that, include: The mapping information acquisition module is used to acquire the field mapping information corresponding to the target data migration type; When the target data migration type is the first heterogeneous migration type, the field mapping information represents the correspondence between multiple source fields in a source data table corresponding to the target business and multiple target fields in the target data table corresponding to the target business; each source data table includes at least one source data entry, each source data entry includes the source field values corresponding to the multiple source fields respectively, and the multiple source fields include at least some of the fields in the multiple target fields; The first field traversal module is used to traverse the plurality of target fields. If, based on the field mapping information, it is determined that there is no source field corresponding to the first target field in each source data entry, and there is a first associated field of the first target field in each source data entry, the field value of the first target field is obtained based on the field value of the first associated field. The first target field is at least one of the plurality of target fields, and the plurality of source fields do not include the first target field. The first data assembly module is used to assemble data based on the field value of the source field corresponding to the second target field in each source data entry and the field value of the first target field, to obtain the first target data entry corresponding to each source data entry; the second target field is at least one of the plurality of target fields, and the plurality of source fields includes the second target field; The first writing module is used to write the first target data entry into the target data table.
9. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data migration method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor according to any one of claims 1 to 7.