User data extraction methods, apparatus, electronic devices and storage media

By assigning a unique index to each user's data, sample data is accurately extracted, solving the uncertainty problem caused by rate limiting and random sampling in existing technologies, and achieving efficient, fair and replayable sample data extraction.

CN119988367BActive Publication Date: 2025-10-31巽风科技(贵州)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510459471.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-10-31
Estimated Expiration
2045-04-14

AI Technical Summary

Technical Problem

In existing technologies, when extracting sample data from user data, there are uncertainties in rate limiting and random sampling, which makes it impossible to replay the sample data extraction and affects the fairness of business operations.

Method used

By assigning a unique index to each user's data, and utilizing the index, total number, and total number of sample data, sample data can be accurately extracted, ensuring the openness, fairness, and replayability of the sample data.

Benefits of technology

It greatly improves sample extraction efficiency, reduces network overhead, enhances the fairness and replayability of extraction, and demonstrates good compatibility and scalability under high traffic and short time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988367B_ABST
    Figure CN119988367B_ABST
Patent Text Reader

Abstract

This invention discloses a user data extraction method, apparatus, electronic device, and storage medium, relating to the field of computer application technology. This method acquires all user data for each user at once during sample data extraction, significantly reducing network overhead and greatly improving sample extraction efficiency. By assigning a unique index to each user data set and utilizing the index, the total number of user data sets, and the total number of sample data sets to accurately extract sample data, the method effectively improves the openness, fairness, and replayability of user data extraction, demonstrating excellent compatibility and scalability when facing higher traffic requests and shorter timeframes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer application technology, and more specifically, to a user data extraction method, apparatus, electronic device, and storage medium. Background Technology

[0002] In existing technologies, when extracting sample data from user data, rate limiting is typically used to filter out most of the user data, and sample data is randomly obtained from the remaining user data. Because rate limiting and random sampling inherently involve uncertainty, the sample data extraction cannot be replayed, posing a risk to business fairness. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a user data extraction method, apparatus, electronic device and storage medium that can improve sample extraction efficiency, fairness and replayability.

[0004] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:

[0005] In a first aspect, the present invention provides a user data extraction method, the method comprising:

[0006] Based on the user information, obtain the corresponding user data; the user information is used to characterize the users participating in the sample extraction.

[0007] The number of samples to be selected is determined based on the total amount of data and the number of samples; the total amount of data refers to the total number of all user data; the number of samples refers to the total number of sample data.

[0008] The step size is determined based on the index, offset, total number of data, and number of data to be selected of the user data; and the minimum index and maximum index are determined based on the step size, offset, total number of data, and number of data to be selected; the offset represents the starting index of the user data to be selected.

[0009] When the index of the user data is the minimum index or the maximum index, the selection state corresponding to the user data is set to selected;

[0010] According to the selection status, the sample data is determined from the user data.

[0011] In an optional implementation, determining the number of samples to be selected based on the total amount of data and the number of samples includes:

[0012] When the total number of data is greater than the number of samples, the number of non-samples is obtained based on the difference between the total number of data and the number of samples.

[0013] When the number of samples is less than the number of non-samples, the number of samples is determined as the number to be selected;

[0014] When the number of samples is not less than the number of non-samples, the number of non-samples is determined as the number to be selected.

[0015] In an optional implementation, determining the step size based on the index, offset, total data quantity, and number of items to be selected of the user data, and determining the minimum and maximum indexes based on the step size, offset, total data quantity, and number of items to be selected, includes:

[0016] Get the offset;

[0017] When the index of the user data does not exceed the offset, the selection status corresponding to the user data is set to unselected;

[0018] When the index of the user data exceeds the offset, a fixed tolerance is determined based on the total amount of data and the number to be selected.

[0019] The step size is determined based on the index of the user data, the offset, and the fixed tolerance.

[0020] The minimum index and the maximum index are determined based on the step size, the fixed tolerance, and the offset.

[0021] In an optional implementation, determining the sample data from the user data according to the selection state includes:

[0022] When the number of samples is less than the number of non-samples, the user data whose selection status is selected is determined as the sample data;

