Zipper table updating method and device and electronic equipment

By obtaining incremental logs and reference times to create data records, the zipper table is updated in real time, which solves the problems of coarse granularity and large delay in traditional zipper table updates, and achieves high-precision and low-latency real-time data updates.

CN118760693APending Publication Date: 2024-10-11CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410891494.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

The zipper table update granularity of the traditional T+1 update method is coarse, the delay is days, and data changes cannot be updated in a timely manner, resulting in data inconsistency.

Method used

By obtaining the incremental log of the source data table, obtain the reference time of the target data from the zipper table storage unit or the preset state storage unit, create data records according to the change type, determine the start and end time of the record, and update the zipper table in real time.

Benefits of technology

It achieves event-based real-time updates, reduces computational complexity and delay, improves the accuracy and real-time nature of data recording, and avoids data inconsistency issues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760693A_ABST
    Figure CN118760693A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data warehouses, and provides a zipper table updating method and device and electronic equipment. The method comprises the following steps: monitoring a source data table to obtain an incremental log, obtaining reference time of target data from a zipper table storage unit or a preset state storage unit, and creating at least one data record for each piece of target data in the incremental log, the starting time of the at least one data record is determined by the reference time or the change time, and the ending time is determined by the change time or the preset maximum time, so that the created at least one data record is sent to the zipper table storage unit to update the zipper table, real-time updating of the zipper table based on the event is realized, and the user experience is improved. The calculation complexity is reduced, the updated data recording time information is convenient to obtain, the real-time performance is high, the delay is low, and the precision of data recording in the zipper table can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data warehouses, and in particular to a zipper table updating method, device and electronic device. Background Art

[0002] In the field of big data, in order to obtain historical slices of data, it is usually necessary to store the data in a zipper table. The zipper table of the traditional T+1 update method can usually only record the last data change of the day. The update granularity is too coarse, and the delay reaches the level of days. It is impossible to update the changes in time, resulting in data inconsistency. Therefore, it is necessary to update the data by generating a zipper table in real time, record every change of the data, reduce the delay and provide it for real-time data processing scenarios. Summary of the invention

[0003] In view of this, embodiments of the present application provide a zipper table updating method, device and electronic device to solve the problem of poor timeliness or high resource consumption of zipper table updating in the prior art.

[0004] According to a first aspect of an embodiment of the present application, a zipper table updating method is provided, comprising:

[0005] Obtaining an incremental log of a source data table, where the incremental log includes at least the data identifier, change type, and change time of the target data in the source data table, where the target data is the data that has changed;

[0006] Obtaining a reference time of the target data from the zipper table storage unit or the preset state storage unit, the reference time being the time when the target data was last changed;

[0007] Creating at least one data record for the target data according to the change type, wherein the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or the preset maximum time;

[0008] At least one data record is sent to the zipper table storage unit to update the zipper table.

[0009] According to a second aspect of an embodiment of the present application, a zipper table updating device is provided, comprising:

[0010] An acquisition module is configured to acquire an incremental log of a source data table, wherein the incremental log includes at least a data identifier, a change type, and a change time of target data in the source data table, and the target data is the data that has been changed;

[0011] The acquisition module is further configured to acquire a reference time of the target data from the zipper table storage unit or the preset state storage unit, the reference time being the time when the target data was last changed;

[0012] a creation module configured to create at least one data record for the target data according to the change type, wherein the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or the preset maximum time;

[0013] The update module is configured to send at least one data record to the zipper table storage unit to update the zipper table.

[0014] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0015] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application monitor the source data table to obtain an incremental log, and obtain the reference time of the target data from the zipper table storage unit or the preset state storage unit, and create at least one data record for each target data in the incremental log, wherein the start time of the at least one data record is determined by the reference time or the change time, and the end time is determined by the change time or the preset maximum time, and then the at least one created data record is sent to the zipper table storage unit to update the zipper table, thereby realizing real-time update of the zipper table based on events, reducing computational complexity, and conveniently obtaining the updated data record time information, with high real-time performance and low latency, which can improve the accuracy of data records in the zipper table.

[0016] Furthermore, the monitoring of the source data table can be implemented using the flink framework without relying on external cache services. The flink framework has strong real-time data processing capabilities, and has the advantages of high throughput and low latency, which can improve query speed. Even if the program that implements this method is restarted, data loss will not occur by enabling the flink checkpoint mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 It is a scenario diagram of an application scenario of an embodiment of the present application.

[0019] Figure 2 It is a flowchart of a zipper table updating method provided in an embodiment of the present application.

[0020] Figure 3 It is a flowchart of a method for obtaining a reference time of target data from a zipper table storage unit or a preset state storage unit provided in an embodiment of the present application.

[0021] Figure 4 It is a flowchart of a method for creating at least one data record for target data when the change type is a new addition type provided in an embodiment of the present application.

