Data writing method, device and equipment based on distributed computing framework

Through the data writing method based on the distributed computing framework, the real-time data writing delay and high concurrency problems from Kafka to the Greenplum data warehouse are solved, and efficient data recovery and operation cost reduction are achieved.

CN118535629APending Publication Date: 2024-08-23CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410640793.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

When real-time data is frequently written from Kafka to the Greenplum data warehouse, there are problems such as data delay and high concurrent writing, which results in high operation and maintenance costs.

Method used

Using a data writing method based on a distributed computing framework, by obtaining the metadata of the data warehouse, subscribing to the target topic, filtering duplicate data, and constructing structured query statements, the data is spliced ​​and transformed and written into the database, using distributed The checkpoint mechanism of the computing framework enables high concurrent writing and automatic recovery.

Benefits of technology

It achieves high concurrent data writing, shortens data recovery time, reduces operating costs, and avoids manual intervention in processing delayed data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535629A
    Figure CN118535629A
Patent Text Reader

Abstract

The invention provides a data writing method, device and equipment based on a distributed computing framework, and relates to the technical field of data acquisition, and the method comprises the following steps: obtaining a metadata construction structural body of a data warehouse, and obtaining a target structural body; subscribing the target theme based on a connector of a distributed computing framework to obtain multiple pieces of target data; obtaining a target set; constructing a structured query statement based on the target structure body to obtain a target statement; splicing and converting all target data in the target set based on the target structural body to obtain a target character stream; and writing the target character stream into a data warehouse database based on the target statement. According to the method, the data is written into the Greenplum number bin by utilizing the data loading statement on the basis of the distributed computing framework, high-concurrency data writing is ensured, the task is continued from the latest successful check point of the task on the basis of a check point mechanism of the distributed computing framework, the delayed data does not need to be processed by manual intervention, the data recovery time can be shortened, and the data recovery efficiency is improved. The operation cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data acquisition technology, and in particular to a data writing method, device and equipment based on a distributed computing framework. Background Art

[0002] Greenplum is built based on the MPP (massive parallel processing) architecture and has good elasticity and linear scalability. It is a big data engine that can provide powerful functions including real-time processing, elastic expansion, hybrid load, cloud native and integrated data analysis. Kafka is a distributed message queue based on the publish / subscribe model, which is mainly used in the field of real-time processing of big data and is the main "transit station" before real-time data enters the lake.

[0003] With the development of digital business, the importance of real-time data is increasing. Many application scenarios require data warehouses to provide real-time data support. However, there are some problems in the high-frequency writing of real-time data from Kafka to the Greenplum data warehouse: real-time data is generated quickly and the data volume is large. The writing concurrency in the data warehouse is high, and data delays often occur. When an exception occurs in the data writing task, the delayed data needs to be manually processed, and the operation and maintenance costs are high. Summary of the invention

[0004] The purpose of the present invention is to provide a data writing method, device and equipment based on a distributed computing framework to improve the above problems. In order to achieve the above purpose, the technical solution adopted by the present invention is as follows:

[0005] In a first aspect, the present application provides a data writing method based on a distributed computing framework, comprising:

[0006] Obtain the metadata of the data warehouse to build a structure and obtain the target structure;

[0007] The connector based on the distributed computing framework subscribes to the target topic to obtain multiple target data;

[0008] All target data are stored in a preset initial set and duplicate data are screened to obtain a target set;

[0009] Constructing a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written;

[0010] All target data in the target set are concatenated and converted based on the target structure to obtain a target character stream;

[0011] The target character stream is written into a data warehouse database based on the target sentence.

[0012] In a second aspect, the present application also provides a data writing device based on a distributed computing framework, comprising:

[0013] A first acquisition unit is used to acquire the metadata construction structure of the data warehouse to obtain a target structure;

[0014] A subscription unit, used to subscribe to a target topic based on a connector of a distributed computing framework to obtain multiple target data;

