A method, device and system for writing data into a data table in real time

By marking the table identifier and database identifier for the data to be written, and using the unified data interface to find the task writer for parallel and serial writing, the problem of multiple Flink task flows and high cost when synchronizing multiple tables in the existing technology is solved. Realized the rational utilization of resources and improved writing speed.

CN117874035BActive Publication Date: 2024-09-24CHINA ELECTRONICS INVESTMENT HLDG LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410153631.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2024-09-24
Estimated Expiration
2044-02-02

AI Technical Summary

Technical Problem

In the existing technology, multiple Flink real-time task streams need to be started when synchronizing multiple tables, resulting in high operation and maintenance management costs, insufficient utilization of CPU memory resources, and increased monitoring and resource allocation costs.

Method used

By marking the table identifier and database identifier for each piece of data to be written, the data is encapsulated into packaged data in a preset format. The unified data interface is sent to the distribution unit, and the matching task writer finds the matching task writer and writes the data table in parallel, reducing Flink tasks. The number of streams enables parallel and serial writing of data.

Benefits of technology

It reduces the number of flow tasks and operation and maintenance management costs, improves resource utilization, reduces monitoring costs, and improves the speed of data writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117874035B
    Figure CN117874035B
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device and system for writing data into a data table in real time, which relates to the field of data storage. The method includes: marking the corresponding table identifier for each piece of data to be written, and marking the library identifier of the database where the data table is located, and encapsulating each piece of data to be written into encapsulated data of a preset data format; searching for a task writer matching the table identifier corresponding to each piece of encapsulated data through the allocation unit; writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in parallel through each task writer, and for any task writer, the task writer writes the data corresponding to the matched encapsulated data serially to the data table corresponding to the table identifier in the order of the sending time. The data written into multiple data sheets can be written in parallel at the same time; the data written into a single data table is written serially to improve the writing speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data storage, and in particular to a method, device and system for writing data into a data table in real time. Background Art

[0002] like Figure 3 As shown, it is a flowchart of writing data into the data table of Iceberg in the prior art, and the writing process is based on a single table design. Every time a table is synchronously written to Iceberg, a Flink real-time task flow needs to be suspended at the same time, that is, when synchronizing multiple tables, multiple Flink task flows need to be started in sequence, and the operation and maintenance management cost is high; CPU memory resource utilization may also be insufficient. In actual scenarios, there is no shortage of synchronization of multiple tables and entire databases. Because the number of tables in actual business is very large, the same number of real-time stream tasks need to be started. In this case, it is necessary to monitor these real-time stream tasks, and it is also necessary to estimate and allocate reasonable resources for each real-time stream task. Otherwise, it is difficult to fully utilize resources, so the operation and maintenance management cost is greatly increased. Summary of the invention

[0003] The embodiments of the present invention provide a method, device and system for writing data into a data table in real time, which can solve the technical problems in the prior art of having many real-time flow tasks when synchronizing multiple tables, high cost of monitoring real-time flow tasks and greatly increased operation and maintenance management costs.

[0004] To achieve the above-mentioned purpose, in a first aspect, an embodiment of the present invention provides a method for writing data into a data table in real time, comprising:

[0005] According to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, each piece of data to be written is marked with a corresponding table identifier and a library identifier of the database where the data table is located, and each piece of data to be written is encapsulated into encapsulated data in a preset data format;

[0006] Use a unified data interface to send each piece of encapsulated data to the distribution unit in real time;

[0007] Find the task writer matching the table identifier corresponding to each piece of encapsulated data through the allocation unit;

[0008] The data corresponding to the matching encapsulated data are written into the data table corresponding to the table identifier in parallel through each task writer. For any task writer, the data corresponding to the matching encapsulated data are written into the data table corresponding to the table identifier in serial order according to the sending time through the task writer.

[0009] In a second aspect, an embodiment of the present invention provides a device for writing data into a data table in real time, comprising:

[0010] A data conversion unit is used to mark the corresponding table identifier for each piece of data to be written and the library identifier of the database where the data table is located according to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, and to encapsulate each piece of data to be written into encapsulated data of a preset data format;

[0011] A transition unit, used to send each piece of encapsulated data to the distribution unit in real time using a unified data interface;

[0012] An allocation unit, used for searching a task writer matching a table identifier corresponding to each piece of encapsulated data through the allocation unit;

[0013] The task writer is used to write the data corresponding to the matching encapsulated data into the data table corresponding to the table identifier in parallel through each task writer. For any task writer, the task writer writes the data corresponding to the matching encapsulated data serially into the data table corresponding to the table identifier in the order of issuance time.

[0014] In a third aspect, an embodiment of the present invention provides a system for writing data into a data table in real time, comprising the aforementioned device for writing data into a data table in real time, and a database, wherein:

[0015] A database is used to store data tables into which packaged data is written.

[0016] The above technical scheme has the following beneficial effects: only need to mark the corresponding data table identifier and database identifier of the captured data source to be written, and change the data type (i.e., data format) and encapsulate it into encapsulated data of the preset data format, then the user can automatically send multiple encapsulated data to the transition unit at the same time, and the transition unit sends each encapsulated data to the allocation unit in real time through the unified data interface, and searches for the task writer matching the data table identifier corresponding to each encapsulated data through the allocation unit; division of labor and cooperation, it is not necessary to set the corresponding Flink task flow for the data written to different data tables when they appear alternately, thus reducing the number of Flink task flows. Each task writer writes the data corresponding to each encapsulated data to the data table corresponding to the data table identifier in parallel, so that the data written to multiple data can be written in parallel at the same time; for any task writer, the task writer writes the data corresponding to the matching encapsulated data to the data table corresponding to the table identifier in serial order according to the sending time, so as to realize the serial writing of the data written to a single data table and improve the writing speed; the number of flow tasks is reduced overall, the cost of monitoring flow tasks is reduced, the operation and maintenance management cost is reduced, and the rational use of resources is realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 is a flow chart of a method for writing data into a data table in real time according to an embodiment of the present invention;

[0019] Figure 2 It is a logical structure diagram of a device for writing data into a data table in real time according to an embodiment of the present invention;

[0020] Figure 3 It is a flow chart of writing data into Iceberg's data table in the prior art;

[0021] Figure 4 is another flow chart of writing data into a data table in real time according to an embodiment of the present invention;

[0022] Figure 5 is a flow chart of converting the data to be written into packaged data in a preset data format according to an embodiment of the present invention;

[0023] Figure 6 4 is a flowchart of file information registration according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] The technical terms involved in the embodiments of the present invention are defined as follows:

[0026] Iceberg is a data lake with open tables for large analytical data sets. The data lake is a centralized repository that can store structured and unstructured data of any size, supports big data and AI computing, and provides unified metadata management and enterprise-level permission control on the data lake. It can also seamlessly connect to multiple computing engines, break data silos, and gain insights into business value.

[0027] Apache Iceberg is a device for receiving and storing large analytical data sets in an embodiment of the present invention;

[0028] RowData is a data format;

[0029] Datastream is an abstract description object of data stream;

[0030] IcebergRowData is a data format;

[0031] IcebergRecord is a data format;

[0032] IcebergSink is a transition unit.

[0033] TaskWriter, task writer;

[0034] Apache Flink is an engine and framework for distributed processing of stateful computations on bounded and unbounded data streams. Apache Flink CDC is a set of source connectors for Apache Flink, referred to as Flink CDC.

[0035] IcebergStreamWriter / IcebergFileCommiter / IcebergLightMerge: All are intermediate operators in the Flink framework, where IcebergStreamWriter is the allocation unit, IcebergFileCommiter is the registrar, and IcebergLightMerge is the merging subunit;

