Real-time data calculation processing method and system, computer equipment and medium
By shifting the burden of managing historical data from memory to the Kudu database disk and leveraging its efficient primary key retrieval capabilities, the high memory consumption problem of existing real-time computing engines is solved, enabling real-time data computation under low-memory hardware conditions and efficient data processing compatible with multi-table join scenarios.
Patent Information
- Application Number
- CN202410757691.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Existing real-time computing engines require full loading of historical data into memory when processing large amounts of data, resulting in high memory usage and increased hardware consumption, which cannot meet the real-time computing needs under low-memory hardware conditions.
The burden of managing historical data in memory is shifted to the Kudu database disk. Leveraging its efficient primary key retrieval capabilities, only the historical data required for calculation is loaded. Data association is performed by generating table relationship views and fast index tables, thus avoiding the loading of irrelevant historical data.
Real-time computation based on SQL statements in the Spark computing engine was achieved under low-memory hardware conditions. It is compatible with CRUD operations in multi-table join scenarios, reducing memory overhead for real-time computation while ensuring computational efficiency.
Smart Images

Figure CN118796953A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data processing technology, and in particular to a real-time data computing and processing method, system, computer equipment and storage medium. Background Art
[0002] With the promotion and application of big data, in order to better deal with the problems of multi-source and complex structure of enterprise business scenario data, building data warehouses to manage and maintain data has become a necessary technical means of business management. At the same time, in order to better meet the real-time needs of business processing, using data warehouses as data support and real-time data computing and processing based on spark or flink computing engines has become a mainstream solution.
[0003] However, the existing real-time computing engine processing flow adopts the operation of stateful recording of data. This is equivalent to loading all the historical data table items into the memory first when the real-time computing task is started or restarted, and then Spark or Flink will form the dependency relationship between the historical data and the new data to perform the associated calculation, so as to realize the full-scenario calculation of data addition, deletion and modification. Although this method can ensure the high efficiency of computing, for scenarios with a large amount of historical data, it not only consumes a large amount of hardware due to the need to consume a considerable amount of memory, which will increase the investment cost of enterprise business management, but also requires additional memory evaluation processing to avoid the risk of memory overflow due to the increase in data volume during task operation, which will increase the performance overhead of computing services, and then lead to insufficient memory hardware or limited host memory expansion scenarios. The real-time computing needs of big data cannot be met, which brings great limitations to the actual production use of enterprises. Summary of the invention
[0004] The purpose of the present invention is to provide a real-time data calculation and processing method, which transfers the pressure of memory management of historical data to the Kudu database disk, and uses its efficient primary key retrieval capability to quickly associate with historical data, so that only the historical data required for calculation needs to be loaded and irrelevant historical data is avoided. The defect of high memory occupancy of existing real-time calculation tasks that require loading all historical data is effectively solved. Real-time calculation of data based on SQL statements in the Spark computing engine can be realized under low-memory hardware conditions. In the multi-table association calculation scenario, it can also be compatible with the operations of adding, deleting and modifying the data of each associated sub-table. While ensuring the real-time calculation efficiency, the real-time calculation memory overhead is effectively reduced.
[0005] In order to achieve the above objectives, it is necessary to provide a real-time data calculation and processing method, system, computer equipment and storage medium in response to the above technical problems.
[0006] In a first aspect, an embodiment of the present invention provides a real-time data calculation and processing method, the method comprising the following steps:
[0007] Generates the corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user, and stores the calculation result table in the Kudu data warehouse;
[0008] Create a spark computing task according to the computing model, and submit the spark computing task to a spark cluster;
[0009] In response to the start of the spark computing task, the corresponding computing model is parsed to generate a corresponding table association view and a quick index table;
[0010] Monitor the binary log changes of the business database and synchronize the updated business data of the business database to the Kudu data warehouse and Kafka server;
[0011] The message queue of the Kafka server is read to obtain the corresponding real-time data to be processed, and according to the operation type of the real-time data to be processed, the table association view and the quick index table, the real-time data to be processed is calculated and processed, and the calculation result table is updated.
[0012] Furthermore, the step of generating a corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user includes:
[0013] Determine whether the stream computing SQL statement includes a subquery;
[0014] If not included, the SQL statement is directly calculated according to the stream to generate the corresponding calculation model and calculation result table;
[0015] If included, the stream computing SQL statement is split into sub-queries to generate corresponding sub-query statements, and according to each sub-query statement, a corresponding sub-computing model and sub-computing result table are generated, and according to the blood dependency relationship between each sub-computing result table, a corresponding calculation result table is constructed.
[0016] Furthermore, the step of parsing the corresponding calculation model to generate the corresponding table association view and quick index table includes:
[0017] By using a sql parser, the sql statement table relationship dependency in the calculation model is parsed to obtain a corresponding table association relationship view; the table association relationship view includes multiple association table dependencies; the association table dependencies include table name, primary key field name, association relationship field name and association type;
[0018] According to the primary key fields of each associated table in the table association view, the primary key MD5 value is calculated, and according to the primary key MD5 value and the primary key fields of each associated table, a corresponding quick index table is generated.
[0019] Furthermore, the step of synchronizing the updated business data of the business database to the Kudu data warehouse and the Kafka server includes:
[0020] The real-time consumption data corresponding to the updated business data is synchronized to the Kafka server through the streamsets data synchronization tool; at the same time,
[0021] According to the updated business data, the source layer data table of the kudu data warehouse is updated.
[0022] Furthermore, the real-time data to be processed includes a database name, an operation type, a data table name to be operated, a field name to be operated, and a corresponding field value;
[0023] The step of performing calculation processing on the real-time data to be processed according to the operation type of the real-time data to be processed, the table association relationship view and the quick index table, and updating the calculation result table comprises:
[0024] When the operation type is to add or modify, the relevant historical data in the Kudu data warehouse is obtained according to the name of the data table to be operated, the name of the field to be operated and the table association view, and the corresponding elastic distributed data set is calculated and generated according to the relevant historical data, the name of the field to be operated and the corresponding field value, and the elastic distributed data set is updated to the corresponding calculation result table in the Kudu data warehouse according to the quick index table;
[0025] When the operation type of the real-time data to be processed is deletion, the corresponding associated table primary key is obtained according to the table name of the data to be operated and the field name to be operated, and the relevant data items of the corresponding calculation result table in the Kudu data warehouse are deleted according to the associated table primary key and the quick index table, and the remaining table item data of the current calculation result table are calculated and updated according to the associated table attributes of the table name of the data to be operated and the table association relationship view.
[0026] Furthermore, the step of acquiring relevant historical data of the Kudu data warehouse according to the name of the data table to be operated, the name of the field to be operated and the table association view includes:
[0027] Generate a temporary view table corresponding to the name of the data table to be operated and the name of the field to be operated according to all the associated table information in the table association relationship view;
[0028] Spark predicate push-down processing is performed according to the temporary view table to obtain corresponding relevant historical data from the Kudu data warehouse.
[0029] Furthermore, the step of calculating and updating the remaining table item data of the current calculation result table according to the associated table attribute of the data table name to be operated and the table association relationship view includes:
[0030] When the attribute of the association table is a sub-table, the corresponding association main table is obtained according to the upper-level table dependency in the corresponding table association view;
[0031] According to the associated main table, the corresponding main table kudu historical data is obtained, and according to the main table kudu historical data, the field name to be operated and the corresponding field value, the corresponding main table temporary result set is calculated and generated;
[0032] According to the temporary result set of the main table, the main table data in the Kudu data warehouse is replaced, and calculation is performed according to the updated main table data to obtain real-time calculation results;
[0033] According to the real-time calculation result, the remaining table item data of the current calculation result table is replaced and updated.
[0034] In a second aspect, an embodiment of the present invention provides a real-time data computing and processing system, the system comprising:
[0035] The calculation model creation module is used to generate the corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user, and store the calculation result table in the Kudu data warehouse;
[0036] A computing task creation module, used to create a spark computing task according to the computing model, and submit the spark computing task to the spark cluster;
[0037] An association relationship extraction module is used to analyze the corresponding computing model in response to the start of the spark computing task, and generate a corresponding table association relationship view and a quick index table;
[0038] Real-time data synchronization module, monitors the binary log changes of the business database, and synchronizes the updated business data of the business database to the Kudu data warehouse and Kafka server;
[0039] The real-time data calculation module is used to read the message queue of the Kafka server, obtain the corresponding real-time data to be processed, and calculate the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the quick index table, and update the calculation result table.
[0040] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0041] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0042] The above-mentioned application provides a real-time data calculation and processing method, system, computer device and storage medium, which realizes the generation of corresponding calculation models and calculation result tables according to the stream calculation SQL statements configured by the user, and stores the calculation result tables in the Kudu data warehouse; creates a Spark calculation task according to the calculation model, and submits the Spark calculation task to the Spark cluster; in response to the start of the Spark calculation task, parses the corresponding calculation model, generates a corresponding table association view and a quick index table; monitors the binary log changes of the business database, and synchronizes the updated business data of the business database to the Kudu data warehouse and the Kafka server; reads the message queue of the Kafka server, obtains the corresponding real-time data to be processed, and calculates and processes the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the quick index table, and updates the technical solution of the calculation result table. Compared with the existing technology, this real-time data calculation and processing method transfers the pressure of memory management of historical data to the Kudu database disk, and uses its efficient primary key retrieval capability to quickly associate with historical data, so that only the historical data required for calculation needs to be loaded and irrelevant historical data is avoided. It effectively solves the high memory usage defect of the existing real-time calculation task execution that requires loading all historical data. It can realize real-time calculation of data based on SQL statements in the spark computing engine under low-memory hardware conditions, and is compatible with the operations of adding, deleting and modifying the data of each associated sub-table in the multi-table associated calculation scenario. While ensuring the real-time calculation efficiency, it effectively reduces the real-time calculation memory overhead and has high practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the process framework of real-time data calculation and processing in an embodiment of the present invention;
[0044] Figure 2 is a flow chart of a real-time data calculation and processing method in an embodiment of the present invention;
[0045] Figure 3 This is a schematic diagram of a SQL query result in an embodiment of the present invention;
[0046] Figure 4 is a schematic diagram of a table association relationship view in an embodiment of the present invention;
[0047] Figure 5 is a schematic diagram of a flow chart of calculating and processing the real-time data to be processed in an embodiment of the present invention;
[0048] Figure 6 is a structural diagram of a real-time data computing and processing system in an embodiment of the present invention;
[0049] Figure 7 It is a diagram of the internal structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical scheme and beneficial effects of the present application clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. Obviously, the embodiments described below are part of the embodiments of the present invention and are only used to illustrate the present invention, but are not used to limit the scope of the present invention. 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.
[0051] The real-time data calculation and processing method provided by the present invention can be understood as an application status that the existing real-time calculation engine processing flow needs to load all historical data table items into the memory to complete the data addition, deletion and modification full-scene calculation tasks, which consumes a lot of memory and hardware investment costs. Figure 1 The illustrated method transfers the pressure of managing historical data in memory to the Kudu database disk, and uses its efficient primary key retrieval capability to quickly associate with historical data, so that only the historical data required for calculation is loaded and no irrelevant historical data is loaded, and the real-time data processing flow can also ensure the high efficiency of data addition, deletion and modification in all scenarios. The following embodiments will explain the real-time data calculation and processing method of the present invention in detail.
[0052] In one embodiment, Figure 2 As shown, a real-time data calculation and processing method is provided, comprising the following steps:
[0053] S11. Generate a corresponding calculation model and calculation result table according to the stream computing SQL statement configured by the user, and store the calculation result table in the Kudu data warehouse; wherein, the stream computing SQL statement can be understood as a SQL (Structured Query Language) structured query statement edited and input by the user based on the relevant configuration interface; in actual applications, the corresponding calculation model and calculation result table can be constructed based on the received SQL statement combined with the pre-configured stream computing SQL template involving relevant parameters such as data source, calculation condition rules and calculation output fields.
[0054] In this embodiment, the calculation model can be used to create corresponding stream computing tasks in the subsequent stream computing processing flow. It needs to correspond to the relevant configuration page parameters and pre-set stream computing sql template parameters for receiving user-configured stream computing sql statements, and can be constructed using a suitable programming language according to actual application requirements. It should be noted that the relevant configuration page parameters and pre-set stream computing sql template settings for receiving user-configured stream computing sql statements can be set according to actual application requirements, and are not specifically limited here. Correspondingly, the calculation result table can be understood as a data table that stores the calculation results after the execution of the sql statement, which is used to show the user a data report of the final calculation results, which is stored in the pre-configured kudu data warehouse for updating and maintaining the subsequent stream computing related results.
[0055] Considering that the existing real-time data calculation process does not support direct calculation of sub-query tasks and needs to rely on non-automatic processing methods such as manual splitting, which is not only time-consuming and labor-intensive, but also affects the overall calculation processing efficiency and cannot avoid manual processing errors, in order to further optimize the real-time data processing process to be compatible with more query task scenarios, this embodiment preferably adds sub-query statement screening and splitting based on stream computing SQL statements to the calculation model creation front end, converts each sub-query into a separate SQL to create a corresponding sub-computing model and sub-computing results for subsequent creation of corresponding spark tasks.
[0056] Specifically, the step of generating a corresponding calculation model and a calculation result table according to the stream calculation SQL statement configured by the user includes:
[0057] Determine whether the stream computing sql statement includes a subquery; wherein the determination of the subquery can be understood as analyzing whether the stream computing sql statement contains multiple select statements;
[0058] If not included, the corresponding calculation model and calculation result table are directly generated according to the stream computing SQL statement; wherein, the generation method of the calculation model and the calculation result table based on the stream computing SQL statement can be implemented by referring to the existing technology, which will not be described in detail here;
[0059] If included, the stream computing sql statement is split into sub-queries to generate corresponding sub-query statements, and according to each sub-query statement, a corresponding sub-computing model and a sub-computing result table are generated, and according to the lineage dependency between each sub-computing result table, a corresponding calculation result table is constructed; wherein the number of sub-query statements is equal to the number of select statements in the stream computing sql statement, that is, each select statement in the stream computing sql statement is split, each sub-query is extracted to form a separate sql statement, and each sql statement is analyzed and processed, and a corresponding sub-computing model (subsequently corresponding to a spark computing task) and a kudu table (sub-computing result table) are established respectively; then, based on the dependency relationship between each sub-query statement in the stream computing sql statement, the lineage dependency relationship between each sub-computing result table is generated, and the calculation result table corresponding to the stream computing sql statement is comprehensively constructed accordingly.
[0060] In actual applications, for example, the received stream computing SQL statement is:
[0061] select * from table_A
[0062] left join(select a from table_B left join(selet c from table_Cwhere...))
[0063] Left join(select b from table_B left join table_D);
[0064] The above SQL statement can be split into:
[0065] selet c from table_C where... / / Subquery
[0066] select a from table_B left join subSelect_3_1; / / subquery intermediate table
[0067] select b from table_B left join table_D; / / Subquery
[0068] Select * from table_A left join subSelect_2_1 left join subSelect_2_2; / / Finally calculate the SQL
[0069] After the above splitting, it is equivalent to forming 4 spark computing tasks in the future; among them, subSelect is the name of the intermediate table generated by the subquery (the number in the middle of the name represents the level depth, and the last number represents the count of the same level). After each task is calculated, it will be stored in the table of the kudu data warehouse. There is a calculation order between each task. The subquery with the deepest level is calculated first. After the calculation is completed, a message notification of the calculation result data of the table will be sent to the upper-level dependent task, and then the upper layer will start the calculation, and so on. It should be noted that the message format of the corresponding calculation result sent by the subquery task can be the same as the data synchronization tool streamset format, which can effectively reuse the code logic of the computing task and avoid additional code development workload.
[0070] This embodiment adds sub-query statement screening and splitting based on stream computing SQL statements to the front end of computing model creation, converts each sub-query into a separate SQL to create a corresponding sub-computing model and sub-computing results for subsequent establishment of corresponding spark tasks. It can support the automatic processing of direct calculation of sub-query tasks, is compatible with more query task scenarios, and can also improve the overall computing processing efficiency and ensure the reliability of real-time computing results.
[0071] S12. Create a spark computing task according to the computing model, and submit the spark computing task to the spark cluster; wherein, the creation and submission process of the spark computing task can be implemented by referring to the existing spark real-time computing task creation and submission process, which will not be repeated here.
[0072] S13, in response to the start of the spark computing task, the corresponding computing model is parsed to generate the corresponding table association view and quick index table; wherein the table association view can be understood as a main table and sub-table dependency view for presenting the association relationship, association type and association field between all data tables involved in the computing model, and the data association maintenance information is established by taking the on condition after the join of the SQL statement as the association basis, and providing the data association basis for the subsequent real-time data processing; for example, Figure 3 From left to right, the data in table aaa, table bbb, and table ccc correspond to each other. Table aaa is used as the reference table. The rows that have no data association in subsequent tables bbb and ccc are empty. Figure 3 The query results shown can be understood as the query results of the first initialization, that is, the initialization data of the wide table in the real-time data warehouse. Considering that the real-time data accessed by the real-time computing process may be Figure 3To find the associated data of an empty data in the table (fill in the empty part of the result in the figure), you need to have a basis to find the data location that needs to be updated. Then you need to use the on condition after the SQL statement join as the association basis and maintain a copy of the association basis data (establish a main table and sub-table dependency view) for subsequent associated real-time data processing, such as accurately obtaining the historical data required for calculation during the subsequent multi-table association real-time calculation task processing.
[0073] The fast index table in this embodiment can be understood as an auxiliary table automatically created with the creation of a computing task. It is a Kudu fast index data table corresponding to a real-time computing task. It stores MD5 values and the primary key IDs of all associated tables calculated by SQL, so as to quickly locate the corresponding MD5 value according to the primary key of the table, and then quickly match the data in the result table according to the MD5 value. For example, there is a pseudo SQL:
[0074] select * from A as a
[0075] left join B as b on a.aid=b.bbb_id
[0076] left join C as c on b.bbb_id=c.cid
[0077] where....
[0078] For the three tables A, B, and C involved in the calculation in the above SQL, the structure of the Kudu fast index data table corresponding to the real-time computing task is shown in Table 1:
[0079] Table 1 Quick Index Table
[0080] OID (primary key MD5 value) aid(primary key ID of table A) bid (primary key ID of table B) cid (primary key ID of table C) 000383af1488e4b9216b1e433b98bbb4 202004140000000782 0001353693 201910170000002427 000055c388d9544ea783f7578fa61c61 201909100000002921 0001353693 201909100000002921 ... ... ... ...
[0081] As shown in Table 1, the amount of data stored in the quick index table corresponds to the result table. The quick index table stores the primary key data of each table, and the result table stores the corresponding detailed data. The OID in the quick index table is equal to the primary key ID in the result table. Each subsequent field is equivalent to the primary key ID of each dependent table. These primary keys of each row of sub-tables are combined to generate the OID (primary key MD5 value). In this embodiment, there are at least two advantages of using MD5 as the basis for quick indexing of kudu data: one is that the length of MD5 is suitable for hash indexing; the other is that the length of these primary key MD5 values combined is fixed and easy to store. That is, the construction and use of the quick index table provides reliable technical support for the efficiency of real-time computing and result updating.
[0082] Specifically, the step of parsing the corresponding calculation model and generating the corresponding table association relationship view and quick index table includes:
[0083] The SQL statement table relationship dependency in the calculation model is parsed by the SQL parser to obtain a corresponding table association relationship view; the table association relationship view includes multiple association table dependencies; the association table dependencies include table name, primary key field name, association relationship field name and association type; in order to facilitate a more intuitive presentation of the table association relationship view, a detailed description is given through corresponding examples; for example, the pseudo SQL code corresponding to the calculation model is:
[0084] select * from A as a
[0085] left join B as b on a.aid=b.bbb_id
[0086] left join C as c on b.bbb_id=c.cid
[0087] where....
[0088] By analyzing the table relationship dependency involved in the SQL code (the content after on), we can know that table A depends on table B and table B depends on table C, and the corresponding generated Figure 4 The table relationship view shown.
[0089] According to the primary key fields of each associated table in the table association view, the primary key MD5 value is calculated, and according to the primary key MD5 value and the primary key fields of each associated table, the corresponding quick index table is generated; wherein, the primary key MD5 value can be understood as the unique identity tag of the calculation result data in the Kudu data warehouse. Under the premise that the primary key fields of all associated tables cannot be modified, the MD5 value calculated by combining the primary keys of all dependent subtables is used as the primary key ID of each result record, which can ensure the rapid positioning of the association between new data and result data, so as to ensure the reliability and efficiency of updating the calculation result table.
[0090] S14, monitor the binary log changes of the business database, and synchronize the updated business data of the business database to the Kudu data warehouse and the Kafka server; wherein, the synchronization of updated business data of the business database can be understood as a process of extracting changed data by monitoring the database binlog (binary log), and updating it to the corresponding data warehouse or real-time stream computing platform based on the data synchronization tool streamsets; specifically, the step of synchronizing the updated business data of the business database to the Kudu data warehouse and the Kafka server includes:
[0091] The real-time consumption data corresponding to the updated business data is synchronized to the Kafka server through the streamsets data synchronization tool; wherein, the process of synchronizing the updated business data to the Kafka server can be understood as first creating the corresponding real-time consumption data information based on the updated business data, and adding it to the message queue of the Kafka server, waiting for the execution of the computing task corresponding to the message reading scheduling; it should be noted that the specific process of generating the corresponding real-time consumption data information according to the updated business data can be referred to the corresponding existing technology implementation, which will not be described in detail here.
[0092] At the same time, according to the updated business data, the source layer data table of the kudu data warehouse is updated; wherein, the source layer data table is the ODS (Operational Data Store) layer data table, which can be understood as all data tables involved in the SQL computing processing stored in the kudu data warehouse; the Streamset tool real-time synchronization will be directly synchronized to the corresponding ODS (source layer) data table, which contains the full amount of historical data and can be used as a historical data table in the subsequent computing task processing flow.
[0093] S15, read the message queue of the kafka server, obtain the corresponding real-time data to be processed, and calculate the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the quick index table, and update the calculation result table; wherein the real-time data to be processed includes the database name, the operation type, the table name of the data to be operated, the field name to be operated and the corresponding field value; the process of calculating the real-time data to be processed is as follows Figure 5 As shown, it can be understood that based on the operation type of the real-time data to be processed, the historical data related to the calculation task is obtained through the table association view, and it is combined with the real-time data to be processed to calculate the data content that needs to be updated in the corresponding calculation result table, and then it is updated to the result table item indexed by the quick index table for related update processing (including adding (Insert) , deleting (delete) and modifying (update)).
[0094] Specifically, the step of performing calculation processing on the real-time data to be processed according to the operation type of the real-time data to be processed, the table association relationship view and the quick index table, and updating the calculation result table includes:
[0095] When the operation type is adding or modifying, the relevant historical data in the Kudu data warehouse is obtained according to the name of the data table to be operated, the name of the field to be operated and the table association view, and the corresponding elastic distributed data set is calculated and generated according to the relevant historical data, the name of the field to be operated and the corresponding field value, and the elastic distributed data set is updated to the corresponding calculation result table in the Kudu data warehouse according to the quick index table.
[0096] Specifically, the step of acquiring relevant historical data of the Kudu data warehouse according to the name of the data table to be operated, the name of the field to be operated and the table association view includes:
[0097] According to all the associated table information in the table association view, a temporary view table corresponding to the data table name to be operated and the field name to be operated is generated; wherein the creation of the temporary view table can be understood as being created through the createOrReplaceTempView method, and the view does not have real data, but is a mapping of the ODS layer data table of the kudu data warehouse;
[0098] Spark predicate push-down processing is performed according to the temporary view table, and corresponding related historical data is obtained from the Kudu data warehouse; wherein, Spark predicate push-down processing can be understood as determining calculation-related data according to SQL association conditions, and then obtaining the required historical data for loading and use from the Kudu data warehouse, which can avoid excessive memory overhead caused by directly loading the full amount of historical data (including too much useless historical data), and can greatly save memory usage in the execution of computing logic.
[0099] In actual applications, the process of adding data and modifying data is the same. First, the real-time data of Kafka (real-time data to be processed) is used to form a temporary view table in Spark according to all the tables associated in the table association view. The historical data in the Kudu ODS layer data table involved in the temporary view table is calculated through the SparkSQL predicate push-down technology to generate a dataset (elastic distributed dataset) temporary cache; then, according to the primary key ID of one or more table data obtained in Kafka, the primary key value is searched in the Kudu quick index table according to its table primary key field to obtain one or more OIDs (MD5 values), and then the corresponding data is deleted from the calculation result table through the OID; finally, the newly calculated data in the dataset is reinserted into the result table to complete the data update, that is, data modification is the process of deleting the associated old data and replacing it with the new data; it should be noted that for the newly added data, if the data cannot be associated in the quick index table, the data will not be deleted, that is, the calculation result in the dataset is directly inserted into the result table to complete the addition.
[0100] When the operation type of the real-time data to be processed is deletion, the corresponding associated table primary key is obtained according to the table name of the data to be operated and the field name to be operated, and the relevant data items of the corresponding calculation result table in the Kudu data warehouse are deleted according to the associated table primary key and the quick index table, and the remaining table item data of the current calculation result table are calculated and updated according to the associated table attributes of the table name of the data to be operated and the table association relationship view.
[0101] Taking into account the characteristics that the actual deletion operation may include two scenarios, namely, sub-table data deletion or main table data deletion, and that the sub-table deletion will affect the update of the result table content of the associated main table, while the main table deletion scenario will not affect other associated tables in the calculation task, in order to ensure the efficiency and accuracy of processing each deletion scenario, this embodiment preferably directly deletes the data to be deleted in the corresponding calculation result table first, and then calculates and updates the data information to be retained in the corresponding calculation result table based on the associated table attributes (main table or sub-table) according to the subdivided deletion scenario.
[0102] Specifically, the step of calculating and updating the remaining table item data of the current calculation result table according to the association table attribute of the data table name to be operated and the table association relationship view includes:
[0103] When the attribute of the association table is a sub-table, the corresponding association main table is obtained according to the upper-layer table dependency in the corresponding table association view; wherein the association main table can be understood as the upper-layer main table that the sub-table depends on based on the association condition (upper-layer table dependency) in the table association view;
[0104] According to the associated main table, the corresponding main table kudu historical data is obtained, and according to the main table kudu historical data, the field name to be operated and the corresponding field value, the corresponding main table temporary result set is calculated and generated; wherein the main table kudu historical data can be understood as the corresponding historical data obtained from the kudu ODS layer data table;
[0105] According to the temporary result set of the main table, the main table data in the Kudu data warehouse is replaced, and calculation is performed according to the updated main table data to obtain real-time calculation results;
[0106] According to the real-time calculation result, the remaining table item data of the current calculation result table is replaced and updated.
[0107] In actual applications, for data deletion scenarios, first obtain the data items whose real-time data types are deleted in the kafka message, and then search for the corresponding primary key values in the quick index table according to the primary key fields of the table based on the primary key IDs of one or more table data obtained in kafka, and obtain one or more OIDs (MD5 values); then, delete the corresponding data in the kudu calculation result table based on the obtained OIDs. The operation of deleting historical data in the calculation result table and the quick index table is the same as the corresponding operation in the aforementioned modification process. However, considering that the ODS layer data table has deleted the corresponding historical data when the data is synchronized in real time, if the spark computing task is directly calculated through the kafka real-time consumption data combined with the historical data, the MD5 value generated will be due to the disappearance of the corresponding historical data. In the case where the result table data cannot be correctly deleted because it cannot be found in the Kudu quick index table, in the scenario of deleting the associated sub-table, based on the current real-time data of Kafka, the corresponding upper-level table dependency is found according to the association condition of the association relationship view (SQL's on condition), the corresponding associated upper-level main table is determined, and then the Kudu historical data of the associated upper-level main table is obtained for calculation to obtain a temporary result data of the dataset main table (the temporary result data is equivalent to the ODS layer table data of Kudu), and finally the calculation SQL is combined with the temporary result data to replace the main table found in the Kudu data warehouse for calculation (the advantage of this is that there is no need to load the full amount of data and only calculate the required data to save memory), and the final result data obtained by calculation is inserted into the corresponding calculation result table. It should be noted that in the scenario of deleting the associated top-level main table, since the higher-level main table cannot be found upward, no additional calculation is required, and the corresponding deletion calculation effect can be met.
[0108] The embodiment of the present application provides a stream computing sql statement configured by the user, generates a corresponding computing model and a computing result table, and stores the computing result table in the kudu data warehouse, creates a spark computing task according to the computing model, and submits the spark computing task to the spark cluster. In response to the start of the spark computing task, the corresponding computing model is parsed, and the corresponding table association view and quick index table are generated. The binary log changes of the business database are monitored, and the updated business data of the business database is synchronized to the kudu data warehouse and the kafka server, and the message queue of the kafka server is read to obtain the corresponding real-time data to be processed, and the real-time data to be processed is read. The operation type of real-time data, table association view and fast index table, the technical solution for calculating and processing the real-time data to be processed, and updating the calculation result table, transfers the pressure of memory management of historical data to the Kudu database disk, and uses its efficient primary key retrieval capability to quickly associate with historical data, so that only the historical data required for calculation needs to be loaded and irrelevant historical data is avoided. It can realize real-time calculation of data based on SQL statements in the spark computing engine under low-memory hardware conditions, and is compatible with the operations of adding, deleting and modifying the data of each associated sub-table in the multi-table association calculation scenario. While ensuring the real-time calculation efficiency, it effectively reduces the real-time calculation memory overhead and has high practical value.
[0109] It should be noted that although the steps in the above flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders.
[0110] In one embodiment, Figure 6 As shown, a real-time data computing and processing system is provided, the system comprising:
[0111] The calculation model creation module 1 is used to generate the corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user, and store the calculation result table in the Kudu data warehouse;
[0112] The computing task creation module 2 is used to create a spark computing task according to the computing model and submit the spark computing task to the spark cluster;
[0113] The association relationship extraction module 3 is used to analyze the corresponding computing model in response to the start of the spark computing task, and generate the corresponding table association relationship view and quick index table;
[0114] Real-time data synchronization module 4 monitors the binary log changes of the business database and synchronizes the updated business data of the business database to the Kudu data warehouse and the Kafka server;
[0115] The real-time data calculation module 5 is used to read the message queue of the Kafka server, obtain the corresponding real-time data to be processed, and calculate the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the quick index table, and update the calculation result table.
[0116] For the specific definition of the real-time data computing and processing system, please refer to the definition of the real-time data computing and processing method above, and the corresponding technical effects can also be obtained equivalently, which will not be repeated here. Each module in the above-mentioned real-time data computing and processing system can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0117] Figure 7 FIG. 1 shows an internal structure diagram of a computer device in an embodiment, and the computer device may specifically be a terminal or a server. Figure 7 As shown, the computer device includes a processor, a memory, a network interface, a display, a camera and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a real-time data calculation and processing method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0118] It can be understood by those skilled in the art that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the present application scheme, and does not constitute a limitation on the computer device to which the present application scheme is applied. The specific computing device may include more or fewer components than shown in the figure, or combine certain components, or have the same component arrangement.
[0119] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the above method are implemented when the processor executes the computer program.
[0120] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0121] In summary, the embodiment of the present invention provides a real-time data calculation processing method and system. The real-time data calculation processing method realizes the stream calculation SQL statement configured by the user, generates the corresponding calculation model and calculation result table, and stores the calculation result table in the Kudu data warehouse. After creating a spark calculation task according to the calculation model and submitting the spark calculation task to the spark cluster, the corresponding calculation model is parsed in response to the start of the spark calculation task, and the corresponding table association view and fast index table are generated. The binary log changes of the business database are monitored, and the updated business data of the business database are synchronized to the Kudu data warehouse and the Kafka server, and the message queue of the Kafka server is read to obtain the corresponding The invention discloses a technical scheme for processing real-time data to be processed, and performing calculation processing on the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the fast index table, and updating the calculation result table. The method transfers the pressure of memory management of historical data to the Kudu database disk, and uses its efficient primary key retrieval capability to quickly associate with historical data, so that only the historical data required for calculation needs to be loaded and irrelevant historical data is avoided. The method can realize real-time calculation of data based on SQL statements in the spark computing engine under low-memory hardware conditions, and is compatible with the operations of adding, deleting and modifying the data of each associated sub-table in the multi-table association calculation scenario. While ensuring the real-time calculation efficiency, it effectively reduces the real-time calculation memory overhead and has high practical value.
[0122] Each embodiment in this specification is described in a progressive manner, and the same or similar parts of each embodiment can be directly referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. It should be noted that the technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0123] The above-mentioned embodiments only express several preferred implementation modes of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in the technical field, several improvements and substitutions can be made without departing from the technical principles of the present invention, and these improvements and substitutions should also be regarded as the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be based on the protection scope of the claims.
Claims
1. A real-time data calculation and processing method, characterized in that: The method comprises the following steps: Generates the corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user, and stores the calculation result table in the Kudu data warehouse; Create a spark computing task according to the computing model, and submit the spark computing task to a spark cluster; In response to the start of the spark computing task, the corresponding computing model is parsed to generate a corresponding table association view and a quick index table; Monitor the binary log changes of the business database and synchronize the updated business data of the business database to the Kudu data warehouse and Kafka server; The message queue of the Kafka server is read to obtain the corresponding real-time data to be processed, and according to the operation type of the real-time data to be processed, the table association view and the quick index table, the real-time data to be processed is calculated and processed, and the calculation result table is updated.
2. The real-time data calculation and processing method according to claim 1, characterized in that: The step of generating a corresponding calculation model and a calculation result table according to the stream calculation SQL statement configured by the user includes: Determine whether the stream computing SQL statement includes a subquery; If not included, the SQL statement is directly calculated according to the stream to generate the corresponding calculation model and calculation result table; If included, the stream computing SQL statement is split into sub-queries to generate corresponding sub-query statements, and according to each sub-query statement, a corresponding sub-computing model and sub-computing result table are generated, and according to the blood dependency relationship between each sub-computing result table, a corresponding calculation result table is constructed.
3. The real-time data calculation and processing method according to claim 1, characterized in that: The step of parsing the corresponding calculation model to generate the corresponding table association view and quick index table includes: By using a sql parser, the sql statement table relationship dependency in the calculation model is parsed to obtain a corresponding table association relationship view; the table association relationship view includes multiple association table dependencies; the association table dependencies include table name, primary key field name, association relationship field name and association type; According to the primary key fields of each associated table in the table association view, the primary key MD5 value is calculated, and according to the primary key MD5 value and the primary key fields of each associated table, a corresponding quick index table is generated.
4. The real-time data calculation and processing method according to claim 1, characterized in that: The step of synchronizing the updated business data of the business database to the Kudu data warehouse and the Kafka server includes: The real-time consumption data corresponding to the updated business data is synchronized to the Kafka server through the streamsets data synchronization tool; at the same time, According to the updated business data, the source layer data table of the kudu data warehouse is updated.
5. The real-time data calculation and processing method according to claim 1, characterized in that: The real-time data to be processed includes the database name, operation type, data table name to be operated, field name to be operated and corresponding field value; The step of performing calculation processing on the real-time data to be processed according to the operation type of the real-time data to be processed, the table association relationship view and the quick index table, and updating the calculation result table comprises: When the operation type is to add or modify, the relevant historical data in the Kudu data warehouse is obtained according to the name of the data table to be operated, the name of the field to be operated and the table association view, and the corresponding elastic distributed data set is calculated and generated according to the relevant historical data, the name of the field to be operated and the corresponding field value, and the elastic distributed data set is updated to the corresponding calculation result table in the Kudu data warehouse according to the quick index table; When the operation type of the real-time data to be processed is deletion, the corresponding associated table primary key is obtained according to the table name of the data to be operated and the field name to be operated, and the relevant data items of the corresponding calculation result table in the Kudu data warehouse are deleted according to the associated table primary key and the quick index table, and the remaining table item data of the current calculation result table are calculated and updated according to the associated table attributes of the table name of the data to be operated and the table association relationship view.
6. The real-time data calculation and processing method according to claim 5, characterized in that: The step of acquiring relevant historical data of the Kudu data warehouse according to the name of the data table to be operated, the name of the field to be operated and the table association view comprises: Generate a temporary view table corresponding to the name of the data table to be operated and the name of the field to be operated according to all the associated table information in the table association relationship view; Spark predicate push-down processing is performed according to the temporary view table to obtain corresponding relevant historical data from the Kudu data warehouse.
7. The real-time data calculation and processing method according to claim 5, characterized in that: The step of calculating and updating the remaining table item data of the current calculation result table according to the association table attribute of the data table name to be operated and the table association relationship view includes: When the attribute of the association table is a sub-table, the corresponding association main table is obtained according to the upper-level table dependency in the corresponding table association view; According to the associated main table, the corresponding main table kudu historical data is obtained, and according to the main table kudu historical data, the field name to be operated and the corresponding field value, the corresponding main table temporary result set is calculated and generated; According to the temporary result set of the main table, the main table data in the Kudu data warehouse is replaced, and calculation is performed according to the updated main table data to obtain real-time calculation results; According to the real-time calculation result, the remaining table item data of the current calculation result table is replaced and updated.
8. A real-time data computing and processing system, characterized in that: The system comprises: The calculation model creation module is used to generate the corresponding calculation model and calculation result table according to the stream calculation SQL statement configured by the user, and store the calculation result table in the Kudu data warehouse; A computing task creation module, used to create a spark computing task according to the computing model, and submit the spark computing task to the spark cluster; An association relationship extraction module is used to analyze the corresponding computing model in response to the start of the spark computing task, and generate a corresponding table association relationship view and a quick index table; Real-time data synchronization module, monitors the binary log changes of the business database, and synchronizes the updated business data of the business database to the Kudu data warehouse and Kafka server; The real-time data calculation module is used to read the message queue of the Kafka server, obtain the corresponding real-time data to be processed, and calculate the real-time data to be processed according to the operation type of the real-time data to be processed, the table association view and the quick index table, and update the calculation result table.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Distributed storage and parallel mining method for state monitoring data
CN102685221A
A big data-based social insurance index warehouse building system and method
CN107169070A
Real-time data warehouse platform
CN107784098A
Big data platform for smart city construction
CN112685385A
Method and device for sorting relationship between database tables and application
CN114153898A
Cited By
Streaming data processing device, method, equipment and system in relational database
CN119336855A