[0015] A screening processing unit, used to store all target data in a preset initial set and perform duplicate data screening processing to obtain a target set;

[0016] A construction unit, used to construct a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written;

[0017] A conversion unit, used for concatenating and converting all target data in the target set based on the target structure to obtain a target character stream;

[0018] A writing unit is used to write the target character stream into a data warehouse database based on the target sentence.

[0019] In a third aspect, the present application also provides a data writing device based on a distributed computing framework, including:

[0020] Memory for storing computer programs;

[0021] A processor is used to implement the steps of the data writing method based on the distributed computing framework when executing the computer program.

[0022] In a fourth aspect, the present application further provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned data writing method based on a distributed computing framework are implemented.

[0023] The beneficial effects of the present invention are:

[0024] The present invention is based on a distributed computing framework and uses data loading statements to write data into a Greenplum data warehouse, ensuring high-concurrency data writing. In addition, based on the checkpoint mechanism of the distributed computing framework, the task is continued from the most recent successful checkpoint of the task, without the need for manual intervention to process delayed data, which can shorten data recovery time and reduce operating costs.

[0025] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by implementing the embodiments of the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 This is a schematic diagram of the flow of a data writing method based on a distributed computing framework described in an embodiment of the present invention;

[0028] Figure 2 It is a schematic diagram of the structure of a data writing device based on a distributed computing framework described in an embodiment of the present invention;

[0029] Figure 3 This is a schematic diagram of the structure of a data writing device based on a distributed computing framework described in an embodiment of the present invention.

[0030] Markings in the figure:

[0031] 10. First acquisition unit; 20. Subscription unit; 30. Screening and processing unit; 40. Construction unit; 50. Conversion unit; 60. Writing unit; 800. Data writing device based on distributed computing framework; 801. Processor; 802. Memory; 803. Multimedia component; 804. I / O interface; 805. Communication component. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0033] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0034] Embodiment 1:

[0035] This embodiment provides a data writing method based on a distributed computing framework.

[0036] See also Figure 1 , the figure shows that the method includes step S10, step S20, step S30, step S40, step S50, step S60, step S70, step S80 and step S90.

[0037] Step S10. Obtain the metadata of the data warehouse to build a structure and obtain a target structure;

[0038] Specifically, Flink is an open source stream processing framework and distributed computing engine, mainly used for real-time data stream processing and batch processing tasks, with the characteristics of high throughput and low latency.

[0039] In this application, the Flink framework is used to write data into the Greenplum data warehouse. First, the dependencies related to Flink and Kafka need to be added, which can be done in the project's build configuration file (such as Maven or Gradle); secondly, the metadata of Greenplum is initialized, specifically setting the JDBC connection information of Greenplum, including the connection URL, user name, password, etc., and determining the name of the Greenplum database and the name of the table to be written; then the structural information of the database table to be written is read from the metadata, including the field name and field type of the table, as the structure of the read and write data.

[0040] Step S20. Subscribe to the target topic based on the connector of the distributed computing framework to obtain multiple target data;

[0041] Specifically, initialize the Flink Kafka connector, including setting the server address of the Kafka cluster and configuring the consumer group ID, to ensure that Flink can correctly connect to and consume Kafka topic data.

[0042] Specifically, step S20 specifically includes step S21, step S22, step S23, step S24, step S25 and step S26:

[0043] Step S21. Obtain the address, authentication information and target topic of the message queue;

[0044] Specifically, the authentication information is used to ensure a secure connection to the Kafka cluster, and the target topic determines the Kafka topic to be consumed.

[0045] Step S22. Based on the address and authentication information of the message queue, a connection between the distributed computing framework and the message queue cluster is established to obtain a target connection channel;

[0046] Step S23. Acquire the consumption data stream corresponding to the target topic based on the target connection channel to obtain multiple initial data;