[0023] When the number of samples is not less than the number of non-samples, the user data whose selection status is not selected is determined as the sample data.

[0024] In an optional implementation, obtaining the corresponding user data based on user information includes:

[0025] The user information is retrieved concurrently from the extraction queue; the extraction queue is used to store user information corresponding to users participating in sample extraction.

[0026] The corresponding user queue is determined based on the user information; the user information corresponds one-to-one with the user queue; the user queue is used to store the user data corresponding to the user information.

[0027] The user queue is traversed to obtain all user data corresponding to the user information.

[0028] In an optional implementation, before the step of obtaining the corresponding user data based on user information, the method further includes:

[0029] Receive a user's sample extraction request; the sample extraction request includes the user identifier and the number of extractions;

[0030] The user information is generated based on the user identifier, and the user information is added to the extraction queue;

[0031] User data is generated based on the user identifier and the number of extractions, and the user data is added to the user queue.

[0032] In an optional implementation, generating user data based on the user identifier and the number of extractions includes:

[0033] When the sum of the current total number of extractions corresponding to the user identifier and the number of extractions does not exceed the extraction threshold, the minimum and maximum index values ​​corresponding to the sample extraction request are obtained based on the number of extractions.

[0034] Based on the user identifier, the minimum index value, and the maximum index value, generate the user data corresponding to the sample extraction request.

[0035] In a second aspect, the present invention provides a user data extraction device, the device comprising:

[0036] The acquisition module is used to acquire corresponding user data based on user information; the user information is used to characterize the users participating in the sample extraction.

[0037] The processing module is used to determine the number of data to be selected based on the total number of data and the number of samples; the total number of data refers to the total number of all user data; the number of samples refers to the total number of sample data; the module determines a step size based on the index and offset of the user data, the total number of data, and the number of data to be selected, and determines a minimum index and a maximum index based on the step size, the offset, the total number of data, and the number of data to be selected; the offset represents the starting index of the user data to be selected; when the index of the user data is the minimum index or the maximum index, the selection state corresponding to the user data is set to selected;

[0038] An extraction module is used to determine the sample data from the user data according to the selection state.

[0039] Thirdly, the present invention provides an electronic device including a processor and a memory, the memory storing machine-executable instructions executable by the processor, the processor executing the machine-executable instructions to implement the user data extraction method described in any of the foregoing embodiments.

[0040] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the user data extraction method as described in any of the foregoing embodiments.

[0041] Compared to existing technologies, the user data extraction method, apparatus, electronic device, and storage medium provided in this invention obtain corresponding user data based on user information; determine the number of samples to be selected based on the total number of data and the number of samples; determine the minimum index and the maximum index based on the index of the user data, the total number of data, and the number of samples to be selected; when the index of the user data is the minimum index or the maximum index, set the selection state of the user data to be selected; and determine sample data from the user data according to the selection state.

[0042] As can be seen, the embodiments of the present invention acquire all user data for each user at once during sample data extraction, which can greatly reduce the network overhead of acquiring user data and significantly improve the efficiency of sample extraction. By assigning a unique index to each user data and using the index of the user data, the total number of user data, and the total number of sample data to accurately extract sample data, the openness, fairness, and replayability of user data extraction are effectively improved, so that it can exhibit excellent compatibility and scalability when facing higher traffic requests and shorter time requirements.

[0043] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0044] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This diagram illustrates a flowchart of a user data extraction method provided in an embodiment of the present invention.

[0046] Figure 2 This diagram illustrates another flowchart of the user data extraction method provided in an embodiment of the present invention.

[0047] Figure 3 This diagram illustrates another flowchart of the user data extraction method provided in an embodiment of the present invention.

[0048] Figure 4 A block diagram of a user data extraction device provided in an embodiment of the present invention is shown.

[0049] Figure 5 A block diagram of an electronic device provided in an embodiment of the present invention is shown.

[0050] Icons: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication module; 300 - User data extraction device; 301 - Acquisition module; 302 - Processing module; 303 - Extraction module. Detailed Implementation

[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0052] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0053] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0054] In today's internet industry, there is a need to extract user data in situations involving a large number of users. For example, various online platforms set up lottery activities, and the process of drawing prizes can be regarded as a process of extracting user data.

