Data processing method and device

By analyzing and judging the high cardinality of associated keys, the data merging operation is optimized, which solves the problems of low data merging efficiency and data skew in the existing technology, and improves the efficiency and stability of data merging.

CN118656383APending Publication Date: 2024-09-17BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410944929.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

The existing data merging method obtains data directly from the data table when processing multiple data tables, resulting in low data merging efficiency and inability to overcome the data skew problem, especially the data skew problem caused by high cardinality associated keys, which affects the overall efficiency and stability. sex.

Method used

By parsing the associated keys in the data merge request, it is judged whether it is a high-cardinality associated key, and based on the judgment result, it is decided to obtain the merged data from the preset cache or directly from the data table, optimizing the data merging operation and overcoming the problem of data skew.

Benefits of technology

It improves the efficiency and stability of data merging operations, reduces the running time and failure probability of data merging tasks, and enhances the reliability of data merging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656383A
    Figure CN118656383A
Patent Text Reader

Abstract

The invention discloses a data processing method and device, and relates to the technical field of big data. A specific embodiment of the method comprises the following steps: analyzing an association key on which data merging in a plurality of data tables depends, judging whether the association key is a high-cardinal-number association key or not, and judging whether a data merging statement for executing data merging is a complex data statement or not; and according to a judgment result, determining to use the data merging statement to obtain the merged data of the plurality of data tables from the preset cache or directly obtain the merged data from each data table. According to the embodiment of the invention, the problem of data skew in data merging caused by a high-cardinal-number association key is solved, the efficiency of data merging operation is improved, and the stability and reliability of data merging are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data technology, and in particular to a data processing method and device. Background Art

[0002] In business data processing in various business scenarios, data merging operations are usually performed on business data in different data tables to establish associations between different data tables and obtain more business data through merging operations.

[0003] In the existing methods for executing data merging, the mapping (Mapper) and reduction (Reducer) stages of the MapReduce structure are usually used to execute different stages of data merging; however, since the structure directly obtains data from the data table at different stages of data processing, the processing efficiency of data merging is low. In an existing optimization method, the amount of data in the data table is judged to distinguish whether the data merging operation is performed according to the memory or the data table; however, the flexibility of determining the size of the data table in this optimization method is low, and it is unable to overcome the data skew problem caused by the imbalance of the amount of data to be merged, resulting in the problem of low overall efficiency of data merging. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a data processing method and device, which can parse out the association key that the data merge in multiple data tables depends on, determine whether the association key is a high-cardinality association key, and determine whether the data merge statement that performs the data merge is a complex data statement; according to the judgment result, determine whether to use the data merge statement to obtain the merged data of multiple data tables from a preset cache or directly obtain the merged data from each data table. The embodiment of the present invention overcomes the data skew problem in data merge caused by high-cardinality association keys, improves the efficiency of data merge operations, and improves the stability and reliability of data merges.

[0005] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a data processing method is provided, characterized in that it includes: receiving a data merge request for business data in multiple data tables, parsing the association key on which the data merge operation of the multiple data tables depends from the data merge request; in response to the association key being a high-cardinality association key, obtaining a data merge statement for performing the merge operation to which the high-cardinality association key belongs; wherein the high-cardinality association key is an association key that meets a preset condition; in response to the data merge statement being a non-complex data statement, obtaining the merged data of the multiple data tables from a preset cache using the data merge statement; in response to the data merge statement being a complex data statement, obtaining the merged data directly from each data table using the data merge statement.

[0006] Optionally, the preset conditions include one or more of an access frequency exceeding a set frequency threshold, an associated data volume exceeding a set data volume threshold, and a data processing time satisfying a time threshold range; further including: obtaining historical merged data of multiple data tables corresponding to the business data; extracting characteristic data corresponding to each association key associated with the data merge from the historical merged data, the characteristic data including one or more of access frequency, associated data volume, and data processing time; according to the characteristic data corresponding to each association key, selecting an association key that meets the preset conditions from each association key as a high-cardinality association key, and storing the high-cardinality association key in an association key cache.

[0007] Optionally, in response to the association key being a high-cardinality association key, the method further includes: determining whether the association key exists in an association key cache, and if so, determining that the association key is a high-cardinality association key.

[0008] Optionally, after obtaining the data merge statement for performing the merge operation to which the high-cardinality association key belongs, it further includes: obtaining each field of multiple data tables contained in the data merge statement; wherein the field includes a high-cardinality association key; obtaining data corresponding to the high-cardinality association key and data corresponding to each field from multiple data tables; and storing the data corresponding to the high-cardinality association key and the data corresponding to each field in a preset cache accordingly.

[0009] Optionally, the data processing method further includes: detecting the remaining space of the preset cache; when it is determined that the remaining space of the preset cache is lower than a set space threshold, using a data cleaning strategy to clean up data from the preset cache to free up space in the preset cache.

[0010] Optionally, in response to the data merge statement being a non-complex data statement, the method further includes: analyzing statement elements in the data merge statement, and determining whether the data merge statement is a complex data statement based on the type of statement elements; and / or determining the execution time of the data merge statement to obtain merged data of multiple data tables from a preset cache, and judging whether the data merge statement is a complex data statement based on the execution time.

