Streaming data service fast response method, computer program product and electronic device
By classifying similar query requests in streaming data services and optimizing caching strategies, the problem of slow response speed of streaming data services is solved and faster data processing and analysis are achieved.
Patent Information
- Application Number
- CN202410535104.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-04-30
AI Technical Summary
Existing streaming data services have slow response times and cannot quickly process and analyze real-time data streams.
By classifying data query requests for similar queries and executing corresponding caching strategies based on the classification results, the response speed of streaming data services can be improved. The specific method includes receiving the target query request, determining the target cache strategy, obtaining the target cache data from the cache data, filtering and calculating the required data, and sending the calculation results. The cached data is formulated based on the classification results of multiple data query requests. Similar queries meet the same conditions for the master table, slave tables and join queries. The classification results are multi-level classified based on aggregation functions, preset fields and windows.
It significantly improves the response speed of streaming data services, reduces the interface response time, and improves the real-time and efficiency of streaming data services.
Smart Images

Figure CN118132609B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for rapid response of streaming data services, a computer program product, and an electronic device. Background Art
[0002] Streaming data service is a technology for processing and analyzing real-time data streams. It allows organizations to continuously and in real time receive data from multiple data sources and process the data to make decisions or responses quickly.
[0003] In related technologies, stream data services allow business callers to use pre-configured query rules, such as Structured Query Language (SQL), to return the results of real-time data stream calculations when users call the interface. However, stream computing systems in related technologies usually create tasks and load data for calculations for each query, resulting in slow responses.
[0004] Based on this, there is an urgent need for a fast response method for stream data services to improve the response speed of stream data services. Summary of the invention
[0005] The purpose of the present application is to provide a method for rapid response of a streaming data service, a computer program product and an electronic device, which are used to improve the response speed of the streaming data service by classifying data query requests of the same type and executing a corresponding caching strategy for each classification according to the classification results.
[0006] The present application provides a method for rapid response of streaming data services, including:
[0007] Receive a target query request called by a target device, and determine a target cache strategy corresponding to the target query request; obtain target cache data corresponding to the target cache strategy from cache data, and filter out required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request; send the data calculation result to the target device; wherein the cache data is obtained based on a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries satisfy at least one of the following: the main table is the same, the sub-table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function in the data query request, the preset field, and the window in the stream data calculation.
[0008] Optionally, before obtaining the target cache data corresponding to the target cache strategy from the cache data, the method also includes: obtaining all data query requests registered in the data service, and classifying the data query requests based on the request field of each data query request to obtain at least one group of similar queries; wherein each group of similar queries includes multiple data query requests.
[0009] Optionally, the data query requests are classified based on the request field of each data query request to obtain at least one group of similar queries, including: dividing multiple data query requests with the same primary table, the same secondary table, and the same conditional statement of the join query into a group of similar queries; wherein the primary table is the data table indicated by the from field in the data query request, the secondary table is the data table indicated by the join field in the data query request, and the conditional statement of the join query is the on condition in the data query request.
[0010] Optionally, before obtaining the target cache data corresponding to the target cache strategy from the cache data, the method also includes: performing multi-level classification based on the aggregation function, preset fields and windows in the stream data calculation of each data query request in the multiple data query requests to obtain a multi-level classification result; based on each level indicated by the multi-level classification result, determining the cache strategy of the data query request corresponding to each level, and performing data caching based on the cache strategy of the data query request corresponding to each level to obtain the cache data.
[0011] Optionally, the preset field includes: a first preset field, a second preset field; the multi-level classification is performed based on the aggregation function, the preset field and the window in the stream data calculation of each data query request in the multiple data query requests to obtain a multi-level classification result, including: a first-level division based on the aggregation function, and the data query requests with the same aggregation function in the multiple data query requests are divided into the same category; a second-level division based on the classification result of the first level and the first preset field, and the data query requests with the same filtering conditions corresponding to the first preset field in the multiple data query requests are divided into the same category; a third-level division based on the classification result of the second level and the second preset field, and the data query requests with the same filtering conditions corresponding to the third preset field in the multiple data query requests are divided into the same category; a fourth-level division based on the classification result of the third level and the window in the stream data calculation, and the data query requests with the same window in the multiple data query requests are divided into the same category; wherein, the first preset field is the Group by field; and the second preset field is the Where field.
[0012] Optionally, the first-level division based on the aggregation function divides the data query requests with the same aggregation function in the multiple data query requests into the same category, including: dividing the data query requests with the first type of aggregation function in the multiple data query requests with the same aggregation function into the first sub-level of the first level; and / or dividing the data query requests with the second type of aggregation function in the multiple data query requests with the same aggregation function into the second sub-level of the first level; wherein the first type of aggregation function is: the calculation result of the multiple data as a whole can be calculated by the separate calculation result of each data in the multiple data; the second type of aggregation function is: the calculation result of the multiple data as a whole cannot be calculated by the separate calculation result of each data in the multiple data.
[0013] Optionally, the caching strategy for the data query requests corresponding to each level based on the levels indicated by the multi-level classification results is determined, including: for the data query requests included in the first sub-level of the first level, caching the overall calculation results of each data corresponding to each data query request; and / or, for the data query requests included in the second sub-level of the first level, separately caching the calculation results of each data in the data corresponding to each data query request.
[0014] Optionally, the second-level division is performed based on the classification result of the first level and the first preset field, and the data query requests with the same filtering condition corresponding to the first preset field in the multiple data query requests are divided into the same category, including: dividing the data query request in which the clause of the first preset field in the first data query request meets the first preset condition into the first sub-level of the second level; and / or dividing the data query request in which the clause of the first preset field in the first data query request does not meet the first preset condition into the second sub-level of the second level; wherein the first data query request is: a data query request among the multiple data query requests that belongs to the same category in the first level and the query frequency is less than a preset frequency threshold; the first preset condition is: there is an inclusion relationship between the clauses of the first preset field.
[0015] Optionally, the caching strategy for the data query requests corresponding to each level based on the levels indicated by the multi-level classification results is determined, including: for the data query requests included in the first sub-level of the second level, caching the aggregated data queried by the data query requests that meet the second preset condition in the first data query request; and / or, for the data query requests included in the second sub-level of the second level, caching the data queried by each data query request in the first data query request; wherein the second preset condition includes: the clause of the first preset field contains the most content.
[0016] Optionally, the third-level division based on the classification result of the second level and the second preset field, and the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests are divided into the same category, including: dividing the data query requests that meet the third preset condition in the second data query request into the first sub-level of the third level; and / or, dividing the data query requests that meet the fourth preset condition in the second data query request into the second sub-level of the third level; and / or, dividing the data query requests that meet the fifth preset condition in the second data query request into the third sub-level of the third level; and / or, dividing the data query requests that meet the sixth preset condition in the second data query request into the third sub-level of the third level. The data query request is divided into the fourth sub-level of the third level; and / or, the data query request that meets the seventh preset condition in the second data query request is divided into the fifth sub-level of the third level; and / or, the data query request that meets the eighth preset condition in the second data query request is divided into the sixth sub-level of the third level; and / or, the data query request that meets the ninth preset condition in the second data query request is divided into the seventh sub-level of the third level; wherein, the second data query request is: the data query request that belongs to the same category in the second level among the multiple data query requests; the third preset condition includes: not satisfying the first preset sub-condition and not satisfying the second preset sub-condition; the The fourth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and not satisfying the fourth preset sub-condition; the fifth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and satisfying the fourth preset sub-condition; the sixth preset condition includes: satisfying the first preset sub-condition, and not satisfying the fifth preset sub-condition; the seventh preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, and not satisfying the second preset sub-condition, or satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, and does not satisfy the sixth preset sub-condition, or satisfies the first preset sub-condition, satisfies the fifth preset sub-condition, satisfies the second preset sub-condition, satisfies the sixth preset sub-condition, and does not satisfy the seventh preset sub-condition; the eighth preset condition includes: satisfies the first preset sub-condition, satisfies the fifth preset sub-condition, satisfies the second preset sub-condition, satisfies the sixth preset sub-condition, satisfies the seventh preset sub-condition, and does not satisfy the eighth preset sub-condition; the ninth preset condition includes: satisfies the first preset sub-condition, satisfies the fifth preset sub-condition, satisfies the second preset sub-condition, satisfies the sixth preset sub-condition, satisfies the seventh preset sub-condition, and satisfies the eighth preset sub-condition;The first preset sub-condition is: the field judgment condition corresponding to the second preset field is a dynamic condition; the dynamic condition is: a non-preset judgment condition; the second preset sub-condition is: the field judgment condition includes a logical operation; the third preset sub-condition is: the query frequency is greater than or equal to the preset frequency threshold; the fourth preset sub-condition is: the field judgment condition includes an indecomposable condition field; the indecomposable condition field is: a sum operation condition field; the fifth preset sub-condition is: the field judgment condition is a dimension type field; the dimension type field is: a field judgment condition in which the number of rows in the slave table is less than the number of rows in the main table of the data query statement, or the number of non-repeated values of the field corresponding to the field judgment condition in the main table is less than the number of rows in the main table; the sixth preset sub-condition is: the field judgment condition includes multiple logical operations; the seventh preset sub-condition is: the number of multiple logical operations included in the field judgment condition exceeds the preset logical operation number threshold; the eighth preset sub-condition is: there is a cache of historical result data of the same data query request as the field judgment condition including multiple logical operations. ;
[0017] Optionally, the caching strategy for the data query request corresponding to each level based on the levels indicated by the multi-level classification result is determined, including: for the data query request included in the first sub-level of the third level, caching the aggregated data of all data query requests; and / or, for the data query request included in the second sub-level of the third level, caching the aggregated data of all data query requests; and / or, for the data query request included in the third sub-level of the third level, caching the aggregated data of each logical operation; and / or, for the data query request included in the fourth sub-level of the third level, calling the computing engine to query each The data queried by each data query request; and / or, for the data query requests contained in the fifth sub-level of the third level, the data queried by the data query requests corresponding to the fields of each dimension type; and / or, for the data query requests contained in the sixth sub-level of the third level, the computing engine is called to query the data queried by each data query request and the queried data is cached; and / or, for the data query requests contained in the seventh sub-level of the third level, the computing engine is called to query the data queried by each data query request and the queried data to be merged, and the data to be merged is merged with the historical result data cache data and then cached.
[0018] Optionally, the third-level division is performed based on the classification result of the second level and the second preset field, and the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests are divided into the same category, including: dividing the data query requests that meet the tenth preset condition in the third data query request into the first sub-level of the fourth level; and / or, dividing the data query requests that meet the eleventh preset condition in the third data query request into the second sub-level of the fourth level; and / or, dividing the data query requests that meet the twelfth preset condition in the third data query request into the third sub-level of the fourth level; and / or, dividing the data query requests that meet the thirteenth preset condition in the third data query request into the fourth sub-level of the fourth level; wherein the third data query request is: a data query request that belongs to the same category in the third level among the multiple data query requests; the tenth preset condition Including: not satisfying the ninth preset sub-condition and satisfying the tenth preset sub-condition; the eleventh preset condition includes: satisfying the ninth preset sub-condition and not satisfying the eleventh preset sub-condition; the twelfth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and satisfying the twelfth preset sub-condition; the thirteenth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and not satisfying the twelfth preset sub-condition; the ninth preset sub-condition is: there is a window condition in the field judgment condition corresponding to the third preset field; the tenth preset sub-condition is: the query frequency is less than the preset frequency threshold; the eleventh preset sub-condition is: the window condition is a session window; the session window is used to divide the stream data into windows based on the session interval; the twelfth preset sub-condition is: whether the interval of incremental data exceeds the session interval; the incremental data is the data increased compared with the previous query.
[0019] Optionally, the caching strategy for the data query request corresponding to each level is determined based on each level indicated by the multi-level classification result, including: for the data query request included in the first sub-level of the fourth level, the incremental data obtained at each query is merged with the historical result data at the last query and cached, and the merged aggregated data is used as the historical result data for the next query; and / or, for the data query request included in the second sub-level of the fourth level, a cache granularity is obtained based on the calculation granularity of windows of multiple data query requests, and the aggregated data is cached based on the cache granularity; the calculation granularity is used to indicate the moving distance of the window; the cache The storage granularity is calculated based on an integer time unit distance of multiple calculation granularities; and / or, for the data query request contained in the third sub-level of the fourth level, the incremental data is divided according to the session interval to obtain multiple segments of data, and the aggregate data of each segmented data is calculated; the result of the first segment of data in the multiple segments of data is merged with the historical result data, and the result of the last segment of data is cached as the historical result data for the next calculation; and / or, for the data query request contained in the fourth sub-level of the fourth level, the data corresponding to the window of the historical result data is aggregated and calculated, and the calculated aggregated data is cached.
[0020] Optionally, the caching strategy for the data query request corresponding to each level is determined based on each level indicated by the multi-level classification result, including: for the first data query request in the second level whose query frequency is greater than or equal to the preset frequency threshold, caching all aggregated data queried by the first data query request; and / or, for the second data query request in the third level that does not meet the first preset sub-condition, meets the second preset sub-condition, and has a query frequency greater than or equal to the preset frequency threshold, caching all aggregated data queried by the second data query request; and / or, for the third data query request in the fourth level whose query frequency is greater than or equal to the preset frequency threshold, merging the query result of the third data query request with the historical result data each time a data query is performed, and using the merged result as the historical result data for the next query; wherein, the first preset sub-condition is: the field judgment condition corresponding to the second preset field is a dynamic condition; the dynamic condition is: a non-preset judgment condition; the second preset sub-condition is: the field judgment condition includes a logical operation.
[0021] Optionally, the preset field also includes: a third preset field; the data is cached based on the caching strategy of the data query request corresponding to each level to obtain the cached data, including: caching the data indicated by the union of the fields in the clauses of the third preset field of each data query request in the multiple data query requests.
[0022] Optionally, the cache strategy for the data query request corresponding to each level is determined based on each level indicated by the multi-level classification result, including: judging whether the cached data can be reused for subsequent calculations based on the window, and discarding the cached data that cannot be reused for subsequent calculations.
[0023] Optionally, the data is cached based on the cache strategy of the data query request corresponding to each level. After obtaining the cached data, the method also includes: determining whether the data queried by the data query request is data during the user subscription period, and discarding the cached data that does not belong to the user subscription period.
[0024] The present application also provides a computer program product, including a computer program / instruction, which implements the steps of any of the above-mentioned streaming data service rapid response methods when executed by a processor.
[0025] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned methods for rapid response of streaming data services are implemented.
[0026] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for rapid response of streaming data services are implemented.
[0027] The fast response method, computer program product and electronic device of the stream data service provided by the present application first receive a target query request called by a target device, and determine the target cache strategy corresponding to the target query request; then, obtain the target cache data corresponding to the target cache strategy from the cache data, and filter out the required cache data from the target cache data for calculation to obtain the data calculation result corresponding to the target query request; finally, send the data calculation result to the target device; wherein the cache data is obtained by: a cache strategy formulated based on the classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries meet at least one of the following: the main table is the same, the secondary table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function, preset field and window in the stream data calculation in the data query request. In this way, the response speed of the stream data service is improved by classifying the data query requests of the same type and executing the corresponding cache strategy for each classification according to the classification results. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0029] Figure 1 It is a structural diagram of the streaming data service provided by this application;
[0030] Figure 2 It is a flowchart of the method for rapid response of streaming data service provided by this application;
[0031] Figure 3 This is a flowchart of generating a cache strategy based on the where condition provided by this application;
[0032] Figure 4 This is a flow chart of generating a cache strategy based on window conditions provided by this application;
[0033] Figure 5 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0036] The data aggregation technology in the related technology can perform data aggregation operations in advance according to the data dimensions of the query and save the results. It can reuse the operation results to a great extent and reduce the amount of calculation. However, there are the following problems: data dimensions and aggregation operations need to be defined in advance and maintained manually. This results in that the data aggregation of a defined data dimension and aggregation operation can only be applicable to the cache acceleration scenario of such aggregation operation under this dimension. In addition, it is necessary to manually analyze the query forms commonly used by business personnel and establish the corresponding aggregation, which has high technical requirements for manual maintenance. The cache granularity is too coarse, which limits the applicable acceleration scenarios. The cache granularity is too fine, which leads to waste of storage space and secondary aggregation calculations, affecting efficiency.
[0037] In response to the above-mentioned technical problems existing in the related technology, an embodiment of the present application provides a method for rapid response of streaming data services, which improves the response speed of streaming data services by maintaining the data results after aggregation, accelerating the calculation process, and reducing the response time of the interface.
[0038] The following is a description of the professional terms involved in the embodiments of the present application:
[0039] Similar queries: A group of queries with the same primary table indicated by the from field in SQL, the same secondary table indicated by the join field, and the same on condition in the join query. The cached aggregation results between similar queries can be reused.
[0040] Similar queries that can reuse cached data: A group of queries belonging to the same group of queries may not necessarily reuse the cached results of other queries. A query that can use the cached results of other queries in the same group of queries after analysis is called a similar query that can reuse cached data.
[0041] Frequent queries: Queries that users call frequently. Defined by threshold configuration (for example, frequency greater than or equal to 1 time / minute). Frequent queries will use different caching strategies.
[0042] Stream processing system: Stream processing system is for processing infinite data. Its data source can be considered as continuously generating data, which can be considered as a data table without a beginning or an end. The stream processing system performs a series of transformations or aggregation operations on these continuously incoming data. The real-time requirements of stream processing are first, fast computing response, and second, real-time incorporation of continuously incoming data into the calculation, which responds to data changes in a timely manner compared to batch computing.
[0043] Watermark: The original data in stream computing may be out of order for some reason, and entering the stream computing system will cause problems such as inaccurate calculations. The watermark is proposed to deal with the problem of disorder. The watermark is a timestamp that is automatically generated with the current received data (the generation rule is customizable). Only the data before the watermark is considered to have arrived and the calculation will be triggered. For example, the rule for generating the watermark is the timestamp of the current received data minus 5 seconds, so the subsequent data can be allowed to be up to 5 seconds late.
[0044] Window: A window is a constraint on the source data based on the time range in stream computing. Since the data stream has no beginning or end, the aggregate computing based on the stream must use certain means to intercept the data in the stream to form a data set with a beginning and an end before the aggregate computing can be performed. This interception method based on the time range is called a window.
[0045] Session window: It is a rule window of the previous window in a specific business scenario. The rule is that if the time interval between two adjacent data in a series of stream data exceeds the session interval, the latter data belongs to a new session window. A typical applicable scenario is to query the number of consecutive login attempts of a user within 3 minutes.
[0046] Data service: In layman's terms, it is a customized service for data query. The stream processing engine supports general queries, but it is more complicated to use. Data service is a customized query, and the caller can quickly obtain specific data without knowing the usage details.
[0047] The query rules configured in the streaming data service are fixed, and the data involved in the same query may be repeated or have logical relationships. Even different queries in the streaming data service may have logical relationships. This feature makes it possible to optimize data cache for such scenarios.
[0048] Streaming data services are different from traditional data analysis. The query statements executed by traditional data analysis users are unpredictable, and any query statement can be executed. The SQL contained in the streaming data service is predefined in advance. For these predefined logics, the present invention realizes automatic analysis of these calculation logics and converts them into caching strategies that match them. Streaming data services usually contain multiple SQLs, and the present invention can comprehensively analyze these SQLs and formulate caching strategies. This strategy can reuse as much cached aggregate data as possible between these SQL queries.
[0049] There are also big differences between stream computing and batch computing. In batch analysis, it is assumed that the original data to be analyzed will not change within a certain period of time. However, stream computing analysis is different. In stream computing analysis, the data to be analyzed is generated in real time. For example, if the same query is executed twice in a short period of time, the returned results are likely to be different (the data to be analyzed has changed). However, during these two calculations, the original data to be calculated may have duplicate parts, and for data services, the user's query is predictable (that is, configured in advance). In this scenario, data aggregation cache can come in handy.
[0050] The uses of aggregate cache include: 1. Reuse of previous settlement results, even cached results between different but similar queries; 2. Because the user's query logic is predictable, the aggregate results can be calculated in advance.
[0051] like Figure 1 As shown, the streaming data service in the embodiment of the present application includes the following modules:
[0052] 1. Data loading module: The computing engine query task is used to call the computing engine to obtain the results into the cache according to the cache strategy requirements.
[0053] The data loading module is a resident stream computing task to avoid frequent startup and stop that causes extra time consumption. This module is responsible for starting the calculation periodically or according to the trigger rules according to the requirements of the cache strategy, reading the streaming raw data that has arrived at the system at the current moment, filtering and aggregating according to the requirements of the cache strategy, generating aggregation results, and then handing them over to the cache storage module for persistent storage.
[0054] 2. Cache storage module. Stores cached aggregate values and associates them with specific query services. The cache storage module is responsible for persisting the results calculated by the data loading module.
[0055] 3. Cache strategy module: Analyze the characteristics of SQL registered to the data service, generate and save cache strategies.
[0056] The cache strategy module is responsible for analyzing all query SQLs registered by the administrator to the data service and generating a cache strategy that can reuse cache results as much as possible. The strategy then controls the data loading module cycle / automatically loads data on demand and aggregates operations. Finally, the generated strategy is saved.
[0057] 4. Query execution module: When a user calls a data query SQL, the results in the cache are loaded according to the corresponding cache strategy to generate the final query result and return it.
[0058] The query execution module intercepts the query execution process of the user, first reads the cache strategy corresponding to the query, reads the corresponding cache data according to the cache strategy, and if there is a part that needs incremental calculation (determined by the cache strategy). These data calculations then call the calculation engine to generate results. Finally, after merging the results read from the cache or the results of incremental calculation, the final query result is obtained and returned to the query caller.
[0059] The following is a detailed description of the method for rapid response to streaming data services provided by the embodiment of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0060] like Figure 2 As shown, an embodiment of the present application provides a method for fast response of a streaming data service, which may include the following steps 201 to 203:
[0061] Step 201: Receive a target query request called by a target device, and determine a target cache strategy corresponding to the target query request.
[0062] Exemplarily, the target device is a device that invokes a target query request, such as Figure 1 After receiving the target query request called by the target device, the query execution module shown will intercept the query process of the target query request and read the target cache policy corresponding to the target query request.
[0063] Step 202: Obtain target cache data corresponding to the target cache policy from the cache data, and filter out required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request.
[0064] Among them, the cached data is obtained by: a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries satisfy at least one of the following: the main table is the same, the slave table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function in the data query request, the preset field and the window in the stream data calculation.
[0065] For example, after obtaining the target cache strategy corresponding to the target query request, the corresponding target cache data can be read according to the target cache strategy, and calculations can be performed based on the target cache data to obtain the data calculation results required by the target query request. If there are parts that require incremental calculations, these data calculations will then call the calculation engine to generate results, and finally the results read from the cache data will be merged with the incremental calculation result data to obtain the final query result, that is, the above data calculation result.
[0066] It should be noted that the cache data is obtained by a cache strategy formulated based on classification results of multiple data query requests, the multiple data query requests are queries of the same type, and the target query request is one of the multiple data query requests.
[0067] Step 203: Send the data calculation result to the target device.
[0068] Exemplarily, after obtaining the final query result (ie, the above-mentioned data calculation result), the query result can be returned to the query caller, ie, the above-mentioned target device.
[0069] It should be noted that the fast response method for streaming data service in the embodiment of the present application can play a role in the following three situations:
[0070] Case 1: The administrator edits the data service and adds, modifies or deletes the data query SQL; Case 2: As the streaming data continues to arrive, the aggregated data is cached; Case 3: The user calls a data service and executes the corresponding SQL. The following describes these three cases respectively.
[0071] For situation 1: Since the cache strategy is generated based on SQL analysis, after the administrator changes the SQL, the cache strategy module needs to be used to regenerate the cache strategy. This causes the cache strategy to change. The newly modified SQL points to the changed cache strategy. Please refer to the cache strategy module section below to see whether the original SQL adopts the new cache strategy generated after the newly added SQL. If the SQL changes, the query execution module will use the new cache strategy when querying and load the cache corresponding to the SQL.
[0072] For case 2: Unlike traditional batch computing, the data to be analyzed in stream computing is generated in real time. In this step, according to the cache strategy generated in case 1, the data loading module periodically performs aggregation operations on the incoming stream data and caches the aggregation results. The cached results are persisted through the cache storage module.
[0073] For case 3: In this case, the query execution module intercepts the user's query and does not directly hand over the query to the stream computing system for processing. First, find the cache strategy corresponding to this query, read the saved cache aggregation data according to the cache strategy generated in case 1, or use the previous cache aggregation data for secondary calculation and processing before returning it to the user.
[0074] The embodiment of the present application provides a method for rapid response of streaming data services, and a reusable data aggregation cache generation strategy in the data service (query method is predictable) scenario. The corresponding cache strategy is generated by analyzing the elements of the query service SQL. The cache generated according to this strategy can reduce the execution time of the current query SQL, and the generated cache can also be reused by other query SQL as much as possible, thereby improving the utilization rate of the cache and reducing the storage occupancy of the cache.
[0075] The fast response method for streaming data services provided in the embodiment of the present application analyzes SQL to formulate a cache plan when configuring a query service, maintains a resident data loading module to load incremental data regularly / according to policy requirements, and intercepts user queries to generate calculation results using cached data.
[0076] Optionally, in an embodiment of the present application, it is possible to analyze the SQL elements of the user's data query request and generate cache data that is as reusable as possible for all data query requests within the service.
[0077] Exemplarily, before the above step 202, the streaming data service fast response method provided by the embodiment of the present application may further include the following step 204:
[0078] Step 204: Obtain all data query requests registered in the data service, and classify the data query requests based on the request field of each data query request to obtain at least one group of similar queries.
[0079] Each group of similar queries includes multiple data query requests.
[0080] For example, since the cache strategy in the embodiment of the present application is formulated for queries within the same group (ie, queries of the same type), before formulating the cache strategy, it is first necessary to classify all data query requests registered by the administrator to the data service.
[0081] Specifically, the above step 204 may further include the following step 204a:
[0082] Step 204a, grouping multiple data query requests with the same primary table, the same secondary table, and the same join query conditional statements into a group of similar queries;
[0083] The master table is the data table indicated by the from field in the data query request, the slave table is the data table indicated by the join field in the data query request, and the conditional statement of the join query is the on condition in the data query request.
[0084] Exemplarily, data query statements with the same primary table indicated by the from field in the data query request, the same secondary table indicated by the join field, and the same on condition of the join query are determined as a group of queries of the same type. The cached aggregation results between queries of the same type have the possibility of being reused.
[0085] Exemplarily, after all data query statements are classified, multiple data query statements in the same type of query may be classified in multiple levels, and different cache strategies may be formulated for different types of data query statements according to the classification results.
[0086] Exemplarily, before the above step 202, the streaming data service fast response method provided in the embodiment of the present application may further include the following steps 205 and 206:
[0087] Step 205: Perform multi-level classification based on the aggregation function, preset fields and windows in the stream data calculation of each data query request in the multiple data query requests to obtain a multi-level classification result.
[0088] For example, in the embodiment of the present application, all data query requests in the same group can be split one by one and classified again according to the following hierarchical order: condition 1, aggregate function; condition 2, Group by field; condition 3, Where field; condition 4, window. There are 4 levels of classification, first classified according to condition 1, and those with the same condition 1 are classified according to condition 2, and so on.
[0089] Exemplarily, after multi-level classification of the same type of queries, each sub-classification may be reused in the cache results of other queries in the same classification.
[0090] Step 206: Based on each level indicated by the multi-level classification result, determine the cache strategy of the data query request corresponding to each level, and cache the data based on the cache strategy of the data query request corresponding to each level to obtain the cached data.
[0091] Exemplarily, after multiple data query requests belonging to the same type of query are classified into multiple levels, a corresponding cache strategy can be formulated for each sub-level of each level, and data is cached based on the formulated cache strategy to obtain the above cached data.
[0092] Exemplarily, the above preset fields include: a first preset field and a second preset field; the first preset field is a Group by field; and the second preset field is a Where field.
[0093] Specifically, the above step 205 may further include the following steps 205a, 205b, 205c and 205d:
[0094] Step 205a: perform a first-level division based on the aggregation function, and divide the data query requests with the same aggregation function in the multiple data query requests into the same category.
[0095] Step 205b: perform a second-level division based on the classification result of the first level and the first preset field, and divide the data query requests with the same filtering condition corresponding to the first preset field in the multiple data query requests into the same category.
[0096] Step 205c: perform a third-level division based on the classification result of the second level and the second preset field, and divide the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests into the same category.
[0097] Step 205d: perform a fourth-level division based on the classification result of the third level and the windows in the stream data calculation, and divide the data query requests with the same windows in the multiple data query requests into the same category.
[0098] For example, the multiple data query requests in the same type of query are first divided into the first level, and then each sub-level of the first level is divided into the second level, and so on, and the multiple query requests are divided into four levels in total. Each sub-level of each level has a corresponding cache strategy.
[0099] Specifically, the step of performing classification based on the aggregation function in the above step 205a may further include at least one of the following steps 205a1 and 205a2:
[0100] Step 205a1: among the multiple data query requests having the same aggregation function, data query requests having the first type of aggregation function are divided into the first sub-level of the first level.
[0101] Step 205a2: among the multiple data query requests having the same aggregation function, data query requests having the second type of aggregation function are divided into the second sub-level of the first level.
[0102] Among them, the first type of aggregation function is: the calculation result of multiple data as a whole can be calculated through the individual calculation results of each data in the multiple data; the second type of aggregation function is: the calculation result of multiple data as a whole cannot be calculated through the individual calculation results of each data in the multiple data.
[0103] Exemplarily, the first sub-level of the first level and the second sub-level of the first level correspond to different cache strategies respectively.
[0104] Specifically, based on the above steps 205a1 and 205a2, the step of formulating a cache strategy for each sub-level of the first level in the above step 206 may further include at least one of the following steps 206a1 and 206a2:
[0105] Step 206a1: For the data query requests included in the first sub-level of the first level, cache the overall calculation results of each data corresponding to each data query request.
[0106] Step 206a2: For the data query requests included in the second sub-level of the first level, the calculation results of each data in each data corresponding to each data query request are cached respectively.
[0107] Exemplarily, for the steps of grading based on aggregation functions, the cache strategy module does not necessarily directly cache the aggregation results, and different aggregation functions require different aggregation data to be cached. For example, for the minimum aggregation function, the minimum value of the two segments of data as a whole can be calculated by the minimum values of the two segments of data respectively, so the minimum value result can be cached directly. However, for the average value, the average value of the two segments of data as a whole cannot be calculated by the average values of the two segments of data respectively, so the average value cannot be cached, and it is necessary to cache the intermediate values that can be combined and calculated according to the characteristics of the aggregation function formula. For example, the average can cache the sample sum and the number of samples. In this way, the average value of the two segments of data can be obtained by adding the sample sum of the two segments of data and dividing it by the number of samples of the two segments of data. Similarly, the variance can cache the sample sum of squares, the sample sum and the number of samples. The same is true for other aggregation functions.
[0108] Specifically, the step of performing classification based on the first preset field in the above step 205b may further include at least one of the following steps 205b1 and 205b2:
[0109] Step 205b1: classify the data query request in which the clause of the first preset field in the first data query request satisfies the first preset condition into the first sub-level of the second level.
[0110] Step 205b2: classify the data query request whose clause of the first preset field in the first data query request does not satisfy the first preset condition into a second sub-level of the second level.
[0111] Among them, the first data query request is: a data query request among the multiple data query requests that belongs to the same category in the first level and whose query frequency is less than a preset frequency threshold; the first preset condition is: there is an inclusion relationship between the clauses of the first preset field.
[0112] Exemplarily, according to whether there is an inclusion relationship between the clauses of the first preset field, the second level can be divided into two sub-levels, and different bytes correspond to different cache strategies.
[0113] Specifically, based on the above steps 205b1 and 205b2, the step of formulating a cache strategy for each sub-level of the second level in the above step 206 may include at least one of the following steps 206b1 and 206b2:
[0114] Step 206b1: For the data query requests included in the first sub-level of the second level, the aggregated data queried by the data query requests that meet the second preset condition in the first data query requests are cached.
[0115] Step 206b2: For the data query requests included in the second sub-level of the second level, cache the data queried by each data query request in the first data query request.
[0116] The second preset condition includes: the clause of the first preset field contains the most content.
[0117] Exemplarily, the fields in the Group by clause are dimension fields. If there are queries in the same group where multiple group by fields have an inclusion relationship (for example, group by a,b and group by a), the aggregated data in the case with the most group by fields is cached. In this case, group by a can be obtained by querying all caches of group by a,b, traversing all cached results of b conditions under each a condition, and then merging them. If the fields after group by are different in the same group of queries, the contents of these queries are cached separately (for example, group by a,b and group by c, the aggregated data of group by a,b and the aggregated data of group by c are cached respectively).
[0118] Specifically, the above step 206 includes the following steps 206b3:
[0119] Step 206b3: For a first data query request in the second level whose query frequency is greater than or equal to a preset frequency threshold, cache all aggregated data queried by the first data query request.
[0120] For example, the group by condition also has an optimization strategy for frequent queries, and the group by condition for frequent queries is not decomposed, so that the final result can be generated without using a secondary aggregation operation of aggregated data in a finer dimension, thus reducing the computation time.
[0121] Specifically, the step of performing classification based on the second preset field in the above step 205b may further include at least one of the following steps 205c1 to 205c7:
[0122] Step 205c1: classify the data query requests that meet the third preset condition in the second data query requests into the first sub-level of the third level.
[0123] Step 205c2: classify the data query requests that meet the fourth preset condition in the second data query requests into the second sub-level of the third level.
[0124] Step 205c3: classify the data query requests in the second data query requests that meet the fifth preset condition into the third sub-level of the third level.
[0125] Step 205c4: classify the data query requests in the second data query requests that meet the sixth preset condition into the fourth sub-level of the third level.
[0126] Step 205c5: classify the data query requests in the second data query requests that meet the seventh preset condition into the fifth sub-level of the third level.
[0127] Step 205c6: classify the data query requests in the second data query requests that meet the eighth preset condition into the sixth sub-level of the third level.
[0128] Step 205c7: classify the data query requests in the second data query requests that meet the ninth preset condition into the seventh sub-level of the third level.
[0129] Among them, the second data query request is: a data query request belonging to the same category in the second level among the multiple data query requests; the third preset condition includes: not satisfying the first preset sub-condition and not satisfying the second preset sub-condition; the fourth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and not satisfying the fourth preset sub-condition; the fifth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and satisfying the fourth preset sub-condition; the sixth preset condition includes: satisfying the first preset sub-condition and not satisfying the fifth preset sub-condition; The seventh preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, and not satisfying the second preset sub-condition, or satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, and not satisfying the sixth preset sub-condition, or satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, and not satisfying the seventh preset sub-condition; the eighth preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, satisfying the seventh preset sub-condition, and not satisfying the eighth preset sub-condition. Preset sub-conditions; the ninth preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, satisfying the seventh preset sub-condition, and satisfying the eighth preset sub-condition; the first preset sub-condition is: the field judgment condition corresponding to the second preset field is a dynamic condition; the dynamic condition is: a non-preset judgment condition; the second preset sub-condition is: the field judgment condition includes a logical operation; the third preset sub-condition is: the query frequency is greater than or equal to the preset frequency threshold; the fourth preset sub-condition is: the field judgment condition contains an indecomposable condition field; the indecomposable condition field is : and operation condition field; the fifth preset sub-condition is: the field judgment condition is a field of dimension type; the field of dimension type is: the field judgment condition that the number of rows in the slave table is less than the number of rows in the main table of the data query statement, or the field judgment condition that the number of non-repeated values of the field corresponding to the field judgment condition in the main table is less than the number of rows in the main table; the sixth preset sub-condition is: the field judgment condition contains multiple logical operations; the seventh preset sub-condition is: the number of multiple logical operations contained in the field judgment condition exceeds the preset logical operation number threshold; the eighth preset sub-condition is: there is historical result data cache data of the same data query request containing multiple logical operations in the field judgment condition.
[0130] For example, Figure 3The figure shows a flow chart of generating a cache strategy based on the where condition, which includes 8 preset sub-conditions (including: condition 1 to condition 9, corresponding to the first preset sub-condition to the ninth preset sub-condition), and based on the 9 preset sub-conditions, the third level can be divided into 7 sub-levels (including: sub-level 1 to sub-level 7, corresponding to the first sub-level to the seventh sub-level of the third level).
[0131] Specifically, based on the above steps 205c1 to 205c7, the step of formulating a cache strategy for each sub-level of the third level in the above step 206 may further include at least one of the following steps 206c1 to 206c7:
[0132] 206c1. For the data query requests included in the first sub-level of the third level, cache the aggregated data of all the data query requests.
[0133] 206c2. For the data query requests included in the second sub-level of the third level, cache the aggregated data of all the data query requests.
[0134] 206c3. For the data query request included in the third sub-level of the third level, cache the aggregated data of each logical operation.
[0135] 206c4. For the data query requests included in the fourth sub-level of the third level, call a computing engine to query the data queried by each data query request.
[0136] 206c5. For the data query request included in the fifth sub-level of the third level, the data queried by the data query request corresponding to the field of each dimension type.
[0137] 206c6. For the data query requests included in the sixth sub-level of the third level, call the computing engine to query the data queried by each data query request and cache the queried data.
[0138] 206c7. For the data query requests included in the seventh sub-level of the third level, call the computing engine to query the data queried by each data query request and cache the queried data to be merged, and merge the data to be merged with the historical result data cache data.
[0139] For example, based on Figure 3As can be seen from the schematic diagram of the generation strategy process shown, the Where filtering condition part. The Where conditions can be divided into equal conditions (e.g., where field_a = x) and non-equal conditions (e.g., where field_a < x). For both types of queries, directly cache the statements after these conditions are filtered. If there is an OR operation in the Where filtering or logical operation is required, decompose the OR operation and cache all the OR conditions that appear in this group of queries at the finest-grained sub-conditions that appear in the user query. For example, if where field_a = x or field_a = y or field_a = z and where field_a = x or field_a = z appear in the same group of queries, what needs to be cached and calculated is the aggregated results of the two conditions field_a = x or field_a = z and field_a = y. In this way, the condition field_a = x or field_a = y or field_a = z can be obtained by combining the operation results of the previous two. For cases where there are more similar queries in the same group, the number of cached aggregated data can be reduced, and the number of cache reconstructions can be reduced. If the user adds a finer-grained query condition (e.g., where field_a = z), in this case, the data under the three filtering conditions field_a = x, field_a = y, and field_a = z need to be cached. Considering that the user creates another query such as where field_a = y or field_a = z, this filtering condition can be obtained by combining field_a = y and field_a = z, and the introduction of this query does not even require reconstructing the cache data. The OR logical operation for non-equal queries is the same as that for equal queries. For AND conditions, the cached aggregated results cannot be combined through logical operations. The AND conditions need to be cached as a whole (AND conditions cannot be decomposed, while OR conditions can be decomposed). For the case where there are composite conditions in the AND sub-conditions, such as A and (B or C), when there are finer-grained cases in the same group (e.g., A and C in the same group), A and (B or C) can be equivalently disassembled into (A and B) or (A and C) through logical operation formulas, and cache the results of A and B and A and C. The Not (negation) logical operation is the same.
[0140] Exemplarily, based on Figure 3As shown in the generation strategy flow diagram, for the dynamic where condition (for example, where field_a = ?), the question mark indicates that the condition is dynamically passed in when the user calls the query. At this time, the cache strategy needs to determine whether field_a is a dimension type. The characteristic of the dimension type is that the value is discrete and finite. Whether a field is a dimension field can be explicitly configured by the user or automatically detected.
[0141] For example, based on Figure 3 As shown in the generation strategy flow diagram, automatic detection counts the number of rows in the table corresponding to this field (the table corresponding to the join field) and the number of rows in the main table (the table corresponding to the clause of the from field). If the number of rows in the table corresponding to the field is much smaller than the number of rows in the main table or the number of rows in the table corresponding to the field is within the range (standard configurable), this field is considered as a dimension type. In other words, the field table corresponding to field_a cannot be found (no join field), and count distinct of this field (how many unique values of this field in the main table) and the number of rows in the main table can be compared. If the number of unique values of this field in the main table is much smaller than the number of rows in the main table (standard configurable), this field is considered as a dimension type.
[0142] For example, based on Figure 3 As shown in the generation strategy flow diagram, for dynamic conditions of dimension type fields, it is necessary to cache the results of each dimension value filter condition. This not only makes the cache quantity controllable (the number of dimension field values is limited) and does not take up too much storage space, but also allows for quick response (the results of various dimension filter conditions have been cached and can be retrieved and returned). For non-equal value dynamic conditions, if the condition field can be regarded as a dimension field (the field type is a comparable type), the above cache solution is also applicable. If the dynamic condition field is not a dimension field, it cannot be accelerated by caching, and the calculation engine needs to be called directly to query the results.
[0143] For example, based on Figure 3 As shown in the generation strategy flow diagram, if multiple dimension field logical operations appear in the dynamic condition, the logical operations need to be decomposed in the previous way regardless of whether it is a frequent query. If a query similar to where field_a = ? and field_b = ? appears at the end of the decomposition, the number of results to be cached is the number of combinations of the number of possible values of field_a and field_b. If the number of combinations exceeds the upper limit of the configuration, the query engine is abandoned and the results after the call are cached, so that they can be reused when the same parameters are called again. If the number of combinations does not exceed the upper limit of the configuration, each combination is cached separately.
[0144] For example, the cache strategy module needs to optimize the where condition for frequent queries. Frequent queries have a high call frequency, and it is necessary to minimize the secondary calculation process of using cached aggregate results. The where condition of frequent queries is not decomposed in any way, and the aggregate data is directly cached as a filter condition.
[0145] Specifically, the above step 206 may further include the following step 206c8:
[0146] Step 206c8: For a second data query request in the third level that does not satisfy the first preset sub-condition, satisfies the second preset sub-condition, and has a query frequency greater than or equal to a preset frequency threshold, cache all aggregated data queried by the second data query request.
[0147] For example, Figure 3 The generation strategy flow diagram shown in FIG. 206 is as follows: Figure 3 The division of the eighth sub-level of the third level can be based on the cache strategy of sub-level 8 obtained based on the judgment of condition 3.
[0148] Specifically, the step of dividing the fourth level into sub-levels based on the window in the above step 205 may include at least one of the following steps 205d1 to 205d4:
[0149] Step 205d1: classify the data query requests that meet the tenth preset condition in the third data query requests into the first sub-level of the fourth level.
[0150] Step 205d2: Classify the data query requests that meet the eleventh preset condition in the third data query requests into the second sub-level of the fourth level.
[0151] Step 205d3: Classify the data query requests that meet the twelfth preset condition in the third data query request into the third sub-level of the fourth level.
[0152] Step 205d4: classify the data query requests that meet the thirteenth preset condition in the third data query requests into the fourth sub-level of the fourth level.
[0153] Among them, the third data query request is: a data query request belonging to the same category in the third level among the multiple data query requests; the tenth preset condition includes: not satisfying the ninth preset sub-condition and satisfying the tenth preset sub-condition; the eleventh preset condition includes: satisfying the ninth preset sub-condition and not satisfying the eleventh preset sub-condition; the twelfth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and satisfying the twelfth preset sub-condition; the thirteenth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and not satisfying the twelfth preset sub-condition; the ninth preset sub-condition is: there is a window condition in the field judgment condition corresponding to the third preset field; the tenth preset sub-condition is: the query frequency is less than the preset frequency threshold; the eleventh preset sub-condition is: the window condition is a session window; the session window is used to divide the stream data into windows based on the session interval; the twelfth preset sub-condition is: whether the interval of incremental data exceeds the session interval; the incremental data is the data increased compared with the previous query.
[0154] Exemplarily, the cache policy module may divide the fourth level based on the window, and divide the fourth level into a maximum of four sub-levels.
[0155] Specifically, based on the above steps 205d1 to 205d4, the step of specifying a cache strategy for each sub-level of the fourth level in the above step 206 may further include at least one of the following steps 206d1 to 206d4:
[0156] Step 206d1: For the data query request contained in the first sub-level of the fourth level, the incremental data obtained in each query is merged with the historical result data of the last query and cached, and the merged aggregated data is used as the historical result data for the next query.
[0157] Step 206d2: For the data query requests contained in the second sub-level of the fourth level, a cache granularity is obtained based on the calculation granularity of the windows of multiple data query requests, and the aggregated data is cached based on the cache granularity; the calculation granularity is used to indicate the moving distance of the window; the cache granularity is calculated based on the integer time unit distance of multiple calculation granularities.
[0158] Step 206d3: For the data query request contained in the third sublevel of the fourth level, the incremental data is divided according to the session interval to obtain multiple segments of data, and the aggregate data of each segment of data after the division is calculated; the result of the first segment of data in the multiple segments of data is merged with the historical result data, and the result of the last segment of data is cached as the historical result data for the next calculation.
[0159] Step 206d4: for the data query request included in the fourth sub-level of the fourth level, aggregate the data corresponding to the window of historical result data, and cache the aggregated data obtained by the calculation.
[0160] For example, Figure 4 As shown, it is a flow chart of generating a cache strategy based on window conditions, which involves 4 preset sub-conditions (including: condition 1 to condition 4, corresponding to the ninth preset sub-condition to the twelfth preset sub-condition mentioned above), and 4 sub-levels (including: sub-level 1 to sub-level 4, corresponding to the first sub-level of the fourth level to the fourth sub-level of the fourth level mentioned above) obtained based on the judgment results of the 4 preset sub-conditions.
[0161] For example, based on Figure 4 As shown in the flowchart of generating a cache strategy based on window conditions, the essence of window conditions is to divide streaming data by time. User queries can have window conditions or not. The cache strategies in these two cases are completely different. For queries without window conditions, historical data needs to be considered. It needs to be divided into two cases: frequent queries and non-frequent queries. For frequent queries, each time a query is executed, the cached aggregation result of the previous query (called historical results) is merged with the aggregation result of the incremental data between the last query and the current query (called incremental results) and returned, and then the calculation result is cached for use in the next query. The amount of data that needs to be calculated for each query is reduced to incremental results, reducing the calculation time.
[0162] For example, based on Figure 4As shown in the flowchart of generating cache strategies based on window conditions, the cache measures for infrequent queries are similar to those mentioned above. The difference is that in order to avoid the query taking too long to calculate the incremental results, a maximum interval can be specified. When the maximum interval arrives, the incremental calculation is automatically triggered, and then cached after merging with the historical results. In this way, the amount of data calculated each time will not exceed the maximum interval range. For queries with window conditions, they can be regarded as where conditions filtered by the timestamp field. However, the aggregated results of window data are the easiest to reuse, and a special cache strategy is designed here. First, for queries with windows in the same group, the initial offsets of the windows need to be aligned (misaligned offsets are equivalent to different initial starting lines, and the results cannot be reused). The principle is to cache the aggregated data of the smallest granularity window. Here, a concept called window calculation granularity is proposed. The calculation granularity of the tumbling window (which can be regarded as a sliding window with a sliding distance equal to the window time span) is the span of the tumbling window. If the window length of the sliding window (which has a time span and slides back for a period of time after each calculation and then calculates again, the data involved in the two calculations may overlap) is an integer multiple of the sliding distance, the calculation granularity is the sliding distance, otherwise it is an integer time unit distance (for example, the window span is 30 seconds, the sliding distance is 20 seconds, and the calculation granularity is 10 seconds). After counting the calculation granularities of these windows, the integer time unit distance of these window calculation granularities is taken as the cache granularity (for example, the calculation granularities are 40s and 20s respectively, and the cache granularity is 10s). Not taking the greatest common divisor here can reduce the probability of rebuilding the cache (for example, if the calculation granularities are 40s and 20s respectively, and the cache granularity takes the greatest common divisor of 20s, and then create a query with a window calculation granularity of 50s, the cache cannot be reused and needs to be rebuilt. Usually, there are many window caches and the reconstruction cost is high). After using this strategy cache, the window calculation can be obtained by using the cached fine-grained window aggregation data for secondary merging, which speeds up the result return speed. Stream computing also has a special session window (the window length is not fixed, the session window has a configuration item session interval, and the time difference between two adjacent data exceeds the session interval, which means that the two adjacent data are the demarcation points of the session window, and the second data belongs to another session window). This kind of window length and demarcation point are not fixed and the cache results cannot be reused. It can be converted into frequent query processing without window conditions. The difference is that when calculation is required, check whether the incremental data interval exceeds the session interval. If not, use the history + incremental method (the same as frequent query processing without window conditions); if there is data with an interval exceeding the session interval, disconnect the data into groups and calculate them separately. The earliest group needs to consider the historical data of the last calculation (belonging to the previous session window). When calculating the subsequent groups, do not consider the historical result data of the previous group until the last group is calculated and the calculation result of this group is saved (the earlier data in the next batch of incremental data may belong to the session window where the group is located).
[0163] Specifically, the above step 206 may further include the following step 206d5:
[0164] Step 206d5: For the third data query request in the fourth level whose query frequency is greater than or equal to the preset frequency threshold, merge the query result of the third data query request with the historical result data each time a data query is performed, and use the merged result as the historical result data for the next query.
[0165] For example, Figure 4 As shown, the above step 206d5 is the cache strategy corresponding to the child level 5 obtained after judging based on condition 2.
[0166] For example, in the embodiment of the present application, for the Select part of the data query request contained in each level, the union of the fields in all Select clauses is cached. In this way, the query can filter out the fields it really needs by projecting the cached results, and one cache can be reused by multiple SQLs.
[0167] Exemplarily, the above-mentioned preset fields also include: a third preset field; the third preset field is a Select field.
[0168] Specifically, the above step 206 may further include the following step 206e:
[0169] Step 206e: cache the data indicated by the union of the fields in the clause of the third preset field of each data query request in the multiple data query requests.
[0170] In this way, by classifying and multi-levelizing the SQL statements corresponding to the registered data query requests, corresponding caching strategies can be formulated for different sub-levels of different levels, which can reduce the execution time of the current query SQL. At the same time, the generated cache can be reused by other query SQLs as much as possible, thereby improving the utilization of the cache and reducing the storage occupancy of the cache.
[0171] Optionally, in the embodiment of the present application, in order to balance the storage space usage, the cache cannot be stored indefinitely. The cache is discarded only for the aggregated results filtered by time (such as a window) or when the query service corresponding to the cache that cannot be reused is deleted.
[0172] Exemplarily, after the above step 206, the streaming data service fast response method provided in the embodiment of the present application may further include at least one of the following steps 207 and 208:
[0173] Step 207: Determine whether the cached data can be reused for subsequent calculations based on the window, and discard the cached data that cannot be reused for subsequent calculations.
[0174] Step 208: determine whether the data queried by the data query request is data during the user's subscription period, and discard cached data that does not belong to the user's subscription period.
[0175] Exemplarily, the abandonment of the cache depends on case 1, whether the cache has the possibility of being reused / used directly; case 2, whether the user query needs to obtain historical data. For case 1, for example, if the data in a window from time 50s to time 80s has not yet arrived to trigger the calculation, then the cached results from time 50s to time 60s and time 60s to time 70s can be reused and cannot be abandoned, and the cached aggregate data between 40s and 50s can be abandoned. For case 2, there are three subdivisions as follows: if the user queries the full amount of data, it involves historical data, and the cache cannot be abandoned; if the user needs to incrementally query the data since the creation of the SQL, it also involves historical data, and the cache cannot be abandoned; if the user only needs to query the data during the subscription period of the service, only the aggregated results during the user's subscription period are cached. During the period when the query is not subscribed by the user, its historical data only caches the most recent calculation results to ensure a quick return when subscribing for the first time.
[0176] In this way, the storage space occupied by the cache can be reduced to a great extent, and the space utilization rate of the storage space can be improved.
[0177] The fast response method for streaming data service provided in the embodiment of the present application, the data loading module, loads data aggregation calculations regularly / on-demand in the form of a resident service and stores them in the cache, which plays a role in advance calculation and reduces the amount of calculation when querying service requests.
[0178] The fast response method of the stream data service provided by the embodiment of the present application, first, receives the target query request called by the target device, and determines the target cache strategy corresponding to the target query request; then, obtains the target cache data corresponding to the target cache strategy from the cache data, and screens out the required cache data from the target cache data for calculation, and obtains the data calculation result corresponding to the target query request; finally, sends the data calculation result to the target device; wherein, the cache data is obtained by: a cache strategy formulated based on the classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries meet at least one of the following: the main table is the same, the slave table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function in the data query request, the preset field and the window in the stream data calculation. In this way, the response speed of the stream data service is improved by classifying the data query requests of the same query and executing the corresponding cache strategy for each classification according to the classification results.
[0179] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor (processor) 510, a communication interface (Communications Interface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logic instructions in the memory 530 to execute the fast response method of the streaming data service, which includes: receiving a target query request called by a target device, and determining a target cache strategy corresponding to the target query request; obtaining target cache data corresponding to the target cache strategy from the cache data, and filtering out the required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request; sending the data calculation result to the target device; wherein the cache data is: obtained based on a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries satisfy at least one of the following: the main table is the same, the slave table is the same, and the conditional statement of the join query is the same; the classification result is: obtained after multi-level classification based on the aggregate function in the data query request, the preset field and the window in the streaming data calculation.
[0180] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0181] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the streaming data service fast response method provided by the above methods, the method including: receiving a target query request called by a target device, and determining a target cache strategy corresponding to the target query request; obtaining target cache data corresponding to the target cache strategy from cache data, and filtering out required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request; sending the data calculation result to the target device; wherein the cache data is obtained by: a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries satisfy at least one of the following: the main table is the same, the slave table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function, preset field in the data query request and the window in the streaming data calculation.
[0182] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned fast response method for streaming data services, the method comprising: receiving a target query request called by a target device, and determining a target cache strategy corresponding to the target query request; obtaining target cache data corresponding to the target cache strategy from the cache data, and filtering out required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request; sending the data calculation result to the target device; wherein the cache data is obtained by: a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are similar queries, and the target query request is one of the multiple data query requests; the similar queries satisfy at least one of the following: the main table is the same, the slave table is the same, and the conditional statement of the join query is the same; the classification result is obtained after multi-level classification based on the aggregate function in the data query request, the preset field, and the window in the streaming data calculation.
[0183] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0184] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0185] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for rapid response of streaming data service, characterized in that: include: Receive a target query request called by a target device, and determine a target cache strategy corresponding to the target query request; Acquire target cache data corresponding to the target cache strategy from the cache data, and filter out required cache data from the target cache data for calculation to obtain a data calculation result corresponding to the target query request; Sending the data calculation result to the target device; The cached data is obtained by: a cache strategy formulated based on classification results of multiple data query requests; the multiple data query requests are queries of the same type, and the target query request is one of the multiple data query requests; the queries of the same type satisfy at least one of the following: the main table is the same, the sub-table is the same, and the conditional statement of the join query is the same; the classification result is obtained based on the following steps: Performing a first-level division based on the aggregation function, dividing the data query requests with the same aggregation function among the multiple data query requests into the same category; Performing a second-level division based on the classification result of the first level and the first preset field, dividing the data query requests with the same filtering condition corresponding to the first preset field in the multiple data query requests into the same category; Performing a third-level division based on the classification result of the second level and the second preset field, dividing the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests into the same category; A fourth level of division is performed based on the classification result of the third level and the windows in the stream data calculation, and the data query requests with the same windows in the multiple data query requests are divided into the same category.
2. The method according to claim 1, characterized in that Before acquiring the target cache data corresponding to the target cache policy from the cache data, the method further includes: Obtain all data query requests registered in the data service, and classify the data query requests based on the request field of each data query request to obtain at least one group of similar queries; Each group of similar queries includes multiple data query requests.
3. The method according to claim 2, characterized in that The data query request is classified based on the request field of each data query request to obtain at least one group of similar queries, including: Multiple data query requests with the same primary table, the same secondary table, and the same join query condition statements are divided into a group of similar queries; The master table is the data table indicated by the from field in the data query request, the slave table is the data table indicated by the join field in the data query request, and the conditional statement of the join query is the on condition in the data query request.
4. The method according to claim 1, characterized in that: Before acquiring the target cache data corresponding to the target cache policy from the cache data, the method further includes: Based on the various levels indicated by the classification result, a cache strategy for the data query request corresponding to each level is determined, and data caching is performed based on the cache strategy for the data query request corresponding to each level to obtain the cached data.
5. The method according to claim 1, characterized in that The first preset field is the Group by field; the second preset field is the Where field.
6. The method according to claim 4, characterized in that The first-level division based on the aggregation function is to classify the data query requests with the same aggregation function in the multiple data query requests into the same category, including: Among the multiple data query requests with the same aggregation function, data query requests with the first type of aggregation function are divided into the first sub-level of the first level; and / or, Among the data query requests with the same aggregation function in the multiple data query requests, data query requests with the aggregation function of the second type are divided into the second sub-level of the first level; Among them, the first type of aggregation function is: the calculation result of multiple data as a whole can be calculated through the individual calculation results of each data in the multiple data; the second type of aggregation function is: the calculation result of multiple data as a whole cannot be calculated through the individual calculation results of each data in the multiple data.
7. The method according to claim 6, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: For the data query requests included in the first sub-level of the first level, cache the overall calculation results of each data corresponding to each data query request; and / or, For the data query requests included in the second sub-level of the first level, the calculation results of each data in each data corresponding to each data query request are cached respectively.
8. The method according to claim 1, characterized in that The second-level division based on the classification result of the first level and the first preset field, dividing the data query requests with the same filtering condition corresponding to the first preset field in the multiple data query requests into the same category, includes: Classify the data query request in which the clause of the first preset field in the first data query request satisfies the first preset condition as a first sub-level of the second level; and / or, Classifying the data query request in which the clause of the first preset field in the first data query request does not satisfy the first preset condition as a second sub-level of the second level; Among them, the first data query request is: a data query request among the multiple data query requests that belongs to the same category in the first level and whose query frequency is less than a preset frequency threshold; the first preset condition is: there is an inclusion relationship between the clauses of the first preset field.
9. The method according to claim 8, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: For the data query requests included in the first sub-level of the second level, caching the aggregated data queried by the data query requests that meet the second preset condition in the first data query requests; and / or, For the data query requests included in the second sub-level of the second level, cache the data queried by each data query request in the first data query request; The second preset condition includes: the clause of the first preset field contains the most content.
10. The method according to claim 1, characterized in that The performing the third-level division based on the classification result of the second level and the second preset field, and dividing the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests into the same category, includes: Classifying the data query requests satisfying the third preset condition in the second data query requests into a first sub-level of the third level; and / or, Classifying the data query requests satisfying a fourth preset condition in the second data query requests into a second sub-level of the third level; and / or, Classifying the data query requests satisfying the fifth preset condition in the second data query requests into a third sub-level of the third level; and / or, Classifying the data query requests satisfying the sixth preset condition in the second data query requests as a fourth sub-level of the third level; and / or, Classifying the data query requests satisfying the seventh preset condition in the second data query requests into the fifth sub-level of the third level; and / or, Classifying the data query requests satisfying the eighth preset condition in the second data query requests as the sixth sub-level of the third level; and / or, Classifying the data query requests satisfying the ninth preset condition in the second data query requests into the seventh sub-level of the third level; Among them, the second data query request is: a data query request belonging to the same category in the second level among the multiple data query requests; the third preset condition includes: not satisfying the first preset sub-condition and not satisfying the second preset sub-condition; the fourth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and not satisfying the fourth preset sub-condition; the fifth preset condition includes: not satisfying the first preset sub-condition, satisfying the second preset sub-condition, not satisfying the third preset sub-condition, and satisfying the fourth preset sub-condition; the sixth preset condition includes: satisfying the first preset sub-condition and not satisfying the fifth preset sub-condition; The seventh preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, and not satisfying the second preset sub-condition, or satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, and not satisfying the sixth preset sub-condition, or satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, and not satisfying the seventh preset sub-condition; the eighth preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, satisfying the seventh preset sub-condition, and not satisfying the eighth preset sub-condition. Preset sub-conditions; the ninth preset condition includes: satisfying the first preset sub-condition, satisfying the fifth preset sub-condition, satisfying the second preset sub-condition, satisfying the sixth preset sub-condition, satisfying the seventh preset sub-condition, and satisfying the eighth preset sub-condition; the first preset sub-condition is: the field judgment condition corresponding to the second preset field is a dynamic condition; the dynamic condition is: a non-preset judgment condition; the second preset sub-condition is: the field judgment condition includes a logical operation; the third preset sub-condition is: the query frequency is greater than or equal to the preset frequency threshold; the fourth preset sub-condition is: the field judgment condition contains an indecomposable condition field; the indecomposable condition field is : and operation condition field; the fifth preset sub-condition is: the field judgment condition is a field of dimension type; the field of dimension type is: the field judgment condition that the number of rows in the slave table is less than the number of rows in the main table of the data query statement, or the field judgment condition that the number of non-repeated values of the field corresponding to the field judgment condition in the main table is less than the number of rows in the main table; the sixth preset sub-condition is: the field judgment condition contains multiple logical operations; the seventh preset sub-condition is: the number of multiple logical operations contained in the field judgment condition exceeds the preset logical operation number threshold; the eighth preset sub-condition is: there is historical result data cache data of the same data query request containing multiple logical operations in the field judgment condition.
11. The method according to claim 10, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: For the data query requests included in the first sub-level of the third level, caching aggregated data of all data query requests; and / or, For the data query requests included in the second sub-level of the third level, caching aggregated data of all data query requests; and / or, For the data query request included in the third sub-level of the third level, caching the aggregated data of each logical operation; and / or, For the data query requests included in the fourth sub-level of the third level, calling a computing engine to query the data queried by each data query request; and / or, For the data query request included in the fifth sub-level of the third level, the data queried by the data query request corresponding to the field of each dimension type; and / or, For the data query requests included in the sixth sub-level of the third level, calling a computing engine to query the data queried by each data query request and caching the queried data; and / or, For the data query requests contained in the seventh sub-level of the third level, the computing engine is called to query the data queried by each data query request and the queried data to be merged, and the data to be merged is merged with the historical result data cache data and then cached.
12. The method according to claim 1, characterized in that The performing the third-level division based on the classification result of the second level and the second preset field, and dividing the data query requests with the same filtering condition corresponding to the third preset field in the multiple data query requests into the same category, includes: Classifying the data query requests satisfying the tenth preset condition in the third data query requests as the first sub-level of the fourth level; and / or, Classifying the data query requests satisfying the eleventh preset condition in the third data query requests as the second sub-level of the fourth level; and / or, Classifying the data query requests satisfying the twelfth preset condition in the third data query requests into the third sub-level of the fourth level; and / or, Classifying the data query requests satisfying the thirteenth preset condition in the third data query requests as a fourth sub-level of the fourth level; Among them, the third data query request is: a data query request belonging to the same category in the third level among the multiple data query requests; the tenth preset condition includes: not satisfying the ninth preset sub-condition and satisfying the tenth preset sub-condition; the eleventh preset condition includes: satisfying the ninth preset sub-condition and not satisfying the eleventh preset sub-condition; the twelfth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and satisfying the twelfth preset sub-condition; the thirteenth preset condition includes: satisfying the ninth preset sub-condition, satisfying the eleventh preset sub-condition, and not satisfying the twelfth preset sub-condition; the ninth preset sub-condition is: there is a window condition in the field judgment condition corresponding to the third preset field; the tenth preset sub-condition is: the query frequency is less than the preset frequency threshold; the eleventh preset sub-condition is: the window condition is a session window; the session window is used to divide the stream data into windows based on the session interval; the twelfth preset sub-condition is: whether the interval of incremental data exceeds the session interval; the incremental data is the data increased compared with the previous query.
13. The method according to claim 12, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: For the data query request included in the first sub-level of the fourth level, the incremental data obtained in each query is merged with the historical result data of the last query and cached, and the merged aggregated data is used as the historical result data of the next query; and / or, For the data query request included in the second sub-level of the fourth level, a cache granularity is obtained based on the calculation granularity of the windows of multiple data query requests, and the aggregated data is cached based on the cache granularity; the calculation granularity is used to indicate the moving distance of the window; the cache granularity is calculated based on the integer time unit distance of multiple calculation granularities; and / or, For the data query request included in the third sub-level of the fourth level, the incremental data is segmented according to the session interval to obtain multiple segments of data, and the aggregate data of each segment of data after segmentation is calculated; the result of the first segment of data in the multiple segments of data is merged with the historical result data, and the result of the last segment of data is cached as the historical result data for the next calculation; and / or, For the data query request included in the fourth sublevel of the fourth level, the data corresponding to the window of historical result data is aggregated and calculated, and the calculated aggregated data is cached.
14. The method according to claim 1, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: For a first data query request in the second level whose query frequency is greater than or equal to a preset frequency threshold, cache all aggregated data queried by the first data query request; and / or, For a second data query request in the third level that does not satisfy the first preset sub-condition, satisfies the second preset sub-condition, and has a query frequency greater than or equal to a preset frequency threshold, cache all aggregated data queried by the second data query request; and / or, For the third data query request in the fourth level whose query frequency is greater than or equal to the preset frequency threshold, merging the query result of the third data query request with the historical result data each time a data query is performed, and using the merged result as the historical result data for the next query; Among them, the first preset sub-condition is: the field judgment condition corresponding to the second preset field is a dynamic condition; the dynamic condition is: a non-preset judgment condition; the second preset sub-condition is: the field judgment condition includes a logical operation.
15. The method according to claim 4, characterized in that The data caching is performed based on the caching strategy of the data query request corresponding to each level to obtain the cached data, including: The data indicated by the union of the fields in the clause of the third preset field of each data query request in the multiple data query requests is cached.
16. The method according to claim 4, characterized in that The step of determining a cache strategy for a data query request corresponding to each level based on the levels indicated by the classification result includes: Based on the window, it is determined whether the cached data can be reused by subsequent calculations, and the cached data that cannot be reused by subsequent calculations is discarded.
17. The method according to claim 4, characterized in that After performing data caching based on the caching strategy of the data query request corresponding to each level and obtaining the cached data, the method further includes: It is determined whether the data queried by the data query request is data during the user's subscription period, and cached data that does not belong to the user's subscription period is discarded.
18. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the streaming data service fast response method described in any one of claims 1 to 17 are implemented.
19. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for rapid response of streaming data service as claimed in any one of claims 1 to 17 are implemented.
20. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the method for rapid response of streaming data services as claimed in any one of claims 1 to 17 are implemented.