[0047] Step S24. Determine the density of the initial data based on the entropy values ​​corresponding to the distribution of the initial data in multiple time periods;

[0048] Step S25. Determine the consumption starting point based on the density of the initial data;

[0049] Step S26. Determine the target data based on the consumption starting point;

[0050] Specifically, the determination of the consumption starting point for the Kafka topic in the present application is based on the density of historical data in the topic. Considering the need to start real-time data acquisition immediately after the connection channel is established, when there is a lot of historical data in the topic, in order to ensure the smooth transmission of real-time data, the consumption starting point is usually set closer to the current time. When there is less historical data in the topic, the consumption starting point can usually be set farther from the current time to obtain more topic data.

[0051] Step S30. All target data are stored in a preset initial set and duplicate data are screened to obtain a target set;

[0052] Specifically, define the KeyedProcessFunction and processElement methods to implement the core logic of data processing, especially the judgment and deduplication of duplicate data based on the time window, to prevent write failures caused by duplicate data, and to ensure the uniqueness of data processing and the stability of the system.

[0053] Specifically, step S30 specifically includes step S31, step S32, step S33, step S34, step S35, step S36 and step S37:

[0054] Step S31. Obtain the current time as the target time;

[0055] Step S32. Calculate the difference between the timestamp of all target data included in the initial set and the target time to obtain multiple time differences;

[0056] Step S33. When the time difference is greater than the set threshold, the target data corresponding to the time difference is discarded to obtain an initial set;

[0057] Step S34. Acquire the real-time data corresponding to the target time, the real-time data carries the constraint field and the timestamp;

[0058] Step S35. Compare the constraint field corresponding to the real-time data with the constraint fields of all target data included in the initial set to obtain a comparison result;

[0059] Step S36. When the comparison result indicates that the real-time data has the same constraint field as the target data in the initial set, the real-time data is discarded;

[0060] Step S37. When the comparison result indicates that the real-time data and the target data constraint fields in the initial set are different, the real-time data is stored in the initial set to obtain the target set;

[0061] Specifically, define KeyedProcessFunction. In the processElement method, based on the unique constraint field of the structure, use 1 minute as the time period to determine data duplication and discard duplicate data to avoid write failure. The time period can be set according to the specific scenario and is not particularly limited here.

[0062] Step S40. Construct a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written;

[0063] Specifically, in Flink, the open method is called when the task starts. You can initialize resources in this method, such as database connections. In GpCopySink, you can initialize the JDBC connection with the Greenplum database in the open method and construct the SQL statement written by COPY based on the data structure.

[0064] First, initialize the JDBC connection and create a JDBC connection using the Greenplum database connection information, account, and password to ensure that it can communicate with the Greenplum database and execute SQL commands. Then construct the SQL statement written by COPY and generate an SQL statement suitable for the COPY command based on the field information of the data structure to ensure that the data can be correctly written to the target table.

[0065] Step S50. All target data in the target set are concatenated and converted based on the target structure to obtain a target character stream;

[0066] Specifically, in the invoke method, each time data is received, the single data passed is obtained from the method parameters, and the Flink context passes each streaming data to the invoke method, so that the invoke method can process the incoming data stream and store it for further processing.

[0067] Specifically, step S50 specifically includes step S51, step S52, step S53, step S54 and step S55:

[0068] Step S51. Acquire the state variables of the target set to obtain the target state variables;

[0069] Step S52. Determine whether the target set is empty based on the target state variable and obtain a determination result;

[0070] Step S53. When the determination result indicates that the target set is not empty, all target data in the target set are sorted to obtain a target sort;

[0071] Specifically, in the present application, the received data is first added to a predefined List collection, and the data is cached in memory for batch processing, which can reduce frequent database write operations and improve system performance; each time the data is added to the List collection, it is necessary to check whether the size of the collection has reached the preset batch size, so as to determine when to write the data in batches; when the collection size reaches the threshold, the batch write operation is triggered. In order to ensure the smooth completion of the write operation, the batch data can be sorted.