[0022] Figure 5 It is a flowchart of a method for creating at least one data record for target data when the change type is an update type provided in an embodiment of the present application.

[0023] Figure 6 It is a flowchart of a method for creating at least one data record for target data when the change type is a deletion type provided in an embodiment of the present application.

[0024] Figure 7 It is a flowchart of another zipper table updating method provided in an embodiment of the present application.

[0025] Figure 8 It is a schematic diagram of a zipper table updating device provided in an embodiment of the present application.

[0026] Fig. 9 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0028] A zipper table updating method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0029] Figure 1 1 is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario may include a terminal device 1, a server 2 and a network 3.

[0030] The terminal device 1 may be a device configured with a source data table monitoring tool, such as a device configured with a flinkcdc tool, which obtains a binary log file (binlog) by monitoring the database storing the source data table. Furthermore, the terminal device 1 may also include a preset state storage unit, which is used to store data state information.

[0031] Server 2 may be a server for storing a zipper table. The zipper table may be partitioned and stored in the server. In one example, the zipper table may be partitioned by day according to the end time in the data. Server 2 may be a single server, or a server cluster consisting of several servers, or a cloud computing service center, which is not limited in the present embodiment.

[0032] Network 3 can be a wired network connected by coaxial cable, twisted pair and optical fiber, or it can be a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., which is not limited in the embodiments of the present application.

[0033] The user can monitor the change events in the source data table through terminal device 1, and generate an incremental log for the changed data. By parsing the incremental log and obtaining the reference time from the zipper table data record stored in the self-server or the preset state storage unit, different data records can be created for different types of change events, and the created data records can be used to update the zipper table.

[0034] It should be noted that the specific types, quantities and combinations of the terminal devices 1, the servers 2 and the networks 3 may be adjusted according to the actual requirements of the application scenarios, and the embodiments of the present application do not impose any restrictions on this.

[0035] As mentioned above, the zipper table of the traditional T+1 update method can usually only record the last data change of the day. The update granularity is too coarse, and the delay reaches the level of days. It is impossible to update the changes in time, resulting in data inconsistency. Therefore, it is necessary to update the data by generating a zipper table in real time, record every data change, reduce the delay and provide it for real-time data processing scenarios.

[0036] The related art provides a technical solution for partially updating the zipper table in real time, which processes each data change in the source data table in real time and updates the zipper table immediately. This processing method will lead to a large number of redundant calculations. For example, for data changes in different fields of the same data, this method will update the data records separately, which will inevitably lead to repeated calculations.

[0037] In view of this, an embodiment of the present application provides a zipper table updating method, which monitors the source data table to obtain an incremental log, and obtains the reference time of the target data from the zipper table storage unit or the preset state storage unit, creates at least one data record for each target data in the incremental log, and the start time of the at least one data record is determined by the reference time or the change time, and the end time is determined by the change time or the preset maximum time, and then sends the created at least one data record to the zipper table storage unit to update the zipper table, thereby realizing real-time update of the zipper table based on events, reducing the computational complexity, and the updated data record time information is convenient to obtain, with high real-time performance and low latency, which can improve the accuracy of data records in the zipper table.

[0038] Figure 2 It is a flowchart of a zipper table updating method provided in an embodiment of the present application. Figure 2 The zipper table update method can be done by Figure 1 The terminal device 1 executes. Figure 2 As shown, the method comprises the following steps:

[0039] In step S201, the incremental log of the source data table is obtained.

[0040] The incremental log includes at least the data identifier, change type and change time of the target data, and the target data is the data that has changed in the source data table.

[0041] In step S202, the reference time of the target data is obtained from the zipper table storage unit or the preset state storage unit.

[0042] The reference time is the time when the target data was last changed.

[0043] In step S203, at least one data record is created for the target data according to the change type.

[0044] The start time of at least one data record is determined by the reference time or the change time, and the end time of at least one data record is determined by the change time or the preset maximum time.

[0045] In step S204, at least one data record is sent to the zipper table storage unit to update the zipper table.

[0046] In an embodiment of the present application, the method can be executed by a terminal device. Furthermore, a resource management tool such as flinkcdc can be configured in the terminal device. The terminal device uses flinkcdc to monitor the data set storing the source data table to obtain the incremental log of the source data table. Among them, the incremental log includes information such as the data identifier, change type and change time of the target data. The target data refers to the data that has changed in the source data table. The incremental log can group each information according to the data identifier of the target data, that is, the information of the same target data is grouped as a group.

[0047] In an embodiment of the present application, a reference time of the target data can be obtained from a zipper table storage unit or a preset state storage unit. The reference time is the time when the target data was last changed. Subsequently, according to the type of change in the target data, at least one data record is created for the target data in different ways. Among them, the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or the preset maximum time. In other words, different data records can be created in different ways according to the type of change of different target data, and the methods for determining the start time and end time of each data record are different.