[0011] Optionally, determining whether the data merge statement is a complex data statement is based on the type of the statement element, including: analyzing the type of statement elements contained in the data merge statement, and determining that the data merge statement is a complex data statement when it is analyzed that the type of the statement element is a complex function, the number of associated tables is at least 3, and a multi-level subquery is one or more.

[0012] Optionally, determining the running time of a data merge statement to obtain merged data of multiple data tables from a preset cache includes: searching for a target time that matches the data merge statement from a time data source that stores the running time of the data merge statement, and determining that the data merge statement is a complex data statement when it is analyzed that the target time exceeds a set time threshold; wherein the time data source is used to store historical data of the running time of each data merge statement to obtain merged data from the preset cache.

[0013] To achieve the above-mentioned purpose, according to a second aspect of an embodiment of the present invention, a data processing device is provided, characterized in that it includes: a request parsing module, an association key determination module and a merge execution module; wherein the request parsing module is used to receive a data merge request for business data in multiple data tables, and parse out the association keys on which the data merge operations of the multiple data tables depend from the data merge request; the association key determination module is used to obtain a data merge statement for performing a merge operation to which the high-cardinality association key belongs in response to the association key being a high-cardinality association key; wherein the high-cardinality association key is an association key that meets preset conditions; the merge execution module is used to obtain merged data of multiple data tables from a preset cache using the data merge statement in response to the data merge statement being a non-complex data statement; and obtain merged data directly from each data table using the data merge statement in response to the data merge statement being a complex data statement.

[0014] Optionally, the data processing device includes preset conditions including one or more of an access frequency exceeding a set frequency threshold, an associated data volume exceeding a set data volume threshold, and a data processing time satisfying a time threshold range; obtaining historical merged data of multiple data tables corresponding to the business data; extracting characteristic data corresponding to each association key associated with the data merge from the historical merged data, the characteristic data including one or more of access frequency, associated data volume, and data processing time; selecting, from each association key, an association key that meets the preset conditions as a high-cardinality association key based on the characteristic data corresponding to each association key, and storing the high-cardinality association key in an association key cache.

[0015] Optionally, in response to the associative key being a high-cardinality associative key, the data processing device is used to determine whether the associative key exists in an associative key cache, and if so, determine that the associative key is a high-cardinality associative key.

[0016] Optionally, after obtaining a data merge statement containing a high-cardinality association key for performing a merge operation, the data processing device is further used to obtain each field of multiple data tables contained in the data merge statement; wherein the field includes a high-cardinality association key; obtain data corresponding to the high-cardinality association key and data corresponding to each field from multiple data tables; and store the data corresponding to the high-cardinality association key and the data corresponding to each field in a preset cache accordingly.

[0017] Optionally, the data processing device is further used to detect the remaining space of the preset cache; when it is determined that the remaining space of the preset cache is lower than a set space threshold, a data cleaning strategy is used to clean up data from the preset cache to free up space in the preset cache.

[0018] Optionally, in response to the data merge statement being a non-complex data statement, the data processing device is further used to analyze statement elements in the data merge statement, and determine whether the data merge statement is a complex data statement based on the type of statement elements; and / or determine the duration of the data merge statement to obtain merged data of multiple data tables from a preset cache, and determine whether the data merge statement is a complex data statement based on the duration.

[0019] Optionally, a data processing device is used to determine whether the data merge statement is a complex data statement based on the type of the statement element, including: analyzing the type of statement elements contained in the data merge statement, and determining that the data merge statement is a complex data statement when it is analyzed that the type of the statement element is a complex function, the number of associated tables is at least 3, and a multi-level subquery is one or more.

[0020] Optionally, a data processing device is used to determine the running time of a data merge statement to obtain merged data of multiple data tables from a preset cache, including: searching for a target duration that matches the data merge statement from a duration data source that stores the running time of the data merge statement, and determining that the data merge statement is a complex data statement when it is analyzed that the target duration exceeds a set duration threshold; wherein the duration data source is used to store historical data of the running time of each data merge statement to obtain merged data from the preset cache.

[0021] To achieve the above-mentioned purpose, according to the third aspect of an embodiment of the present invention, there is provided an electronic device for data processing, characterized in that it includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any method as described in the above-mentioned data processing method.

[0022] To achieve the above-mentioned purpose, according to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, a method as described in any of the above-mentioned data processing methods is implemented.

[0023] To achieve the above-mentioned purpose, according to a fifth aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, characterized in that when the program is executed by a processor, a method as described in any one of the above-mentioned data processing methods is implemented.

[0024] An embodiment of the above invention has the following advantages or beneficial effects: it can parse the association key that the data merge in multiple data tables depends on, judge whether the association key is a high-cardinality association key, and judge whether the data merge statement for executing the data merge is a complex data statement; according to the judgment result, it is determined to use the data merge statement to obtain the merged data of multiple data tables from the preset cache or directly obtain the merged data from each data table. The embodiment of the present invention overcomes the data skew problem in data merge caused by high-cardinality association keys, improves the efficiency of data merge operations, and improves the stability and reliability of data merge.

[0025] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0027] Figure 1 It is a flowchart of a data processing method provided by an embodiment of the present invention;

[0028] Figure 2 It is a structural diagram of existing data merging processing provided by an embodiment of the present invention;