[0072] Specifically, step S53 specifically includes step S531, step S532, step S533, step S534 and step S535:

[0073] Step S531. Determine a first ranking based on the timestamps of all target data in the target set;

[0074] Step S532. Based on the constraint fields of all target data in the target set, all target data are divided into multiple categories to obtain multiple category sets;

[0075] Step S533. Calculate the ratio of the number of target data contained in each category set to the number of all target data to obtain multiple category ratios;

[0076] Step S534. Sort the corresponding target data based on the size of the category ratio to obtain a second sort;

[0077] Step S535. Obtain a target ranking based on the first ranking and the second ranking;

[0078] Specifically, usually, the data in the front order are data with higher importance and a time farther from the current time, and the data in the back order are data with lower importance and a time closer to the current time.

[0079] Step S54. Based on the target sorting and the target structure, the target data is sequentially concatenated to obtain multiple character strings;

[0080] Step S55. Convert multiple character strings to obtain a target character stream;

[0081] Specifically, the field value of each data is obtained, and according to the structure information and field type of the table, the field value is spliced ​​into a string format that meets the requirements of the COPY command, and all the spliced ​​data strings are combined into a large string, thereby converting this large string into an InputStream (character stream).

[0082] Step S60. Writing the target character stream into the data warehouse database based on the target sentence;

[0083] Specifically, obtain the CopyManager instance from the JDBC connection, use the copyIn method of CopyManager, execute the COPY command, and write the character stream data into the Greenplum database. When the data is written successfully, clear the data cached in the List collection to ensure that the data is not processed repeatedly, and release memory space to prepare for new data caching; if the data writing fails, catch the exception and roll back the transaction, cancel the written data, close the CopyManager and JDBC connection, release resources, throw an exception, and terminate the task, thereby ensuring data consistency and system stability, and preventing data inconsistency caused by successful writing of some data.

[0084] Step S70. Based on the verification function and the preset timeout parameter, a target Boolean value is obtained, where the target Boolean value is used to indicate whether the database connection is valid;

[0085] Step S80. When the target Boolean value indicates that the database connection is invalid, a return operation is performed;

[0086] Step S90. When the target Boolean value indicates that the database connection is valid, all object resources related to the data warehouse database are closed and a return operation is performed;

[0087] Specifically, after the data is written, a validity check is required to check whether the JDBC connection object is empty or closed. If the JDBC connection is valid, call the connection's close method to release the resources occupied by the database, ensure that the resources are released correctly, avoid resource leakage and connection pool problems, and ensure that the closing operation is performed only when the connection is valid to avoid errors.

[0088] Set the Flink task checkpoint execution cycle, package it into a running Flink program, and use the Flink client to submit it to the Yarn manager to run the Flink task. The Flink task will record the time when the data is written according to the checkpoint time cycle. When the Flink task fails, it will resume from the last successful checkpoint. There is no need to manually process delayed data, and the operation and maintenance cost is low.

[0089] Embodiment 2:

[0090] like Figure 2 As shown, this embodiment provides a data writing device based on a distributed computing framework, the device comprising:

[0091] A first acquisition unit 10 is used to acquire a metadata construction structure of a data warehouse to obtain a target structure;

[0092] A subscription unit 20, used to subscribe to a target topic based on a connector of a distributed computing framework to obtain a plurality of target data;

[0093] A screening processing unit 30 is used to store all target data in a preset initial set and perform duplicate data screening processing to obtain a target set;

[0094] A construction unit 40 is used to construct a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written;

[0095] A conversion unit 50 is used to perform splicing and conversion processing on all target data in the target set based on the target structure to obtain a target character stream;

[0096] The writing unit 60 is used to write the target character stream into the data warehouse database based on the target sentence.

[0097] In a specific embodiment disclosed in the present application, the screening processing unit 30 includes:

[0098] A second acquisition unit is used to acquire the current time as the target time;

[0099] A first calculation unit is used to calculate the difference between the timestamp of all target data included in the initial set and the target time to obtain multiple time difference values;

[0100] A first discarding unit is used to discard the target data corresponding to the time difference when the time difference is greater than a set threshold, so as to obtain an initial set;

[0101] A third acquisition unit is used to acquire real-time data corresponding to the target time, where the real-time data carries a constraint field and a timestamp;

[0102] A comparison unit, used to compare the constraint field corresponding to the real-time data with the constraint fields of all target data included in the initial set to obtain a comparison result;

[0103] A second discarding unit is used to discard the real-time data when the comparison result indicates that the real-time data has the same constraint field as the target data in the initial set;

[0104] The storage unit is used to store the real-time data in the initial set to obtain the target set when the comparison result indicates that the real-time data and the target data constraint field in the initial set are different.

[0105] In a specific implementation disclosed in the present application, the subscription unit 20 includes:

[0106] A fourth acquisition unit, used to acquire the address, authentication information and target subject of the message queue;

[0107] An establishing unit, used to establish a connection between the distributed computing framework and the message queue cluster based on the address and authentication information of the message queue, and obtain a target connection channel;

[0108] A fifth acquisition unit, configured to acquire a consumption data stream corresponding to a target topic based on a target connection channel, and obtain a plurality of initial data;

[0109] A first determining unit, configured to determine the density of the initial data based on entropy values ​​corresponding to the distribution of the initial data in multiple time periods;

[0110] The second unit is used to determine the consumption starting point based on the density of the initial data;

[0111] The third determining unit is used to determine the target data based on the consumption starting point.

[0112] In a specific embodiment disclosed in the present application, the conversion unit 50 includes:

[0113] A sixth acquisition unit, used to acquire the state variables of the target set to obtain the target state variables;

[0114] A determination unit, used for determining whether the target set is empty based on the target state variable, and obtaining a determination result;

[0115] A sorting unit, used for sorting all target data in the target set to obtain a target sorting when the determination result indicates that the target set is not empty;

[0116] A concatenation unit is used to concatenate target data in sequence based on the target sorting and the target structure to obtain multiple character strings;

[0117] The processing unit is used to convert multiple character strings to obtain a target character stream.

[0118] In a specific implementation disclosed in the present application, the sorting unit includes:

[0119] A fourth determining unit, configured to determine a first ranking based on the timestamps of all target data in the target set;

[0120] A partitioning unit, used for partitioning all target data into multiple categories based on the constraint fields of all target data in the target set, to obtain multiple category sets;

[0121] A second calculation unit is used to calculate the ratio of the number of target data contained in each category set to the number of all target data, so as to obtain a plurality of category ratios;

[0122] A first obtaining unit is used to sort the corresponding target data based on the size of the category ratio to obtain a second sorting;

[0123] The second obtaining unit is used to obtain a target sorting based on the first sorting and the second sorting.

[0124] In a specific embodiment disclosed in the present application, the device includes:

[0125] A seventh acquisition unit, used to acquire a target Boolean value based on the verification function and a preset timeout parameter, where the target Boolean value is used to indicate whether the database connection is valid;

[0126] An operation unit, used for performing a return operation when the target Boolean value represents that the database connection is invalid;

[0127] The closing unit is used to close all object resources related to the data warehouse database and perform a return operation when the target Boolean value indicates that the database connection is valid.

[0128] It should be noted that, regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0129] Embodiment 3:

[0130] Corresponding to the above method embodiment, this embodiment also provides a data writing device based on a distributed computing framework. The data writing device based on a distributed computing framework described below and the data writing method based on a distributed computing framework described above can refer to each other.