[0048] In the embodiment of the present application, the at least one created data record may be sent to the zipper table storage unit to update the zipper table.

[0049] According to the technical solution provided in the embodiment of the present application, the source data table is monitored to obtain an incremental log, and the reference time of the target data is obtained from the zipper table storage unit or the preset state storage unit, and at least one data record is created for each target data in the incremental log. The start time of the at least one data record is determined by the reference time or the change time, and the end time is determined by the change time or the preset maximum time. Then, the at least one created data record is sent to the zipper table storage unit to update the zipper table, thereby realizing real-time update of the zipper table based on events, reducing the computational complexity, and conveniently acquiring the updated data record time information, with high real-time performance and low latency, which can improve the accuracy of data records in the zipper table.

[0050] Figure 3 1 is a flow chart of a method for obtaining a reference time of target data from a zipper table storage unit or a preset state storage unit provided in an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:

[0051] In step S301, in response to the change type being an update type or a deletion type, the target data state information is queried in a preset state storage unit.

[0052] The target data status information includes at least the data identification and time information of the target data.

[0053] In step S302, in response to the query result being not empty, it is determined that the time information in the target data state information is the reference time.

[0054] In step S303, in response to the query result being empty, the latest data record of the target data is obtained from the zipper table storage unit, and the data start time in the latest data record is determined as the reference time.

[0055] In the embodiment of the present application, when the change type of the target data is an update type or a deletion type, it is necessary to use a reference time to determine the start time of the corresponding data record. Therefore, when determining that the change type of the target data is an update type or a deletion type, the target data state information can be first queried in the preset state storage unit. The preset state storage unit can be a storage unit deployed in the terminal device.

[0056] In one example, the data identifier of the target data can be used as a query variable to query whether there is a record corresponding to the data identifier in the preset state storage unit. If the query result is not empty, it indicates that the target data has a record in the preset state storage unit, so the record corresponding to the data identifier of the target data, that is, the time information in the target data state information, can be directly used as the reference time.

[0057] On the contrary, if the query result is empty, it indicates that the target data does not exist in the preset state storage unit. In this case, the reference time can be directly queried in the zipper table storage unit. In one example, since the data in the zipper table storage unit is partitioned by day using the end time in the data, the latest data record of the target data can be queried in the preset maximum time partition of the zipper table storage unit using the data identifier of the target data as the query variable, and the start time in the latest data record is used as the reference time.

[0058] By adopting the technical solution of the embodiment of the present application, data status information, including data identification and data time information, is pre-stored in a preset status storage unit in the terminal device, so that the terminal can easily and efficiently obtain the reference time of the target data, thereby improving the efficiency of subsequent creation of data records of the target data and improving the efficiency of updating the zipper table.

[0059] In the embodiment of the present application, the change type may include a new type, an update type, and a deletion type, and the change type may be obtained by querying the incremental log. In one example, the change type may be obtained by querying the "op" field of the incremental log. When op=i, it indicates that the change type is a new type; when op=u, it indicates that the change type is an update type; and when op=d, it indicates that the change type is a deletion type.

[0060] Furthermore, the incremental log may also include data information of the target data. Among them, for the target data of the update type, its data information may include data information before the update and data information after the update. It is understandable that for the target data of the added type and the deleted type, the incremental log may also include the data information field before the update and the data information field after the update, but the data information before the update of the target data of the added type is empty, and the data information after the update of the target data of the deleted type is empty.

[0061] Figure 4 1 is a flow chart of a method for creating at least one data record for target data when the change type is a new type provided in an embodiment of the present application. Figure 4 As shown, the method comprises the following steps:

[0062] In step S401, a new data record is created for the target data.

[0063] The identifier of the newly added data record is the same as the data identifier of the target data.

[0064] In step S402, the change time is used as the start time of the newly added data record, and the preset maximum time is used as the end time of the newly added data record.

[0065] In step S403, the data information of the target data in the incremental log is used as the data information of the newly added data record.

[0066] In step S404, a data status field is added to the newly added data record, and the data status is marked as normal.

[0067] In the embodiment of the present application, when the change type is a new addition type, a new data record can be created for the target data first, and then the contents of each field of the new data record can be filled in in sequence in the following manner: the data identifier of the target data is used as the data identifier of the new data record; the change time is used as the start time of the new data record, and the preset maximum time is used as the end time of the new data record; the data information of the target data in the incremental log is used as the data information of the new data record. Furthermore, a data status field can be added to the new data record, and the data status field can be marked as normal.