[0029] Figure 3 It is a structural diagram of a data merging process provided by an embodiment of the present invention;

[0030] Figure 4 It is a schematic diagram of the structure of an intelligent cache layer provided by an embodiment of the present invention;

[0031] Figure 5 is a structural schematic diagram of a data processing device provided by an embodiment of the present invention;

[0032] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] It should be noted that the collection, use, storage, sharing and transfer of user personal information involved in the technical solution of the present invention are in compliance with the provisions of relevant laws and regulations, and the user needs to be informed and the user's consent or authorization is obtained. When applicable, the user's personal information is de-identified and / or anonymized and / or encrypted. Data processing in various business scenarios usually includes table association (merge) operations.

[0036] In the following description, the associated table refers to different data tables to be merged; the association of data tables represents the merging of data in the data tables.

[0037] Table association is the process of combining data from two or more tables based on one or more common fields (i.e. association keys). This operation allows users to establish associations between different tables and use these associations in queries to obtain more information about the data. Table associations include inner joins, left joins, right joins, full joins, etc. These association operations associate data from different tables to meet various query requirements and obtain richer data. Various association operations are more likely to be used in actual business scenarios.

[0038] Data table association is an important operation for processing large-scale data. When processing data tables with large data volumes, in order to overcome the problem of low performance, different data merging type strategies can be selected based on factors such as data volume, query requirements, and hardware resources to obtain the best performance and results. Among them, one association operation is to compile the association operation into a MapReduce task. A general association task includes a mapping (Mapper) stage and a sorting (Reducer) stage. The mapper reads data from the association table and sends the association key and association value pairs to the intermediate file. The data engine sorts and merges the association value pairs in the shuffle (Shuffle) stage. The reducer uses the sorted results as input to perform the actual association (merging) work. The shuffle stage consumes a lot of resources because it needs to sort and merge.

[0039] One optimization method is the Map join (broadcast join) task, which aims to save resources in the shuffle and sort stages by performing association operations only in the mapping stage. When the data size of one of the association tables is small enough to fit in the memory, all mappers can save the data in the memory and perform data table association operations in the memory, so that all association operations can be completed in the mapping stage. However, the Map Join of this method has scalability issues. When a large number of mappers read small association tables from the data source into the memory at the same time, the association table can easily become a performance bottleneck, causing the mapper to time out during the read operation.

[0040] Another optimization method is to use distributed automatic matching cache table Map Join operation. In this method, during compilation, the query processor generates a conditional task containing a task list; one of the tasks is parsed and run during execution. First, the original regular association task should be put into the task list, and then the query processor generates a series of Map Join tasks by assuming that each input table may be a large table. During the execution phase, the conditional task understands the file size (i.e., the amount of data) of each input association table. If all the association tables are large tables and cannot be converted to Map Join, then the regular association task can be run; if one of the association tables is large and the other association tables are small tables, the corresponding Map Join local task is selected to run, which can automatically and dynamically convert the regular association to Map Join.

[0041] However, whether it is direct merging of data tables through MapReduce, or optimized MapJoin, or data merging of distributed cache tables, it is impossible to solve the problem of low data merging performance and efficiency caused by data skew. In actual usage scenarios, the probability of data skew is very high, especially when some association keys are hit with a high probability and high frequency (the hit association keys are high-cardinality association keys), and high-frequency association behavior will cause some executors and nodes to run very slowly, which in turn leads to a decrease in the overall data merging processing efficiency and processing speed. In addition, high-cardinality association keys will change dynamically with the actual business situation, and existing methods lack the identification and processing of high-cardinality association keys.

[0042] In view of this, if Figure 1 As shown, an embodiment of the present invention provides a method for data processing, which may include the following steps:

[0043] Step S101: receiving a data merging request for business data in multiple data tables, and parsing the data merging request to obtain association keys on which the data merging operation of the multiple data tables depends.

[0044] Specifically, for different business scenarios, there are data merging requests for business data. For example, for the business scenario of user behavior analysis for e-commerce, on the e-commerce platform, user clicks, browsing, adding to shopping carts and purchasing behaviors can generate user behavior log data. When there is a need to optimize the recommendation system, the background needs to associate these log data with user information data for analysis.

[0045] Furthermore, in order to achieve the purpose of related data analysis, it is necessary to merge the data of multiple data tables storing user information data and data tables storing user behavior log data, and the multiple data tables to be merged have associated keys that the data merging operation depends on. For example, the associated key that the user information data table and the user behavior data table rely on for merging is the user ID (user_id).

[0046] Step S102: in response to the association key being a high-cardinality association key, obtaining a data merge statement for executing a merge operation to which the high-cardinality association key belongs; wherein the high-cardinality association key is an association key that meets a preset condition.

[0047] Specifically, after determining the association key on which the merge depends, the embodiment of the present invention further determines whether the association key is a high cardinality association key; wherein, the high cardinality association key (High Cardinality Join Keys, HCK for short) is an association key that meets the preset conditions. In the embodiment of the present invention, the high cardinality association key is associated with the problem of data skew (unbalanced data load) in the data merge operation. For example: in the data merge operation of multiple data tables, the key value of one or more association keys appears frequently. Because the key value appears too frequently, the data merge task corresponding to the key value will be concentrated, resulting in excessive burden and data skew, thereby affecting the performance of the entire query. For another example, because the association operation of certain key values ​​is too frequent, some Mappers or Reducers process too much data, while other Mappers or Reducers process relatively less data, resulting in unbalanced load of data merge processing.