[0036] Checkpoint: An operation that makes Flink state fault-tolerant, allowing the state and the corresponding stream position to be restored;

[0037] Due to industry practice, most of the names in the embodiments of the present invention are expressed in English. Those that are not translated into Chinese have no specific Chinese meaning and only need to implement the corresponding functions.

[0038] like Figure 1 As shown, in combination with an embodiment of the present invention, a method for writing data into a data table in real time is provided, comprising:

[0039] S101: According to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, each piece of data to be written is marked with a corresponding table identifier and a library identifier of the database where the data table is located, and each piece of data to be written is encapsulated into encapsulated data in a preset data format;

[0040] S102: using a unified data interface to send each piece of encapsulated data to a distribution unit in real time;

[0041] S103: searching, through the allocation unit, for a task writer that matches the table identifier corresponding to each piece of encapsulated data;

[0042] S104: The task writers write the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in parallel. For any task writer, the task writer writes the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in serial order according to the sending time.

[0043] The embodiment of the present invention only needs to mark the corresponding data table identifier and database identifier of the captured data source to be written, and change the data type (i.e., data format) to encapsulate it into encapsulated data of a preset data format. Then, the user can automatically send multiple encapsulated data to the transition unit at the same time. The transition unit sends each encapsulated data to the allocation unit in real time through a unified data interface, and the allocation unit searches for a task writer that matches the data table identifier corresponding to each encapsulated data. With division of labor and cooperation, there is no need to set up corresponding Flink task flows for the data written to different data tables that appear alternately when they appear, thereby reducing the number of Flink task flows.

[0044] Through each task writer, the data corresponding to each encapsulated data is written into the data table corresponding to the data table identifier in parallel, so that the data of multiple data can be written in parallel at the same time; for any task writer, through the task writer, the data corresponding to the matching encapsulated data is written serially to the data table corresponding to the table identifier in the order of issuance time, so that the data written into a single data table is written serially and the writing speed is improved; overall, the number of flow tasks is reduced, the cost of monitoring flow tasks is reduced, the operation and maintenance management cost is reduced, and the rational use of resources is achieved.

[0045] Specifically, Apache Iceberg is designed based on the computing distributed processing framework Apache Flink and the data lake framework Iceberg. Compared with the original connector design of Apache Flink and Iceberg, Apache Iceberg strengthens the function of the connector. It can dynamically synchronize the data of various data sources to multiple data tables of Apache Iceberg by relying on the excellent streaming data synchronization capability of Apache Flink. The writing process is as follows: Figure 4 shown.

[0046] Based on the Flink framework, in order to dynamically write multiple data to be written into their corresponding data tables at the same time and in parallel, when the data to be written is captured, the format of the data to be written is unified into a preset data format, and each data to be written is marked with the corresponding data table identifier and the database identifier of the database where the data table is located, thereby forming encapsulated data. Each preset data format has specific requirements, and can achieve the simultaneous and parallel writing of multiple data to be written into their corresponding data tables (i.e. Iceberg).

[0047] like Figure 3 As shown, the data to be written in the RowData, IcebergRowData or IcebergRecord data format captured in the DataStream stream from the data source in the future will be converted into a data stream type with a preset data format of the DataStream required by the transition unit (IcebergSink) through corresponding format conversion (Map).

[0048] Preferably, the method for writing data into a data table in real time further includes:

[0049] S105: Capturing, by a first data capture unit, data to be written whose storage type is a newly added data type; wherein the storage type marked in the data to be written is a newly added data type;

[0050] S106: Capture, through the second data capture unit, data to be written of the deletion data type and data to be written of the update data type; wherein, for the data to be written of the update data type, the storage type marked in the data to be written is the update data type; for the data to be written of the deletion data type, the storage type marked in the data to be written is the deletion data type.

[0051] S105 and S106 are both executed before S101, and the data to be written is captured by the first data capture unit and the second data capture unit, so as to facilitate the subsequent marking of the corresponding data table identifier for each data to be written according to the data type, and the database identifier of the database where the data table is located, and encapsulate each data to be written into encapsulated data in a preset data format.

[0052] Specifically, Figure 5As shown, the first data capture unit captures the data to be written in the RowData data format from the data source (such as log data), and the second data capture unit Apache Flink CDC captures the data to be written in the RowData, IcebergRowData or IcebergRecord data format from all data sources; each piece of data to be written needs to be marked with the database identifier and data table identifier to be written, and finally form encapsulated data; so that the encapsulated data can be sent to the transition unit (IcebergSink) in the form of a data stream (Datastream), and then the task writer (TaskWriter) can dynamically write the data in the encapsulated data into the corresponding target data table according to the table identifier. Among them, the database identifier and the data table identifier are both unique. When Apache Flink CDC is used, it is set to access multiple databases, such as MySQL, PostgreSQL, Oracle, and SQL Server, thereby realizing access to serialization interfaces for operations on different data formats. The default is the basic lightweight data exchange format (json). Therefore, after Apache Flink CDC captures the data to be written in the IcebergRowData or IcebergRecord data format from the data source, it can directly convert the data to be written into the required preset data format, that is, output the data stream type required by the transition unit (IcebergSink).

[0053] Preferably, for the data to be written whose storage type is a newly added data type, the data to be written carries the newly added data;

[0054] For the data to be written whose storage type is the deletion data type, the data to be written carries any characteristic data of the first stored data to be deleted;

[0055] For the data to be written whose storage type is the update data type, the data to be written carries the update data and any characteristic data of the second stored data corresponding to the update data;

[0056] S101: According to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, each piece of data to be written is marked with a corresponding table identifier and a library identifier of the database where the data table is located, and each piece of data to be written is encapsulated into encapsulated data in a preset data format, including:

[0057] S101-1: When the storage type is a newly added data type, according to the newly added data, the table identifier of the data table to which the newly added data is to be written and the library identifier of the database where the data table is located are searched in the table allocation list, the table identifier and the library identifier are marked for the newly added data in the data to be written, and the data is packaged into the first newly added type packaged data in a preset data format, wherein the table identifiers corresponding to the data tables into which different data contents are written are set in advance in the table allocation list;

[0058] S101-2: When the storage type is a deletion data type, according to any characteristic data of the first stored data to be deleted, the table identifier of the data table where the first stored data is located and the library identifier of the database where the data table is located are searched in the table allocation list, the table identifier and the library identifier are marked for any characteristic data of the first stored data, and the data are encapsulated into first deletion type encapsulation data in a preset data format;

[0059] S101-3: When the storage type is an update data type, according to any characteristic data of the second stored data corresponding to the update data, the table identifier of the data table where the second stored data is located and the library identifier of the database where the data table is located are searched in the table allocation list, the table identifier and the library identifier are marked for any characteristic data of the second stored data, and encapsulated into second deletion type encapsulation data of a preset data format, and a notification of the completion of deletion of the second stored data after writing the second stored data to the corresponding data table is set in the second deletion type encapsulation data; and, according to the update data, the table identifier and the library identifier of the data table where the second stored data is located are marked for the update data, and encapsulated into second newly added type encapsulation data of a preset data format, the second newly added type encapsulation data has an association relationship with the corresponding second deletion type encapsulation data, and it is set in the second newly added type encapsulation data: the writing operation of the corresponding second newly added type encapsulation data is executed according to the notification of the completion of deletion of the second stored data with the association relationship;

[0060] The encapsulated data includes first newly added encapsulated data, first deleted encapsulated data, second newly added encapsulated data and second deleted encapsulated data.

[0061] For data of different data types to be written, a matching identification method is adopted to mark the data table identifier, so as to realize the diversion and classification of the data to be written through the unique table identifier in the future, so that the data to be written in multiple tables can be written in parallel at the same time, and the data to be written in a single data table can be written serially.