[0068] As mentioned above, the data information of the target data in the incremental log may include the data information before the change and the data information after the change. For the newly added type of target data, there is no data information before the change, that is, in the incremental log of the newly added type of target data, the data information before the change is empty, so the data information after the change can be directly used as the data information of the newly added data record.

[0069] In an example, if the content of a target data of a Binlog log is:

[0070]

[0071] Among them, before represents the data information of the target data before updating, after represents the data information of the target data after updating; id represents the data identifier of the target data, name and so on represent the data information of the target data; source represents the library name or table name; op represents the change type; ts_ms represents the change time; transaction represents the transaction, which is empty here.

[0072] From the content recorded in the above incremental log, it can be known that since op=i, the change type of the target data is a new addition type. At this time, a new data record can be created, and the data identifier of the target data is used as the identifier of the new data record, the change time ts_ms is used as the start time of the new data record, the preset maximum time such as "9999-12-31" is used as the end time of the new data record, and the data information is used as the data information of the new data record. Furthermore, a data status field state can be added to the new data record, and the state is set to 1 to indicate that the status of the target data is normal, thereby obtaining an exemplary new data record as follows:

[0073] "id":001, "start_time": "2024-04-25T14:29:11.123Z", "end_time": "9999-12-31", "state":1, "name": "lily",...

[0074] In the embodiment of the present application, further, when the change type is a new type, the method for creating at least one data record for the target data may also include:

[0075] In step S405, the data identifier and data status of the target data are obtained from the newly added data record.

[0076] In step S406, the data identifier and data state of the target data are saved in a preset state storage unit.

[0077] In an embodiment of the present application, after a new data record of the target data is created, since the target data is new data, its status information is not saved in the original preset status storage unit. Therefore, it is necessary to synchronously save the status information of the target data to the preset status storage unit so that when the target data changes again, its status information can be quickly queried from the preset status storage unit.

[0078] In an embodiment of the present application, the data identifier and data status of the target data can be obtained from the newly added data record, and then the data identifier and data status of the target data can be saved to a preset state storage unit, thereby completing the synchronization of the target data state information in the preset state storage unit.

[0079] Figure 5 1 is a flow chart of a method for creating at least one data record for target data when the change type is an update type provided in an embodiment of the present application. Figure 5 As shown, the method comprises the following steps:

[0080] In step S501, two update data records are created for the target data.

[0081] The identifiers of the two updated data records are the same as the data identifier of the target data.

[0082] In step S502, the reference time is used as the start time of the first update data record, and the change time is used as the end time of the first update data record.

[0083] In step S503, the data information before the target data is updated in the incremental log is used as the data information of the first updated data record.

[0084] In step S504, a data status field is added to the first update data record, and the data status is marked as normal.

[0085] In step S505, the change time is increased by a preset threshold as the start time of the second update data record, and the preset maximum time is used as the end time of the second update data record.

[0086] In step S506, the updated data information of the target data in the incremental log is used as the data information of the second updated data record.

[0087] In step S507, a data status field is added to the second update data record, and the data status is marked as normal.

[0088] In an embodiment of the present application, when the change type is an update type, two update data records may be created for the target data, one for recording the data information before the update, and the other for recording the data information after the update.

[0089] For the first update data record that records the data information before the update, the contents of each field can be filled in order in the following manner: the data identifier of the target data is used as the data identifier of the first update data record; the reference time is used as the start time of the first update data record, and the change time is used as the end time of the first update data record; the data information before the change of the target data is used as the data information of the first update data record. Furthermore, a data status field can be added to the first update data record, and the data status field can be marked as normal.

[0090] For the second update data record that records the updated data information, the contents of each field can be filled in order in the following manner: the data identifier of the target data is used as the data identifier of the second update data record; the change time is used as the start time of the second update data record, and the preset maximum time is used as the end time of the second update data record; the changed data information of the target data is used as the data information of the second update data record. Furthermore, a data status field can also be added to the second update data record, and the data status field can be marked as normal.

[0091] In one example, if the content of another target data of the Binlog log is:

[0092]

[0093]

[0094] Since op=u, the change type of the target data is an update type. At this time, two update data records can be created, and the data identifier of the target data is used as the identifier of the two update data records, the reference time is used as the start time of the first update data record, the change time ts_ms is used as the end time of the first update data record, and the start time of the second update data record, the preset maximum time such as "9999-12-31" is used as the end time of the second update data record, the data information in the before field is used as the data information of the first update data record, and the data information in the after field is used as the data information of the second update data record. Furthermore, a data status field state can be added to each of the two update data records, and the state is set to 1 to indicate that the status of the target data is normal, thereby obtaining two exemplary update data records as follows:

[0095] "id":001, "start_time": "2024-04-25T14:29:11.123Z", "end_time": "2024-04-25T19:47:58.123Z", "state":1, "name": "lily",...