[0048] The following example illustrates a scenario where data skew is associated with a high cardinality association key:

[0049] Scenario 1: High-frequency association: The key values ​​of some association keys appear frequently in data merge operations. For example, in the order data table, one or more users place orders frequently, and the user ID can be used as a high-cardinality association key.

[0050] Scenario 2: Uneven data distribution: For example, in the user activity data of a social media platform, some active users generate a large number of records, while most users have relatively few records. The user IDs of extremely active users can be used as high-cardinality association keys in data merging operations.

[0051] Scenario 3: Popular and sparse values: There are a small number of very popular values ​​and a large number of sparse values ​​in the data set. For example, in page click log data, the number of clicks on popular pages is much higher than that on other pages. The page ID of the popular page is used as a high-cardinality association key in the data merge operation.

[0052] Furthermore, in an embodiment of the present invention, preset conditions for determining a high-cardinality association key include one or more of an access frequency exceeding a set frequency threshold, an associated data volume exceeding a set data volume threshold, and a data processing duration satisfying a duration threshold range; the method of an embodiment of the present invention further includes: obtaining historical merge data of multiple data tables corresponding to business data; extracting feature data corresponding to each association key associated with the data merge from the historical merge data, the feature data including one or more of access frequency, associated data volume, and data processing duration; selecting an association key that meets the preset conditions from each association key as a high-cardinality association key based on the feature data corresponding to each association key, and storing the high-cardinality association key in an association key cache.

[0053] Specifically, the embodiments of the present invention determine high cardinality association keys through various methods such as real-time monitoring and historical merge data analysis; specifically, the task of processing data merge can be processed through real-time monitoring and the characteristic data such as the access frequency, data processing time and associated data volume of each association key that the data merge depends on can be recorded through logs. Furthermore, the characteristic data in the logs can be counted, that is, the number of accesses, the amount of associated data and the data processing time of each association key can be obtained.

[0054] Further, for the access frequency, it is determined whether the access frequency of each associated key obtained by statistics is higher than the set frequency threshold, and the access frequency of the associated key is higher than the set frequency threshold as a preset condition, and the associated key that meets the preset condition is selected from each associated key as a high cardinality associated key. Among them, the set frequency threshold can be determined according to the historical data of the business. For the amount of associated data, data tilt analysis can be performed to analyze the load conditions of different nodes and actuators, identify the associated key with unbalanced load (data tilt) due to the amount of associated data exceeding the set data volume threshold, and judge the associated key as a high cardinality associated key. For the data processing time, the average time and maximum time required to process each associated key can be calculated, and the data processing time meeting the time threshold range can be used as the preset condition for selecting the high cardinality associated key; it can be understood that the preset condition can be a preset condition including one or more of the access frequency exceeding the set frequency threshold, the associated data volume exceeding the set data volume threshold, and the data processing time meeting the time threshold range; the preset condition can be set according to the actual business scenario, for example, the associated key with the access frequency exceeding a certain frequency threshold and the data processing time exceeding the time threshold is regarded as a high cardinality associated key.

[0055] Furthermore, before executing the determination whether the association key exists in the association key cache, a high cardinality association key is selected from each association key according to a preset condition, and the high cardinality association key is stored in the association key cache (eg, a heap, a memory, a cache, etc.).

[0056] Furthermore, the method for determining whether an association key is a high-cardinality association key in the embodiment of the present invention is: determining whether the association key exists in an association key cache, and if so, determining that the association key is a high-cardinality association key.

[0057] Furthermore, in an embodiment of the present invention, the timing for triggering the judgment of whether an association key is a high-cardinality association key includes: real-time monitoring of the execution of the data merging task, and triggering the judgment when data skew or node load is too high; before the execution of the data merging task: before the task is executed, based on historical merged data and preprocessing analysis, potential high-cardinality association keys are identified in advance; periodic analysis: statistical analysis of historical merged data is performed at set intervals (for example, every day or every week) to judge and identify high-cardinality association keys.

[0058] Further, obtaining a data merge statement for performing a merge operation to which the high cardinality association key belongs;

[0059] For example, the data merge statement is: SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id; Among them, "INNER JOIN" is an equivalue join, which associates (merges) the data in the two tables that meet the join conditions and outputs the merged data that meets the conditions. "Table 1" and "Table 2" are the two data tables to be merged, and "id" is a high-cardinality association key.

[0060] Step S103: In response to the data merge statement being a non-complex data statement, using the data merge statement to obtain merged data of multiple data tables from a preset cache; in response to the data merge statement being a complex data statement, using the data merge statement to directly obtain merged data from each data table.

[0061] Specifically, in an embodiment of the present invention, a determination is further made as to whether the data merge statement is a complex data statement based on the data merge statement; wherein the complexity of the data merge statement is related to the efficiency and performance of executing the data merge statement.

[0062] Furthermore, there are the following methods to determine whether a data merge statement is a complex data statement:

[0063] The first method: Analyze the type of statement elements in the data merge statement, and determine whether the data merge statement is a complex data statement according to the type of statement elements. Specifically, the type of statement elements can be a data table, data operation function, etc. that are related to the data merge in the data merge statement. Whether the data operation function is a complex function is used as a condition for determining whether the data merge statement is a complex data statement. Complex functions include, for example: Aggregate functions: such as SUM(), AVG(), COUNT(), etc., especially when used in combination or nested; Window functions: such as ROW_NUMBER(), RANK(), LEAD(), etc. Window functions are used to analyze and sort data. Complex conditional functions: such as CASE expressions, COALESCE(), NULLIF(), POSEXPLODE(), etc., especially when the conditional logic is complex or nested; further determine whether the data operation function includes a subquery with multiple nested levels, and determine that the data merge statement is a complex data statement when the data operation function is determined to be a complex function or a multi-level subquery; further, the number of data tables to be merged can also be used as a judgment condition for determining whether the data merge statement is a complex data statement, for example: if the number of data tables to be merged is 3 or more, the data merge statement is determined to be a complex data statement. That is, determining whether the data merge statement is a complex data statement based on the type of the statement element includes: analyzing the type of the statement element contained in the data merge statement, analyzing the type of the statement element contained in the data merge statement, and determining that the data merge statement is a complex data statement when the type of the statement element is analyzed to be one or more of a complex function, the number of associated tables is at least 3, and a multi-level subquery.

[0064] The second method is to determine the execution time of the data merge statement to obtain the merged data of multiple data tables from the preset cache, and determine whether the data merge statement is a complex data statement based on the execution time.

[0065] Specifically, from the duration data source storing the running time of the data merge statement, the target duration matching the data merge statement is searched, and when it is analyzed that the target duration exceeds the set duration threshold, the data merge statement is determined to be a complex data statement; wherein the duration data source is used to store the historical data of the running time of each data merge statement to obtain the merged data from the preset cache. In an embodiment of the present invention, the historical duration data of the running time of each data merge statement to obtain the merged data from the preset cache (i.e., the time required to complete the data merge) can be recorded and stored in the duration data source, and for the data merge statement to be determined, its corresponding target duration can be searched according to the duration data source, and if the target duration exceeds the set duration threshold, the data merge statement is determined to be a complex data statement. It can be understood that the data merge statement can be executed as a non-complex statement when it is executed for the first time, and the running time of the data merge statement is recorded in the duration data source.

[0066] The third method: a combination of the first and second methods.

[0067] That is, before responding to the data merge statement being a non-complex data statement, it also includes: analyzing statement elements in the data merge statement, and determining whether the data merge statement is a complex data statement based on the type of statement elements; and / or; determining the execution time of the data merge statement to obtain the merged data of multiple data tables from a preset cache, and judging whether the data merge statement is a complex data statement based on the execution time.

[0068] Furthermore, if it is determined that the data merge statement is a non-complex data statement, the merged data of multiple data tables are obtained from a preset cache using the data merge statement; if it is determined that the data merge statement is a complex data statement, the merged data are directly obtained from each data table using the data merge statement.

[0069] The preset cache stores fields and data in different data tables associated with the data merge statement. Specifically, after obtaining the data merge statement for performing the merge operation to which the high cardinality association key belongs, it further includes: obtaining each field of multiple data tables contained in the data merge statement; wherein the field includes a high cardinality association key; obtaining data corresponding to the high cardinality association key and data corresponding to each field from multiple data tables; and storing the data corresponding to the high cardinality association key and the data corresponding to each field in the preset cache accordingly. It can be understood that the association key is a field in the fields contained in the multiple data tables to be merged, and each data table includes multiple other fields in addition to the association key. The merged data is the data corresponding to multiple fields in the multiple data tables (that is, not only the data containing the association key), so as to realize the merging (association) of data from different data tables. Therefore, the embodiment of the present invention obtains the data corresponding to the high cardinality association key and the data corresponding to each field from multiple data tables in advance; and stores the data corresponding to the high cardinality association key and the data corresponding to each field in the preset cache accordingly; so that the merged data can be directly obtained from the preset cache when the merge operation is performed using the data merge statement.

[0070] Further preferably, the embodiment of the present invention can detect the remaining space of the preset cache, and when it is determined that the remaining space of the preset cache is lower than the set space threshold, use the data cleaning strategy to clean up the data from the preset cache to release the space of the preset cache. Specifically, the data cleaning strategy can be an LRU (Least Recently Used, LRU for short) elimination algorithm, which detects the cache space and removes the least recently used data from the cache to release space for new data. The LRU algorithm determines the least recently used data based on the access time of the data by maintaining the data access history.

[0071] Furthermore, when it is determined that the association key is not a high-cardinality association key, or when it is determined that the data merge statement is a complex data statement, the data merge statement is used to directly obtain the merged data from each data table (that is, the business data required for the merge is not obtained from the preset cache); in addition to overcoming the problem of data skew caused by high-cardinality association keys, the flexibility of the data volume of the preset cache can be maintained, and the size of the preset cache space can be within a reasonable range, thereby improving the efficiency of data merge processing.