[0131] Figure 3 FIG. 8 is a block diagram of a data writing device 800 based on a distributed computing framework according to an exemplary embodiment. Figure 3 As shown, the data writing device 800 based on the distributed computing framework may include: a processor 801, a memory 802. The data writing device 800 based on the distributed computing framework may also include one or more of a multimedia component 803, an I / O interface 804, and a communication component 805.

[0132] The processor 801 is used to control the overall operation of the data writing device 800 based on the distributed computing framework to complete all or part of the steps in the above-mentioned data writing method based on the distributed computing framework. The memory 802 is used to store various types of data to support the operation of the data writing device 800 based on the distributed computing framework. These data may include, for example, instructions for any application or method operating on the data writing device 800 based on the distributed computing framework, as well as application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 802 or sent via the communication component 805. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 804 provides an interface between the processor 801 and other interface modules, and the above-mentioned other interface modules can be keyboards, mice, buttons, etc. These buttons can be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the data writing device 800 based on the distributed computing framework and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 805 can include: Wi-Fi module, Bluetooth module, NFC module.

[0133] In an exemplary embodiment, the data writing device 800 based on the distributed computing framework can be implemented by one or more application specific integrated circuits (Application Specific Integrated Circuit, referred to as ASIC), digital signal processors (Digital Signal Processor, referred to as DSP), digital signal processing devices (Digital Signal Processing Device, referred to as DSPD), programmable logic devices (Programmable Logic Device, referred to as PLD), field programmable gate arrays (Field Programmable Gate Array, referred to as FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned data writing method based on the distributed computing framework.

[0134] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned data writing method based on the distributed computing framework are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 802 including program instructions, and the above-mentioned program instructions can be executed by the processor 801 of the data writing device 800 based on the distributed computing framework to complete the above-mentioned data writing method based on the distributed computing framework.

[0135] Embodiment 4:

[0136] Corresponding to the above method embodiment, a readable storage medium is also provided in this embodiment. The readable storage medium described below and the data writing method based on the distributed computing framework described above can refer to each other.

[0137] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the data writing method based on a distributed computing framework of the above method embodiment.

[0138] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.

[0139] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0140] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A data writing method based on a distributed computing framework, characterized in that: include: Obtain the metadata of the data warehouse to build a structure and obtain the target structure; The connector based on the distributed computing framework subscribes to the target topic to obtain multiple target data; All target data are stored in a preset initial set and duplicate data are screened to obtain a target set; Constructing a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written; All target data in the target set are concatenated and converted based on the target structure to obtain a target character stream; The target character stream is written into a data warehouse database based on the target sentence.

2. The data writing method based on the distributed computing framework according to claim 1 is characterized in that ,Store all target data in the preset initial set and perform duplicate data screening to obtain the target set. Each target data carries a constraint field and a timestamp, including: Get the current time as the target time; Calculate the difference between the timestamp of all target data included in the initial set and the target time to obtain multiple time difference values; When the time difference is greater than a set threshold, the target data corresponding to the time difference is discarded to obtain an initial set; Acquire real-time data corresponding to the target time, wherein the real-time data carries a constraint field and a timestamp; Compare the constraint field corresponding to the real-time data with the constraint fields of all target data included in the initial set to obtain a comparison result; When the comparison result indicates that the real-time data is identical to the target data constraint field in the initial set, discarding the real-time data; When the comparison result indicates that the real-time data is different from the target data constraint field in the initial set, the real-time data is stored in the initial set to obtain the target set.

3. The data writing method based on the distributed computing framework according to claim 1 is characterized in that ,The connector based on the distributed computing framework subscribes to the target topic and obtains multiple target data, including: Get the address, authentication information and target topic of the message queue; Based on the address of the message queue and the authentication information, a connection is established between a distributed computing framework and a message queue cluster to obtain a target connection channel; Acquire the consumption data stream corresponding to the target topic based on the target connection channel to obtain a plurality of initial data; Determining the density of the initial data based on entropy values ​​corresponding to the distribution of the initial data in multiple time periods; Determining a consumption starting point based on the density of the initial data; The target data is determined based on the consumption starting point.