[0096] "id":001, "start_time": "2024-04-25T19:47:58.124Z", "end_time": "9999-12-31", "state":1, "name": "jimi",...

[0097] In the embodiment of the present application, further, the method of creating at least one data record for the target data when the change type is an update type may also include:

[0098] In step S508, the time information of the target data in the preset state storage unit is updated by increasing the preset threshold value using the change time, and the updated target data information in the preset state storage unit is obtained.

[0099] In the embodiment of the present application, after the update data record of the target data is created, since the change event of the target data has changed, that is, the state of the target data has changed, it is necessary to update the state information in the preset state storage unit. When updating, the state information of the target data can be synchronously saved to the preset state storage unit, including using the change time to update the time information of the target data in the preset state storage unit.

[0100] Figure 6 1 is a flow chart of a method for creating at least one data record for target data when the change type provided by the embodiment of the present application is a deletion type. Figure 6 As shown, the method comprises the following steps:

[0101] In step S601, two deletion data records are created for the target data.

[0102] The identifiers of the two deleted data records are the same as the data identifier of the target data.

[0103] In step S602, the reference time is used as the start time of the first deleted data record, and the change time is used as the end time of the first deleted data record.

[0104] In step S603, the data information of the target data in the incremental log is used as the data information of the first deleted data record.

[0105] In step S604, a data status field is added to the first deleted data record, and the data status is marked as normal.

[0106] In step S605, the change time is increased by a preset threshold as the start time of the second deleted data record, and the preset maximum time is used as the end time of the second deleted data record.

[0107] In step S606, the data information of the target data in the incremental log is used as the data information of the second deleted data record.

[0108] In step S607, a data status field is added to the second deleted data record, and the data status is marked as abnormal.

[0109] In an embodiment of the present application, when the change type is a deletion type, two deletion data records may be created for the target data, one for recording the data information before the deletion, and the other for recording the data information after the deletion.

[0110] For the first deleted data record that records the data information before deletion, the contents of each field can be filled in order in the following manner: the data identifier of the target data is used as the data identifier of the first deleted data record; the reference time is used as the start time of the first deleted data record, and the change time is used as the end time of the first deleted data record; the data information before the change of the target data is used as the data information of the first deleted data record. Furthermore, a data status field can be added to the first deleted data record, and the data status field can be marked as normal.

[0111] For the second deleted data record of the data information after the record is deleted, the contents of each field can be filled in order in the following manner: the data identifier of the target data is used as the data identifier of the second deleted data record; the change time is used as the start time of the second deleted data record, and the preset maximum time is used as the end time of the second deleted data record; the data information of the target data in the incremental log is used as the data information of the second deleted data record. Furthermore, a data status field can be added to the second deleted data record, and the data status field can be marked as abnormal.

[0112] As mentioned above, the data information of the target data in the incremental log may include the data information before the change and the data information after the change. For the target data of the deletion type, there is no data information after the change, that is, in the incremental log of the target data of the deletion type, the data information after the change is empty, so the data information before the change can be directly used as the data information of the two deletion data records.

[0113] In one example, if the content of another target data of the Binlog log is:

[0114]

[0115] Since op=d, the change type of the target data is a deletion type. At this time, two deletion data records can be created, and the data identifier of the target data is used as the identifier of the two deletion data records, the reference time is used as the start time of the first deletion data record, the change time ts_ms is used as the end time of the first deletion data record, and the start time of the second deletion data record, the preset maximum time such as "9999-12-31" is used as the end time of the second deletion data record, and the data information in the before field is used as the data information of the first deletion data record and the second deletion data record. Furthermore, a data status field state can be added to each of the two deletion data records, and the state of the first day's deletion data record is set to 1 to indicate that the state of the target data corresponding to the record is normal, and the state of the second deletion data record is set to 0 to indicate that the state of the target data corresponding to the record is abnormal, and the two exemplary deletion data records are obtained as follows:

[0116] "id":001, "start_time": "2024-04-25T19:47:58.124Z", "end_time": "2024-04-26T10:14:38.245Z", "state":1, "name": "jimi",...

[0117] "id":001, "start_time": "2024-04-26T10:14:38.246Z", "end_time": "9999-12-31", "state":0, "name": "jimi",...

[0118] In the embodiment of the present application, further, the method of creating at least one data record for the target data when the change type is a deletion type may also include:

[0119] In step S608, the target data state information is queried in the preset state storage unit.

[0120] In step S609, in response to the query result being not empty, the target data state information is deleted.

[0121] In the embodiment of the present application, after the deletion data record of the target data is created, since the target data has been deleted, the state information of the target data needs to be synchronously deleted from the preset state storage unit. When deleting, the data identifier of the target data can be used to query in the preset state storage unit, and the query result can be deleted.

