Data query method and device, equipment, medium and product
By obtaining and pre-calculating multiple dimensional collections and combinations of data in data drilling, and establishing mapping relationships, the problem of reduced query performance of large data sets is solved and efficient data query is achieved.
Patent Information
- Application Number
- CN202410703063.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-10-22
AI Technical Summary
The query performance of existing data drilling methods drops sharply in large data sets, resulting in increased response time and reduced data query efficiency.
By obtaining multiple dimension sets of original data, the possible combinations between all dimension sets are determined, all combinations are pre-calculated based on preset rules, calculation results are generated, and mapping relationships are established to reduce repeated calculations during real-time queries. Improve query efficiency.
Significantly reduces query response time, improves the accuracy and efficiency of data queries, and avoids the need to retrieve large amounts of data in the database.
Smart Images

Figure CN118820291A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data query method, device, equipment, medium and product. Background Art
[0002] In today's increasingly digital world, data analysis and data drilling have become key tools for corporate decision-making, business optimization, and user experience improvement. Data drilling technology allows users to gradually segment data according to a specific hierarchy or dimension, thereby gaining a deep understanding of the trends and patterns behind the data. However, with the rapid growth of data volume and increasing complexity, traditional data drilling methods face huge challenges.
[0003] In the existing technology, data drilling usually relies on real-time query and aggregation of raw data, which is feasible when the data volume is small. However, in large data sets, especially those containing multi-dimensional fields, this method will cause a sharp decline in query performance. This is because each query needs to retrieve a large amount of data from the database, which increases the query response time and reduces the efficiency of data query. Summary of the invention
[0004] The present application provides a data query method, device, equipment, medium and product, which can improve data query efficiency.
[0005] In a first aspect, an embodiment of the present application provides a data query method, the method comprising:
[0006] Acquire multiple dimension sets corresponding to a set of original data, where one dimension set includes at least one field data belonging to a dimension type, and a set of original data includes field data of multiple dimensions;
[0007] According to the preset combination rules, determine all possible combinations between all dimension sets;
[0008] Based on the original data and the historical data associated with the original data, all possible combinations are pre-calculated according to the preset calculation rules to obtain multiple calculation results corresponding to each combination, one combination corresponding to one calculation result, the preset calculation rules are determined according to the combination, and the calculation results are used to indicate the statistical results corresponding to the combination;
[0009] Based on the multiple calculation results and all possible combinations, a mapping relationship is created, where the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combinations;
[0010] According to the query conditions input by the user, the calculation results corresponding to the query conditions are obtained from the mapping relationship.
[0011] In a second aspect, the present application provides a data query device, the device comprising:
[0012] A first acquisition module is used to acquire multiple dimension sets corresponding to a set of original data, where a dimension set includes at least one field data belonging to a dimension type, and a set of original data includes field data of multiple dimensions;
[0013] A determination module, used to determine all possible combinations between all dimension sets according to preset combination rules;
[0014] A calculation module is used to pre-calculate all possible combinations based on the original data and historical data associated with the original data according to preset calculation rules, and obtain multiple calculation results corresponding to each combination, one combination corresponding to one calculation result, the preset calculation rule is determined according to the combination, and the calculation result is used to indicate the statistical result corresponding to the combination;
[0015] A creation module, used to create a mapping relationship based on multiple calculation results and all possible combinations, wherein the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combinations;
[0016] The second acquisition module is used to acquire the calculation result corresponding to the query condition from the mapping relationship according to the query condition input by the user.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;
[0018] When the processor executes the computer program instructions, the data query method in any one of the embodiments of the first aspect is implemented.
[0019] In a fourth aspect, an embodiment of the present application provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, a data query method as in any one of the embodiments in the first aspect is implemented.
[0020] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a data query method as in any one of the embodiments in the first aspect above.
[0021] In a data query method, device, equipment, medium and product provided in an embodiment of the present application, multiple dimension sets of original data are first obtained, and all possible combinations between all dimension sets are determined. Subsequently, based on the original data and historical data, all possible combinations are pre-calculated according to preset calculation rules, thereby generating calculation results corresponding to each combination. This pre-calculation process not only avoids or reduces repeated calculations during real-time queries, but also greatly reduces the need to retrieve a large amount of data from the database during queries by pre-storing the calculation results. In addition, by creating a mapping relationship, a one-to-one correspondence is established between multiple calculation results and multiple combinations, so that when the query conditions input by the user are received, the calculation results corresponding to the search conditions can be quickly obtained from the preset mapping relationship. This method reduces the response time of the query, thereby improving the accuracy of data query and the efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0023] Figure 1 It is a flowchart of a data query method provided by an embodiment of the present application;
[0024] Figure 2 It is a structural schematic diagram of a data query device provided in an embodiment of the present application;
[0025] Figure 3 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0027] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0028] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0029] Data drilling refers to presenting data in segments according to a certain hierarchy or dimension, so that the data range that users are concerned about can be gradually drilled down and focused on a small point from a relatively large surface. In a data analysis system, users with different roles may have different business concerns, so they have different requirements for the dimension and granularity of the data. In order to meet the requirements of each role using the data analysis system, data drilling is needed. Through the drilling function, users can have a deeper understanding of the data, find problems more easily, and make correct decisions.
[0030] For example, in an electric vehicle shared charging pile management system, order data is a multi-dimensional data that includes fields such as order generation time, order generation address, charging station ID, charging equipment ID, charging user ID, charging power, charging time, charging electricity fee, etc. A system administrator may be concerned about the total charging power in Sichuan Province in 2022; a power station administrator may be concerned about the number of charging orders for a power station on July 26, 2022; an individual user may be concerned about his or her own charging electricity fee in July 2022.
[0031] In the process of data drilling, the existing technical solution is generally to store the original data in a Structured Query Language (Sql) database when the original data is generated. When data drilling is required, all data that meets the conditions is searched according to different dimensional conditions, and then summarized and analyzed. The existing technical solution will cause a sharp drop in query performance when the amount of data is huge.
[0032] In order to solve the problems existing in the prior art, the embodiments of the present application provide a data query method, device, equipment, medium and product.
[0033] The present application embodiment provides a data query method, device, equipment, medium and product. The following first introduces the data query method provided by the present application embodiment. Figure 1 As shown, the method specifically comprises the following steps:
[0034] S100, obtaining multiple dimension sets corresponding to a group of original data, where a dimension set includes at least one field data belonging to a dimension type, and a group of original data includes field data of multiple dimensions.
[0035] Optionally, in the embodiment of the present application, field data is a specific value in the original data, and field data is usually associated with a specific field name or column name. Field data can be a value (such as age, price), text (such as name, address), date (such as birthday, purchase date), etc. In a dimension set, field data is used to fill fields belonging to the same dimension type.
[0036] A dimension set is a data structure used to organize and store field data belonging to the same dimension type. Dimensions are used to describe the attributes or characteristics of business objects, such as users, products, time, etc. Each dimension set contains at least one field data, which together define all the important attributes of the dimension.
[0037] Optionally, in a feasible implementation of the present application, it is assumed that there is an original data set about online shopping, and this data set contains the shopping behavior information of users. Specifically, the data set can be decomposed according to the following steps to obtain multiple dimension sets:
[0038] First, you can analyze the fields in the raw data and determine which fields can be classified into different dimensions. In this example, the following dimensions can be identified: time, product, user, location, and transaction details.
[0039] For the time dimension, you can extract the date field from the original data and split it into different levels, such as year, month, day, etc. In addition, to facilitate query, you can also add an "ALL time" element that represents the full amount of time.
[0040] For the product dimension, you can extract fields such as product ID, product name, and product category from the original data and classify them into the product dimension. In this way, you can filter and analyze products based on their different attributes.
[0041] In terms of user dimension, fields such as user ID, user name, user age, user gender, etc. can be extracted from the original data and classified into the user dimension. In this way, the shopping behaviors and preferences of different user groups can be analyzed.
[0042] The geographic location dimension includes the user's delivery address information, such as province, city, district, county, etc. This information can help understand the geographical distribution of users and the regional differences in shopping habits.
[0043] Finally, the transaction details dimension contains the specific information of the order, such as order ID, order amount, payment method, order status, etc. These fields are very important for analyzing the transaction process and transaction results.
[0044] After determining these dimensions, we can select the corresponding fields from the original data as needed to construct sets of various dimensions. These dimension sets will provide strong support for our subsequent data analysis and query. By combining and filtering these dimension sets, we can obtain rich data insights, help us better understand users' shopping behaviors and preferences, and optimize product recommendations and marketing strategies.
[0045] S200, determining all possible combinations between all dimension sets according to preset combination rules.
[0046] Optionally, in a feasible implementation of the present application, in order to determine all possible combinations between all dimension sets according to preset combination rules, it is possible to first clarify the various dimension sets in the system, such as time, geographic location, user type, product category, etc., and understand the potential associations and limitations between them.
[0047] When determining the combination method, you can use a hierarchical or tree-like structure to organize these dimension sets. First, you can choose a core dimension as a starting point, such as the time dimension, and then gradually add other dimensions to form a combination based on preset rules. At each node, it will be decided whether to continue to expand or stop based on the preset combination rules.
[0048] In the specific implementation, an algorithm or script can be written, which traverses all dimension sets and generates all possible combinations according to preset rules. This algorithm can be designed to be recursive to handle complex combinations. In addition, in order to ensure that the generated combinations are valid and conform to business logic, validation and filtering steps can be embedded in the algorithm.
[0049] This method can systematically generate all possible combinations and ensure that they comply with the preset combination rules. These combinations will provide us with rich query and analysis options.
[0050] S300, based on the original data and the historical data associated with the original data, pre-calculate all possible combinations according to preset calculation rules to obtain multiple calculation results corresponding to each combination, one combination corresponds to one calculation result, the preset calculation rules are determined according to the combination, and the calculation results are used to indicate the statistical results corresponding to the combination.
[0051] Optionally, in a feasible implementation of the present application, in order to efficiently utilize the original data and the historical data associated therewith, it is necessary to pre-calculate all possible combinations according to preset calculation rules so as to quickly obtain the statistical results corresponding to each combination. This pre-calculation process is a key step in data analysis and decision support systems, which significantly improves the efficiency and accuracy of data queries.
[0052] Specifically, first, the specific content of the preset calculation rules needs to be clarified. These rules can be based on business logic and data analysis requirements, and define how to calculate the corresponding statistical results based on the dimensional elements in the combination method. For example, if the combination method includes three dimensions: time, geographic location, and user type, the preset calculation rules may stipulate that statistical indicators such as the number of orders, average order amount, and user activity under the combination method need to be calculated.
[0053] Next, the original data and historical data are used as input to pre-calculate each combination according to the preset calculation rules. This process can be achieved by writing a special calculation program or using existing data analysis tools. During the calculation process, the program will filter out the corresponding data subsets in the original data and historical data according to the dimensional elements in each combination, and calculate according to the preset calculation rules.
[0054] The pre-calculated results will be stored in the form of one combination corresponding to one calculation result, and these results will directly indicate the statistical results corresponding to the combination. For example, for the above combination of time, geographic location and user type, the pre-calculated result may be a data set containing statistical indicators such as order quantity, average order amount and user activity.
[0055] This pre-calculation method can quickly return corresponding statistical results when users query, without the need for complex real-time calculations. This not only improves the system's response speed, but also ensures the accuracy and consistency of query results. In addition, the pre-calculated results can also serve as the basis for subsequent data analysis and decision support, helping us better understand the patterns and trends in the data.
[0056] S400: Create a mapping relationship based on the multiple calculation results and all possible combination methods, where the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combination methods.
[0057] Optionally, in a possible implementation of the present application, in order to effectively manage and utilize multiple calculation results obtained by pre-calculation, it is necessary to create a mapping relationship that can clearly indicate the one-to-one correspondence between each calculation result and all possible combinations. This step is of great significance for data management and subsequent data analysis, query optimization, etc.
[0058] Specifically, first of all, we need to clarify the purpose and importance of the mapping relationship. The mapping relationship is not just a simple correspondence table, but also an efficient index system that can quickly locate the calculation results corresponding to a specific combination in massive data. This precise and fast correspondence is crucial to improving system performance and user experience.
[0059] Next, a detailed mapping relationship will be constructed based on the pre-calculated multiple calculation results and all possible combinations. This process can be implemented through programming, using data structures and algorithms to organize and manage this data. Specifically, hash tables, dictionary trees, or databases can be used to store mapping relationships, ensuring that each combination has a unique identifier and can quickly locate the corresponding calculation result.
[0060] When building a mapping relationship, it is necessary to ensure that each calculation result corresponds to one and only one combination, and at the same time, it is also necessary to ensure that each combination has one and only one calculation result corresponding to it. This one-to-one correspondence is the basis of the mapping relationship and the key to ensuring data accuracy and consistency.
[0061] After creating a mapping relationship, you can use it to perform efficient data management and query operations. For example, when a user needs to query the statistical results under a specific combination, he can directly find the corresponding calculation results through the mapping relationship without recalculating. This not only improves query efficiency, but also reduces system resource consumption.
[0062] S500: According to the query condition input by the user, a calculation result corresponding to the query condition is obtained from the mapping relationship.
[0063] Optionally, in a possible implementation of the present application, when a user enters specific query conditions, it is necessary to quickly and accurately retrieve calculation results that match these query conditions from a preset mapping relationship. To achieve this goal, it is necessary to ensure the accuracy and completeness of the mapping relationship so as to cover all possible query conditions and corresponding calculation results.
[0064] Once the user enters the query conditions, the system will immediately start the retrieval mechanism. This process usually involves parsing and standardizing the query conditions to ensure that they can accurately match the key fields in the mapping relationship. During the parsing process, the system can perform appropriate conversion or expansion according to the complexity of the query conditions to cover a wider search scope.
[0065] Next, the system will traverse the preset mapping relationship to find the items that match the query conditions. This step uses the one-to-one correspondence in the mapping relationship to quickly locate the combination that matches the query conditions. After finding the matching combination, the system can directly obtain the corresponding calculation results.
[0066] In order to improve the retrieval efficiency, some optimization strategies can also be adopted. For example, data structures such as hash tables or index trees can be used to store mapping relationships so that query operations can be completed in constant time. In addition, cache mechanisms can be used to store commonly used query results to reduce repeated access to mapping relationships.
[0067] In addition to basic search functions, the system can also provide some advanced query options to meet users' more complex query needs. For example, users may want to perform combined queries based on multiple conditions, or sort and filter query results. In order to achieve these functions, corresponding query engines and data processing modules can be integrated into the system to ensure that users can flexibly obtain the required calculation results.
[0068] In a data query method, device, equipment, medium and product provided in an embodiment of the present application, multiple dimension sets of original data are first obtained, and all possible combinations between all dimension sets are determined. Subsequently, based on the original data and historical data, all possible combinations are pre-calculated according to preset calculation rules, thereby generating calculation results corresponding to each combination. This pre-calculation process not only avoids or reduces repeated calculations during real-time queries, but also greatly reduces the need to retrieve a large amount of data from the database during queries by pre-storing the calculation results. In addition, by creating a mapping relationship, a one-to-one correspondence is established between multiple calculation results and multiple combinations, so that when the query conditions input by the user are received, the calculation results corresponding to the search conditions can be quickly obtained from the preset mapping relationship. This method reduces the response time of the query, thereby improving the accuracy of data query and the efficiency of data query.
[0069] In one embodiment, the above step 100 may specifically perform the following steps:
[0070] S110, obtaining the subordinate relationship between all field data in the original data;
[0071] S120, setting the field data belonging to the same subordinate relationship as a dimension set;
[0072] S130: Set the field data belonging to the statistic dimension as a dimension set.
[0073] Optionally, in a specific implementation of the present application, the original data is first generated: Assume that the electric vehicle shared charging pile system generates an order data (i.e., original data) at a certain moment as follows:
[0074]
[0075] Then, dimensional decomposition is performed: Taking the above-mentioned electric vehicle shared charging pile order data as an example, first, the related data is decomposed into different dimensional sets according to business needs.
[0076] The decomposition principle is:
[0077] ① When searching, fields with subordinate relationships belong to the same dimension set. For example, the time dimension has a natural subordinate relationship; the location dimension subordinate relationship is: equipment is subordinate to the power station, the power station is subordinate to the district, the district is subordinate to the city, and the city is subordinate to the province.
[0078] ②Statistics are a single dimension set.
[0079] ③In addition to the statistical dimension set, ALL elements can be added to each dimension as needed.
[0080] The ALL element has a specific meaning. It refers to a special query condition or combination method, which is used to indicate the situation of including all possible values or elements. For example, in a database query, a query containing "ALL" may return all data in the table containing the dimension.
[0081] According to the decomposition principle, the order data of electric vehicle shared charging piles can be decomposed into four dimensional sets:
[0082] S 时间 ={ALL time, 2022, July 2022, July 26, 2022} (i.e. dimension set)
[0083] S 位置 ={ALL location, Sichuan Province, Chengdu City, Sichuan Province, Wuhou District, Chengdu City, Sichuan Province, power station id: 12, equipment id: a01}
[0084] S 用户 ={ALL users, userid:781}
[0085] S 统计量 ={charging power, charging time, charging electricity fee, number of charging orders}
[0086] In these optional embodiments, step S110 identifies the subordinate relationships between all field data in the original data, and provides the intrinsic connection and hierarchical structure of the data, which helps to understand the essence of the data more deeply. Secondly, step S120 organizes the field data with the same subordinate relationship into a dimension set, realizes the logical grouping and aggregation of the data, which not only improves the readability and usability of the data, but also facilitates subsequent data analysis and mining. Finally, step S130 independently sets the field data of the statistical dimension as a dimension set, highlights the importance of statistical data, and provides it with a special processing and storage method, ensuring the accuracy and reliability of the statistical data.
[0087] In summary, these steps not only improve the efficiency and accuracy of data processing, but also make the data more structured, easier to manage and use. This data organization and classification method is particularly important for complex data analysis scenarios, which can better mine data value and provide strong support for business decisions and insights.
[0088] In one embodiment, the above step 200 may specifically perform the following steps:
[0089] S210, performing Cartesian product operations on all dimension sets to obtain all possible combinations between all dimension sets.
[0090] Optionally, in a specific implementation of the present application, a Cartesian product calculation is performed on all dimension sets obtained in S110-130. The significance of this step is to obtain all possible search condition combinations for multi-dimensional data such as charging orders for shared charging piles for electric vehicles. Specifically:
[0091]
[0092] According to the Cartesian product operation, we know that S k The number of elements is: |S k |=|S 时间 |*|S 位置 |*|S 用户 |*|S 统计量 |=4*6*2*4=192. k That is the specific number of all possible combinations.
[0093] In these optional embodiments, by performing Cartesian product operations on all dimension sets, all possible combinations between all dimension sets can be obtained. This step greatly improves the flexibility and comprehensiveness of data query and analysis, because users can freely construct complex query conditions based on these combinations to meet different business needs. At the same time, pre-calculating and storing all possible combinations can significantly improve query efficiency, reduce system response time, and provide users with a better experience. In addition, these combinations also provide a rich data foundation for subsequent data analysis and mining, which helps to discover potential patterns and correlations in the data. In short, this step provides strong support for data processing and analysis, and is an important part of building an efficient and flexible data processing system.
[0094] In one embodiment, the above step 300 may specifically perform the following steps:
[0095] S310, determining the field data of the original data corresponding to a first mode as a current value, wherein the first mode is any one of all possible combinations;
[0096] S320, acquiring a historical value corresponding to the first method from historical data;
[0097] S330, calculating the current value and the historical value according to a preset calculation rule corresponding to the first method to obtain a calculation result corresponding to the first method, wherein the preset calculation rule includes at least one of summing, averaging and set calculating.
[0098] Optionally, in a feasible implementation of the present application, first, in S310, one is selected from all possible dimension combination methods as a first method, and the field data of the original data corresponding to the combination method is determined as the current value. This step is to clarify the data set to be analyzed and the corresponding field, so as to perform specific calculations later.
[0099] Next, in S320, according to the selected first method, the corresponding historical value is retrieved from the historical data. The historical data usually includes various data records in the past period of time. By retrieving these historical data, historical data points related to the current analysis scenario can be obtained, thereby providing a benchmark for subsequent comparison and calculation.
[0100] Finally, in S330, the current value and the historical value are calculated according to the preset calculation rules to obtain the calculation result corresponding to the first method. These preset calculation rules may include common mathematical operations such as summation and average, or more complex calculation logic, such as the number of elements in a set, the calculation ratio, etc. The selection of these calculation rules depends on the specific business needs and data analysis goals. By executing these calculation rules, the calculation results under each dimension combination can be obtained, thereby comprehensively evaluating the relationship and difference between the original data and the historical data.
[0101] Specifically, taking the sales data of an e-commerce platform as an example, assume that the two dimensions of "product category" and "time" are selected as the first method. In S310, the original data corresponding to these two dimensions (such as the sales of a certain type of product in a certain time period) are determined as the current value. Then, in S320, the historical sales data corresponding to this dimension combination is retrieved from the historical data as the historical value. Finally, in step S33, you may choose to calculate the average value, growth rate and other indicators of the current sales and historical sales to evaluate the sales performance of this type of product in different time periods. Through this process, we can obtain the calculation results under each dimensional combination, thereby providing valuable sales data analysis and business decision support for the e-commerce platform.
[0102] In these optional embodiments, this analysis method not only improves the accuracy and comprehensiveness of data analysis, but also can more accurately evaluate the development trend of the business by comparing current and historical data, providing strong support for decision making. In addition, the flexibility of the preset calculation rules also ensures that the analysis results can meet the needs of different business scenarios.
[0103] In one embodiment, the above step 400 may specifically perform the following steps:
[0104] S410, determining all possible combinations as multiple keys, and determining the multiple calculation results as multiple values, where one combination corresponds to one key and one calculation result, and one calculation result corresponds to one value and one combination;
[0105] S420, storing the multiple values and the multiple keys in a database in the form of key-value pairs, wherein the mapping relationship is the key-value pairs, and one key-value pair corresponds to one combination method and one calculation result;
[0106] In one embodiment, after the above step 420, the method may further specifically perform the following steps:
[0107] S421, acquiring first data, where the data type of the first data is the same as that of the original data, and the first data is acquired later than the original data;
[0108] S422, pre-calculating all possible second modes corresponding to the first data to obtain multiple first results;
[0109] S423, when there is a second way among all the possible second ways that is the same as any one of the possible combination ways, update the value corresponding to the third way in the key-value pair to the first result corresponding to the third way, and the third way is a second way among all the possible second ways that is the same as any one of the possible combination ways.
[0110] Optionally, in a specific implementation of the present application, a Cartesian product operation is first performed on the decomposed dimension set to obtain an operation result S k , and then S k Convert all elements in S to search keys by converting k Perform string concatenation on ordered subsets of elements.
[0111] Specifically, according to the result set S of the Cartesian product operation k , generate a search key, and use the S obtained above for the charging order of electric vehicle shared charging piles k For example, the number of keys generated is equal to S k The number of elements is 192.
[0112] For example, the element {2022, Sichuan Province, ALL users, charging power} will generate the key: "2022_Sichuan Province_ALL users_charging power" (corresponding to a combination); the element {July 26, 2022, power station id: 12, ALL users, number of charging orders} will generate the key: "July 26, 2022_power station id: 12_ALL users_number of charging orders".
[0113] Then, all 192 keys generated are summarized and pre-calculated in the key-value database. The calculation rules need to be based on S 统计量 In the data of the example, all statistics are summed. Of course, in other implementations of the present application, the pre-calculation can also be an average calculation, a set calculation, etc.
[0114] For example, for the key "2022_Sichuan Province_ALL Users_Charging Power", the value will be 3.2 degrees higher than the old value (that is, the historical value of the historical data corresponding to the key); for the key "July 26, 2022_Power Station ID: 12_ALL Users_Number of Charging Orders", the value will be 1 higher than the old value. If the key does not exist, the old value is treated as 0, and the same applies to other keys. Each time an order data is added, the above steps need to be repeated to update the value of the key-value database to the latest calculation result of the corresponding key.
[0115]
[0116] Optionally, in a complete embodiment of the present application, step one: original data generation; assuming that the electric vehicle shared charging pile system generates an order data at a certain moment.
[0117] Step 2: Dimension decomposition: Taking the electric vehicle shared charging pile order data shown in step 1 as an example, first decompose the related data into different dimension sets according to business needs.
[0118] The decomposition principle is:
[0119] ① When searching, fields with subordinate relationships belong to the same dimension set. For example, the time dimension has a natural subordinate relationship; the location dimension subordinate relationship is: equipment is subordinate to the power station, the power station is subordinate to the district, the district is subordinate to the city, and the city is subordinate to the province.
[0120] ②Statistics are a single dimension set.
[0121] ③In addition to the statistical dimension set, ALL elements can be added to each dimension as needed.
[0122] For the data shown in step 1, according to the decomposition principle, it can be decomposed into 4 dimensional sets:
[0123] S 时间 ={ALL time, 2022, July 2022, July 26, 2022}
[0124] S 位置 ={ALL location, Sichuan Province, Chengdu City, Sichuan Province, Wuhou District, Chengdu City, Sichuan Province, power station id: 12, equipment id: a01}
[0125] S 用户 ={ALL users, userid:781}
[0126] S 统计量 ={charging power, charging time, charging electricity fee, number of charging orders}
[0127] Step 3: Cartesian product calculation is performed on all sets obtained in step 2. The significance of this step is to obtain all possible combinations of search conditions for multi-dimensional data such as charging orders for shared charging piles for electric vehicles.
[0128]
[0129] S k The number of elements is: |S k |=|S 时间 |*|S 位置 |*|S 用户 |*|S 统计量 |=4*6*2*4=192
[0130] Step 4: Based on the Cartesian product result set S obtained in step 3 k , generate search keys. For this example, the number of keys generated is equal to S k The number of elements is 192.
[0131] For example, the element {2022, Sichuan Province, ALL users, charging power} will generate the key: "2022_Sichuan Province_ALL users_charging power"; the element {July 26, 2022, power station id: 12, ALL users, number of charging orders} will generate the key: "July 26, 2022_power station id: 12_ALL users_number of charging orders".
[0132] Step 5: Summarize and pre-calculate all 192 keys generated in step 4 in the key-value database. The calculation rules need to be based on S 统计量 In the data shown in the example, all statistics are summations.
[0133] For example, for the key "2022_Sichuan Province_ALL users_Charging power" in the step four example, the value will be 3.2 degrees higher than the old value; for the key "July 26, 2022_Power station id:12_ALL users_Number of charging orders", the value will be 1 higher than the old value. If the key does not exist, the old value will be treated as 0, and the same applies to other keys.
[0134] Each time an order data (ie, new original data, equivalent to the first data) is generated, steps one to five are repeated to update the key-value database.
[0135] In these optional embodiments, by storing all possible combinations in the form of key-value pairs in the database (steps S410 and S420), the system can quickly respond to subsequent computing requirements for the same or similar data combinations, directly query and return the stored results without recalculation, thereby greatly reducing computing time and improving processing efficiency.
[0136] Secondly, when new data (such as the first data) is generated (step S421), the system can quickly pre-calculate the new data combination (step S422) and check whether these new combinations are the same as the stored combinations (step S423). If they are the same, the corresponding key-value pairs in the database are directly updated to ensure the real-time and accuracy of the data. This dynamic update mechanism enables the system to continuously adapt to data changes and keep the data up to date.
[0137] In summary, these steps not only improve the efficiency of data processing by optimizing data storage and query mechanisms and realizing dynamic data updates, but also ensure the accuracy and real-time nature of data, providing users with a better user experience and data support.
[0138] In one embodiment, the above step 500 may specifically perform the following steps:
[0139] S510, determining a target combination method corresponding to the query condition according to the query condition;
[0140] S520: Acquire a calculation result matching the target combination mode from the mapping relationship.
[0141] Optionally, in a specific implementation of the present application, ① generate a search key based on the search condition (i.e., query condition): for example, to query the total charging power in Sichuan Province in 2022, the search key will be generated: "2022_Sichuan Province_ALL users_charging power"; to query the total number of orders for the power station with id 12 on July 26, 2022, the search key "July 26, 2022_Power station id: 12_ALL users_charging order number" will be generated.
[0142] ②According to the search key obtained in ①, query the key-value database to obtain the result. If no result is found, it is treated as 0. It should be noted that this application uses the charging order data of shared charging piles for electric vehicles for example analysis, which does not mean that this solution is only applicable to the charging order data of shared charging piles for electric vehicles. It can also be online shopping order data, takeaway order data, etc.
[0143] Optionally, in an embodiment of the present application, by adopting the technical means of data pre-computation, the query of original data-aggregation process during data drilling is converted into a query of pre-computation results, which can greatly improve the efficiency of data query during data drilling and greatly reduce the CPU and memory overhead generated during real-time query in the prior art.
[0144] In these optional embodiments, by generating a specific search key according to the search conditions, the system can accurately locate the data required by the user. This key-based query method avoids the complex query statements in traditional databases, greatly simplifies the query process, and improves the query speed. At the same time, the use of a key-value database to store pre-calculated results enables the system to quickly respond to query requests and directly return results without the need to calculate again, further improving retrieval efficiency. In addition, when no results are found, the system treats the results as 0, ensuring the integrity and consistency of the data and avoiding errors or misleading caused by missing data. In short, these steps improve the system's response speed and data accuracy by optimizing the data retrieval mechanism, providing users with more convenient and reliable data services.
[0145] Figure 2 A schematic diagram of the structure of a data query device provided in another embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0146] Reference Figure 2 , the data query device may include:
[0147] A first acquisition module 201 is used to acquire multiple dimension sets corresponding to a set of original data, where a dimension set includes at least one field data belonging to a dimension type, and a set of original data includes field data of multiple dimensions;
[0148] A determination module 202 is used to determine all possible combinations between all dimension sets according to a preset combination rule;
[0149] A calculation module 203 is used to pre-calculate all possible combinations based on the original data and historical data associated with the original data according to a preset calculation rule to obtain a plurality of calculation results corresponding to each combination, one combination corresponding to one calculation result, the preset calculation rule is determined according to the combination, and the calculation result is used to indicate the statistical result corresponding to the combination;
[0150] A creation module 204, configured to create a mapping relationship based on the multiple calculation results and the possible combination methods, wherein the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combination methods;
[0151] The second acquisition module 205 is used to acquire the calculation result corresponding to the query condition from the mapping relationship according to the query condition input by the user.
[0152] In one embodiment, the first acquisition module 201 may include:
[0153] A first acquisition submodule is used to acquire the subordinate relationship between all field data in the original data;
[0154] The first setting submodule is used to set the field data belonging to the same subordinate relationship as a dimension set;
[0155] The second setting submodule is used to set the field data belonging to the statistic dimension as a dimension set.
[0156] In one embodiment, the determination module 202 may include:
[0157] The first calculation submodule is used to perform Cartesian product operations on all dimension sets to obtain all possible combinations between all dimension sets.
[0158] In one embodiment, the calculation module 203 may include:
[0159] A first determining submodule, configured to determine the field data of the original data corresponding to a first mode as a current value, wherein the first mode is any one of all possible combinations;
[0160] A second acquisition submodule, used for acquiring a historical value corresponding to the first method from historical data;
[0161] The second calculation submodule is used to calculate the current value and the historical value according to the preset calculation rule corresponding to the first method to obtain the calculation result corresponding to the first method, and the preset calculation rule includes at least one of summing, averaging and set calculation.
[0162] In one embodiment, the creation module 204 may include:
[0163] A second determination submodule, configured to determine all possible combinations as multiple keys, and determine the multiple calculation results as multiple values, wherein one combination corresponds to one key and one calculation result, and one calculation result corresponds to one value and one combination;
[0164] The first storage submodule is used to store the multiple values and the multiple keys in the form of key-value pairs in a database, the mapping relationship is the key-value pairs, and one key-value pair corresponds to one combination method and one calculation result.
[0165] In one embodiment, the data query device may include:
[0166] A third acquisition module is used to acquire first data, where the data type of the first data is the same as that of the original data, and the first data is acquired later than the original data;
[0167] A second calculation module, used for pre-calculating all possible second modes corresponding to the first data to obtain multiple first results;
[0168] An update module is used to update the value corresponding to the third mode in the key-value pair to a first result corresponding to the third mode when there is a second mode that is the same as any one of all possible combination modes among all possible second modes, and the third mode is a second mode that is the same as any one of all possible combination modes among all possible second modes.
[0169] In one embodiment, the second acquisition module 205 may include:
[0170] A third determination submodule is used to determine a target combination mode corresponding to the query condition according to the query condition;
[0171] The third acquisition submodule is used to acquire a calculation result matching the target combination mode from the mapping relationship.
[0172] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application, and are devices corresponding to the above-mentioned battery thermal runaway warning method. All implementation methods in the above-mentioned method embodiment are applicable to the embodiments of the device. Its specific functions and technical effects can be found in the method embodiment part, which will not be repeated here.
[0173] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0174] Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0175] The device may include a processor 301 and a memory 302 storing program instructions.
[0176] When the processor 301 executes the program, the steps in any of the above method embodiments are implemented.
[0177] Exemplarily, the program may be divided into one or more modules / units, one or more modules / units are stored in the memory 302, and executed by the processor 301 to complete the present application. One or more modules / units may be a series of program instruction segments capable of completing a specific function, and the instruction segments are used to describe the execution process of the program in the device.
[0178] Specifically, the processor 301 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0179] The memory 302 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 302 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 302 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 302 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 302 is a non-volatile solid-state memory.
[0180] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) readable storage media (e.g., memory devices) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0181] The processor 301 implements any one of the methods in the above embodiments by reading and executing program instructions stored in the memory 302 .
[0182] In one example, the electronic device may further include a communication interface 303 and a bus 310. The processor 301, the memory 302, and the communication interface 303 are connected via the bus 310 and communicate with each other.
[0183] The communication interface 303 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0184] Bus 310 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 310 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0185] In addition, in combination with the method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores program instructions; when the program instructions are executed by a processor, any one of the methods in the above embodiment is implemented.
[0186] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0187] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0188] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0189] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0190] The functional modules shown in the above block diagram can be implemented as hardware, software, firmware or their combination. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer grids such as the Internet, intranets, etc.
[0191] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0192] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0193] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A data query method, It is characterized in that The method comprises: Acquire multiple dimension sets corresponding to a set of original data, where one dimension set includes at least one field data belonging to a dimension type, and a set of original data includes field data of multiple dimensions; According to the preset combination rules, determine all possible combinations between all dimension sets; Based on the original data and the historical data associated with the original data, pre-calculate all possible combinations according to preset calculation rules to obtain multiple calculation results corresponding to each combination, one combination corresponding to one calculation result, the preset calculation rule is determined according to the combination, and the calculation result is used to indicate the statistical result corresponding to the combination; Based on the multiple calculation results and the possible combination methods, creating a mapping relationship, wherein the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combination methods; According to the query condition input by the user, a calculation result corresponding to the query condition is obtained from the mapping relationship.
2. The method according to claim 1, It is characterized in that The obtaining of multiple dimension sets corresponding to a set of original data includes: Obtaining the subordinate relationship between all field data in the original data; Set the field data belonging to the same affiliation as a dimension set; Set the field data belonging to the statistics dimension as a dimension set.
3. The method according to claim 1, It is characterized in that The step of determining all possible combinations of all dimension sets according to the preset combination rules includes: Cartesian product operations are performed on all dimension sets to obtain all possible combinations between all dimension sets.
4. The method according to claim 1, It is characterized in that The pre-calculation of all possible combinations is performed based on the original data and the historical data associated with the original data according to a preset calculation rule to obtain a plurality of calculation results corresponding to each combination, including: Determine the field data of the original data corresponding to a first mode as a current value, wherein the first mode is any one of all possible combinations; Acquire a historical value corresponding to the first method from historical data; According to the preset calculation rule corresponding to the first method, the current value and the historical value are calculated to obtain the calculation result corresponding to the first method, and the preset calculation rule includes at least one of summing, averaging and set calculation.
5. The method according to claim 1, It is characterized in that The creating a mapping relationship based on the multiple calculation results and all possible combinations includes: Determine all possible combinations as multiple keys, and determine the multiple calculation results as multiple values, where one combination corresponds to one key and one calculation result, and one calculation result corresponds to one value and one combination; The multiple values and the multiple keys are stored in a database in the form of key-value pairs, wherein the mapping relationship is the key-value pairs, and one key-value pair corresponds to one combination method and one calculation result; After the multiple values and the multiple keys are stored in a database in the form of key-value pairs, and the mapping relationship is the key-value pairs, the method further includes: Acquire first data, where the data type of the first data is the same as that of the original data, and the first data is acquired later than the original data; Pre-calculating all possible second modes corresponding to the first data to obtain multiple first results; In the case that there is a second way among all possible second ways that is the same as any one of all possible combination ways, the value corresponding to the third way in the key-value pair is updated to the first result corresponding to the third way, and the third way is a second way among all possible second ways that is the same as any one of all possible combination ways.
6. The method according to claim 1, It is characterized in that The obtaining, according to the query condition input by the user, a calculation result corresponding to the query condition from the mapping relationship includes: According to the query condition, determining a target combination method corresponding to the query condition; A calculation result matching the target combination mode is obtained from the mapping relationship.
7. A data query device, It is characterized in that The device comprises: A first acquisition module is used to acquire multiple dimension sets corresponding to a set of original data, where a dimension set includes at least one field data belonging to a dimension type, and a set of original data includes field data of multiple dimensions; A determination module, used to determine all possible combinations between all dimension sets according to preset combination rules; A calculation module, configured to pre-calculate all possible combinations based on the original data and historical data associated with the original data according to a preset calculation rule, to obtain a plurality of calculation results corresponding to each combination, one combination corresponding to one calculation result, the preset calculation rule being determined according to the combination, and the calculation result being used to indicate a statistical result corresponding to the combination; A creation module, configured to create a mapping relationship based on the multiple calculation results and all possible combinations, wherein the mapping relationship includes a one-to-one correspondence between the multiple calculation results and the multiple combinations; The second acquisition module is used to acquire a calculation result corresponding to the query condition from the mapping relationship according to the query condition input by the user.
8. An electronic device, It is characterized in that The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the data query method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the data query method according to any one of claims 1 to 6 is implemented.
10. A computer program product, It is characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the data query method as described in any one of claims 1 to 6.