[0055] When faced with high traffic volumes impacting the system, achieving absolutely fair sample extraction becomes difficult. To ensure fairness in sample extraction, rate limiting is typically used to filter out the majority of user data, followed by a random number generation algorithm to determine whether user data can be extracted as sample data. However, due to the inherent uncertainties in rate limiting and random number generation algorithms, the user data extraction process cannot be recreated or replayed, thus posing a risk to the fairness of the business operations.

[0056] Based on this, the user data extraction method and apparatus provided in this embodiment of the invention can acquire all user data of each user at once when extracting sample data, which can greatly reduce the network overhead of acquiring user data and greatly improve the sample extraction efficiency. By assigning a unique index to each user data and using the index of the user data, the total number of user data, and the total number of sample data to accurately extract sample data, the openness, fairness, and replayability of user data extraction are effectively improved, so that it can exhibit excellent compatibility and scalability when facing higher traffic requests and shorter time requirements.

[0057] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0058] Please see Figure 1 , Figure 1 A flowchart illustrating a user data extraction method provided by an embodiment of the present invention is shown. The method should include the following steps:

[0059] Step S40: Obtain the corresponding user data based on the user information.

[0060] User information is used to characterize the users who participated in the sample extraction.

[0061] In this embodiment of the invention, obtaining user data requires the user's consent or authorization. User information can uniquely identify the user participating in the sample extraction, and user information may include user account, user ID, or user name. Based on the user information, all user data corresponding to that user is obtained, i.e., the target user data.

[0062] Step S50: Determine the number of samples to be selected based on the total number of data and the number of samples.

[0063] The total data quantity refers to the total number of all user data, and the sample quantity refers to the total number of sample data.

[0064] In this embodiment of the invention, the user data extraction process is determined based on the total amount of data and the number of samples. When the total amount of data is less than or equal to the number of samples, all user data corresponding to the user information is determined as sample data; that is, all user data corresponding to each user is determined as sample data. For example, in a lottery, everyone receives a prize, meaning the number of prizes and the number of draws are the same, which also means the number of samples and the total amount of data are the same.

[0065] When the total amount of data exceeds the number of samples, the number of data to be selected is determined based on the total amount of data and the number of samples. The number of data to be selected represents the number of user data items whose selection status is selected.

[0066] Step S60: Determine the step size based on the index, offset, total number of data, and number of data to be selected of the user data, and determine the minimum index and maximum index based on the step size, offset, total number of data, and number of data to be selected.

[0067] The offset represents the starting index of the user data to be selected.

[0068] Step S70: Determine whether the index of the user data is the minimum index or the maximum index.

[0069] In this embodiment of the invention, when the index of the target user data is equal to the minimum index or the maximum index, step S80 is executed. When the index of the target user data is not equal to the minimum index and the index of the target user data is not equal to the maximum index, step S90 is executed. The index of the user data can be a positive integer, such as a user data ID (e.g., 1, 100, etc.), globally uniquely addressed to uniquely identify the user data.

[0070] Step S80: If yes, set the selection status corresponding to the user data to be selected.

[0071] Step S90: If not, set the selection status corresponding to the user data to unselected.

[0072] Step S100: Determine sample data from user data according to the selection status.

[0073] In this embodiment of the invention, the selection status of target user data whose index is the minimum index or the maximum index is set to selected, and the selection status of target user data whose index is neither the minimum index nor the maximum index is set to unselected. Finally, sample data is selected from the target user data based on the selection status, and the extraction result of the sample data is notified to the user.

[0074] In summary, the user data extraction method provided in this embodiment of the invention obtains corresponding user data based on user information; determines the number of samples to be selected based on the total number of data and the number of samples; determines the minimum index and the maximum index based on the index of the user data, the total number of data, and the number of samples to be selected; when the index of the user data is the minimum index or the maximum index, the selection state corresponding to the user data is set to selected; and sample data is determined from the user data according to the selection state.