[0122] Figure 7FIG. 1 is a flow chart of another zipper table updating method provided in an embodiment of the present application. Figure 7 As shown, the source data table can be determined first; then flinkcdc is used to monitor the source data table to obtain binlog logs; next, the binlog logs are parsed and grouped according to the primary key identifier (identity document, id); for each group of data, the operation type is first determined according to the op field in the binlog log; if the operation type is a new type, the data in the after field in the binlog and the change event in the ts_ms field are taken out, the change time is formatted as the start time, "9999-12-31" is used as the end time, and the state field is added to mark the state as normal, and then these fields are assembled into the newly added data record and stored in doris, and the change time is formatted and stored in the state storage unit.

[0123] If the operation type is update or delete, you can first query whether the state is empty in the state storage unit. If not, take out the state value and record it as start_time. If so, query the value of the start_ts field from the "9999-12-31" partition of Doris according to the id, and record the value as start_time; next, for the update operation type, you can take out the data of before and ts_ms change time in the binlog, format the change time as the end time, use start_time as the start time, and mark the state as normal, as the first update data record for recording historical data; on the other hand, take out the data of the after field in the binlog, increase the preset threshold value for the change time, for example, add one millisecond as the start time, "9999-12-31" as the end time, and mark the state as normal, and assemble to obtain the second update data record; finally, store both update data records in Doris, and add one millisecond to the above change time for formatting and store it in the state storage unit.

[0124] For the deletion operation type, the data of before and ts_ms change time in binlog can be taken out, the change time can be formatted as the end time, start_time can be used as the start time, and the state mark status is normal, as the first deletion data record recording historical data; on the other hand, the data of the before field in binlog is still taken out, and the change time increases the preset threshold, for example, one millisecond is added as the start time, "9999-12-31" is used as the end time, and the state mark status is abnormal, and the second deletion data record is assembled; finally, both deletion data records are stored in doris, and the status of the data is deleted in the state storage unit.

[0125] In other words, the zipper table can be a zipper wide table, and the zipper wide table is stored in Doris. The primary key model of Doris can be used to update according to the primary key. The zipper table is partitioned by day according to the end time in the data, and the end time and the primary key in the source data are used as the primary key in the zipper table; to query the latest status, it is to filter out the data in the normal state from the "9999-12-31" partition; to query the deleted data and the last status, it is to filter out the deleted data from the "9999-12-31" partition, and to query the historical slice at a certain moment, it is to use the start time and the end time for range search.

[0126] Users can use flinkCDC to monitor the required source data table and obtain binlog logs. Then parse the logs and group them according to the primary key ID in the data. Then perform different processing according to the different operation types in the binlog logs.

[0127] If the operation type is new, the content of the after field in the log is the new content. The start_time, end_time, and state fields are added to the new content. The start_time is formatted with the update time of the ts_ms field in the log. The end_time is "9999-12-31" to indicate the latest state. The state is 1 to indicate the normal state. The assembled data is written to doris, and the ts_ms field is formatted with time and stored in the flink state.

[0128] If the operation type is not new, you can first query whether there is a value in the status. If so, return the value. If not, query the value of start_time in the data of the id in the "9999-12-31" partition in the doris table and return the value.

[0129] If the operation type is update, you can take out the data before and ts_ms change time in the log, format the change time as the end time, use start_time as the start time, and mark the state as normal. This is historical data; take out the data after the log, add one millisecond to the change time and format it as the start time, "9999-12-31" as the end time, and mark the state as normal. Assemble the data into the latest state, add one millisecond to the change time, format it, and save it in the state.

[0130] If the operation type is deletion, you can take out the data in the before field in the log and the change time in the ts_ms field, format the change time as the end time, use start_time as the start time, add the state field to mark the status as normal, this is historical data, change the start time in this data to the end time to "9999-12-31", mark the state as abnormal, assemble it into data marked for deletion, and clear the data in the state.

[0131] The technical solution provided by the embodiment of the present application queries the latest status of the data, that is, filters out the normal status data with state 1 in the "9999-12-31" partition in the zipper table, queries the deleted data, that is, the last status, filters out the deleted status data with state 0 in the "9999-12-31" partition, and queries the data status at a certain time time, that is, the time range of the fields start_time and end_time in the query table includes the data of time. According to the operation type of the target data in the source data table that sends different changes, the corresponding data records can be quickly generated, and the zipper table can be updated using the data records. In the application scenario of obtaining historical slices in the big data field, a fine-grained real-time update method of the zipper table is provided.

[0132] By adopting the technical solution provided in the embodiment of the present application, the zipper table can be generated or updated in real time, and the changes in data can be recorded in real time to ensure consistency with the data source; the data granularity of this method is accurate to each change of the source data, rather than only recording the last change of the day. At the same time, by using the flink framework, high real-time data processing can be achieved, with the advantages of high throughput and low latency.

