Data processing method and device
By using the Flink framework in the risk control system to generate the time window of the smallest time unit for data aggregation, the problem of low timeliness of real-time data statistics in the existing technology is solved, and resource efficiency and timeliness are improved.
Patent Information
- Application Number
- CN202110918904.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-11
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-08-11
AI Technical Summary
In the real-time statistics and calculation tasks of data in the big data ecosystem, the timeliness of existing technologies is affected by resource consumption and large amounts of data, resulting in a reduction in the timeliness of data output.
By using the Flink framework in the risk control system, a time window with the smallest time unit is generated for data aggregation, reducing resource consumption and improving the timeliness of data output.
It achieves high resource efficiency, improves the timeliness of data output, and meets the timeliness needs of application scenarios such as real-time data analysis and anti-fraud.
Smart Images

Figure CN113609202B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a data processing method and device. Background Art
[0002] In the current big data ecosystem at home and abroad, companies have increasingly higher requirements for the timeliness of data. In application scenarios such as anti-fraud, anomaly detection, real-time data warehouse, and real-time data analysis, real-time statistics of data can provide accurate one-time state consistency guarantee, event time support, and state management features.
[0003] In the prior art, real-time statistics and calculation tasks for data are pre-set before the activity starts. Usually, when performing calculation tasks, different dimensions of time are set to start the corresponding time window to count the task data. For example, before the ranking activity starts, in order to prevent the existence of vote-rigging behavior, the risk control system sets four rules of 1 minute, 5 minutes, 1 hour, and 1 day. It is necessary to set time windows in four time dimensions of 1 minute, 5 minutes, 1 hour, and 1 day to analyze real-time task data. The larger the time span for data analysis, such as a time span of 1 hour or 1 day, more resources are required to store and count the intermediate data. The larger the time span, the more data needs to be stored, and the higher the resources consumed, which affects the timeliness of data output. Summary of the invention
[0004] In view of this, the present invention provides a data processing method, through which a time window is generated with a minimum time unit to aggregate data, thereby reducing resource consumption and improving the timeliness of data output.
[0005] The present invention also provides a data processing device to ensure the implementation and application of the above method in practice.
[0006] A data processing method, the method being applied to a risk control system, the method comprising:
[0007] When it is detected that the user sends an operation request corresponding to the target activity, a current event message corresponding to the operation request is generated, and the event message is added to a preset message queue. The Flink framework is applied to process each event message in sequence according to the order in which the event messages added to the message queue are added.
[0008] When the Flink framework processes the current event message, it obtains the latest updated rule information corresponding to the target activity in the preset rule library;
[0009] Associating the rule information with the event message to obtain completion information;
[0010] Determine the aggregation type corresponding to the rule information, and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to a preset minimum time unit;
[0011] Applying the current time window to aggregate the completion information according to the aggregation type to obtain an aggregation result, and persistently storing the aggregation result in a preset database;
[0012] When the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information is obtained, and the aggregation result is extracted from the database;
[0013] Determining whether the aggregation result complies with the activity rules;
[0014] When the aggregation result meets the activity rule, sending a request success message corresponding to the operation request to the user;
[0015] When the aggregation result does not conform to the activity rule, a request failure message corresponding to the operation request is sent to the user.
[0016] In the above method, optionally, the adding the event message to a preset message queue includes:
[0017] The event message is converted into an event message in json format, and the event message in the converted format is added to the message queue.
[0018] In the above method, optionally, associating the rule information with the event message to obtain the completion information includes:
[0019] Parsing the event message to obtain the event code contained in the event message;
[0020] Parsing the rule information to obtain the rule code contained in the rule information;
[0021] Detecting whether the event code is consistent with the rule code;
[0022] If the event code is consistent with the rule code, the event message is associated with the rule information to obtain the completion information.
[0023] In the above method, optionally, the step of persistently storing the aggregation result in a preset database includes:
[0024] Obtain each result field of the aggregation result;
[0025] Performing a hash operation on each of the result fields to obtain a key value of the aggregated result, where the key value is a unique identification code of the aggregated result;
[0026] Determine the database interface corresponding to the aggregation type;
[0027] The key value is associated with the aggregation result to obtain an associated result, and the associated result is stored in the database via the database interface.
[0028] In the above method, optionally, the determining whether the aggregation result complies with the activity rule includes:
[0029] Obtaining the parameter value range contained in the activity rule and the result parameter in the aggregation result;
[0030] Determine whether the result parameter is within the parameter value range;
[0031] If the result parameter is within the parameter value range, determining that the aggregation result satisfies the activity rule;
[0032] If the result parameter is not within the parameter value range, it is determined that the aggregation result does not satisfy the activity rule.
[0033] The above method may optionally further include:
[0034] Obtaining the activity cycle corresponding to the activity rule;
[0035] Determining whether the current time point is a critical time point of the activity cycle;
[0036] If the current time point is not a critical time point of the activity cycle, then based on the minimum time unit, continue to generate a time window for the next time point; when the user does not send an operation request corresponding to the target activity at the next time point, the time window for the next time point records the aggregated result of the current time window; when the user sends an operation request corresponding to the target activity again at the next time point, the time window for the next time point records the aggregated result corresponding to the operation request at the next time point;
[0037] If the current time point is a critical time point of the activity cycle, the aggregation results recorded in the current time window are cleared.
[0038] A data processing device, the device is applied to a risk control system, the device comprising:
[0039] The first generating unit is used to generate a current event message corresponding to the operation request when detecting that the user sends an operation request corresponding to the target activity, and add the event message to a preset message queue, and apply the Flink framework to process each event message in sequence according to the order in which the event messages added to the message queue are added;
[0040] A first acquisition unit is configured to acquire the most recently updated rule information corresponding to the target activity in a preset rule library when the Flink framework processes the current event message;
[0041] an associating unit, configured to associate the rule information with the event message to obtain complementary information;
[0042] A second generating unit is used to determine the aggregation type corresponding to the rule information and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to a preset minimum time unit;
[0043] an aggregation unit, configured to apply the current time window to aggregate the completion information according to the aggregation type, obtain an aggregation result, and persistently store the aggregation result in a preset database;
[0044] A second acquisition unit is configured to acquire, when the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information, and extract the aggregation result from the database;
[0045] A judging unit, used to judge whether the aggregation result complies with the activity rule;
[0046] A first sending unit, configured to send a request success message corresponding to the operation request to the user when the aggregation result meets the activity rule;
[0047] The second sending unit is used to send a request failure message corresponding to the operation request to the user when the aggregation result does not meet the activity rule.
[0048] In the above device, optionally, the first generating unit includes:
[0049] The conversion subunit is used to convert the event message into an event message in json format, and add the event message in the converted format to the message queue.
[0050] In the above device, optionally, the association unit includes:
[0051] A first parsing subunit, configured to parse the event message to obtain an event code contained in the event message;
[0052] A second parsing subunit, configured to parse the rule information to obtain a rule code contained in the rule information;
[0053] A detection subunit, used for detecting whether the event code is consistent with the rule code;
[0054] The associating subunit is used to associate the event message with the rule information to obtain the completion information if the event code is consistent with the rule code.
[0055] In the above device, optionally, the polymerization unit comprises:
[0056] A first acquisition subunit, used to acquire each result field of the aggregation result;
[0057] A calculation subunit, used for performing a hash operation on each of the result fields to obtain a key value of the aggregated result, where the key value is a unique identification code of the aggregated result;
[0058] A first determining subunit, used to determine a database interface corresponding to the aggregation type;
[0059] The storage subunit is used to associate the key value with the aggregation result, obtain the association result, and store the association result in the database via the database interface.
[0060] A storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned data processing method.
[0061] An electronic device includes a memory and one or more instructions, wherein the one or more instructions are stored in the memory and are configured to be executed by one or more processors to perform the above data processing method.
[0062] Compared with the prior art, the present invention has the following advantages:
[0063] The present invention provides a data processing method, comprising: when it is detected that a user sends an operation request corresponding to a target activity, generating a current event message corresponding to the operation request, and adding the event message to a preset message queue, applying the Flink framework to process each event message added to the message queue in the order in which each event message is added; when the Flink framework processes the current event message, obtaining the most recently updated rule information corresponding to the target activity in a preset rule library; associating the rule information with the event message to obtain completion information; determining the aggregation type corresponding to the rule information, and generating a current time window corresponding to the current time point; The risk control system generates a time window in real time according to the preset minimum time unit; applies the current time window to aggregate the completion information according to the aggregation type, obtains the aggregation result, and stores the aggregation result persistently in a preset database; when the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, obtains the activity rule corresponding to the target activity in the rule information, and extracts the aggregation result from the database; determines whether the aggregation result complies with the activity rule; when the aggregation result complies with the activity rule, sends the user a request success message corresponding to the operation request; when the aggregation result does not comply with the activity rule, sends the user a request failure message corresponding to the operation request. The method provided by the present invention is applied to generate a time window with the minimum time unit to aggregate data, reduce resource consumption, and improve the timeliness of data output. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0065] Figure 1 A method flow chart of a data processing method provided by an embodiment of the present invention;
[0066] Figure 2 A flowchart of another method of a data processing method provided by an embodiment of the present invention;
[0067] Figure 3 A flowchart of another method of a data processing method provided by an embodiment of the present invention;
[0068] Figure 4 A device structure diagram of a data processing device provided by an embodiment of the present invention;
[0069] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, the elements defined by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0072] The present invention can be used in many general or special computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or devices, etc.
[0073] The embodiment of the present invention provides a data processing method, which can be applied to a variety of system platforms, and its execution subject can be a risk control system. The method flow chart of the method is as follows: Figure 1 As shown, specifically including:
[0074] S101: When it is detected that a user sends an operation request corresponding to a target activity, a current event message corresponding to the operation request is generated, and the event message is added to a preset message queue. The Flink framework is applied to process each event message in sequence according to the order in which the event messages added to the message queue are added.
[0075] In the present invention, the event message includes multiple fields, each of which includes eventTime event time, eventCode rule model code, and fields is a field list Map structure customized by the access party. When a user participates in a target activity, a corresponding operation request can be issued according to the activity rules. The risk control system generates a corresponding current event message based on the operation request sent by the user.
[0076] For example, the target activity is a ranking activity. A user participates in the ranking activity and clicks to vote for a contestant. The user's terminal device sends an operation request based on the user's operation of clicking to vote, and the risk control system generates a current event message based on the request.
[0077] It should be noted that the message queue is used to store event messages. Each time an event message is generated, the event message is added to the message queue in sequence according to the event time. Each event message in the message queue is processed in sequence by Flink Kafka Consumer011 in the Flink framework. Flink Kafka Consumer011 is an instruction for consuming event messages.
[0078] Among them, the Flink framework is a streaming data flow execution engine framework set up in the risk control system. In the process of processing event messages, the event messages are processed as event streams.
[0079] Specifically, adding the event message to a preset message queue includes:
[0080] The event message is converted into an event message in json format, and the event message in the converted format is added to the message queue.
[0081] It is understandable that the message queue supports information in json format, so when the current event message is added to the message queue, the message format of the event message is changed to json format.
[0082] S102: When the Flink framework processes the current event message, the rule information corresponding to the target activity that is most recently updated in a preset rule library is obtained.
[0083] In the present invention, the rule base is used to store and update rules, and the backend operator formulates and updates the rules. The rule information includes active rules and multiple fields, each of which is eventCode rule model code, aggregateType aggregation type, searchIntervalType time slice type, searchIntervalValue time slice size, searchField aggregation business field, and functionField aggregation measurement field.
[0084] Specifically, since the Flink framework is a streaming data flow execution engine framework, after obtaining the latest rule information in the rule base, the rule information is used as a rule flow.
[0085] S103: Associating the rule information with the event message to obtain supplementary information.
[0086] In the present invention, the rule information and the event message are associated, and the obtained supplementary information includes all the fields of the event message and all the fields of the rule information.
[0087] Specifically, associating the rule information with the event message to obtain the completion information includes:
[0088] Parsing the event message to obtain the event code contained in the event message;
[0089] Parsing the rule information to obtain the rule code contained in the rule information;
[0090] Detecting whether the event code is consistent with the rule code;
[0091] If the event code is consistent with the rule code, the event message is associated with the rule information to obtain the completion information.
[0092] It should be noted that the event code is the eventCode in the event message, and the rule code is also the eventCode in the rule information. Check whether the two codes are consistent. If they are consistent, associate the event message and the rule, complete the rule information in the event message, and obtain the completed information. The completed information is used to characterize the occurrence of the activity event of the target activity and the rules corresponding to the event.
[0093] S104: Determine the aggregation type corresponding to the rule information, and generate a current time window corresponding to the current time point.
[0094] The risk control system generates a time window in real time according to a preset minimum time unit.
[0095] Specifically, the risk control system generates a time window corresponding to each user in real time according to the minimum time unit. For example, if the minimum time unit is 1s, the risk control system will generate a time window per second. When a user sends an operation request, the event message and the rule message are associated, and the current time window is generated according to the minimum time unit corresponding to the current time point.
[0096] S105: Apply the current time window to aggregate the completion information according to the aggregation type to obtain an aggregation result, and persistently store the aggregation result in a preset database.
[0097] In the present invention, the time window is a control for recording whether the operation event corresponding to the target activity occurs in the minimum time unit of the current time point. If the operation event corresponding to the target activity occurs, it is recorded and aggregated, otherwise, no operation is performed. The aggregated completion information is saved in the database Redis.
[0098] Specifically, the aggregation type includes multiple aggregation methods, and each aggregation method includes: counting, deduplication, summing, maximum value, minimum value, and average value.
[0099] Among them, the aggregation type and the aggregation method in the aggregation type are determined according to the rule information, and each aggregation method corresponds to an execution instruction. The count is accumulated using Redis's incrBy; the deduplication uses the HyperLogLog data structure to store the details, so as to achieve the deduplication of massive data with the least resource cost; the sum is accumulated using incrByFloat; the maximum and minimum values are stored in an ordered set data structure, and the score and member content are consistent when written, and the score is the maximum or minimum value of the smallest unit aggregation result; the average value uses a Hash structure to store a sum field and a total field, and accumulates according to the key dimension.
[0100] S106: When the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information is obtained, and the aggregation result is extracted from the database;
[0101] After the aggregation result is input into the database, the database writes it into a corresponding table according to the aggregation result, and the table records the aggregation result corresponding to at least one operation event related to the user including the aggregation result. When the aggregation result needs to be verified, the aggregation result is extracted from the database, and the activity rule in the rule information is obtained at the same time.
[0102] It should be noted that the activity rules include the activity period and parameter value range. For example, if the activity rule of the ranking activity is that the same user is only allowed to be ranked three times in one day, then the activity period is one day and the parameter value range is (0,3].
[0103] S107: Determine whether the aggregation result complies with the activity rules.
[0104] Specifically, when the aggregation result meets the activity rule, S108 is executed; when the aggregation result does not meet the activity rule, S109 is executed.
[0105] For example, a user participates in a ranking activity. The activity rule of the ranking activity is that the same user is only allowed to participate in the ranking three times within one day. The operation request currently sent by the user is the second ranking operation request, so the aggregation result of the time window is 2 times.
[0106] S108: Sending a request success message corresponding to the operation request to the user.
[0107] In the present invention, after the user's request is successful, the user is allowed to participate in the target activity, that is, the relevant operations of the target activity currently participated by the user are valid. For example, if a user participates in a ranking activity and performs a voting operation, and it is determined that the number of votes meets the activity rules, a voting success message is sent to the user.
[0108] S109: Sending a request failure message corresponding to the operation request to the user.
[0109] In the present invention, if the user request fails, the user's operation request is rejected, and the related operations of the target activity currently participating in are invalid. For example, if a user participates in a ranking activity and votes, and it is determined that the number of votes does not meet the activity rules, a voting failure message is sent to the user.
[0110] In the data processing method provided by the embodiment of the present invention, when the user sends an operation request corresponding to the target activity, a current event message corresponding to the operation request is generated. The current event message is added to the message queue, and the Flink framework in the application risk control system processes each event message in the message queue in turn according to the first-in-first-out principle. When the current event message needs to be processed, the rule information corresponding to the target activity in the rule library is obtained, and the rule information is associated with the event message to obtain the completion information. Determine the aggregation type corresponding to the rule information, and generate the current time window corresponding to the current time point at the same time. The completion information is aggregated according to the aggregation type by the currently generated time window to obtain the aggregation result. The aggregation result is stored in the database. When the trigger module triggers the execution instruction, the activity rule corresponding to the target activity in the rule information is obtained, the aggregation result of the target activity is extracted, and it is determined whether the aggregation result satisfies the activity rule. If so, a request success message is sent to the user, otherwise a request failure message is sent.
[0111] By applying the method provided in the embodiment of the present invention, a time window is generated with a minimum time unit to aggregate data, thereby reducing resource consumption and improving the timeliness of data output.
[0112] refer to Figure 2In the method provided by the embodiment of the present invention, based on the content of S105 above, the step of persistently storing the aggregation result in a pre-set database includes:
[0113] S201: Obtain each result field of the aggregation result.
[0114] In the present invention, each result field in the aggregation result includes: business field, aggregation time slice corresponding to the current time window, value, expiration time expire, and aggregation type aggregate Type.
[0115] S202: Perform a hash operation on each of the result fields to obtain a key value of the aggregated result.
[0116] The key value is a unique identification code of the aggregation result.
[0117] In the present invention, the key value of the database Redis is composed of aggregation time slices, business fields, and aggregation type dimensions. The aggregation time slices, business fields, and aggregation types are hashed to obtain the key value.
[0118] S203: Determine the database interface corresponding to the aggregation type.
[0119] In the present invention, different aggregation types correspond to different database interfaces, and the aggregation results are saved to the database through different database interfaces.
[0120] S204: Associating the key value with the aggregation result to obtain an associated result, and storing the associated result in the database via the database interface.
[0121] In the present invention, the key value is associated with the aggregation result, and the association result is stored in the database via the database interface. The database is provided with an information table, and the information table uses the key as the index information of the aggregation result. When the aggregation result needs to be checked, the corresponding aggregation result is found by the key.
[0122] In the method provided by the embodiment of the present invention, the aggregation result field is hashed to obtain the key, and the database interface Redis API for inputting the aggregation result into the database for storage is determined according to the aggregation type. The key and the aggregation result are associated, and the associated association result is stored in the database through the database interface.
[0123] By applying the method provided in the embodiment of the present invention, a key corresponding to the aggregation result is generated, and the corresponding aggregation result is searched through the key, thereby shortening the data query time.
[0124] refer to Figure 3In the method provided by the embodiment of the present invention, based on the content of S107 above, the step of judging whether the aggregation result complies with the activity rule includes:
[0125] S301: Obtain the parameter value range contained in the activity rule and the result parameter in the aggregation result.
[0126] In the present invention, in each field of the aggregation result, value is a result parameter, which can be a parameter obtained by accumulating, summing, averaging, taking the maximum value or the minimum value of the completed parameters.
[0127] S302: Determine whether the result parameter is within the parameter value range.
[0128] In the present invention, if the result parameter is within the parameter value range, S303 is executed; if the result parameter is not within the parameter value range, S304 is executed.
[0129] S303: Determine whether the aggregation result satisfies the activity rule.
[0130] S304: Determine that the aggregation result does not satisfy the activity rule.
[0131] In the method provided in the embodiment of the present invention, an aggregation method in the aggregation type corresponding to the activity rule, each aggregation method of the aggregation type is accumulation, summation, average value, maximum value and minimum value, etc. For example, if the aggregation method corresponding to the activity rule is accumulation, then the parameter value range of the activity rule is (0, N], where N is the maximum value that can be accumulated. Therefore, in the process of determining whether the aggregation result meets the activity result, the structural parameters in the aggregation result and the parameter value range specified in the activity rule are obtained. If the result parameter is within the value range, the aggregation result meets the activity rule, otherwise it does not meet the activity rule.
[0132] Based on the method provided in the above embodiment, there are the following specific embodiments:
[0133] The target activity that the user participates in is a shooting game. The game stipulates that the user can only click and shoot 10 times per second at most. When the user clicks and shoots within one second, an event message corresponding to the user's click and shoot is generated and the event message is associated with the game regulations to generate completion information. According to the aggregation type, the aggregation method is selected as summation. The time window calculates the total number of times the user clicks and shoots within one second, and generates the corresponding aggregation result, which includes the total number of shootings. Determine whether the number of shootings exceeds 10 times. If it does not exceed, it indicates that the user is shooting normally and the current shooting is valid; if it exceeds, it is determined that the user may use plug-ins or other cheating auxiliary means, and the current shooting is invalid.
[0134] Furthermore, when the risk control system generates a time window based on the minimum time unit, it records each aggregation result according to the set time period, which is the activity cycle set by the activity rules. For example, in a voting activity, it is stipulated that each user can only vote once a day. Then the risk control system will generate a time window corresponding to each user in real time according to the minimum time unit within a day, so as to record whether the user corresponding to the time window at the current moment generates an event message of the target activity through each generated time window.
[0135] Based on the method provided in the above embodiment, the embodiment of the present invention further includes:
[0136] Obtaining the activity cycle corresponding to the activity rule;
[0137] Determining whether the current time point is a critical time point of the activity cycle;
[0138] If the current time point is not a critical time point of the activity cycle, then based on the minimum time unit, continue to generate a time window for the next time point; when the user does not send an operation request corresponding to the target activity at the next time point, the time window for the next time point records the aggregated result of the current time window; when the user sends an operation request corresponding to the target activity again at the next time point, the time window for the next time point records the aggregated result corresponding to the operation request at the next time point;
[0139] If the current time point is a critical time point of the activity cycle, the aggregation results recorded in the current time window are cleared.
[0140] It should be noted that the current time point corresponding to the current time window is a time point of a minimum time unit in the activity cycle. According to the activity cycle, it is determined whether the current time point is a critical time point of the activity cycle, that is, whether the activity cycle is to end or enter the next activity cycle. If not, the next time window is generated according to the minimum time unit when the next time point arrives. After the next time window is generated, it is determined whether an event message of the user operating the target activity occurs. If yes, the risk control system continues to execute the above-mentioned process from S101 to S109, and the next generated time window records the aggregation result of the next time point. The aggregation result of the next time point is related to the aggregation result of the current time point. The aggregation of the next time point is the result of statistics on the aggregation result of the current time; if not, the next generated time window will not make any record, and the aggregation result corresponding to the next time point is empty, and inherits the existing aggregation result of the previous time window. If the current time point is a critical time point of the activity cycle, the aggregation result recorded in the current time window corresponding to the current time point is deleted, and after entering the next activity cycle, the time window continues to be generated in real time according to the minimum time unit.
[0141] Based on the method provided in the above embodiment, another embodiment of the present invention is:
[0142] The user participates in the ranking activity and clicks on the ranking in the terminal device, and the terminal device generates an event message based on the user's click operation. The risk control system adds the event message to the message queue. When the risk control system processes the event message in the message queue, it obtains the rule information of the ranking activity, and associates the event message with the rule information to obtain the completed information. Among them, the rule information terminal activity rule is that the same user or the same device ID can only be ranked 5 times in a day. The risk control system generates the current time window corresponding to the current time point. The current time window accumulates the user's current ranking operation as the 6th time, then the corresponding structure is entered into the database for storage, and after judgment, it is determined that the user's click to the ranking has failed. At the same time, the risk control system determines whether the current time point is the critical time point of the activity cycle based on the activity cycle of 1 day, such as whether the current time point is 23:59:59. If it is the critical time point, the accumulated number of times in the current time window will be cleared, and the number will be counted again after entering the next activity cycle; if it is not the critical time point, the risk control system will generate the next time window at the next time point after the current time point; if the user is on the list again at the next time point, the accumulated number of times in the next time window will be 7 times; if the user is not on the list at the next time point, the accumulated number of times recorded in the next time window will still be 6 times.
[0143] By applying the method provided in the embodiment of the present invention, a minimum time window is generated in real time to aggregate data, thereby reducing resource consumption and improving the timeliness of data output.
[0144] The specific implementation processes and derivative methods of the above-mentioned embodiments are all within the protection scope of the present invention.
[0145] and Figure 1 Corresponding to the method described above, the embodiment of the present invention further provides a data processing device for Figure 1 In the specific implementation of the method, the data processing device provided in the embodiment of the present invention can be used in the risk control system, and its structural diagram is as follows Figure 4 As shown, specifically including:
[0146] The first generating unit 401 is used to generate a current event message corresponding to the operation request when detecting that the user sends an operation request corresponding to the target activity, and add the event message to a preset message queue, and apply the Flink framework to process each event message in sequence according to the order in which the event messages added to the message queue are added;
[0147] A first acquisition unit 402 is configured to acquire the latest updated rule information corresponding to the target activity in a preset rule base when the Flink framework processes the current event message;
[0148] An associating unit 403 is used to associate the rule information with the event message to obtain supplementary information;
[0149] The second generating unit 404 is used to determine the aggregation type corresponding to the rule information, and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to the preset minimum time unit;
[0150] An aggregation unit 405 is used to apply the current time window to aggregate the completion information according to the aggregation type to obtain an aggregation result, and store the aggregation result persistently in a preset database;
[0151] A second acquisition unit 406 is configured to acquire the activity rule corresponding to the target activity in the rule information and extract the aggregation result from the database when the trigger module in the risk control system triggers the execution instruction corresponding to the operation request;
[0152] A judging unit 407 is used to judge whether the aggregation result complies with the activity rule;
[0153] A first sending unit 408, configured to send a request success message corresponding to the operation request to the user when the aggregation result meets the activity rule;
[0154] The second sending unit 409 is configured to send a request failure message corresponding to the operation request to the user when the aggregation result does not conform to the activity rule.
[0155] In the data processing device provided by the embodiment of the present invention, when the user sends an operation request corresponding to the target activity, a current event message corresponding to the operation request is generated. The current event message is added to the message queue, and the Flink framework in the application risk control system processes each event message in the message queue in turn according to the first-in-first-out principle. When the current event message needs to be processed, the rule information corresponding to the target activity in the rule library is obtained, and the rule information is associated with the event message to obtain the completion information. Determine the aggregation type corresponding to the rule information, and generate the current time window corresponding to the current time point at the same time. The completion information is aggregated according to the aggregation type by the currently generated time window to obtain the aggregation result. The aggregation result is stored in the database, and the trigger module triggers the execution instruction to obtain the activity rule corresponding to the target activity in the rule information, extract the aggregation result of the target activity, and determine whether the aggregation result satisfies the activity rule. If so, a request success message is sent to the user, otherwise a request failure message is sent.
[0156] By using the device provided in the embodiment of the present invention, a time window is generated with a minimum time unit to aggregate data, thereby reducing resource consumption and improving the timeliness of data output.
[0157] In the device provided by the embodiment of the present invention, the first generating unit includes:
[0158] The conversion subunit is used to convert the event message into an event message in json format, and add the event message in the converted format to the message queue.
[0159] In the device provided by the embodiment of the present invention, the association unit includes:
[0160] A first parsing subunit, configured to parse the event message to obtain an event code contained in the event message;
[0161] A second parsing subunit, configured to parse the rule information to obtain a rule code contained in the rule information;
[0162] A detection subunit, used for detecting whether the event code is consistent with the rule code;
[0163] The associating subunit is used to associate the event message with the rule information to obtain the completion information if the event code is consistent with the rule code.
[0164] In the device provided by the embodiment of the present invention, the aggregation unit includes:
[0165] A first acquisition subunit, used to acquire each result field of the aggregation result;
[0166] A calculation subunit, used for performing a hash operation on each of the result fields to obtain a key value of the aggregated result, where the key value is a unique identification code of the aggregated result;
[0167] A first determining subunit, used to determine a database interface corresponding to the aggregation type;
[0168] The storage subunit is used to associate the key value with the aggregation result, obtain the association result, and store the association result in the database via the database interface.
[0169] In the device provided by the embodiment of the present invention, the judging unit includes:
[0170] A second acquisition subunit is used to acquire the parameter value range contained in the activity rule and the result parameter in the aggregation result;
[0171] A first judging subunit, used to judge whether the result parameter is within the parameter value range;
[0172] A second determining subunit, configured to determine that the aggregation result satisfies the activity rule if the result parameter is within the parameter value range;
[0173] The third determining subunit is used to determine that the aggregation result does not satisfy the activity rule if the result parameter is not within the parameter value range.
[0174] The device provided in the embodiment of the present invention further includes:
[0175] A third acquisition subunit is used to acquire the activity cycle period corresponding to the activity rule;
[0176] A second judging subunit, used to judge whether the current time point is a critical time point of the activity cycle;
[0177] The first execution subunit is used to continue to generate a time window for a next time point based on the minimum time unit if the current time point is not a critical time point of the activity cycle; when the user does not send an operation request corresponding to the target activity at the next time point, the time window for the next time point records the aggregated result of the current time window; when the user sends an operation request corresponding to the target activity again at the next time point, the time window for the next time point records the aggregated result corresponding to the operation request at the next time point;
[0178] The second execution subunit is used to clear the aggregation results recorded in the current time window if the current time point is a critical time point of the activity cycle.
[0179] For the specific working process of each unit and sub-unit in the data processing device disclosed in the above embodiment of the present invention, reference can be made to the corresponding content in the data processing method disclosed in the above embodiment of the present invention, and will not be repeated here.
[0180] An embodiment of the present invention further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned data processing method.
[0181] The embodiment of the present invention further provides an electronic device, the structural diagram of which is shown in FIG. Figure 5 As shown, it specifically includes a memory 501 and one or more instructions 502, wherein the one or more instructions 502 are stored in the memory 501 and are configured to be executed by one or more processors 503 to perform the following operations:
[0182] When it is detected that the user sends an operation request corresponding to the target activity, a current event message corresponding to the operation request is generated, and the event message is added to a preset message queue. The Flink framework is applied to process each event message in sequence according to the order in which the event messages added to the message queue are added.
[0183] When the Flink framework processes the current event message, it obtains the latest updated rule information corresponding to the target activity in the preset rule library;
[0184] Associating the rule information with the event message to obtain completion information;
[0185] Determine the aggregation type corresponding to the rule information, and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to the preset minimum time unit;
[0186] Applying the current time window to aggregate the completion information according to the aggregation type to obtain an aggregation result, and persistently storing the aggregation result in a preset database;
[0187] When the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information is obtained, and the aggregation result is extracted from the database;
[0188] Determining whether the aggregation result complies with the activity rules;
[0189] When the aggregation result meets the activity rule, sending a request success message corresponding to the operation request to the user;
[0190] When the aggregation result does not conform to the activity rule, a request failure message corresponding to the operation request is sent to the user.
[0191] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0192] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, computer software, or a combination of both.
[0193] In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0194] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data processing method, characterized in that: The method is applied to a risk control system, and includes: When a user sends an operation request corresponding to the target activity, a current event message corresponding to the operation request is generated and added to a pre-set message queue. The Flink framework is then applied to process each event message in the order in which they were added to the message queue. When the Flink framework processes the current event message, it obtains the latest updated rule information corresponding to the target activity from the pre-set rule library. The rule information includes multiple fields, namely, the rule model, aggregation type, time slice type, time slice size, aggregation business field, and aggregation metric field. Parsing the event message to obtain the event code contained in the event message; Parsing the rule information to obtain the rule code contained in the rule information; Detecting whether the event code is consistent with the rule code; If the event code is consistent with the rule code, the event message is associated with the rule information to obtain the completion information; Determine the aggregation type corresponding to the rule information and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to a preset minimum time unit, and the aggregation type includes multiple aggregation methods, each of which includes counting, deduplication, summing, maximum value, minimum value, and average value; Applying the current time window to aggregate the completion information according to the aggregation type to obtain an aggregation result, and persistently storing the aggregation result in a pre-set database; When the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information is obtained, and the aggregation result is extracted from the database; Determining whether the aggregation result complies with the activity rules; When the aggregation result meets the activity rule, sending a request success message corresponding to the operation request to the user; When the aggregation result does not comply with the activity rule, sending a request failure message corresponding to the operation request to the user; Obtaining the activity cycle corresponding to the activity rule; Determining whether the current time point is a critical time point of the activity cycle; If the current time point is not a critical time point of the activity cycle, then based on the minimum time unit, continue to generate a time window for the next time point; when the user does not send an operation request corresponding to the target activity at the next time point, the time window for the next time point records the aggregated result of the current time window; when the user sends an operation request corresponding to the target activity again at the next time point, the time window for the next time point records the aggregated result corresponding to the operation request at the next time point; If the current time point is a critical time point of the activity cycle, the aggregation results recorded in the current time window are cleared.
2. The method according to claim 1, characterized in that The step of adding the event message to a preset message queue includes: The event message is converted into an event message in JSON format, and the event message in the converted format is added to the message queue.
3. The method according to claim 1, characterized in that The step of persistently storing the aggregation result in a preset database includes: Obtain each result field of the aggregation result; Performing a hash operation on each of the result fields to obtain a key value of the aggregated result, where the key value is a unique identification code of the aggregated result; Determine the database interface corresponding to the aggregation type; The key value is associated with the aggregation result to obtain an associated result, and the associated result is stored in the database via the database interface.
4. The method according to claim 3, characterized in that The determining whether the aggregation result complies with the activity rule includes: Obtaining the parameter value range contained in the activity rule and the result parameter in the aggregation result; Determine whether the result parameter is within the parameter value range; If the result parameter is within the parameter value range, determining that the aggregation result satisfies the activity rule; If the result parameter is not within the parameter value range, it is determined that the aggregation result does not meet the activity rule.
5. A data processing device, characterized in that: The device is applied to a wind control system and includes: The first generating unit is configured to, upon detecting that a user sends an operation request corresponding to a target activity, generate a current event message corresponding to the operation request, add the event message to a pre-set message queue, and apply the Flink framework to process each event message in the order in which they were added to the message queue. A first acquisition unit is configured to, when the Flink framework processes the current event message, acquire the most recently updated rule information corresponding to the target activity from a preset rule library, wherein the rule information includes multiple fields, namely, a rule model, an aggregation type, a time slice type, a time slice size, an aggregated business field, and an aggregated metric field; an associating unit, configured to associate the rule information with the event message to obtain complementary information; A second generating unit is configured to determine an aggregation type corresponding to the rule information and generate a current time window corresponding to the current time point; the risk control system generates the time window in real time according to a preset minimum time unit, the aggregation type includes multiple aggregation methods, and each aggregation method includes counting, deduplication, summing, maximum value, minimum value, and average value; an aggregation unit, configured to apply the current time window to aggregate the completion information according to the aggregation type, obtain an aggregation result, and persistently store the aggregation result in a pre-set database; a second acquiring unit, configured to acquire, when the trigger module in the risk control system triggers the execution instruction corresponding to the operation request, the activity rule corresponding to the target activity in the rule information, and extract the aggregated result from the database; A judging unit, configured to judge whether the aggregation result complies with the activity rules; A first sending unit, configured to send a request success message corresponding to the operation request to the user when the aggregation result meets the activity rule; a second sending unit, configured to send a request failure message corresponding to the operation request to the user when the aggregation result does not comply with the activity rule; The association unit includes: a first parsing subunit, configured to parse the event message and obtain an event code contained in the event message; a second parsing subunit, configured to parse the rule information and obtain a rule code contained in the rule information; a detection subunit, configured to detect whether the event code is consistent with the rule code; an associating subunit, configured to associate the event message with the rule information to obtain completion information if the event code is consistent with the rule code; The device further comprises: A third acquisition subunit is used to obtain the activity cycle period corresponding to the activity rule; A second judging subunit is configured to judge whether the current time point is a critical time point of the activity cycle; The first execution sub-unit is configured to, if the current time point is not a critical time point of the activity cycle, continue to generate a time window for a next time point based on the minimum time unit; when the user does not send an operation request corresponding to the target activity at the next time point, the time window for the next time point records the aggregated result of the current time window; when the user sends an operation request corresponding to the target activity again at the next time point, the time window for the next time point records the aggregated result corresponding to the operation request at the next time point; The second execution subunit is configured to clear the aggregation results recorded in the current time window if the current time point is a critical time point of the activity cycle.
6. The device according to claim 5, characterized in that The first generating unit includes: The conversion subunit is used to convert the event message into an event message in JSON format, and add the event message in the converted format to the message queue.
7. The device according to claim 5, characterized in that The polymer unit comprises: A first acquisition subunit is used to acquire each result field of the aggregation result; A calculation subunit, configured to perform a hash operation on each of the result fields to obtain a key value of the aggregated result, where the key value is a unique identification code of the aggregated result; A first determining subunit is used to determine a database interface corresponding to the aggregation type; The storage subunit is used to associate the key value with the aggregation result, obtain the association result, and store the association result in the database via the database interface.