[0075] As can be seen, the embodiments of the present invention acquire all user data for each user at once during sample data extraction, which can greatly reduce the network overhead of acquiring user data and significantly improve the efficiency of sample extraction. By assigning a unique index to each user data and using the index of the user data, the total number of user data, and the total number of sample data to accurately extract sample data, the openness, fairness, and replayability of user data extraction are effectively improved, so that it can exhibit excellent compatibility and scalability when facing higher traffic requests and shorter time requirements.

[0076] Optionally, when the total amount of data exceeds the sample size, the following is one possible approach to determining the number of samples to be selected. Please refer to [link to relevant documentation]. Figure 2 The sub-steps of step S50 may include:

[0077] Step S501: When the total number of data is greater than the number of samples, the number of non-samples is obtained based on the difference between the total number of data and the number of samples.

[0078] Step S502: When the number of samples is less than the number of non-samples, the number of samples is determined as the number to be selected.

[0079] Step S503: When the number of samples is not less than the number of non-samples, the number of non-samples is determined as the number to be selected.

[0080] In this embodiment of the invention, assuming the total number of data points is greater than the number of samples but less than or equal to twice the number of samples, the number of non-sample data points is determined based on the difference between the total number of data points and the number of samples. In this case, the number of samples is greater than or equal to the number of non-sample data points. To improve the efficiency of user data extraction, non-sample data is selected from the user data, and the number of non-sample data points is taken as the number to be selected. Here, the number of non-sample data points refers to the number of user data points that have not become sample data points.

[0081] Suppose the total amount of data is greater than twice the number of samples, in which case the number of samples is less than the number of non-samples. To improve the efficiency of user data extraction, sample data is selected from the user data, and the number of samples is taken as the number to be selected.

[0082] As can be seen, the embodiments of the present invention determine the user data to be selected based on the size of the sample quantity and the non-sample quantity. When the sample quantity is less than the non-sample quantity, sample data is selected from the user data. When the sample quantity is not less than the non-sample quantity, non-sample data is selected from the user data. This ensures a smaller number of data to be selected, effectively improving the efficiency of user data extraction.

[0083] Optionally, regarding how to determine the minimum and maximum indexes for each user's data, one possible implementation method is provided below. Please refer to [link / reference]. Figure 2 The sub-steps of step S60 may include:

[0084] Step S601: Obtain the offset.

[0085] In this embodiment of the invention, it is assumed that the system starts a single thread to count the number of samples and the total number of data. To ensure the fairness of sample data extraction, an offset is randomly generated based on the total number of data and the number to be selected, and the offset is recorded to ensure the replay of the sample data extraction process. The formula for calculating the offset is as follows:

[0086] offset=rand(floor(total / selector))

[0087] Where offset is the offset; total is the total number of data; selector is the number of data to be selected; floor is the floor function; and rand is the random function.

[0088] Step S602: When the index of the user data does not exceed the offset, set the selection status of the user data to unselected.

[0089] In this embodiment of the invention, the offset serves as the starting index for extracting user data to be selected. User data with an index less than the offset is considered unselected, and its selection status is set to unselected. For example, if the total number of data is 100, the indices of all user data range from 1 to 100, and the number of data to be selected (selector) is 6, then the offset is a random value not exceeding 16. Let's assume the offset is 5. Therefore, when the index of user data is less than or equal to 5, that user data is considered unselected. User data with an unselected status will skip steps S603-S605 and steps S70-S90, and will directly proceed to step S100.

[0090] Step S603: When the index of user data exceeds the offset, a fixed tolerance is determined based on the total number of data and the number to be selected.

[0091] In this embodiment of the invention, the ratio of the total number of data points to the number of data points to be selected is defined as a fixed tolerance. The formula for calculating the fixed tolerance is as follows:

[0092] tolerance=total / selector

[0093] Here, tolerance is a fixed tolerance. For example, if the total number of data is 100 and the number of selectors is 6, then the fixed tolerance is a decimal greater than 16 and less than 17. If one decimal place is retained, the tolerance is 16.7.

[0094] Step S604: Determine the step size based on the index, offset, and fixed tolerance of the user data.

[0095] Step S605: Determine the minimum index and the maximum index based on the step size, fixed tolerance, and offset.