[0133] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0134] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0135] Figure 8 Schematic diagram of a zipper table updating device provided in an embodiment of the present application. Figure 8 As shown, the device comprises:

[0136] The acquisition module 801 is configured to acquire the incremental log of the source data table. The incremental log includes at least the data identifier, change type and change time of the target data in the source data table. The target data is the data that has changed.

[0137] The acquisition module 801 is further configured to acquire a reference time of the target data from the zipper table storage unit or the preset state storage unit, where the reference time is the time when the target data was last changed.

[0138] The creation module 802 is configured to create at least one data record for the target data according to the change type, the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or the preset maximum time.

[0139] The updating module 803 is configured to send at least one data record to the zipper table storage unit to update the zipper table.

[0140] According to the technical solution provided in the embodiment of the present application, the source data table is monitored to obtain an incremental log, and the reference time of the target data is obtained from the zipper table storage unit or the preset state storage unit, and at least one data record is created for each target data in the incremental log. The start time of the at least one data record is determined by the reference time or the change time, and the end time is determined by the change time or the preset maximum time. Then, the at least one created data record is sent to the zipper table storage unit to update the zipper table, thereby realizing real-time update of the zipper table based on events, reducing the computational complexity, and conveniently acquiring the updated data record time information, with high real-time performance and low latency, which can improve the accuracy of data records in the zipper table.

[0141] In an embodiment of the present application, obtaining a reference time of target data from a zipper table storage unit or a preset state storage unit includes: in response to a change type being an update type or a deletion type, querying target data state information in a preset state storage unit, the target data state information including at least a data identifier and time information of the target data; in response to a query result being not empty, determining the time information in the target data state information as a reference time; in response to a query result being empty, obtaining the latest data record of the target data from the zipper table storage unit, and determining the data start time in the latest data record as the reference time.

[0142] In an embodiment of the present application, the change type includes at least a new type, and the incremental log also includes data information of the target data; in response to the change type being a new type, at least one data record is created for the target data, including: creating a new data record for the target data, the identifier of the new data record is the same as the data identifier of the target data; using the change time as the start time of the new data record, and the preset maximum time as the end time of the new data record; using the data information of the target data in the incremental log as the data information of the new data record; adding a data status field in the new data record, and marking the data status as normal.

[0143] In the embodiment of the present application, after completing the creation of the new data record, it also includes: obtaining the data identifier and data status of the target data from the new data record; and saving the data identifier and data status of the target data to a preset status storage unit.

[0144] In an embodiment of the present application, the change type includes at least an update type, and the incremental log also includes data information of the target data, and the data information includes data information before the update and data information after the update; in response to the change type being an update type, at least one data record is created for the target data, including: creating two update data records for the target data, and the identifiers of the two update data records are the same as the data identifier of the target data; using the reference time as the start time of the first update data record, and the change time as the end time of the first update data record; using the data information before the update of the target data in the incremental log as the data information of the first update data record; adding a data status field in the first update data record, and marking the data status as normal; increasing the change time by a preset threshold as the start time of the second update data record, and the preset maximum time as the end time of the second update data record; using the data information after the update of the target data in the incremental log as the data information of the second update data record; adding a data status field in the second update data record, and marking the data status as normal.

[0145] In the embodiment of the present application, after completing the creation of the update data record, it also includes: using the change time to increase the preset threshold to update the time information of the target data in the preset state storage unit, and obtaining the updated target data information in the preset state storage unit.

[0146] In an embodiment of the present application, the change type includes at least a deletion type, and the incremental log also includes data information of the target data; in response to the change type being a deletion type, at least one data record is created for the target data, including: creating two deletion data records for the target data, the identifiers of the two deletion data records are the same as the data identifier of the target data; using the reference time as the start time of the first deletion data record, and the change time as the end time of the first deletion data record; using the data information of the target data in the incremental log as the data information of the first deletion data record; adding a data status field in the first deletion data record, and marking the data status as normal; increasing the change time by a preset threshold as the start time of the second deletion data record, and the preset maximum time as the end time of the second deletion data record; using the data information of the target data in the incremental log as the data information of the second deletion data record; adding a data status field in the second deletion data record, and marking the data status as abnormal.

[0147] In the embodiment of the present application, after completing the creation of the deleted data record, it also includes: querying the target data status information in the preset status storage unit; in response to the query result being not empty, deleting the target data status information.

[0148] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0149] Fig. 9 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 9 of this embodiment includes: a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901. When the processor 901 executes the computer program 903, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 901 executes the computer program 903, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0150] The electronic device 9 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 9 may include, but is not limited to, a processor 901 and a memory 902. Those skilled in the art will appreciate that Fig. 9 The electronic device 9 is merely an example and does not limit the electronic device 9 , and may include more or less components than those shown in the figure, or different components.