[0062] For the data to be written of the deleted data type, the first stored data is directly written into the deleted data area of ​​the data table where the first stored data is saved. When encapsulating the data to be written, only any characteristic data marking table identifier and library identifier of the first stored data need to be marked.

[0063] Iceberg relies on the data file (DataFile) and the delete data file (DeleteFile) to implement the update by cooperating with the reading mechanism to implement the update. For the data to be written of the update data type, the second stored data needs to be written into the deleted data area of ​​the data table where the second stored data is stored, and then the updated data is written into the original position of the second stored data. Therefore, the table identifier and library identifier are marked for any characteristic data of the second stored data, and the second stored data is first written into the deleted data area of ​​the data table where the second stored data is stored; the table identifier and library identifier of the data table where the second stored data is located are marked for the updated data, and the updated data is written into the original position where the updated data is written into the second stored data.

[0064] Preferably, the task writer refers to a deletion-type task writer or a new-type task writer;

[0065] S103: searching, through the allocation unit, for a task writer that matches the table identifier corresponding to each piece of encapsulated data, including:

[0066] S103-1: For the first deletion type encapsulated data and the second deletion type encapsulated data corresponding to the same table identifier, matching the deletion type task writer corresponding to the table identifier through the allocation unit;

[0067] S103-2: For the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier, matching the newly added class task writer corresponding to the table identifier through the allocation unit;

[0068] Achieve matching of the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier to one or more deletion class task writers, and matching of the first addition class encapsulated data and the second addition class encapsulated data corresponding to the same table identifier to one or more addition class task writers, so as to achieve serial writing of the data written into a single data table;

[0069] Different task writers are matched to different data tables, and the same task writer corresponds to a fixed data table. Through S103-1 and S103-2, serial writing of data in a single data table is jointly realized, and data written in multiple data tables can be written in parallel at the same time, thereby improving the writing speed.

[0070] Specifically, the encapsulated data is connected to the transition unit (IcebergSink) in the form of a data stream, and the transition unit evenly distributes the encapsulated data to multiple downstream allocation units (IcebergStreamWriter). The allocation unit will search for the corresponding task writer (TaskWriter) in the memory through the table identifier of the encapsulated data, and complete the operation of writing to the data table corresponding to the table identifier through the task writer (TaskWriter). If the task writer role corresponding to this table identifier does not exist in the memory, the allocation unit will automatically create a new task writer and save it to the memory for writing, completing the operation of writing to the data table corresponding to the table identifier.

[0071] S104: writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in parallel through each task writer, and for any task writer, writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in serial order according to the sending time through the task writer, including:

[0072] S104-1: For the first deletion encapsulated data and the second deletion encapsulated data corresponding to the same table identifier, the first stored data and the second stored data are serially written into the deletion data area in the data table corresponding to the table identifier in the order of issuance time by a matching deletion task writer;

[0073] S104-2: For the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier, the first newly added class encapsulated data and the second newly added class encapsulated data are serially written into the data table corresponding to the table identifier in the order of issuance time through a matching newly added class task writer.

[0074] The data corresponding to the matched encapsulated data is serially written into the data table corresponding to the table identifier in the order of the sending time.

[0075] S104-1, including:

[0076] For the first deletion-type encapsulated data, through a matching deletion-type task writer, according to the table identifier marked for any characteristic data of the first stored data, a table attribute corresponding to any characteristic data of the first stored data in the data table corresponding to the table identifier is searched, and the data group where the characteristic data corresponding to the table attribute is located is taken as the first stored data, and the first stored data is written into the deletion data area of ​​the data table corresponding to the table identifier;

[0077] For the second deletion class encapsulated data, through a matching deletion class task writer, according to the table identifier marked for any characteristic data of the second stored data, a table attribute corresponding to any characteristic data of the second stored data in the data table corresponding to the table identifier is searched, and the data group where the characteristic data corresponding to the table attribute is located is taken as the second stored data, and the second stored data is written into the deletion data area of ​​the data table corresponding to the table identifier, and a notification of the completion of deletion of the second stored data is generated;

[0078] For the data to be written of the deleted data type, the first stored data is directly written into the deleted data area of ​​the data table where the first stored data is stored.

[0079] For the data to be written of the update data type, the second stored data needs to be written into the deleted data area of ​​the data table where the second stored data is stored, and then the update data is written into the original position of the second stored data.