[0096] In this embodiment of the invention, a step size, a minimum index, and a maximum index are calculated for each user data set. Specifically, the difference between the index and the offset of the user data is calculated to obtain a deviation value, and the step size is determined based on the ratio of the deviation value to a fixed tolerance.

[0097] The formulas for calculating the step size, minimum index, and maximum index are as follows:

[0098] step=floor((index-offset) / tolerance)

[0099] index_min=round(step×tolerance+offset+1)

[0100] index_max=round((step+1)×tolerance+offset+1)

[0101] Where step is the step size; index is the index of the user data; index_min is the minimum index; index_max is the maximum index; and round is the rounding function.

[0102] As can be seen, the embodiments of the present invention can quickly determine the minimum index and the maximum index based on the fixed tolerance, use the minimum index and the maximum index to determine whether user data is extracted as sample data, and reverse index to the user corresponding to the user data, thereby achieving the fairness of sample extraction.

[0103] Alternatively, one possible implementation method for selecting sample data is provided below. Figure 1 The sub-steps of step S100 may include:

[0104] When the number of samples is less than the number of non-samples, the user data in the selected state is determined as sample data; when the number of samples is not less than the number of non-samples, the user data in the selected state is determined as sample data.

[0105] In this embodiment of the invention, when the number of samples is less than the number of non-samples, in order to improve the extraction efficiency of user data, sample data is selected from the user data, and the selection state corresponding to the selected user data is set to "selected". That is to say, the selected user data is the sample data.

[0106] When the number of sample data is not less than the number of non-sample data, in order to improve the efficiency of user data extraction, non-sample data is selected from the user data, and the selection status of the selected user data is set to "selected". In other words, the selected user data is the non-sample data, and the unselected user data is the sample data.

[0107] As can be seen, in the embodiments of the present invention, when extracting user data, sample data or non-sample data is extracted according to the smaller amount of data, which effectively improves the extraction efficiency of user data.

[0108] Optionally, regarding how to obtain user data for each user, the following is one possible implementation method. Please refer to [link / reference]. Figure 3 , Figure 1 The sub-steps of step S40 may include:

[0109] Step S401: Concurrently retrieve user information from the extraction queue.

[0110] The extraction queue is used to store user information corresponding to users who participated in the sample extraction.

[0111] In this embodiment of the invention, it is assumed that the system starts multiple threads to concurrently retrieve user information from the extraction queue, and each thread processes the retrieved user information.

[0112] Step S402: Determine the corresponding user queue based on the user information.

[0113] Each user information corresponds one-to-one with a user queue, and the user queue is used to store the user data corresponding to the user information.

[0114] In this embodiment of the invention, each user is assigned a user queue, which stores all of that user's data. That is, there is a one-to-one correspondence between users, user information, and user queues; the user queue corresponding to a user, i.e., the target user queue, can be found through the user information.

[0115] Step S403: Traverse the user queue to obtain all user data corresponding to the user information.

[0116] In this embodiment of the invention, all user data is retrieved by traversing the target user queue to obtain the user data corresponding to the user information, i.e., the target user data. Sample data is extracted based on the target user data until the extraction queue is empty, thus completing the sample data extraction operation.

[0117] It's worth noting that, assuming there are m users participating in the sample extraction, and the extraction threshold for each user is n, current sample extraction methods typically process one extraction request from one user at a time. Therefore, completing the sample extraction requires processing... The sample extraction complexity is [number] times. In this embodiment of the invention, the sample extraction complexity is only related to the number of users. Each time, all user data of the same user is obtained and processed, so it takes m processing times to complete the sample extraction, and the sample extraction complexity is O(m).

[0118] As can be seen, the embodiments of the present invention store the data users corresponding to multiple sample extraction requests of the same user into the corresponding user queue through the merging mechanism, and use multi-threaded concurrency to extract samples from all user data in each user queue, which greatly improves the concurrency efficiency and thus improves the user data extraction efficiency.

[0119] Optionally, regarding how to generate user information and user data based on user sample extraction requests, the following is a possible implementation method. Please refer to [link to relevant documentation]. Figure 3 ,exist Figure 1 Before step S40, the following steps may also be included:

[0120] Step S10: Receive the user's sample extraction request.

[0121] The sample extraction request includes the user identifier and the number of extractions.