[0072] It can be seen that the embodiment of the present invention determines whether to use the data merge statement to obtain the merged data of multiple data tables from the preset cache, or to use the data merge statement to directly obtain the merged data from each data table, by judging whether the association key in the data merge statement is a high-cardinality association key, and further judging whether the data merge statement is a complex data statement. The embodiment of the present invention overcomes the problems of data skew and load imbalance in the data table data merge process, improves the efficiency of data merging, and reduces the running time and running failure probability of the data merge task.

[0073] The following comparison Figure 2 The structure of the prior art shown, Figure 3 The structure of the embodiment of the present invention shown in the figure illustrates the structure of the data merging processing provided by the embodiment of the present invention.

[0074] Figure 2 The structure of the existing technology includes: data table x and data table y to be merged; upstream and downstream tasks (task A, task C) to process the merge and the intermediate MapJoin task; Map Join is a query optimization strategy of the data processing engine Hive to improve query performance. In Hive, when performing a merge (association) operation of a data table, the MapReduce local task can be used to load the data of a smaller data table into memory, reducing data transmission and query costs. Figure 2 As shown in the figure, the MapJoin task includes multiple mapping processes 1~n (i.e. Mapper). Figure 2 The existing method shown is based on the MapReduce framework and determines whether to read data from the cache according to the size of the data table.

[0075] Figure 3 The data merging processing structure provided by the embodiment of the present invention is as follows: Figure 3 As shown, Figure 2 Compared with the prior art structure, an intelligent cache layer 100 is added, and the intelligent cache layer 100 implements any method provided by the implementation of the present invention. The specific description of the intelligent cache layer 100 is consistent with the description of step S101 to step S103, and will not be repeated here. The embodiment of the present invention utilizes the optimization of the intelligent cache layer 100 to overcome the problems of data skew and load imbalance in the data table data merging process, improves the efficiency of data merging, and reduces the running time and running failure probability of the data merging task.

[0076] Further, Figure 4 A schematic diagram of the structure of the intelligent cache layer provided by an embodiment of the present invention is shown.

[0077] like Figure 4As shown, the structure of the intelligent cache layer includes: a preset cache, a judgment component 401 for identifying high-cardinality association keys, an intelligent router 402 for analyzing whether a data merge statement is a complex statement, a cache manager 403 for monitoring and cleaning data in the preset cache, a high-cardinality association key manager 404 for processing the reading and writing of data in the preset cache, and an association key storage 405 for storing high-cardinality association keys.

[0078] The preset cache can be set based on the Redis cache strategy to store data corresponding to high-cardinality association keys and data corresponding to each field in the preset cache. The overall deployment is based on Redis and can comply with various management strategies and fault-tolerant mechanisms of Redis, providing stability and reliability of the preset cache.

[0079] The high-cardinality association key manager 404 is used to determine the high-cardinality association key based on the historical data of the data merging result, and interact with different data sources or components, synchronize the information of the high-cardinality association key with the cache manager 403, and synchronize the information of the cardinality association key with the association key storage 405. It can also obtain the data of the high-cardinality association key and its related fields from the data table, and write the data into the preset cache; in the subsequent data merging process, it can also be used to read data from the preset cache.

[0080] The cache manager 403 is used to manage the data in the preset cache, for example, to clean up the data in the preset cache through the LRU algorithm to achieve the effect of real-time cache update.

[0081] The association key cache 405 is used to store each high-cardinality association key identified by the determination component 401 .

[0082] The determination component 401 is used to determine whether the association key is a high cardinality association key according to whether the association key exists in the association key cache 405 .

[0083] The intelligent router 402 is used to analyze whether the data merge statement is a complex statement after the judgment component 401 determines the high cardinality association key, and execute different data merge routes according to the analysis result: routing to a preset cache or routing to a data table.

[0084] Figure 4 The data tables to be merged are data table x and data table y. Figure 4 The components shown and the interactions between the components implement any method provided by the embodiments of the present invention. The specific description of the steps executed by each component is consistent with the description of step S101 to step S103, and will not be repeated here.

[0085] The embodiments of the present invention can be applied to a variety of scenarios, improve the efficiency and stability of data merging processing in different application scenarios, and overcome the data skew problem existing in the prior art. For example:

[0086] 1. Scenarios for user behavior analysis in e-commerce and retail businesses: On e-commerce platforms, every click, browse, add to cart, and purchase behavior of a user will generate log data. In order to optimize the recommendation system for users, the platform needs to correlate these log data with user information data for analysis. Due to the large user base and the large amount of behavior data for each user, for data merging, the user ID (user_id) and product ID (sku_id) are high-cardinality association keys, which leads to data skew problems, such as some popular products being frequently clicked or purchased by a large number of users.

[0087] The improved data merging method provided by the embodiment of the present invention can overcome data skew to a large extent. By analyzing high-cardinality association keys, bucketing data based on the Mapper task in MapReduce, and performing data pre-aggregation and preset caching, the performance and accuracy of user behavior analysis are improved, thereby better personalizing recommended content and improving user satisfaction and recommendation accuracy.

[0088] 2. Real-time transaction monitoring scenarios in financial services: Financial institutions usually need to monitor a large amount of transaction data in real time in order to quickly identify and prevent fraud. Each transaction will generate data containing transaction time, transaction amount, transaction account and other information, which needs to be associated with user account information. Due to the huge amount of transaction data and high real-time requirements, the transaction number (transaction_id) and user account (account_id) are high-cardinality association keys, and high-frequency trading accounts may cause data skew.