[0080] According to the data to be written of the delete data type and the data to be written of the update data type, when writing is performed, it is necessary (through the basis field set in the setting unit (upsert), and the basis field is the IDENTIFIER attribute in the table properties of the data table. The IDENTIFIER attribute indicates a field name in the stored data and the specific content corresponding to the field. For example, if the field name is id and the corresponding specific content is 1, the IDENTIFIER attribute is: id=1.

[0081] When the basis field that needs to be set when writing is specified, the value of the IDENTIFIER attribute in the table attributes is read as the basis field for updating or deleting data. When updating or deleting data, the task writer (TaskWriter) will write the existing data with id=1 into the deleted data area of ​​the current data table; if it is updating data, it is also necessary to write the updated data in the corresponding position of the existing data. When the data needs to be read later, the reading mechanism will compare the first-class data table and the second-class data table of the snapshot version of the corresponding file information to determine which is the latest data record.

[0082] S104-2, including:

[0083] For the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier, the first newly added class encapsulated data and the second newly added class encapsulated data are serially written into the data table corresponding to the table identifier in the order of issuance time through a matching newly added class task writer; wherein:

[0084] For the first newly added class encapsulated data, the newly added data is written into the corresponding data table according to the newly added data marking table identifier through the matching newly added class task writer;

[0085] For the second newly added class encapsulated data, after receiving the notification that the associated second stored data has been deleted, the matching new class task writer searches for the table attribute corresponding to any characteristic data of the second stored data in the corresponding data table according to the table identifier for updating the data, and writes the updated data to the data group where the characteristic data corresponding to the table attribute is located, overwriting the second stored data.

[0086] Therefore, the table identifier and library identifier are marked for any characteristic data of the second stored data, so that the second stored data is written into the deleted data area of ​​the data table where the second stored data is saved; the table identifier and library identifier of the data table where the second stored data is located are marked for the updated data, so that the updated data is written into the original position where the updated data was written into the second stored data.

[0087] Preferably, the method for writing data into a data table in real time further includes:

[0088] S107: In the process of each task writer writing the matching encapsulated data into the data table corresponding to the table identifier in parallel, the storage location of each encapsulated data is collected by the information collector of the allocation unit to form file information of a preset data structure; the file information with the same table identifier is sent to the same registrar; S107 is executed synchronously with S104.

[0089] S108: For any registrar, the received file information is added to its own file information list through the registrar;

[0090] S109: Parse each file information in the file information list into file information in a metadata serialization structure; and register the file information in the metadata serialization structure into the metadata table.

[0091] Register the file information of the written data in the metadata of the data table to make the data visible for reading. Then, when the data needs to be read, first find the latest first-level structure version. All the data can be found through the corresponding metadata list in the first-level structure, and then read and output the data.

[0092] Specifically, the management of data files is controlled by the first-level structure (Snapshot), the second-level structure is the metadata of the data table (Manifest), and the third-level structure is the data. A first-level structure corresponds to a set of second-level structure lists, representing the data status of the data table at a certain point in time. A second-level structure is the metadata information that records the status of the data table, which contains the structure of the data table and the corresponding set of data lists. The third-level structure is each specific set of data.

[0093] Although the above operation of writing to the data table corresponding to the table identifier is completed, it is not registered in the metadata of the data table, so the data reading is not visible. The invisibility of data reading is related to the reading mechanism. The reading mechanism is that when reading, you need to find the latest first-level structure version first. You can find all the data through the corresponding metadata list in the first-level structure, and then read the data and output the data.

[0094] Because the above only completes the operation of writing data to the data table corresponding to the table identifier, and is not registered in the metadata of the data table, it is necessary that when the task writer writes the data to be written into the data table, the allocation unit will collect the file information of the data. The file information refers to the storage location of the data written to the data table, and generate a data structure of the specified root form WriterResult and send it to the downstream registrar (IcebergFileCommiter). After receiving the file information, the registrar will add it to its own file information list, triggering the mechanism (Checkpoint) for periodic execution of the unsolvable data flow, or the mechanism (endInput) triggered after the last data of the bounded stream data is processed, parsing the file information into an internal metadata serialization structure that is the same as the metadata data structure. The registrar executes the internal submission method to bind the file information to the metadata and register it in the metadata list of the current first-level structure, thereby completing a batch of writes and updating the version of the first-level structure.

[0095] Preferably, the method for writing data into a data table in real time further includes:

[0096] S110: After the registrar adds the received file information to its own file information list, the registrar merges the multiple file information into a merged file with a capacity within a threshold range according to the capacity of each file information added to itself, and retains each file information before the merger as a historical snapshot for a preset time before deleting it; S110 is executed after S108 and before S109.

[0097] S109: Parsing each file information in the file information list into file information of a metadata serialization structure, including:

[0098] Parse each file information in the merged file into file information of a metadata serialization structure.

[0099] The file information depends on Flink's mechanism for periodic execution of unsolvable data streams (Checkpoint), or the mechanism (endInput) triggered after the last data of bounded stream data is processed and distributed to the corresponding downstream register. Specifically, according to the data distribution mechanism of data identification (KeyBy) of table identifiers, when there are multiple registers downstream, the file information with the same table identifier is distributed to the corresponding downstream register by using the table identifier as the Key value, ensuring that the metadata of the data written into a table is submitted serially, and multiple tables can be submitted in parallel, avoiding the need to submit one table after another in sequence when there are multiple tables.

[0100] In real-time writing scenarios, real-time performance and file information (metadata, also known as small files) are always incompatible. If a Checkpoint or endInput is triggered to execute submission every time a file information is generated, then a high Checkpoint frequency will result in high real-time performance but more small files, and vice versa, a high Checkpoint frequency will result in low real-time performance and fewer small files. Figure 6 As shown, in the embodiment of the present invention, a lightweight small file merging function is adopted, and the number of file information to be automatically merged can be set. The merging subunit in the registrar scans the file information according to the configuration, and merges multiple file information into a merged file whose capacity is within the threshold range. The merging subunit can also scan the file information capacity according to the configuration, and merge when the capacity of the small file is less than the first threshold; the capacity of the merged file is moderate and can take into account real-time performance, because a particularly large size may have a certain impact on the efficiency of real-time writing and the execution time of the checkpoint. Then, when the set size and trigger frequency are reached, the metadata corresponding to the data in the same data table will be registered serially, and the metadata corresponding to different data tables will be registered in parallel. Reduce the number of small files over a period of time and relieve the pressure on file managers.

[0101] After the small files are merged, the original small files are not cleared, but retained in the generated historical snapshots. They are retained in the historical snapshot versions and have expiration times set. After the small files expire, the deletion operation needs to be performed to expire the historical snapshots. This achieves lightweight file information merging, while also retaining an appropriate number of historical snapshot versions of small files. The historical snapshot versions are retained for tracing back historical data. If the current version of the data contains dirty data, the data can be rewritten by going back to the previous historical snapshot version.

[0102] Preferably, the method for writing data into a data table in real time further includes:

[0103] S120: When the allocation unit fails to find a task writer corresponding to the data table identifier, it automatically creates a task writer corresponding to the data table identifier. S120 is executed synchronously with S103.

[0104] Different task writers are matched to different data tables. The same task writer corresponds to a fixed data table, so that data written to a single data table can be written serially. Data written to multiple data tables can be written in parallel at the same time, which improves the writing speed. When the amount of data to be written is very large, the pre-created task writer has been used up, and the data table identifier is still marked for the data to be written. If the task writer corresponding to the table identifier is not created, it can be created in real time to write the data to the corresponding data table.

[0105] like Figure 2 As shown, in combination with an embodiment of the present invention, a device for writing data into a data table in real time is provided, comprising:

[0106] A data conversion unit is used to mark the corresponding table identifier for each piece of data to be written and the library identifier of the database where the data table is located according to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, and to encapsulate each piece of data to be written into encapsulated data of a preset data format;

[0107] A transition unit, used to send each piece of encapsulated data to the distribution unit in real time using a unified data interface;

[0108] An allocation unit, used for searching a task writer matching a table identifier corresponding to each piece of encapsulated data through the allocation unit;

[0109] The task writer is used to write the data corresponding to the matching encapsulated data into the data table corresponding to the table identifier in parallel through each task writer. For any task writer, the task writer writes the data corresponding to the matching encapsulated data serially into the data table corresponding to the table identifier in the order of issuance time.

[0110] The embodiment of the present invention only needs to mark the corresponding data table identifier and database identifier of the captured data source to be written, and change the data type (i.e., data format) to encapsulate it into encapsulated data of a preset data format. Then, the user can automatically send multiple encapsulated data to the transition unit at the same time. The transition unit sends each encapsulated data to the allocation unit in real time through a unified data interface, and searches for a task writer that matches the data table identifier corresponding to each encapsulated data through the allocation unit; division of labor and cooperation, it is not necessary to set the corresponding Flink task flow for the data written to different data tables when they appear alternately, thereby reducing the number of Flink task flows. Each task writer writes the data corresponding to each encapsulated data to the data table corresponding to the data table identifier in parallel, so that the data written to multiple data can be written in parallel at the same time; for any task writer, the task writer writes the data corresponding to the matching encapsulated data serially to the data table corresponding to the table identifier in the order of sending time, so that the data written to a single data table is serially written, thereby improving the writing speed; the number of flow tasks is reduced overall, the cost of monitoring flow tasks is reduced, the cost of operation and maintenance management is reduced, and the rational use of resources is realized.

[0111] Specifically, Apache Iceberg is designed based on the computing distributed processing framework Apache Flink and the data lake framework Iceberg. Compared with the original connector design of Apache Flink and Iceberg, Apache Iceberg strengthens the function of the connector. It can dynamically synchronize the data of various data sources to multiple data tables of Apache Iceberg by relying on the excellent streaming data synchronization capability of Apache Flink. The writing process is as follows: Figure 4 shown.

[0112] Based on the Flink framework, in order to dynamically write multiple data to be written into their corresponding data tables at the same time and in parallel, when the data to be written is captured, the format of the data to be written is unified into a preset data format, and each data to be written is marked with the corresponding data table identifier and the database identifier of the database where the data table is located, thereby forming encapsulated data. Each preset data format has specific requirements, and can achieve the simultaneous and parallel writing of multiple data to be written into their corresponding data tables (i.e. Iceberg).

[0113] like Figure 3As shown, the data to be written in the RowData, IcebergRowData or IcebergRecord data format captured in the DataStream stream from the data source in the future will be converted into a data stream type with a preset data format of the DataStream required by the transition unit (IcebergSink) through corresponding format conversion (Map).

[0114] Preferably, the device for writing data into the data table in real time also includes:

[0115] A first data capture unit is used to capture data to be written whose storage type is a newly added data type; wherein the storage type marked in the data to be written is a newly added data type;

[0116] The second data capture unit is used to capture the data to be written whose storage type is the delete data type and the data to be written whose storage type is the update data type through the second data capture unit; wherein, for the data to be written of the update data type, the storage type marked in the data to be written is the update data type; and for the data to be written of the delete data type, the storage type marked in the data to be written is the delete data type.

[0117] The data to be written is captured by the first data capture unit and the second data capture unit, so that each piece of data to be written is subsequently marked with a corresponding data table identifier according to the data type, and a database identifier of the database where the data table is located, and each piece of data to be written is encapsulated into encapsulated data in a preset data format.

[0118] Specifically, Figure 5 As shown, the first data capture unit captures the data to be written in the RowData data format from the data source (such as log data), and the second data capture unit Apache Flink CDC captures the data to be written in the RowData, IcebergRowData or IcebergRecord data format from all data sources; each piece of data to be written needs to be marked with the database identifier and data table identifier to be written, and finally form encapsulated data; so that the encapsulated data can be sent to the transition unit (IcebergSink) in the form of a data stream (Datastream), and then the task writer (TaskWriter) can dynamically write the data in the encapsulated data into the corresponding target data table according to the table identifier. Among them, the database identifier and the data table identifier are both unique.

[0119] When Apache Flink CDC is used, it is set to access multiple databases, such as MySQL, PostgreSQL, Oracle, and SQL Server, so as to implement serialization interfaces for accessing different data formats. The default is the basic lightweight data exchange format (json). Therefore, after Apache Flink CDC captures the data to be written in the IcebergRowData or IcebergRecord data format from the data source, it can directly convert the data to be written into the required preset data format, that is, output the data stream type required by the transition unit (IcebergSink).

[0120] Preferably, for the data to be written whose storage type is a newly added data type, the data to be written carries the newly added data;

[0121] For the data to be written whose storage type is the deletion data type, the data to be written carries any characteristic data of the first stored data to be deleted;

[0122] For the data to be written whose storage type is the update data type, the data to be written carries the update data and any characteristic data of the second stored data corresponding to the update data;

[0123] Data conversion unit, including:

[0124] a first conversion unit, for, when the storage type is a newly added data type, searching in the table allocation sheet for a table identifier of a data table into which the newly added data is to be written and a library identifier of a database where the data table is located, marking the table identifier and the library identifier for the newly added data in the data to be written, and encapsulating the data into the first newly added type encapsulated data in a preset data format, wherein the table identifiers corresponding to the data tables into which different data contents are written are set in advance in the table allocation sheet;

[0125] A second conversion unit is used for, when the storage type is a deletion data type, searching in the table allocation sheet for a table identifier of a data table where the first stored data is located and a library identifier of a database where the data table is located, according to any characteristic data of the first stored data to be deleted, marking the table identifier and the library identifier for any characteristic data of the first stored data, and encapsulating them into first deletion type encapsulated data in a preset data format;

[0126] A third conversion unit is used for, when the storage type is an update data type, searching in the table allocation list for the table identifier of the data table where the second stored data is located and the library identifier of the database where the data table is located according to any characteristic data of the second stored data corresponding to the update data, marking the table identifier and the library identifier for any characteristic data of the second stored data, encapsulating them into second deletion class encapsulation data of a preset data format, and setting in the second deletion class encapsulation data a notification of completion of deletion of the second stored data after writing the second stored data to the corresponding data table; and, marking the table identifier and the library identifier of the data table where the second stored data is located for the update data according to the update data, encapsulating them into second newly added class encapsulation data of a preset data format, the second newly added class encapsulation data having an association relationship with the corresponding second deletion class encapsulation data, and setting in the second newly added class encapsulation data: executing the corresponding writing operation of the second newly added class encapsulation data according to the notification of completion of deletion of the second stored data having the association relationship;

[0127] The encapsulated data includes first newly added encapsulated data, first deleted encapsulated data, second newly added encapsulated data and second deleted encapsulated data.

[0128] For data to be written of different data types, a matching identification method is used to mark the data table identifier, so that the data to be written can be divided and classified through the unique data table identifier in the future, so that data written into multiple data sheets can be written in parallel at the same time, and data written into a single data table can be written serially. For data to be written of the deleted data type, the first stored data is directly written into the deleted data area of ​​the data table where the first stored data is saved. When encapsulating the data to be written, only any characteristic data of the first stored data needs to be marked, and the table identifier and library identifier need to be marked.

[0129] Iceberg implements update writing by cooperating with the reading mechanism of the data file (DataFile) and the delete data file (DeleteFile) to implement the update. For the data to be written of the update data type, the second stored data must first be written into the deleted data area of ​​the data table where the second stored data is stored, and then the updated data is written into the original position of the second stored data. Therefore, the table identifier and library identifier are marked for any characteristic data of the second stored data, so that the second stored data is written into the deleted data area of ​​the data table where the second stored data is stored; the table identifier and library identifier of the data table where the second stored data is located are marked for the updated data, so that the updated data is written into the original position where the updated data is written into the second stored data.

[0130] Preferably, the task writer refers to a deletion-type task writer or a new-type task writer;

[0131] Distribution unit, comprising:

[0132] A first allocation subunit is used for matching the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier through the allocation unit with the deletion class task writer corresponding to the table identifier;

[0133] A second allocation subunit is used for matching the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier through the allocation unit with the newly added class task writer corresponding to the table identifier;

[0134] Achieve matching of the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier to one or more deletion class task writers, and matching of the first addition class encapsulated data and the second addition class encapsulated data corresponding to the same table identifier to one or more addition class task writers, so as to achieve serial writing of the data written into a single data table;

[0135] Different task writers are matched for different data tables, and the same task writer corresponds to a fixed data table. The first allocation subunit and the second allocation subunit are used to jointly realize serial writing of data in a single data table, and data written in multiple data tables can be written in parallel at the same time, thereby improving the writing speed.

[0136] Specifically, the encapsulated data is connected to the transition unit (IcebergSink) in the form of a data stream, and the transition unit evenly distributes the encapsulated data to multiple downstream allocation units (IcebergStreamWriter). The allocation unit will search for the corresponding task writer (TaskWriter) in the memory through the table identifier of the encapsulated data, and complete the operation of writing to the data table corresponding to the table identifier through the task writer (TaskWriter). If the task writer role corresponding to this table identifier does not exist in the memory, the allocation unit will automatically create a new task writer and save it to the memory for writing, completing the operation of writing to the data table corresponding to the table identifier.

[0137] Task Composer, including:

[0138] A deletion task writer is used to write the first stored data and the second stored data in series into a deletion data area in a data table corresponding to the table identifier in the order of sending time for the first deletion encapsulated data and the second deletion encapsulated data corresponding to the same table identifier through a matching deletion task writer;

[0139] A new class task writer is used to write the first new class encapsulated data and the second new class encapsulated data corresponding to the same table identifier in serial order of issuance time into the data table corresponding to the table identifier through a matching new class task writer.

[0140] The data corresponding to the matched encapsulated data is serially written into the data table corresponding to the table identifier in the order of the sending time.

[0141] Delete class task writer, specifically used for:

[0142] For the first deletion-type encapsulated data, through a matching deletion-type task writer, according to the table identifier marked for any characteristic data of the first stored data, a table attribute corresponding to any characteristic data of the first stored data in the data table corresponding to the table identifier is searched, and the data group where the characteristic data corresponding to the table attribute is located is taken as the first stored data, and the first stored data is written into the deletion data area of ​​the data table corresponding to the table identifier;

[0143] For the second deletion class encapsulated data, through a matching deletion class task writer, according to the table identifier marked for any characteristic data of the second stored data, a table attribute corresponding to any characteristic data of the second stored data in the data table corresponding to the table identifier is searched, and the data group where the characteristic data corresponding to the table attribute is located is taken as the second stored data, and the second stored data is written into the deletion data area of ​​the data table corresponding to the table identifier, and a notification of the completion of deletion of the second stored data is generated;

[0144] For the data to be written of the deleted data type, the first stored data is directly written into the deleted data area of ​​the data table where the first stored data is stored.

[0145] For the data to be written of the update data type, the second stored data needs to be written into the deleted data area of ​​the data table where the second stored data is stored, and then the update data is written into the original position of the second stored data.

[0146] According to the data to be written of the delete data type and the data to be written of the update data type, when writing is performed, it is necessary (through the basis field set in the setting unit (upsert), and the basis field is the IDENTIFIER attribute in the table properties of the data table. The IDENTIFIER attribute indicates a field name in the stored data and the specific content corresponding to the field. For example, if the field name is id and the corresponding specific content is 1, the IDENTIFIER attribute is: id=1.

[0147] When the basis field that needs to be set when writing is specified, the value of the IDENTIFIER attribute in the table attributes is read as the basis field for updating or deleting data. When updating or deleting data, the task writer (TaskWriter) will write the existing data with id=1 into the deleted data area of ​​the current data table; if it is updating data, it is also necessary to write the updated data in the corresponding position of the existing data. When the data needs to be read later, the reading mechanism will compare the first-class data table and the second-class data table of the snapshot version of the corresponding file information to determine which is the latest data record.

[0148] Added new class TaskWriter, specifically for:

[0149] For the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier, the first newly added class encapsulated data and the second newly added class encapsulated data are serially written into the data table corresponding to the table identifier in the order of issuance time through a matching newly added class task writer; wherein:

[0150] For the first newly added class encapsulated data, the newly added data is written into the corresponding data table according to the newly added data marking table identifier through the matching newly added class task writer;

[0151] For the second newly added class encapsulated data, after receiving the notification that the associated second stored data has been deleted, the matching new class task writer searches for the table attribute corresponding to any characteristic data of the second stored data in the corresponding data table according to the table identifier for updating the data, and writes the updated data to the data group where the characteristic data corresponding to the table attribute is located, overwriting the second stored data.

[0152] Therefore, the table identifier and library identifier are marked for any characteristic data of the second stored data, so that the second stored data is written into the deleted data area of ​​the data table where the second stored data is saved; the table identifier and library identifier of the data table where the second stored data is located are marked for the updated data, so that the updated data is written into the original position where the updated data was written into the second stored data.

[0153] Preferably, the device for writing data into the data table in real time further comprises an information collector arranged in the allocation unit, wherein:

[0154] The information collector is used to collect the storage location of each piece of encapsulated data through the information collector of the allocation unit during the process of each task writer writing the matched encapsulated data into the data table corresponding to the table identifier in parallel, so as to form file information of a preset data structure; and send the file information with the same table identifier to the same register;

[0155] The registrar is used to add the received file information to its own file information list through the registrar, parse each file information in the file information list into file information of metadata serialization structure; and register the file information of metadata serialization structure into the metadata table.

[0156] Register the file information of the written data in the metadata of the data table to make the data visible for reading. Then, when the data needs to be read, first find the latest first-level structure version. All the data can be found through the corresponding metadata list in the first-level structure, and then read and output the data.

[0157] Specifically, the management of data files is controlled by the first-level structure (Snapshot), the second-level structure is the metadata of the data table (Manifest), and the third-level structure is the data. A first-level structure corresponds to a set of second-level structure lists, representing the data status of the data table at a certain point in time. A second-level structure is the metadata information that records the status of the data table, which contains the structure of the data table and the corresponding set of data lists. The third-level structure is each specific set of data.

[0158] Although the above operation of writing to the data table corresponding to the table identifier is completed, it is not registered in the metadata of the data table, so the data reading is not visible. The invisibility of data reading is related to the reading mechanism. The reading mechanism is that when reading, you need to find the latest first-level structure version first. You can find all the data through the corresponding metadata list in the first-level structure, and then read the data and output the data.

[0159] Because the above operation only completes the operation of writing data to the data table corresponding to the table identifier and is not registered in the metadata of the data table, it is necessary that during the process of the task writer writing the data to be written into the data table, the allocation unit collects the file information of the data. The file information refers to the storage location of the data written to the data table, generates a data structure of the specified root type WriterResult, and sends it to the downstream registrar (IcebergFileCommiter).

[0160] After receiving the file information, the registrar will add it to its own file information list, triggering the periodic execution mechanism (Checkpoint) of the unsolvable data stream, or the mechanism triggered after the last data of the bounded stream is processed (endInput), parsing the file information into an internal metadata serialization structure that is the same as the metadata data structure. The registrar executes the internal submission method to bind the file information to the metadata and register it in the metadata list of the current first-level structure, thereby completing a batch of writes and updating the version of the first-level structure.

[0161] Preferably, the registrar is used to add the received file information to its own file information list, and then each registrar merges multiple file information into a merged file with a capacity within a threshold range according to the capacity of each file information added to itself, and retains each file information before the merge as a historical snapshot for a preset time before deleting it; and, parses each file information in the merged file into file information of a metadata serialization structure.

[0162] The file information depends on Flink's mechanism for periodic execution of unsolvable data streams (Checkpoint), or the mechanism (endInput) triggered after the last data of bounded stream data is processed and distributed to the corresponding downstream register. Specifically, according to the data distribution mechanism of data identification (KeyBy) of table identifiers, when there are multiple registers downstream, the file information with the same table identifier is distributed to the corresponding downstream register by using the table identifier as the Key value, ensuring that the metadata of the data written into a table is submitted serially, and multiple tables can be submitted in parallel, avoiding the need to submit one table after another in sequence when there are multiple tables.

[0163] In real-time writing scenarios, real-time performance and file information (metadata, also known as small files) are always incompatible. If a Checkpoint or endInput is triggered to execute submission every time a file information is generated, then a high Checkpoint frequency will result in high real-time performance but more small files, and vice versa, a high Checkpoint frequency will result in low real-time performance and fewer small files. Figure 6 As shown, in the embodiment of the present invention, a lightweight small file merging function is adopted, and the number of file information to be automatically merged can be set. The merging subunit in the registrar scans the file information according to the configuration, and merges multiple file information into a merged file whose capacity is within the threshold range. The merging subunit can also scan the file information capacity according to the configuration, and merge when the capacity of the small file is less than the first threshold; the capacity of the merged file is moderate and can take into account real-time performance, because a particularly large size may have a certain impact on the efficiency of real-time writing and the execution time of the checkpoint. Then, when the set size and trigger frequency are reached, the metadata corresponding to the data in the same data table will be registered serially, and the metadata corresponding to different data tables will be registered in parallel. Reduce the number of small files over a period of time and relieve the pressure on file managers.

[0164] After the small files are merged, the original small files are not cleared, but retained in the generated historical snapshots. They are retained in the historical snapshot versions and have expiration times set. After the small files expire, the deletion operation needs to be performed to expire the historical snapshots. This achieves lightweight file information merging, while also retaining an appropriate number of historical snapshot versions of small files. The historical snapshot versions are retained for tracing back historical data. If the current version of the data contains dirty data, the data can be rewritten by going back to the previous historical snapshot version.

[0165] Preferably, the device for writing data into the data table in real time also includes:

[0166] The allocation unit is used to automatically create a task writer corresponding to the data table identifier when the task writer corresponding to the data table identifier is not found.

[0167] Different task writers are matched to different data tables. The same task writer corresponds to a fixed data table, so that data written to a single data table can be written serially. Data written to multiple data tables can be written in parallel at the same time, which improves the writing speed. When the amount of data to be written is very large, the pre-created task writer has been used up, and the data table identifier is still marked for the data to be written. If the task writer corresponding to the table identifier is not created, it can be created in real time to write the data to the corresponding data table.

[0168] In conjunction with an embodiment of the present invention, a system for writing data into a data table in real time is provided, comprising any of the above-mentioned devices for writing data into a data table in real time, and a database, wherein:

[0169] Database, used to store data tables where encapsulated data is written.

[0170] In conjunction with an embodiment of the present invention, a computer-readable storage medium is provided, which stores one or more programs. When the one or more programs are executed by a computer device, the computer device executes any of the aforementioned methods for writing data into a data table in real time.

[0171] The beneficial effects achieved by the embodiments of the present invention are as follows:

[0172] The embodiment of the present invention only needs to mark the corresponding data table identifier and database identifier of the data to be written of the captured data source, change the data type (i.e., data format), and encapsulate it into encapsulated data of a preset data format. Then, the user can automatically set multiple encapsulated data in one Flink stream task and simultaneously enter the transition unit with a unified data interface. The transition unit sends each encapsulated data to the allocation unit in real time through the unified data interface, and the allocation unit searches for the task writer that matches the data table identifier corresponding to each encapsulated data. With division of labor and cooperation, there is no need to set up the corresponding Flink task flows for the data written to different data tables that appear alternately when they appear, thereby reducing the number of Flink task flows.

[0173] Through each task writer, the data corresponding to each encapsulated data is written into the data table corresponding to the data table identifier in real time, so that the data written into a single data table can be written serially, and the data written into multiple data tables can be written in parallel at the same time, which improves the writing speed; overall, the number of flow tasks is reduced, the cost of monitoring flow tasks is reduced, the operation and maintenance management cost is reduced, and the rational use of resources is achieved.

[0174] The embodiment of the present invention merges file information (i.e., small files) generated in real time, especially file information whose file capacity is less than a first threshold, to form a merged file. It is not necessary to register each file information generated in the metadata table through a register, which relieves the pressure of file processing and the pressure of file managers. At the same time, it retains the historical snapshot version of small files and cooperates with the snapshot expiration mechanism. The use can maintain the small files at a controllable number, and retains the historical snapshot version for tracing back historical data. If there is dirty data in the current version of the data, the data can be rewritten by going back to the previous version, thereby realizing the management and reasonable use of small files.

[0175] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.

[0176] In the above detailed description, various features are grouped together in a single embodiment to simplify the present disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiment of the claimed subject matter requires more features than those clearly stated in each claim. On the contrary, as reflected in the attached claims, the present invention is in a state of less than all the features of the disclosed single embodiment. Therefore, the attached claims are hereby expressly incorporated into the detailed description, with each claim acting alone as a separate preferred embodiment of the present invention. The disclosed embodiments are described above to enable any technician in the field to implement or use the present invention. It is obvious to those skilled in the art that various modifications of these embodiments are obvious, and the general principles defined herein may also be applied to other embodiments without departing from the spirit and scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments given herein, but is consistent with the broadest scope of the principles and novel features disclosed in the present application.

[0177] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".

[0178] Those skilled in the art may also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention may be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps described above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.

[0179] The various illustrative logic blocks or units described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of the above. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.

[0180] The steps of the method or algorithm described in the embodiments of the present invention can be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a user terminal. Optionally, the processor and the storage medium can also be arranged in different components in the user terminal.

[0181] In one or more exemplary designs, the above functions described in the embodiments of the present invention can be implemented in hardware, software, firmware or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, DVD, floppy disk and blue-ray disk. Disks usually copy data magnetically, while discs usually copy data optically with lasers. The above combination can also be included in computer readable media.

[0182] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for writing data into a data table in real time, characterized in that: include: According to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, each piece of data to be written is marked with a corresponding table identifier, and a library identifier of the database where the data table is located is marked, and each piece of data to be written is encapsulated into encapsulated data in a preset data format; Using a unified data interface to send each piece of the encapsulated data to the distribution unit in real time; Searching, by the allocation unit, for a task writer that matches a table identifier corresponding to each piece of the encapsulated data; The data corresponding to the matched encapsulated data are written into the data table corresponding to the table identifier in parallel by each task writer, and for any task writer, the data corresponding to the matched encapsulated data are written into the data table corresponding to the table identifier in serial order according to the sending time by the task writer; The method for writing data into a data table in real time also includes: Capturing, by a first data capture unit, data to be written whose storage type is a newly added data type; wherein the storage type marked in the data to be written is the newly added data type; Capturing, by a second data capture unit, data to be written of a deletion data type and data to be written of an update data type; wherein, for the data to be written of the update data type, the storage type marked in the data to be written is the update data type; and for the data to be written of the deletion data type, the storage type marked in the data to be written is the deletion data type; For the data to be written whose storage type is a newly added data type, the data to be written carries the newly added data; For the data to be written whose storage type is the deletion data type, the data to be written carries any characteristic data of the first stored data to be deleted; For the data to be written whose storage type is the update data type, the data to be written carries the update data and any characteristic data of the second stored data corresponding to the update data; The method includes marking a corresponding table identifier for each piece of data to be written according to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, and marking a library identifier of the database where the data table is located, and encapsulating each piece of data to be written into encapsulated data in a preset data format, including: When the storage type is a newly added data type, according to the newly added data, the table identifier of the data table to which the newly added data is to be written and the library identifier of the database where the data table is located are searched in the table allocation list, the table identifier and the library identifier are marked for the newly added data in the data to be written, and the data is packaged into the first newly added type packaged data in a preset data format, wherein the table identifiers corresponding to the data tables into which different data contents are written are set in advance in the table allocation list; When the storage type is a deletion data type, according to any characteristic data of the first stored data to be deleted, searching the table identifier of the data table where the first stored data is located and the library identifier of the database where the data table is located in the table allocation list, marking the table identifier and the library identifier for any characteristic data of the first stored data, and encapsulating them into first deletion type encapsulation data in a preset data format; When the storage type is an update data type, according to any characteristic data of the second stored data corresponding to the update data, the table identifier of the data table where the second stored data is located and the library identifier of the database where the data table is located are searched in the table allocation list, the table identifier and the library identifier are marked for any characteristic data of the second stored data, and encapsulated into second deletion type encapsulation data in a preset data format, and a notification of the completion of deleting the second stored data after writing the second stored data to the corresponding data table is set in the second deletion type encapsulation data; and, according to the update data, the table identifier and the library identifier of the data table where the second stored data is located are marked for the update data, and encapsulated into second newly added type encapsulation data in a preset data format, the second newly added type encapsulation data has an association relationship with the corresponding second deletion type encapsulation data, and it is set in the second newly added type encapsulation data: according to the notification of the completion of deleting the second stored data in the association relationship, the corresponding writing operation of the second newly added type encapsulation data is executed; The encapsulated data includes the first newly added encapsulated data, the first deleted encapsulated data, the second newly added encapsulated data and the second deleted encapsulated data; The task writer refers to a deletion-type task writer or a new addition-type task writer; The step of searching, by the allocation unit, for a task writer that matches a table identifier corresponding to each piece of the encapsulated data comprises: For the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier, matching the deletion class task writer corresponding to the table identifier through the allocation unit; For the first newly added class encapsulation data and the second newly added class encapsulation data corresponding to the same table identifier, matching the newly added class task writer corresponding to the table identifier through the allocation unit; The step of writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in parallel by each task writer, and for any task writer, writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in serial order according to the sending time by the task writer, includes: For the first deletion encapsulated data and the second deletion encapsulated data corresponding to the same table identifier, the first stored data and the second stored data are serially written into the deletion data area in the data table corresponding to the table identifier in the order of issuance time through the matching deletion task writer; For the first newly added class encapsulation data and the second newly added class encapsulation data corresponding to the same table identifier, the first newly added class encapsulation data and the second newly added class encapsulation data are serially written into the data table corresponding to the table identifier in the order of issuance time through the matching newly added class task writer.

2. The method for writing data into a data table in real time according to claim 1, wherein for the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier, the first stored data and the second stored data are serially written into the deletion data area in the data table corresponding to the table identifier in the order of issuance time through the matching deletion class task writer, comprising: For the first deletion-type encapsulated data, through the matched deletion-type task writer, according to the table identifier marked for any characteristic data of the first stored data, find the table attribute corresponding to any characteristic data of the first stored data in the data table corresponding to the table identifier, take the data group where the characteristic data corresponding to the table attribute is located as the first stored data, and write the first stored data into the deletion data area of ​​the data table corresponding to the table identifier; For the second deletion-type encapsulated data, through the matched deletion-type task writer, according to the table identifier marked for any characteristic data of the second stored data, the table attribute corresponding to any characteristic data of the second stored data in the data table corresponding to the table identifier is searched, the data group where the characteristic data corresponding to the table attribute is located is taken as the second stored data, the second stored data is written into the deletion data area of ​​the data table corresponding to the table identifier, and a notification of the completion of deletion of the second stored data is generated; The first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier are serially written into the data table corresponding to the table identifier in the order of issuance time by the matched newly added class task writer, including: For the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier, the first newly added class encapsulated data and the second newly added class encapsulated data are serially written into the data table corresponding to the table identifier in the order of issuance time through the matched newly added class task writer; wherein: For the first newly added class encapsulated data, the newly added data is written into the corresponding data table by the matched newly added class task writer according to the newly added data marking the table identifier; For the second newly added class encapsulated data, after receiving the notification that the associated second stored data has been deleted, the matching new class task writer searches for the table attribute corresponding to any characteristic data of the second stored data in the corresponding data table according to the table identifier marked for the updated data, and writes the updated data to the data group where the characteristic data corresponding to the table attribute is located, overwriting the second stored data.

3. The method for writing data into a data table in real time according to claim 1, characterized in that: Also includes: In the process that each of the task writers writes the matched encapsulated data into the data table corresponding to the table identifier in parallel, the storage location of each piece of the encapsulated data is collected by the information collector of the allocation unit to form file information of a preset data structure; Sending the file information with the same table identifier to the same registrar; For any registrar, the received file information is added to its own file information list through the registrar; each file information in the file information list is parsed into file information of metadata serialization structure; and the file information of metadata serialization structure is registered in the metadata table.

4. The method for writing data into a data table in real time according to claim 3, characterized in that: Also includes: After the register adds the received file information to its own file information list, the register merges the plurality of file information into a merged file whose capacity is within a threshold range according to the capacity of each of the file information added to itself, and retains each of the file information before merging as a historical snapshot for a preset time before deleting it; The step of parsing each piece of file information in the file information list into file information of a metadata serialization structure includes: Each piece of file information in the merged file is parsed into file information of a metadata serialization structure.

5. A device for writing data into a data table in real time, characterized in that: include: A data conversion unit is used to mark the corresponding table identifier for each piece of data to be written, and mark the library identifier of the database where the data table is located, according to the data content corresponding to the captured data to be written and the storage type corresponding to the data to be written, and encapsulate each piece of data to be written into encapsulated data of a preset data format; A transition unit, used to send each piece of the encapsulated data to the distribution unit in real time using a unified data interface; an allocation unit, configured to search through the allocation unit for a task writer that matches a table identifier corresponding to each piece of the encapsulated data; A task writer, used for writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in parallel through each task writer, and for any task writer, writing the data corresponding to the matched encapsulated data into the data table corresponding to the table identifier in serial order according to the sending time through the task writer; The device for writing data into a data table in real time also includes: A first data capture unit is used to capture data to be written whose storage type is a newly added data type; wherein the storage type marked in the data to be written is a newly added data type; A second data capture unit is used to capture, through the second data capture unit, data to be written whose storage type is the delete data type and data to be written whose storage type is the update data type; wherein, for the data to be written of the update data type, the storage type marked in the data to be written is the update data type; and for the data to be written of the delete data type, the storage type marked in the data to be written is the delete data type; For the data to be written whose storage type is a newly added data type, the data to be written carries the newly added data; For the data to be written whose storage type is the deletion data type, the data to be written carries any characteristic data of the first stored data to be deleted; For the data to be written whose storage type is the update data type, the data to be written carries the update data and any characteristic data of the second stored data corresponding to the update data; Data conversion unit, including: a first conversion unit, for, when the storage type is a newly added data type, searching in the table allocation sheet for a table identifier of a data table into which the newly added data is to be written and a library identifier of a database where the data table is located, marking the table identifier and the library identifier for the newly added data in the data to be written, and encapsulating the data into the first newly added type encapsulated data in a preset data format, wherein the table identifiers corresponding to the data tables into which different data contents are written are set in advance in the table allocation sheet; A second conversion unit is used for, when the storage type is a deletion data type, searching in the table allocation sheet for a table identifier of a data table where the first stored data is located and a library identifier of a database where the data table is located, according to any characteristic data of the first stored data to be deleted, marking the table identifier and the library identifier for any characteristic data of the first stored data, and encapsulating them into first deletion type encapsulated data in a preset data format; A third conversion unit is used for, when the storage type is an update data type, searching in the table allocation list for the table identifier of the data table where the second stored data is located and the library identifier of the database where the data table is located according to any characteristic data of the second stored data corresponding to the update data, marking the table identifier and the library identifier for any characteristic data of the second stored data, encapsulating them into second deletion class encapsulation data of a preset data format, and setting in the second deletion class encapsulation data a notification of completion of deletion of the second stored data after writing the second stored data to the corresponding data table; and, marking the table identifier and the library identifier of the data table where the second stored data is located for the update data according to the update data, encapsulating them into second newly added class encapsulation data of a preset data format, the second newly added class encapsulation data having an association relationship with the corresponding second deletion class encapsulation data, and setting in the second newly added class encapsulation data: executing the corresponding writing operation of the second newly added class encapsulation data according to the notification of completion of deletion of the second stored data having the association relationship; The encapsulated data includes first newly added encapsulated data, first deleted encapsulated data, second newly added encapsulated data and second deleted encapsulated data; Task writer refers to deleting class task writer or adding class task writer; Distribution unit, comprising: A first allocation subunit is used for matching the first deletion class encapsulated data and the second deletion class encapsulated data corresponding to the same table identifier through the allocation unit with the deletion class task writer corresponding to the table identifier; A second allocation subunit is used for matching the first newly added class encapsulated data and the second newly added class encapsulated data corresponding to the same table identifier through the allocation unit with the newly added class task writer corresponding to the table identifier; Task Composer, including: A deletion task writer is used to write the first stored data and the second stored data in series into a deletion data area in a data table corresponding to the table identifier in the order of sending time for the first deletion encapsulated data and the second deletion encapsulated data corresponding to the same table identifier through a matching deletion task writer; A new class task writer is used to write the first new class encapsulated data and the second new class encapsulated data corresponding to the same table identifier in serial order of issuance time into the data table corresponding to the table identifier through a matching new class task writer.

6. A system for writing data into a data table in real time, characterized in that: The device for writing data into a data table in real time as claimed in claim 5, and a database, wherein: The database is used to store the data table into which the encapsulation data is written.