[0122] In this embodiment of the invention, a user participates in a sample extraction activity by specifying the number of extractions through a client. The client responds to the user's operation, generates a sample extraction request based on the user identifier and the number of extractions, and sends the sample extraction request to an electronic device. The user identifier can be a user account, user ID, or user name; this invention does not limit its specific type.

[0123] Step S20: Generate user information based on the user identifier and add the user information to the extraction queue.

[0124] Step S30: Generate user data based on user identifier and number of extractions, and add the user data to the user queue.

[0125] In this embodiment of the invention, user information can be added to the extraction queue in the order of receiving sample extraction requests, the corresponding user queue can be obtained according to the user identifier, and the newly generated user data can be saved to the corresponding user queue in sequence.

[0126] As one possible implementation, an extraction queue is implemented based on Redis sets. By utilizing the automatic deduplication function of Redis sets, user information in the extraction queue is automatically deduplicated to ensure that each user information in the extraction queue is unique, thereby avoiding duplicate extraction of user data and effectively improving the accuracy, fairness and efficiency of sample data extraction.

[0127] It should be noted that if the extraction queue does not have an automatic deduplication function, it is necessary to first determine whether user information already exists in the extraction queue. If it already exists, there is no need to generate new user information; if it does not exist, the user information generated based on the user identifier is added to the extraction queue to ensure the uniqueness of user information in the extraction queue. This invention does not limit the implementation method for ensuring the uniqueness of user information in the extraction queue.

[0128] Alternatively, one possible implementation for generating user data is provided below. Figure 3 The sub-step of generating user data in step S30 may include:

[0129] When the sum of the current total number of extractions corresponding to the user identifier and the number of extractions does not exceed the extraction threshold, the minimum and maximum index values ​​corresponding to the sample extraction request are obtained based on the number of extractions; user data corresponding to the sample extraction request is generated based on the user identifier, the minimum index value, and the maximum index value.

[0130] In this embodiment of the invention, during the initialization of the user data extraction system, configuration items are loaded to determine the number of samples and the extraction threshold. The extraction threshold represents the maximum number of times a user can participate in sample extraction. To enhance the diversity of sample extraction, continuous extraction is supported; each time a user initiates a sample extraction request, they can specify the number of extractions for that request.

[0131] Upon receiving a user's sample extraction request, for each request, the system first obtains the user's current total number of extractions based on the user identifier. When the sum of the current total number of extractions corresponding to the user identifier and the number of extractions exceeds the extraction threshold, the user is notified that the maximum number of sample extractions has been reached. This prevents users from initiating unlimited sample extraction requests, which could lead to the security risk of the user data extraction system being overloaded, and effectively improves the reliability of user data extraction.

[0132] For sample extraction requests that do not exceed the extraction threshold, the extraction count is input into the extraction counter, which is then used to generate the maximum index value corresponding to this sample extraction request. Specifically, the extraction counter is used to automatically allocate consecutive indices. Starting from the last allocated index, the extraction counter continuously allocates indices for the specified number of extractions, using the smallest newly allocated index as the minimum index value and the largest newly allocated index as the maximum index value.

[0133] Starting from the minimum index value and moving to the maximum index value, user data is generated for each newly allocated index based on the user identifier. This user data includes the index itself.

[0134] It should be noted that, to reduce the storage space occupied by user data, the index can be directly used as user data. User extraction records are created based on the sample extraction request. Each user extraction record includes a user identifier, a minimum index value, and a maximum index value. The user extraction records are retrieved based on the user information, and the sample data is determined using the indexes in the user extraction records that are greater than or equal to the minimum index value and less than or equal to the maximum index value.

[0135] As one possible implementation, a clustered Redis high-performance cache can be used to store key data such as extraction queues, user queues, and extraction thresholds, thereby supporting millions of participating users.

[0136] Based on the same inventive concept, this embodiment of the invention also provides a user data extraction device. Its basic principle and the resulting technical effects are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0137] Please see Figure 4 , Figure 4 The diagram shows a block illustration of a user data extraction device 300 according to an embodiment of the present invention. The user data extraction device 300 includes an acquisition module 301, a processing module 302, and an extraction module 303.

