Sampling query method, device, electronic device and computer-readable storage medium
By building user partition storage strategy and hashing algorithm, the problem of slow query speed in big data environment is solved, and the efficiency and accuracy of data analysis are improved.
Patent Information
- Application Number
- CN202210236128.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-11
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-03-11
AI Technical Summary
In a big data environment, the full query method is slow due to the large amount of data, which affects the efficiency of data analysis, making it difficult to quickly grasp the user behavior trends.
By obtaining the user's internal identity, a user partition storage strategy is constructed, a user partition is stored in the original event information using a hash algorithm, and data is queried in the partition event information based on the preset data query information and sampling ratio to generate query results.
Improve the efficiency and accuracy of data analysis. By building user grouping strategies, it can quickly filter out corresponding groups for data query, reducing the time of a single query.
Smart Images

Figure CN114840565B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data analysis technology, and in particular to a sampling query method, device, electronic device, and computer-readable storage medium. Background Art
[0002] In the era of big data, every product has unique core indicators to measure its success, and data analysis is an important method to calculate product indicators.
[0003] When monitoring and evaluating the data indicators of certain products, full queries are generally used to obtain accurate data for analysis. However, when the actual data volume is very large, the full query method will seriously affect the efficiency of data analysis due to the long time it takes to obtain the full data and the slow speed of a single query. It is not easy to quickly grasp the behavioral trends of users on certain indicators.
[0004] Therefore, in order to avoid the problem that the current query method affects the efficiency of data analysis when the amount of data is very large, it is necessary to propose a sampling query method to improve the efficiency and accuracy of data analysis. Summary of the Invention
[0005] The present application provides a sampling query method, device, electronic device and computer-readable storage medium for improving the efficiency and accuracy of data analysis.
[0006] In order to solve the above technical problems, this application provides the following technical solutions:
[0007] This application provides a sampling query method, including:
[0008] Obtaining original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier;
[0009] Determine a user partition identifier according to the user internal identifier, and store the user partition identifier in the original event information to obtain partition event information;
[0010] Data is queried in the partition event information according to the preset data query information and the sampling ratio, and a query result is generated according to the queried data.
[0011] Accordingly, the present application also provides a sampling query device, comprising:
[0012] A first acquisition module is configured to acquire original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier;
[0013] a partition module, configured to determine a user partition identifier according to the user internal identifier, and store the user partition identifier in the original event information to obtain partition event information;
[0014] The sampling calculation module is used to query data in the partition event information according to the preset data query information and the sampling ratio, and generate a query result according to the queried data.
[0015] At the same time, the present application provides an electronic device, which includes a processor and a memory, the memory is used to store computer programs, and the processor is used to run the computer programs in the memory to execute the steps in the above-mentioned sampling query method.
[0016] In addition, the present application also provides a computer-readable storage medium, which stores multiple instructions. The instructions are suitable for a processor to load to execute the steps in the above-mentioned sampling query method.
[0017] Beneficial effects: The present application provides a sampling query method, device, electronic device and computer-readable storage medium. Specifically, the method first obtains the original event information, preset data query information and a sampling ratio, wherein the original event information includes a user internal identifier, and then determines the user partition identifier based on the user internal identifier, and stores the user partition identifier in the original event information to obtain the partition event information, and finally queries the data in the partition event information based on the preset data query information and the sampling ratio, and generates a query result based on the queried data. The method constructs a set of user grouping strategies based on the user internal identifier, so that users of different groups can be stored using different partition storage strategies. When performing a sampling query, the corresponding group can be quickly screened out according to the sampling ratio to further perform data query, thereby improving the efficiency and accuracy of data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The following detailed description of the specific embodiments of the present application in conjunction with the accompanying drawings will make the technical solutions and other beneficial effects of the present application apparent.
[0019] Figure 1 Schematic diagram of the system architecture of the sampling query system provided in the embodiment of the present application.
[0020] Figure 2 This is a flow chart of the sampling query method provided in an embodiment of the present application.
[0021] Figure 3 This is another flowchart of the sampling query method provided in an embodiment of the present application.
[0022] Figure 4 This is a schematic diagram of the sampling query interface provided in an embodiment of the present application.
[0023] Figure 5 It is a structural diagram of the sampling query device provided in an embodiment of the present application.
[0024] Figure 6 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0026] The terms "including" and "having" and any variations thereof in the specification and claims of this application are intended to cover non-exclusive inclusions; the division of modules appearing in this application is merely a logical division, and there may be other division methods when implemented in actual applications, for example, multiple modules may be combined into or integrated into another system, or some features may be ignored or not executed.
[0027] In this application, the original event information is the information that describes the original event model, such as the event name (event_id), the user's internal identifier (user_id), the user's original identifier (distinct_id), the date of the event (month_id, week_id, day, etc.), and the specific time (time) of the event.
[0028] In this application, the preset data query information is the information used for data query that is manually set or system default, which includes data query conditions (such as event name, date of event occurrence, etc.) and data query indicators (such as counting indicators such as number of visitors, page views, length of stay, and composite indicators such as bounce rate, visit depth, conversion rate, etc.).
[0029] In this application, the sampling ratio ranges from the sampling granularity to 1, wherein the sampling granularity is determined by the number of preset regions. For example, if the number of preset regions is 64, the sampling granularity is 1 / 64.
[0030] In this application, the user partition identifier is the partition number of the user partition storage, which is recorded as sample_group_id.
[0031] In this application, the partition event information includes not only the original event information but also the user partition identifier and the area identifier (event_bucket).
[0032] The present application provides a sampling query method, device, electronic device and computer-readable storage medium.
[0033] See also Figure 1 , Figure 1 This is a schematic diagram of the system architecture of the sampling query system provided by this application. Figure 1 As shown, the sampling query system at least includes a query terminal 101 and a data server 102, wherein:
[0034] A communication link is provided between the query terminal 101 and the data server 102 to implement information exchange. The types of communication links may include wired, wireless communication links or optical fiber cables, etc., and this application does not limit them.
[0035] The query terminal 101 may be a terminal device with a data query function, such as a smart phone, a tablet computer, or a laptop computer.
[0036] The data server 102 can be an independent server or a server network or server cluster composed of servers; for example, the server described in this application includes but is not limited to a computer, a network host, a database server, and an application server or a cloud server composed of multiple servers, wherein the cloud server is composed of a large number of computers or network servers based on cloud computing (Cloud Computing).
[0037] The present application proposes a sampling query system, which includes a query terminal 101 and a data server 102. Specifically, the data server 102 obtains original event information, preset data query information, and a sampling ratio from the query terminal 101, wherein the original event information includes a user internal identifier, and then determines a user partition identifier based on the user internal identifier, and stores the user partition identifier in the original event information to obtain partition event information. Finally, data is queried in the partition event information based on the preset data query information and sampling ratio, and a query result is generated based on the queried data. The data server 102 then feeds the query result back to the query terminal 101 for display.
[0038] In the above sampling query process, the sampling query system builds a set of user grouping strategies based on the user's internal identification, so that users in different groups can be stored using different partition storage strategies. When performing sampling queries, the corresponding groups can be quickly screened out according to the sampling ratio for further data query, thereby improving the efficiency and accuracy of data analysis.
[0039] It should be noted that Figure 1The system architecture diagram shown is only an example. The server, terminal, and scenario described in the embodiment of this application are intended to more clearly illustrate the technical solution of the embodiment of this application, and do not constitute a limitation on the technical solution provided by the embodiment of this application. It is known to those skilled in the art that with the evolution of the system and the emergence of new business scenarios, the technical solution provided by the embodiment of this application is also applicable to similar technical problems. The following are detailed descriptions. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0040] Based on the system architecture of the above sampling query system, the sampling query method in this application will be introduced in detail below. Figure 2 As shown, Figure 2 : is a flow chart of a sampling query method provided in an embodiment of the present application. The method includes at least the following steps:
[0041] S201: Acquire original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier.
[0042] The original event information, preset data query information and sampling ratio in the query terminal are obtained through the data server. The original event information is information describing the original event model, such as the event name (event_id), the user's internal identifier (user_id), the user's original identifier (distinct_id), the date of the event (month_id, week_id, day, etc.), and the specific time of the event (time); the preset data query information is information set manually or by default by the system for data query, which includes data query conditions (such as event name, date of event occurrence, etc.) and data query indicators (such as counting indicators such as the number of visitors, page views, and length of stay, and composite indicators such as bounce rate, visit depth, and conversion rate); the sampling ratio ranges from sampling granularity to 1, wherein the sampling granularity is determined by the preset number of regions. For example, if the preset number of regions is 64, the sampling granularity is 1 / 64.
[0043] Specifically, the event model (i.e., the Event model) includes two core entities: event and user. Among them, the event entity simply describes a user completing a specific thing in a certain way at a certain time and place. From this, it can be seen that a complete event (event) contains the following key factors: the user participating in the event. In the data interface, the user's original identifier (distinct_id) is usually used to set the user's unique ID. For non-logged-in users, this ID can be an anonymous ID such as a cookie or device ID. For logged-in users, the actual user ID assigned by the background is generally used; the actual time when the event occurred (month_id, week_id, day, time, etc.). In the data interface, the time field is generally used to record the time of the event accurate to milliseconds. Month_id is the month, week_id is the week, and day is the specific XX year XX month XX day; the location where the event occurred, the way the user engaged in the event, and the specific content of the event performed by the user are not involved in this application and will not be described in detail. The user entity corresponds to a real user, and is generally identified by the user's original identifier (distinct_id), and is associated with the behavior (i.e., event) performed by this user through the user's original identifier (distinct_id). In addition, in this application, for each user, the system will first generate a unique internal ID (i.e., user internal identifier user_id) based on the user's account information, and then calculate the partition information to which the user should belong based on the user's internal identifier. This will be explained in detail below.
[0044] S202: Determine the user partition identifier according to the user internal identifier, and store the user partition identifier in the original event information to obtain partition event information.
[0045] In one embodiment, during the import of large amounts of user behavior data, in order to ensure the integrity of a single user behavior sequence and the accuracy of user statistical data in the case of large data sampling, the present application constructs a set of user partition storage strategies for partitioning storage according to users during the import of user behavior data. The user partition storage strategy is based on the user's internal identifier, and its specific steps include: obtaining a preset number of areas; determining the user partition identifier corresponding to the user's internal identifier based on the user's internal identifier and the preset number of areas. The preset number of areas can be set manually or by system default. The number of areas is the total number of areas of the user partition, and each user area can also be called a bucket. The number of areas is the total number of buckets. The preset number of areas can be set manually or by system default.
[0046] Furthermore, the specific steps for obtaining the user internal identifier based on the user internal identifier and the preset number of zones include: calculating the storage address of the user internal identifier based on the hash algorithm and the user internal identifier; performing a modulo operation on the storage address based on the preset number of zones to obtain the user partition identifier corresponding to the user partition identifier. Among them, the hash algorithm can adopt MD4, MD5, and SHA-1. MD5 and SHA-1 can be said to be the most widely used hash algorithms currently, and they are both designed based on MD4. Specifically, the process of calculating the user partition identifier is shown in Formula 1:
[0047] sample_group_id=Hash(user_id)%region_num(Formula 1);
[0048] Here, sample_group_id is the user partition identifier for user partition storage, user_id is the user's internal identifier, region_num is the preset number of regions (for example, 32, 64, etc.), % represents the remainder in computer language, and Hash(user_id) represents the operation performed on the user's internal identifier (user_id) using a hash algorithm (a hash algorithm is a cryptographic algorithm that can only encrypt, not decrypt, and can convert information of any length into a fixed-length string). The storage address calculated by the hash function and user_id (the storage address here is only the storage address in the hash table, not the actual physical address) is called the hash address. It should be noted that the user's internal identifier (user_id) is stored in a hash table.
[0049] At the same time, after calculating the user partition identifier (sample_group_id), the system will automatically store the user partition identifier (sample_group_id) in the original event information and exist as a separate user attribute column to obtain partition event information containing the user partition identifier column.
[0050] S203: Query data in the partition event information according to preset data query information and sampling ratio, and generate query results based on the queried data.
[0051] Since the original event information has been partitioned according to the user's internal identifier in S202, the data of interest can be searched in the partitioned event information according to the preset data query information and sampling ratio. The specific process will be described below.
[0052] In one embodiment, the specific steps of performing a sampling query on data include: determining the target event information and the data calculation method based on the preset data query information and the sampling ratio; querying the data in the target event information based on the target event information and the data calculation method, and generating a query result based on the queried data. Among them, the preset data query information includes data query conditions and data query indicators, and the data query conditions include the name of the pre-queried event and the date of the pre-queried event; the sampling ratio is a sampling indicator in the proportional sampling method. Proportional sampling refers to a method of sampling according to a uniform ratio without considering the size of the sample variability. The range of the sampling ratio in this application is related to the preset number of user areas. Common sampling ratios include 1 / 2, 1 / 4, etc. It should be noted that the reciprocal of the preset number of user areas is called the sampling granularity. If the preset number of user areas is 64, the sampling granularity is 1 / 64.
[0053] The specific steps of determining target event information and a data calculation method based on preset data query information and a sampling ratio include: parsing the preset data query information to obtain data query conditions and data query indicators; filtering target event information from the partitioned event information based on the data query conditions; and determining a data calculation method based on the data query indicators and the sampling ratio. The data query conditions include the name of the pre-queried event and the date of occurrence of the pre-queried event, and the data query indicators include the total number of times (a common indicator used in event analysis functions, which refers to the number of times an event is triggered within a selected time range; for example, when selecting a page view event and viewing by total number of times, the calculated value is the page view count), the number of triggered users (a common indicator used in event analysis functions, which refers to the number of independent users who triggered an event within a selected time range; for example, when selecting a successful registration event and viewing by number of independent users, the calculated value is the number of successful registrations within the selected time range), and the average number of times per person (a common indicator used in event analysis functions, which refers to the average number of times an event is triggered by independent users within a selected time range; for example, when selecting a page view event and viewing by average number of times per person, the calculated value is the average page view depth per person).
[0054] For example, to query the number of users who viewed event 1001 on XX-XX-XX-DD, event 1001 and XX-XX-XX-DD are the data query conditions, and the number of users who viewed the event is the data query indicator. Therefore, based on the data query conditions, we can filter out events from the partitioned event information that meet the conditions of event name 1001 and event occurrence time XX-XX-XX-DD, and use the relevant information of the filtered target event as the target event information.
[0055] In one embodiment, different data query indicators may have different data calculation methods, so it is necessary to determine the data calculation method according to the type of data query indicator, and the specific steps include: determining a proportional coefficient according to the data query indicator and the sampling ratio; determining a data calculation method according to the proportional coefficient and the sampling ratio. Specifically, data query indicators can be divided into indicators that need to be amplified according to the sampling ratio and indicators that do not need to be amplified according to the sampling ratio (such as per capita number of times (per capita triggering number of a certain event), per capita value (per capita value of a certain digital type attribute), maximum value (maximum value of a certain digital type attribute), minimum value (minimum value of a certain digital type attribute), and per capita session number, etc.); wherein, if the data query indicator is an indicator that needs to be amplified according to the sampling ratio, the proportional coefficient is the inverse of the sampling ratio, and the data calculation method is to extract the corresponding event information according to the sampling ratio for query, and then multiply it by the proportional coefficient to ensure that the final statistical result is close to the actual data result; if the data query indicator is an indicator that does not need to be amplified according to the sampling ratio, the proportional coefficient is 1, and the data calculation method is to only extract the corresponding event information according to the sampling ratio for query.
[0056] In one embodiment, two types of data calculation methods and target event information are obtained according to the above steps and descriptions. The specific steps for querying data based on this include: performing a modulo operation on the user partition identifier according to the data calculation method to obtain a sampled user partition identifier; determining the sampling event information from the target event information according to the sampled user partition identifier, and generating a sampling result based on the sampling event information; calculating the sampling result according to the data query index and the data calculation method to obtain a query result.
[0057] For example, to query the number of users who triggered page browsing event 1001 on XX-XX-XX, the SQL statement calculated using the non-sampling query logic is: select count(distinc user_id) as uv from events where day = 'XX-XX-XX' and event_id = 1001, where uv is the number of daily active users on the web (the number of unique users who visited the website within a day (00:00-24:00) (based on browser cookies). Multiple visits to the website by the same visitor in a single day are only counted once). However, this non-sampling query logic is not suitable for large data volumes. Because a single query is very slow, this non-sampling query method can seriously affect analysis efficiency.
[0058] When the sampling query method proposed in this application is used, for indicators such as page views that need to be amplified according to the sampling ratio, assuming that the sampling ratio is 1 / 2, since only half of the users are sampled during the sampling process and included in the sampling statistics, the number of users counted for the page views will be reduced by half after sampling. Therefore, the final aggregated result needs to be multiplied by the proportional coefficient (i.e., the inverse of the sampling ratio) to ensure that the final statistical result is close to the actual data result. Specifically, if you want to query the number of users who triggered the page browsing event 1001 on XX-XX-XX day, the calculation method SQL statement under the logic of the sampling query proposed in this application is: select 2*count(distinct user_id)as uv from eventswhere day='XX-XX-XX'and event_id=1001and sample_group_id%2=0, wherein, through "where day='XX-XX-XX'and The "event_id=1001" statement filters out the target event information that meets the data query conditions. The "sample_group_id%2=0" statement performs a modulo calculation on the user partition identifier (sample_group_id). Because the sampling ratio is 1 / 2, the divisor in the modulo calculation is 2. Similarly, if the sampling ratio is 1 / a (a is a positive integer), the divisor in the modulo calculation is a. It can be seen that adding this condition to the where condition can ensure that half of the user data is included in the sampling statistical results. The sampling query can quickly filter out the sampled events, thereby improving the efficiency of data analysis. Finally, the "count(distinct user_id)" statement is used to calculate the number of users covered by the sampled event information that meets the aforementioned data query conditions and sampling ratio. Since sampling of indicators such as page views will result in a decrease in the number of users that can be counted, the final query result is obtained by multiplying it by the scale factor 2 in the final calculation.
[0059] In addition, when using the sampling query method proposed in this application, for indicators such as average page views per person that do not need to be magnified according to the sampling ratio, it is assumed that the sampling ratio is 1 / 2. Since only half of the users are sampled and included in the sampling statistics during the sampling process, this sampling will not cause the average page views per person to be reduced by half, so its proportional coefficient is 1. Specifically, if you want to query the average number of users who triggered the page browsing event 1001 on XX-XX-XX day, the calculation method SQL statement under the logic of the sampling query proposed in this application is: select count(*) / count(distinct user_id)from events where day='201-11-22'and event_id=1001and sample_group_id%2=0, wherein, through "where day='XX-XX-XX'and The "event_id=1001" statement filters out the target event information that meets the data query conditions. The "sample_group_id%2=0" statement performs a modulo calculation on the user partition identifier (sample_group_id). Because the sampling ratio is 1 / 2, the divisor in the modulo calculation is 2. Similarly, if the sampling ratio is 1 / a (a is a positive integer), the divisor in the modulo calculation is a. It can be seen that adding this condition to the where condition can ensure that half of the user data is included in the sampling statistical results. The sampling query can quickly filter out the sampled events, thereby improving the efficiency of data analysis. Finally, the "count(*) / count(distinct user_id)" statement is used to calculate the average number of users in the sampled event information that meets the aforementioned data query conditions and sampling ratio. At the same time, since this indicator is the average number of views per person, it does not need to be amplified according to the sampling ratio. Therefore, in the final calculation, the final query result is obtained by multiplying it by the scale factor 1.
[0060] It should be noted that the original event information, partition event information, target event information and sampled event information involved in this application are all stored using a typical event table structure.
[0061] like Figure 3 As shown, Figure 3 Another flow chart of the sampling query method provided in the embodiment of the present application. The sampling query method provided in the present application is simply divided into the following steps:
[0062] S301: Event import.
[0063] That is, the system imports event information such as front-end operations, back-end logs, and business data into the data server for storage.
[0064] S302: Partitioning according to user internal identification.
[0065] During the import of large amounts of user behavior data, to ensure the integrity of individual user behavior sequences and the accuracy of user statistics in large data sampling scenarios, this application has established a user partition storage strategy for partitioning storage by user. This user partition storage strategy is based on the user's internal identifier. By constructing a hash algorithm, the same user can only be assigned to one group, and users in different groups use different partition storage strategies.
[0066] S303: Obtain user partition 0, user partition 1, ... user partition N-1.
[0067] After partitioning the events according to S302, that is, grouping the users, user partition 0, user partition 1, ..., user partition N-1 are obtained, where N is the number of preset areas.
[0068] S304: Sampling query.
[0069] For sampling queries of partitioned event information, there are two main sampling calculation methods: one that requires scaling the index according to the sampling ratio, and the other that does not. However, regardless of the index type, the sampling query step first requires determining the target event information based on the data query conditions in the preset data query information, and then determining the data calculation method based on the data query index and the sampling ratio.
[0070] S305: Restore indicators.
[0071] The main difference between the two different types of data query indicators is the different proportional coefficients when restoring the indicators: for indicators that need to be amplified according to the sampling ratio, the data calculation method is to extract the corresponding event information according to the sampling ratio for query, and then multiply it by the proportional coefficient to ensure that the final statistical result is close to the actual data result; for indicators that do not need to be amplified according to the sampling ratio, the data calculation method is to extract the corresponding event information according to the sampling ratio for query, and no other calculations are required.
[0072] S306: Return the query result.
[0073] After processing the event information according to the above process, the final query result is obtained and fed back to the query terminal.
[0074] like Figure 4 As shown, Figure 4 This is a schematic diagram of the sampling query interface of the query terminal provided in the embodiment of the present application. Figure 4As shown, users can query data indicators by themselves (for example, the number of users browsing a web page), and can also select the sampling ratio by sliding the "Sampling Settings" slider. They can also choose to display the query results in an "approximate calculation". Figure 4 The lower part is the query result display area, which is mainly used to display the query results of data query indicators. Users can choose the display method of the query results (such as line chart, bar chart, and pie chart, etc.).
[0075] The sampling query method provided in this application can be applied to all analysis models of big data user behavior analysis. The typical usage scenario is that when the actual amount of data is very large, the speed of a single query is very slow. At this time, the data of a small number of users can be selected by query sampling to quickly verify the hypothesis and observe the trend. When the specific indicators to be paid attention to and assessed are finally determined, a full query can be selected to obtain accurate values. Of course, there may be discrepancies between the results deduced from the query sampling and the actual full query results. When the scale of user data is larger and the data distribution is more uniform, the discrepancy will be smaller. If you only focus on the trend of the data, then do a sampling query on a small number of user groups, and the error caused by the query sampling will not be so obvious.
[0076] Based on the content of the above embodiment, the present application embodiment provides a sampling query device. The sampling query device is used to execute the sampling query method provided in the above method embodiment. Specifically, please refer to Figure 5 , the device comprises:
[0077] A first acquisition module 501 is configured to acquire original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier;
[0078] A partition module 502 is configured to determine a user partition identifier based on the user internal identifier, and store the user partition identifier in the original event information to obtain partition event information;
[0079] The sampling calculation module 503 is configured to query data in the partition event information according to the preset data query information and the sampling ratio, and generate a query result according to the queried data.
[0080] In one embodiment, the partitioning module 502 includes:
[0081] The second acquisition module is used to obtain the preset number of areas;
[0082] The partition identifier determining module is configured to determine the user partition identifier corresponding to the user internal identifier according to the user internal identifier and the preset number of areas.
[0083] In one embodiment, the partition identification determination module includes:
[0084] An address calculation module, configured to calculate a storage address of the user internal identifier based on a hash algorithm and the user internal identifier;
[0085] The identifier calculation module is used to perform a modulo operation on the storage address based on the preset number of areas to obtain a user partition identifier corresponding to the user partition identifier.
[0086] In one embodiment, the sampling calculation module 503 includes:
[0087] A first determination module is configured to determine target event information and a data calculation method based on the preset data query information and the sampling ratio;
[0088] The first query module is used to query data in the target event information according to the target event information and the data calculation method, and generate a query result according to the queried data.
[0089] In one embodiment, the first determining module includes:
[0090] An information parsing module, configured to parse the preset data query information to obtain data query conditions and data query indicators;
[0091] An information screening module, configured to screen target event information from the partition event information according to the data query condition;
[0092] The second determination module is used to determine the data calculation method according to the data query index and the sampling ratio.
[0093] In one embodiment, the second determining module includes:
[0094] A coefficient determination module, configured to determine a proportional coefficient based on the data query index and the sampling ratio;
[0095] The third determining module is used to determine the data calculation method according to the proportional coefficient and the sampling ratio.
[0096] In one embodiment, the sampling query device further includes:
[0097] a partition operation module, configured to perform a modulo operation on the user partition identifier according to the data calculation method to obtain a sampled user partition identifier;
[0098] a sampling module, configured to determine sampling event information from the target event information according to the sampled user partition identifier, and generate a sampling result according to the sampling event information;
[0099] The query calculation module is used to calculate the sampling results according to the data query index and the data calculation method to obtain the query results.
[0100] The sampling query device of the embodiment of the present application can be used to execute the technical solution of the aforementioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0101] Different from the current technology, the sampling query device provided by this application is equipped with a partitioning module. Through the partitioning module, a set of user grouping strategies can be constructed based on the user's internal identification, so that users of different groups can be stored using different partitioning storage strategies. When performing sampling queries, the corresponding groups can be quickly screened out according to the sampling ratio for further data query, thereby improving the efficiency and accuracy of data analysis.
[0102] Accordingly, the embodiment of the present application further provides an electronic device, such as Figure 6 As shown, the electronic device may include a processor 601 with one or more processing cores, a wireless (WiFi, Wireless Fidelity) module 602, a memory 603 with one or more computer-readable storage media, an audio circuit 604, a display unit 605, an input unit 606, a sensor 607, a power supply 608, and a radio frequency (RF, Radio Frequency) circuit 609. Those skilled in the art will understand that Figure 6 The structure of the electronic device shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0103] The processor 601 is the control center of the electronic device. It connects all parts of the electronic device using various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 603 and accessing data stored in the memory 603, it performs various functions of the electronic device and processes data, thereby monitoring the entire electronic device. In one embodiment, the processor 601 may include one or more processing cores; preferably, the processor 601 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 601.
[0104] WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through the wireless module 602. It provides users with wireless broadband Internet access. Figure 6The wireless module 602 is shown, but it is understandable that it is not an essential component of the terminal and can be omitted as needed without changing the essence of the invention.
[0105] The memory 603 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing by running the computer programs and modules stored in the memory 603. The memory 603 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area may store data created according to the use of the terminal (such as audio data, a phone book, etc.). In addition, the memory 603 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 603 may also include a memory controller to provide the processor 601 and the input unit 606 with access to the memory 603.
[0106] The audio circuit 604 includes a speaker, which provides an audio interface between the user and the electronic device. The audio circuit 604 can convert received audio data into electrical signals and transmit them to the speaker, which then converts them into sound signals for output. Conversely, the speaker converts collected sound signals into electrical signals, which are received by the audio circuit 604 and converted into audio data. The audio data is then output to the processor 601 for processing, and then transmitted via the RF circuit 609 to, for example, another electronic device. Alternatively, the audio data may be output to the memory 603 for further processing. The audio circuit 604 may also include an earphone jack to allow communication between external headphones and the electronic device.
[0107] The display unit 605 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the terminal, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 605 may include a display panel. In one embodiment, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch-sensitive surface can cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor 601 to determine the type of touch event. The processor 601 then provides corresponding visual output on the display panel according to the type of touch event. Although in Figure 6In the embodiment, the touch-sensitive surface and the display panel are implemented as two independent components to implement input and output functions. However, in some embodiments, the touch-sensitive surface and the display panel can be integrated to implement input and output functions.
[0108] The input unit 606 can be used to receive digital or character input and generate keyboard, mouse, joystick, optical, or trackball signal input related to user settings and function control. Specifically, in one embodiment, the input unit 606 may include a touch-sensitive surface and other input devices. A touch-sensitive surface, also known as a touch display or touchpad, can detect user touch operations on or near it (for example, operations performed by a user using a finger, stylus, or any other suitable object or accessory on or near the touch-sensitive surface) and drive corresponding connected devices according to a pre-set program. In one embodiment, the touch-sensitive surface may include a touch detection device and a touch controller. The touch detection device detects the user's touch position and detects signals generated by the touch operation, transmitting the signals to the touch controller. The touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 601. It can also receive and execute commands from the processor 601. Furthermore, touch-sensitive surfaces can be implemented using various types of devices, including resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface, the input unit 606 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0109] The electronic device may further include at least one sensor 607, such as a light sensor, a motion sensor, or other sensors. Other sensors that may be configured in the electronic device, such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., will not be described in detail here.
[0110] The electronic device also includes a power supply 608 (e.g., a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 601 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 608 can also include any of one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other components.
[0111] The radio frequency circuit 609 can be used to receive and send signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is handed over to one or more processors 601 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency circuit 609 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a subscriber identity module (SIM) card, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the radio frequency circuit 609 can also communicate with the network and other devices through wireless communication. Wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0112] Although not shown, the electronic device may also include a camera, a Bluetooth module, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 601 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 603 according to the following instructions, and the processor 601 will run the application programs stored in the memory 603, thereby achieving the following functions:
[0113] Obtaining original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier;
[0114] Determine a user partition identifier according to the user internal identifier, and store the user partition identifier in the original event information to obtain partition event information;
[0115] Data is queried in the partition event information according to the preset data query information and the sampling ratio, and a query result is generated according to the queried data.
[0116] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0117] To this end, an embodiment of the present application provides a computer-readable storage medium, which stores a plurality of instructions that can be loaded by a processor to implement the functions of the above-mentioned sampling query method.
[0118] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0119] The above is a detailed introduction to the sampling query method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A sampling query method, characterized in that: include: Obtaining original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier; Get the preset number of regions; Determining, based on the user internal identifier and the preset number of regions, a user partition identifier corresponding to the user internal identifier, and storing the user partition identifier in the original event information to obtain partition event information, wherein the sampling ratio has a value range between a sampling granularity and 1, and the sampling granularity is determined based on the preset number of regions; Data is queried in the partition event information according to the preset data query information and the sampling ratio, and a query result is generated according to the queried data.
2. The sampling query method according to claim 1, characterized in that: The step of determining the user partition identifier corresponding to the user internal identifier according to the user internal identifier and the preset number of areas includes: Calculating a storage address of the user internal identifier based on a hash algorithm and the user internal identifier; A modulo operation is performed on the storage address based on the preset number of areas to obtain a user partition identifier corresponding to the user partition identifier.
3. The sampling query method according to claim 1, characterized in that: The step of querying data in the partition event information according to the preset data query information and the sampling ratio, and generating a query result according to the queried data includes: Determining target event information and data calculation method according to the preset data query information and the sampling ratio; Data is queried in the target event information according to the target event information and the data calculation method, and a query result is generated according to the queried data.
4. The sampling query method according to claim 3, characterized in that: The step of determining target event information and a data calculation method based on the preset data query information and the sampling ratio includes: Parsing the preset data query information to obtain data query conditions and data query indicators; Filtering target event information from the partition event information according to the data query condition; A data calculation method is determined based on the data query index and the sampling ratio.
5. The sampling query method according to claim 4, characterized in that: The step of determining the data calculation method according to the data query index and the sampling ratio includes: Determining a proportional coefficient according to the data query index and the sampling ratio; A data calculation method is determined according to the proportional coefficient and the sampling ratio.
6. The sampling query method according to claim 5, characterized in that: The step of querying data in the target event information according to the target event information and the data calculation method, and generating a query result according to the queried data includes: Performing a modulo operation on the user partition identifier according to the data calculation method to obtain a sampled user partition identifier; determining sampling event information from the target event information according to the sampled user partition identifier, and generating a sampling result according to the sampling event information; The sampling result is calculated according to the data query index and the data calculation method to obtain a query result.
7. A sampling query device, characterized in that: include: A first acquisition module is configured to acquire original event information, preset data query information, and a sampling ratio, wherein the original event information includes a user internal identifier; a partitioning module, configured to obtain a preset number of regions; determine a user partition identifier corresponding to the user internal identifier based on the user internal identifier and the preset number of regions, and store the user partition identifier in the original event information to obtain partition event information, wherein the sampling ratio has a value range between a sampling granularity and 1, and the sampling granularity is determined based on the preset number of regions; The sampling calculation module is used to query data in the partition event information according to the preset data query information and the sampling ratio, and generate a query result according to the queried data.
8. An electronic device, characterized in that: The system comprises a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to run the computer program in the memory to execute the steps in the sampling query method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the sampling query method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for statistic of audience rating
CN101355686A
Data sampling method and device, storage medium and processor
CN110399413A