[0089] The improved data merging method provided by the embodiment of the present invention can accelerate the processing and association (merging) of transaction data. By using dynamic partitioning and distributed caching technology, the real-time monitoring system can quickly identify abnormal transactions in large-scale data streams and reduce the risk of fraud.

[0090] 3. Scenarios for patient data integration in medical and health services: In the medical field, patient data stored in different systems (such as electronic medical records, laboratory systems, and drug management systems) need to be merged and integrated to provide doctors with comprehensive patient information to support diagnosis and treatment. Since each patient has a large amount of historical records, the patient number (patient_id) is a high-cardinality association key. Data skew may occur in some frequently visited patients (such as patients with chronic diseases).

[0091] Through the improved data merging method provided by the embodiment of the present invention, patient data from different systems can be efficiently integrated, and the Mapper task partitioning and bucketing strategy in MapReduce can be used to optimize data distribution and reduce data skew, thereby improving the speed and accuracy of data integration and supporting timely and effective medical decisions.

[0092] 4. For transportation tracking scenarios in logistics and supply chain management: Logistics companies usually need to track each package in the transportation process in real time and associate (merge) this data with order information to ensure that the package is delivered on time and provide customers with accurate tracking information. Due to the large amount of order and transportation data generated every day, the order number (order_id) and package number (package_id) are high-cardinality association keys, which may cause data skew in some popular logistics routes or peak periods.

[0093] The improved data merging method provided by the embodiment of the present invention can accelerate the association operation of order and transportation data. The pre-aggregation and distributed cache technology is used to update and query the package status in real time, ensuring that customers can obtain accurate package tracking information in a timely manner and improving the quality of logistics services.

[0094] 5. Traffic management scenarios in smart city business: Usually, the traffic management system of smart cities needs to collect and analyze traffic flow data in real time to optimize traffic signals and reduce traffic congestion. These data need to be associated with historical traffic data and event data. Due to the large number of traffic sensors and vehicles, the smart sensor number (sensor_id) and vehicle number (vehicle_id) are high-cardinality association keys. The data skew problem is significant during peak hours.

[0095] The improved data merging method provided by the embodiment of the present invention can quickly process and associate a large amount of real-time traffic data. Partitioning and bucketing techniques are used to optimize data distribution and reduce data skew during peak hours, thereby improving the response speed and decision-making efficiency of the traffic management system, reducing traffic congestion and improving travel experience.

[0096] Through the description of various application scenarios, it can be known that data skew has a high probability of occurrence. The embodiments of the present invention determine whether the association key is a high-cardinality association key and whether the data merge statement for executing the data merge is a complex data statement; according to the judgment result, it is determined to use the data merge statement to obtain the merged data of multiple data tables from the preset cache or directly obtain the merged data from each data table, thereby overcoming the data skew problem in data merging caused by high-cardinality association keys, improving the efficiency of data merging operations, and improving the stability and reliability of data merging.

[0097] like Figure 5As shown, the embodiment of the present invention provides a data processing device 500, including: a request parsing module 501, a correlation key determination module 502 and a merging execution module 503; wherein,

[0098] The request parsing module 501 is used to receive a data merging request for business data in multiple data tables, and parse the data merging request to obtain the association key on which the data merging operation of the multiple data tables depends;

[0099] The determining association key module 502 is used for obtaining, in response to the association key being a high cardinality association key, a data merging statement for performing a merging operation to which the high cardinality association key belongs; wherein the high cardinality association key is an association key that satisfies a preset condition;

[0100] The execution merge module 503 is used to obtain the merged data of multiple data tables from the preset cache using the data merge statement in response to the data merge statement being a non-complex data statement; and to obtain the merged data directly from each data table using the data merge statement in response to the data merge statement being a complex data statement.

[0101] An embodiment of the present invention also provides an electronic device for data processing, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the method provided in any of the above embodiments.

[0102] An embodiment of the present invention further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the method provided in any of the above embodiments is implemented.

[0103] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the method provided in any of the above embodiments when executed by a processor.

[0104] Figure 6 An exemplary system architecture 600 is shown to which the data processing method or data processing device according to the embodiment of the present invention can be applied.

[0105] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0106] Users can use terminal devices 601, 602, 603 to interact with server 605 through network 604 to receive or send messages, etc. Various client applications can be installed on terminal devices 601, 602, 603, such as electronic shopping mall client applications, web browser applications, search applications, instant messaging tools, and email clients.

[0107] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting various client applications, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0108] The server 605 may be a server that provides various services, such as a background management server that provides support for client applications used by users using the terminal devices 601, 602, and 603. The background management server may process the received data merging requests for multiple data tables and feed back the results of the data merging to the terminal device.

[0109] It should be noted that the data processing method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the data processing device is generally arranged in the server 605 .

[0110] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0111] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0112] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0113] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0114] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0115] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0116] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0117] The modules and / or units involved in the embodiments of the present invention may be implemented in software or hardware. The modules and / or units described may also be provided in a processor, for example, may be described as: a processor including a request parsing module, an association key determination module, and a merge execution module. The names of these modules do not, in some cases, constitute limitations on the modules themselves, for example, the request parsing module may also be described as "a module that parses the association keys on which the data merge operation of multiple data tables depends from the data merge request".