[0151] The processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0152] The memory 902 may be an internal storage unit of the electronic device 9, for example, a hard disk or memory of the electronic device 9. The memory 902 may also be an external storage device of the electronic device 9, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 9. The memory 902 may also include both an internal storage unit of the electronic device 9 and an external storage device. The memory 902 is used to store computer programs and other programs and data required by the electronic device.

[0153] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0154] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A zipper table updating method, characterized in that: include: Obtaining an incremental log of a source data table, wherein the incremental log includes at least a data identifier, a change type, and a change time of target data, wherein the target data is data that has changed in the source data table; Acquire a reference time of the target data from a zipper table storage unit or a preset state storage unit, where the reference time is the time when the target data was last changed; Creating at least one data record for the target data according to the change type, wherein the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or a preset maximum time; The at least one data record is sent to the zipper table storage unit to update the zipper table.

2. The method according to claim 1, characterized in that: The obtaining of the reference time of the target data from the zipper table storage unit or the preset state storage unit includes: In response to the change type being an update type or a deletion type, querying the target data state information in the preset state storage unit, the target data state information at least including a data identifier and time information of the target data; In response to the query result being not empty, determining that the time information in the target data state information is the reference time; In response to the query result being empty, the latest data record of the target data is obtained from the zipper table storage unit, and the data start time in the latest data record is determined as the reference time.

3. The method according to claim 1, characterized in that: The change type at least includes a new addition type, and the incremental log also includes data information of the target data; In response to the change type being a new addition type, creating at least one data record for the target data includes: Creating a new data record for the target data, wherein the identifier of the new data record is the same as the data identifier of the target data; The change time is used as the start time of the newly added data record, and the preset maximum time is used as the end time of the newly added data record; Using the data information of the target data in the incremental log as the data information of the newly added data record; A data status field is added to the newly added data record, and the data status is marked as normal.

4. The method according to claim 3, characterized in that After completing the creation of the newly added data record, the method further includes: Acquire the data identifier and data status of the target data from the newly added data record; The data identifier and data status of the target data are saved in the preset status storage unit.

5. The method according to claim 1, characterized in that: The change type at least includes an update type, and the incremental log also includes data information of the target data, and the data information includes data information before the update and data information after the update; In response to the change type being an update type, creating at least one data record for the target data includes: Creating two update data records for the target data, wherein the identifiers of the two update data records are the same as the data identifier of the target data; Using the reference time as the start time of the first update data record, and the change time as the end time of the first update data record; Using the data information before the target data is updated in the incremental log as the data information of the first update data record; Adding a data status field in the first update data record, and marking the data status as normal; Increasing the change time by a preset threshold value as the start time of the second update data record, and the preset maximum time as the end time of the second update data record; Using updated data information of the target data in the incremental log as data information of the second updated data record; A data status field is added to the second update data record, and the data status is marked as normal.

6. The method according to claim 5, characterized in that After completing the creation of the update data record, the method further includes: The preset threshold is increased by using the change time to update the time information of the target data in the preset state storage unit, and the updated target data information in the preset state storage unit is obtained.

7. The method according to claim 1, characterized in that The change type at least includes a deletion type, and the incremental log also includes data information of the target data; In response to the change type being a deletion type, creating at least one data record for the target data includes: Creating two deletion data records for the target data, wherein the identifiers of the two deletion data records are the same as the data identifier of the target data; Using the reference time as the start time of the first deleted data record, and the change time as the end time of the first deleted data record; Using the data information of the target data in the incremental log as the data information of the first deleted data record; Adding a data status field in the first deleted data record, and marking the data status as normal; Increasing the change time by a preset threshold value as the start time of the second deletion data record, and the preset maximum time as the end time of the second deletion data record; Using the data information of the target data in the incremental log as the data information of the second deleted data record; A data status field is added to the second deleted data record, and the data status is marked as abnormal.

8. The method according to claim 7, characterized in that After completing the creation of the deletion data record, the method further includes: Query the target data status information in the preset status storage unit; In response to the query result being not empty, the target data state information is deleted.

9. A zipper table updating device, characterized in that: include: An acquisition module is configured to acquire an incremental log of a source data table, wherein the incremental log includes at least a data identifier, a change type, and a change time of target data in the source data table, wherein the target data is data that has changed; The acquisition module is further configured to acquire a reference time of the target data from the zipper table storage unit or the preset state storage unit, the reference time being the time when the target data was last changed; a creation module, configured to create at least one data record for the target data according to the change type, wherein the start time of the at least one data record is determined by the reference time or the change time, and the end time of the at least one data record is determined by the change time or a preset maximum time; An updating module is configured to send the at least one data record to the zipper table storage unit to update the zipper table.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.