[0138] The acquisition module 301 is used to acquire corresponding user data based on user information; the user information is used to represent the users participating in the sample extraction.

[0139] Processing module 302 is used to determine the number of data to be selected based on the total number of data and the number of samples; the total number of data is the total number of all user data; the number of samples is the total number of sample data; the step size is determined based on the index of the user data, the offset, the total number of data, and the number of data to be selected, and the minimum index and the maximum index are determined based on the step size, the offset, the total number of data, and the number of data to be selected; the offset represents the starting index of the user data to be selected; when the index of the user data is the minimum index or the maximum index, the selection state of the user data is set to selected;

[0140] Extraction module 303 is used to determine sample data from user data according to the selection status.

[0141] In summary, the user data extraction device provided in this embodiment of the invention acquires all user data for each user at once during sample data extraction, which can greatly reduce the network overhead of acquiring user data and significantly improve sample extraction efficiency. By assigning a unique index to each user data and using the index of the user data, the total number of user data, and the total number of sample data to accurately extract sample data, the device effectively improves the openness, fairness, and replayability of user data extraction, thus demonstrating excellent compatibility and scalability when facing higher traffic requests and shorter time requirements.

[0142] Optionally, the processing module 302 is specifically used to obtain the number of non-samples based on the difference between the total number of data and the number of samples when the total number of data is greater than the number of samples; to determine the number of samples as the number to be selected when the number of samples is less than the number of non-samples; and to determine the number of non-samples as the number to be selected when the number of samples is not less than the number of non-samples.

[0143] Optionally, the processing module 302 is specifically used to obtain the offset; when the index of the user data does not exceed the offset, the selection status of the user data is set to unselected; when the index of the user data exceeds the offset, a fixed tolerance is determined based on the total number of data and the number to be selected; a step size is determined based on the index, offset, and fixed tolerance of the user data; and the minimum index and maximum index are determined based on the step size, fixed tolerance, and offset.

[0144] Optionally, the extraction module 303 is specifically used to determine the selected user data as sample data when the number of samples is less than the number of non-samples; and to determine the unselected user data as sample data when the number of samples is not less than the number of non-samples.

[0145] Optionally, the acquisition module 301 is specifically used to concurrently acquire user information from the extraction queue; the extraction queue is used to store user information corresponding to users participating in sample extraction; the corresponding user queue is determined according to the user information; there is a one-to-one correspondence between user information and user queue; the user queue is used to store user data corresponding to user information; and all user data corresponding to user information is obtained by traversing the user queue.

[0146] Optionally, the acquisition module 301 is further configured to receive a user's sample extraction request; the sample extraction request includes a user identifier and the number of extractions; generate user information based on the user identifier and add the user information to the extraction queue; generate user data based on the user identifier and the number of extractions and add the user data to the user queue.

[0147] Optionally, the acquisition module 301 is specifically used to obtain the minimum and maximum index values ​​corresponding to the sample extraction request based on the number of extractions when the sum of the current total number of extractions corresponding to the user identifier and the number of extractions does not exceed the extraction threshold; and to generate user data corresponding to the sample extraction request based on the user identifier, the minimum index value, and the maximum index value.

[0148] Please see Figure 5 , Figure 5 This is a block diagram of an electronic device 100 provided in an embodiment of the present invention. The electronic device 100 can be any device with data processing capabilities, such as a personal computer, laptop computer, or server. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0149] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0150] The processor 120 is used to read / write data or programs stored in the memory 110 and perform corresponding functions. For example, when a computer program stored in the memory 110 is executed by the processor 120, the user data extraction method disclosed in the above embodiments can be implemented.

[0151] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals via a network, and to send and receive data via the network.

[0152] It should be understood that, Figure 5 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 5 The more or fewer components shown, or having the same Figure 5 The different configurations shown. Figure 5 The components shown can be implemented using hardware, software, or a combination thereof.

[0153] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 120, implements the user data extraction method disclosed in the above embodiments.

[0154] This invention also provides a program product that, when executed by processor 120, implements the user data extraction method disclosed in the above embodiments.