[0118] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by one of the devices, the device includes: receiving a data merge request for business data in multiple data tables, parsing the association keys on which the data merge operations of the multiple data tables depend from the data merge request; in response to the association key being a high-cardinality association key, obtaining a data merge statement for performing the merge operation to which the high-cardinality association key belongs; wherein the high-cardinality association key is an association key that meets a preset condition; in response to the data merge statement being a non-complex data statement, using the data merge statement to obtain the merged data of multiple data tables from a preset cache; in response to the data merge statement being a complex data statement, using the data merge statement to directly obtain the merged data from each data table.

[0119] The embodiments of the present invention can parse the association keys that the data merge in multiple data tables depends on, determine whether the association keys are high-cardinality association keys, and determine whether the data merge statement for executing the data merge is a complex data statement; according to the judgment result, determine whether to use the data merge statement to obtain the merged data of multiple data tables from a preset cache or directly obtain the merged data from each data table. The embodiments of the present invention overcome the data skew problem in data merge caused by high-cardinality association keys, improve the efficiency of data merge operations, and improve the stability and reliability of data merge.

[0120] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data processing method, characterized in that: include: Receiving a data merging request for business data in a plurality of data tables, and parsing the data merging request to obtain association keys on which data merging operations of the plurality of data tables depend; In response to the association key being a high-cardinality association key, obtaining a data merge statement for performing a merge operation to which the high-cardinality association key belongs; wherein the high-cardinality association key is an association key that satisfies a preset condition; In response to the data merge statement being a non-complex data statement, the data merge statement is used to obtain merged data of multiple data tables from a preset cache; in response to the data merge statement being a complex data statement, the data merge statement is used to directly obtain merged data from each data table.

2. The method according to claim 1, characterized in that The preset conditions include one or more of the following: the access frequency exceeds a set frequency threshold, the associated data volume exceeds a set data volume threshold, and the data processing time meets a time threshold range; The method further comprises: Obtain historical merged data of multiple data tables corresponding to the business data; Extracting characteristic data corresponding to each associated key associated with the data merge from the historical merged data, wherein the characteristic data includes one or more of access frequency, associated data volume, and data processing time; According to the characteristic data corresponding to each association key, an association key satisfying the preset condition is selected from each association key as a high cardinality association key, and the high cardinality association key is stored in an association key cache.

3. The method according to claim 2, characterized in that Before the response that the association key is a high cardinality association key, the method includes: It is determined whether the association key exists in the association key cache, and if so, the association key is determined to be a high-cardinality association key.

4. The method according to claim 1, characterized in that: After obtaining the data merge statement for executing the merge operation to which the high cardinality association key belongs, further comprising: Acquire each field of the plurality of data tables contained in the data merge statement; wherein the fields include high cardinality association keys; Acquire data corresponding to the high-cardinality association key and data corresponding to each of the fields from the plurality of data tables; The data corresponding to the high-cardinality association key and the data corresponding to each of the fields are correspondingly stored in a preset cache.

5. The method according to claim 1 or 4, characterized in that: Further including: Detecting the remaining space of the preset cache; When it is determined that the remaining space of the preset cache is lower than a set space threshold, data is cleared from the preset cache using a data clearing strategy to release space in the preset cache.

6. The method according to claim 1, characterized in that Before responding that the data merge statement is a non-complex data statement, the method further includes: Analyze the statement elements in the data merge statement, and determine whether the data merge statement is a complex data statement according to the type of the statement elements; and / or; Determine the execution time of the data merge statement to obtain the merged data of the plurality of data tables from the preset cache, and determine whether the data merge statement is a complex data statement according to the execution time.

7. The method according to claim 6, characterized in that The determining, according to the type of the statement element, whether the data merge statement is a complex data statement includes: Analyze the type of statement elements contained in the data merge statement, and determine that the data merge statement is a complex data statement when it is analyzed that the type of the statement element is one or more of a complex function, the number of associated tables is at least 3, and a multi-level subquery.

8. The method according to claim 6, characterized in that The determining the duration of the execution of the data merge statement to obtain the merged data of the plurality of data tables from the preset cache includes: Searching for a target duration matching the data merge statement from a duration data source storing the running duration of the data merge statement, and determining that the data merge statement is a complex data statement when it is found that the target duration exceeds a set duration threshold; The duration data source is used to store historical data of the duration that each data merge statement takes to obtain merged data from a preset cache.

9. A data processing device, characterized in that: include: Parsing request module, determining association key module and executing merging module; wherein, The parsing request module is used to receive a data merging request for business data in multiple data tables, and parse the data merging request to obtain the association key on which the data merging operation of the multiple data tables depends; The determining association key module is used for obtaining, in response to the association key being a high cardinality association key, a data merge statement for performing a merge operation to which the high cardinality association key belongs; wherein the high cardinality association key is an association key that satisfies a preset condition; The execution merge module is used to, in response to the data merge statement being a non-complex data statement, use the data merge statement to obtain the merged data of multiple data tables from a preset cache; in response to the data merge statement being a complex data statement, use the data merge statement to directly obtain the merged data from each data table.

10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

12. A computer program product, comprising a computer program, characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.