4. The data writing method based on the distributed computing framework according to claim 2 is characterized in that , all target data in the target set are spliced ​​and transformed based on the target structure to obtain the target character stream, including: Acquire the state variables of the target set to obtain the target state variables; Determine whether the target set is empty based on the target state variable to obtain a determination result; When the determination result indicates that the target set is not empty, all target data in the target set are sorted to obtain a target sort; Based on the target sorting and the target structure, the target data is sequentially concatenated to obtain multiple character strings; The multiple character strings are converted to obtain the target character stream.

5. A data writing device based on a distributed computing framework, characterized in that: include: A first acquisition unit is used to acquire the metadata construction structure of the data warehouse to obtain a target structure; A subscription unit, used to subscribe to a target topic based on a connector of a distributed computing framework to obtain multiple target data; A screening processing unit, used to store all target data in a preset initial set and perform duplicate data screening processing to obtain a target set; A construction unit, used to construct a structured query statement based on the target structure to obtain a target statement, wherein the structured query statement includes a target table name of the data warehouse and a target field name to which data needs to be written; A conversion unit, used for concatenating and converting all target data in the target set based on the target structure to obtain a target character stream; A writing unit is used to write the target character stream into a data warehouse database based on the target sentence.

6. The data writing device based on the distributed computing framework according to claim 5 is characterized in that: The screening processing unit comprises: A second acquisition unit is used to acquire the current time as the target time; A first calculation unit, configured to calculate the difference between the timestamp of all target data included in the initial set and the target time, to obtain a plurality of time differences; A first discarding unit, configured to discard target data corresponding to the time difference when the time difference is greater than a set threshold, to obtain an initial set; A third acquisition unit, used to acquire real-time data corresponding to the target time, wherein the real-time data carries a constraint field and a timestamp; A comparison unit, used to compare the constraint field corresponding to the real-time data with the constraint fields of all target data included in the initial set to obtain a comparison result; A second discarding unit, configured to discard the real-time data when the comparison result indicates that the real-time data has the same constraint field as the target data in the initial set; The storage unit is used to store the real-time data in the initial set to obtain the target set when the comparison result indicates that the real-time data is different from the target data constraint field in the initial set.

7. The data writing device based on the distributed computing framework according to claim 5, characterized in that: The subscription unit includes: A fourth acquisition unit, used to acquire the address, authentication information and target subject of the message queue; An establishing unit, configured to establish a connection between a distributed computing framework and a message queue cluster based on the address of the message queue and the authentication information, and obtain a target connection channel; A fifth acquisition unit, configured to acquire a consumption data stream corresponding to the target topic based on the target connection channel to obtain a plurality of initial data; A first determining unit, configured to determine the density of the initial data based on entropy values ​​corresponding to distribution conditions of the initial data in multiple time periods; A second confirmation unit is used to determine a consumption starting point based on the density of the initial data; The third determining unit is used to determine the target data based on the consumption starting point.

8. The data writing device based on the distributed computing framework according to claim 6 is characterized in that: The conversion unit comprises: A sixth acquisition unit, configured to acquire the state variables of the target set to obtain the target state variables; A determination unit, configured to determine whether the target set is empty based on the target state variable, and obtain a determination result; A sorting unit, configured to sort all target data in the target set to obtain a target sort when the determination result indicates that the target set is not empty; A concatenation unit, configured to sequentially concatenate the target data based on the target sorting and the target structure to obtain a plurality of character strings; The processing unit is used to convert multiple character strings to obtain the target character stream.

9. A data writing device based on a distributed computing framework, characterized in that: include: Memory for storing computer programs; A processor, used to implement the steps of the data writing method based on a distributed computing framework as described in any one of claims 1 to 4 when executing the computer program.

10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the data writing method based on a distributed computing framework as described in any one of claims 1 to 4.