[0155] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0156] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0157] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0158] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for extracting user data, characterized in that, The method includes: Based on the user information, obtain the corresponding user data; the user information is used to characterize the users participating in the sample extraction. The number of samples to be selected is determined based on the total amount of data and the number of samples; the total amount of data refers to the total number of all user data; the number of samples refers to the total number of sample data. The process involves determining a step size based on the user data's index, offset, total data quantity, and number of items to be selected, and then determining a minimum and maximum index based on the step size, offset, total data quantity, and number of items to be selected. This includes: randomly generating the offset based on the total data quantity and number of items to be selected; determining a fixed tolerance based on the total data quantity and number of items to be selected when the user data's index exceeds the offset; determining a step size based on the user data's index, offset, and fixed tolerance; and determining the minimum and maximum indexes based on the step size, fixed tolerance, and offset. The offset represents the starting index of the user data to be selected. When the index of the user data is the minimum index or the maximum index, the selection state corresponding to the user data is set to selected; According to the selection status, the sample data is determined from the user data.

2. The user data extraction method according to claim 1, characterized in that, The process of determining the number of samples to be selected based on the total amount of data and the number of samples includes: When the total number of data is greater than the number of samples, the number of non-samples is obtained based on the difference between the total number of data and the number of samples. When the number of samples is less than the number of non-samples, the number of samples is determined as the number to be selected; When the number of samples is not less than the number of non-samples, the number of non-samples is determined as the number to be selected.

3. The user data extraction method according to claim 2, characterized in that, The step of determining the sample data from the user data according to the selection state includes: When the number of samples is less than the number of non-samples, the user data whose selection status is selected is determined as the sample data; When the number of samples is not less than the number of non-samples, the user data whose selection status is not selected is determined as the sample data.

4. The user data extraction method according to claim 1, characterized in that, The step of obtaining corresponding user data based on user information includes: The user information is retrieved concurrently from the extraction queue; the extraction queue is used to store user information corresponding to users participating in sample extraction. The corresponding user queue is determined based on the user information; the user information corresponds one-to-one with the user queue; the user queue is used to store the user data corresponding to the user information. The user queue is traversed to obtain all user data corresponding to the user information.

5. The user data extraction method according to claim 1, characterized in that, Before the step of obtaining the corresponding user data based on user information, the method further includes: Receive a user's sample extraction request; the sample extraction request includes the user identifier and the number of extractions; The user information is generated based on the user identifier, and the user information is added to the extraction queue; User data is generated based on the user identifier and the number of extractions, and the user data is added to the user queue.

6. The user data extraction method according to claim 5, characterized in that, The step of generating user data based on the user identifier and the number of extractions includes: When the sum of the current total number of extractions corresponding to the user identifier and the number of extractions does not exceed the extraction threshold, the minimum and maximum index values ​​corresponding to the sample extraction request are obtained based on the number of extractions. Based on the user identifier, the minimum index value, and the maximum index value, generate the user data corresponding to the sample extraction request.

7. A user data extraction device, characterized in that, The device includes: The acquisition module is used to acquire corresponding user data based on user information; the user information is used to characterize the users participating in the sample extraction. A processing module is used to determine the number of data to be selected based on the total number of data and the number of samples; the total number of data refers to the total number of all user data; the number of samples refers to the total number of sample data; the module determines a step size based on the index and offset of the user data, the total number of data, and the number of data to be selected, and determines a minimum index and a maximum index based on the step size, the offset, the total number of data, and the number of data to be selected, including: randomly generating the offset based on the total number of data and the number of data to be selected; when the index of the user data exceeds the offset, determining a fixed tolerance based on the total number of data and the number of data to be selected; determining a step size based on the index, the offset, and the fixed tolerance; determining the minimum index and the maximum index based on the step size, the fixed tolerance, and the offset; the offset represents the starting index of the user data to be selected; when the index of the user data is the minimum index or the maximum index, setting the selection state corresponding to the user data to be selected; An extraction module is used to determine the sample data from the user data according to the selection state.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the user data extraction method according to any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the user data extraction method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Data extracting method and device, electronic equipment and computer readable storage medium

    CN108399266A

  • Data retrieval method, system and device, electronic equipment and storage medium

    CN114398520A