Dynamic user group generation method and apparatus, and storage medium
By listening to user change events and determining the scope of impact, dynamic user groups are generated using a full or incremental update strategy. This solves the problems of low real-time performance and efficiency in generating dynamic user groups in existing technologies, and achieves real-time updates and resource optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 中建三局信息科技有限公司
- Filing Date
- 2025-09-17
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies for generating dynamic user groups suffer from low real-time performance and efficiency, cannot respond to changes in user status in real time, rely on professional technicians, lack flexibility, cause delays in user group member relationships, and consume large amounts of computing resources.
By monitoring user change events, determining the scope of impact, and using full or incremental update strategies to generate dynamic user groups, including monitoring user change events, determining the scope of impact, and executing optimized SQL queries in parallel or performing incremental calculations in memory, the redundant calculations and resource consumption can be reduced.
It enables real-time updates of dynamic user groups, improves the real-time performance and efficiency of generating dynamic user groups, reduces system resource consumption, and ensures the consistency and accuracy of user groups and conditional expressions.
Smart Images

Figure CN121166705B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and specifically to a method, apparatus, and storage medium for generating dynamic user groups. Background Technology
[0002] A user group is a set of users that meet the same set of characteristics. Its members are automatically added or removed as the underlying data changes, without manual intervention. In enterprise IT scenarios, it is often necessary to dynamically select specific objects from entities such as users, roles, or organizations based on configured conditions for operations such as authorization, message push, and permission verification. Dynamic user groups are particularly important for improving fine-grained and precise access control of entities.
[0003] In related technologies, dynamic user groups are typically computed based on batch processing, where the system is pre-configured with fixed conditions. However, this method of filtering user groups based on fixed conditions cannot respond to changes in user status in real time, resulting in lag in user group membership relationships and poor flexibility. Changes to conditions require developer intervention, making it unsuitable for non-technical users to customize and quickly configure. Furthermore, batch processing usually requires repeated scanning and computation of full or large-scale user data. When the number of users is large (e.g., tens of millions), it puts heavy pressure on the database and computing cluster, has long execution cycles, and consumes significant storage I / O and computing resources.
[0004] Therefore, it can be seen that the dynamic user group generation scheme in the relevant technology relies on professional technicians, has poor flexibility, and cannot calculate dynamic user groups in real time, which reduces the real-time performance and efficiency of generating dynamic user groups. Summary of the Invention
[0005] In view of this, it is necessary to provide a method, apparatus and storage medium for generating dynamic user groups to solve the technical problems of low real-time performance and efficiency in generating dynamic user groups in the prior art, and the inconvenience of dynamic user group management.
[0006] To address the aforementioned technical problems, in a first aspect, the present invention provides a method for generating dynamic user groups, comprising: Listen for user change events in the current user group; Determine the scope of impact of the current user group affected by the execution of the user change event; If the scope of influence is greater than a preset range, the current user group is fully updated to generate a dynamic user group; If the scope of influence is less than or equal to the preset scope, the current user group within the scope of influence is incrementally updated based on the user change event to generate a dynamic user group.
[0007] In one possible implementation, the current user group is configured with user characteristic conditional expressions; determining the scope of influence of the current user group affected by the user change event includes: Obtain the event field value carried in the user change event; Substitute the event field value into the user characteristic condition expression and perform a Boolean operation to obtain a Boolean result; The range of the current user group corresponding to the user characteristic condition expression that affects the flipping of the Boolean result or the Boolean result being true is determined as the range of influence.
[0008] In one possible implementation, when the scope of influence exceeds a preset range, performing a full update on the current user group to obtain a dynamic user group includes: Based on the mapping relationship between the user feature condition expression and the preset database table, the user feature condition expression is converted into multiple SQL query statements; The SQL query statement is subjected to structured optimization processing to generate multiple optimized SQL query statements; In the database corresponding to the SQL query statement, each of the optimized SQL query statements is executed in parallel to generate the dynamic user group.
[0009] In one possible implementation, the structured optimization process includes at least one of the following: Remove invalid and conflicting conditions from the SQL query statement; The join operation in the SQL query statement that does not need to return column data in the preset database table is converted into a semi-join in the WHERE clause; Before executing the multi-table join operation in the SQL query statement, the database tables in the preset database tables that meet the preset filtering conditions are filtered. Store the high-frequency subqueries in the SQL query statement that are reused more than the threshold into a temporary table; Adjust the execution order of the SQL query statements so that the database table with fewer rows drives the database table with more rows; The deep pagination in the SQL query statement uses an ID cursor pagination mechanism; The SQL query statements are cached, and cached items whose execution time exceeds a preset time threshold are marked for manual optimization. Visualize the SQL queries whose execution cost is higher than a preset cost.
[0010] In one possible implementation, the incremental update of the current user group within the affected scope based on the user change event to generate a dynamic user group includes: Obtain the memory condition expression corresponding to the current user group within the scope of influence; Recursively traverse the Boolean values corresponding to the memory condition expression; Based on the Boolean value, the current user group within the scope of influence is incrementally updated to generate a dynamic user group.
[0011] In one possible implementation, the step of incrementally updating the current user group within the scope of influence based on the Boolean value to generate a dynamic user group includes: The repeated expressions and corresponding intermediate results in the memory condition expressions corresponding to the current user group under the influence range are cached to obtain cached data. Using a short-circuit judgment method, the current user group within the scope of influence is calculated based on the Boolean value and the cached data to obtain the calculation result; The memory condition expression for the current user group in the calculation result is split into multiple sub-expressions; The dynamic user group is generated by batch calculating multiple sub-expressions using a multi-threaded or parallel streaming approach.
[0012] In one possible implementation, after generating the dynamic user group, the following is also included: The dynamic user group is fully updated using a timed scheduler.
[0013] In one possible implementation, after generating the dynamic user group, the following is also included: Based on the difference between the dynamic user group and the current user group, a corresponding user group change event is published.
[0014] Secondly, the present invention also provides a dynamic user group generation apparatus, comprising: The listening unit is used to listen for user change events in the current user group. A determining unit is configured to determine the scope of influence of the current user group affected by the execution of the user change event; The first update unit is used to perform a full update on the current user group and generate a dynamic user group when the scope of influence is greater than a preset range. The second update unit is used to incrementally update the current user group under the influence range based on the user change event when the influence range is less than or equal to the preset range, thereby generating a dynamic user group.
[0015] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein the memory is used to store a program; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the dynamic user group generation method described in any of the above implementations.
[0016] Fourthly, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, can implement the steps of the dynamic user group generation method described in any of the above implementations.
[0017] The beneficial effects of this invention are: The dynamic user group generation method provided by this invention monitors user change events in the current user group and captures real-time changes in the attributes or status of the current user group. This enables the immediate triggering of subsequent dynamic user group calculations based on an event-driven mechanism, effectively avoiding the response delay problem of traditional batch processing methods and achieving real-time updates of the current user group. Furthermore, it determines the scope of influence of user change events on the current user group. By determining the scope of influence, the degree of impact of user change events on the current user group can be quantified, allowing for the use of appropriate update methods to recalculate the current user group based on the degree of influence. It also ensures that user groups within the current user group affected by user change events are re-evaluated, thereby avoiding unnecessary calculations and data processing and reducing system resource consumption. This improves the efficiency of dynamic user group updates and enables greater flexibility in updating the current user group. When the impact range exceeds a preset range, a full update of the current user group is performed to generate a dynamic user group, ensuring a comprehensive update of the current users and improving the consistency and accuracy between the dynamic user group and its corresponding conditional expression. When the impact range is less than or equal to a preset range, incremental updates of the current user group within the impact range are performed based on user change events to generate a dynamic user group. This avoids a full scan and redundant calculation of the current user group, reducing computational complexity and execution time, improving the efficiency and real-time performance of updating the current user group, enhancing the real-time performance and efficiency of generating dynamic user groups, and improving the efficiency of dynamic user group management. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1A schematic flowchart of an embodiment of the dynamic user group generation method provided by the present invention; Figure 2 For the present invention Figure 1 A schematic diagram of an embodiment of S102; Figure 3 For the present invention Figure 1 A schematic diagram of an embodiment of S103; Figure 4 A schematic diagram of an embodiment of the dynamic user group generation device provided by the present invention; Figure 5 A schematic diagram of an embodiment of the electronic device provided by the present invention. Detailed Implementation
[0020] 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 a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0021] In the description of the embodiments of the present invention, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0022] The terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature.
[0023] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0024] The execution subject of the dynamic user group generation method in this application embodiment can be the dynamic user group generation device provided in this application embodiment, or different types of electronic devices such as server equipment, physical host, or user equipment (UE) that integrate the dynamic user group generation device. The dynamic user group generation device can be implemented in hardware or software. The UE can specifically be a terminal device such as a smartphone, tablet computer, laptop computer, handheld computer, desktop computer, or personal digital assistant (PDA).
[0025] This invention provides a method, apparatus, and storage medium for generating dynamic user groups, which will be described below.
[0026] Figure 1 This is a schematic flowchart of an embodiment of the dynamic user group generation method provided by the present invention, as shown below. Figure 1 As shown, the dynamic user group generation method includes: S101, Listen for user change events in the current user group.
[0027] In this context, the current user group refers to user groups that are not currently being updated. In this embodiment, a user group refers to a set of users determined according to predefined user group rules. These rules can be based on user attributes (such as department, job level, geographical location, etc.), behaviors (such as login frequency, etc.), or other business logic. For example, in one application scenario, an alert could be issued to users in Company A whose position is manager; in this scenario, the current user group would be the set of users in Company A whose position is manager.
[0028] User change events refer to events that occur when user information, such as user attributes or status, changes within the current user group. These include, but are not limited to, updates to user information (such as name, contact information, job title changes, etc.), recording of user behavior (such as login, purchase, browsing, etc.), and adjustments to user permissions. User change events can be published to the event bus or message queue in the form of messages for monitoring.
[0029] Specifically, by connecting with an event center (such as Kafka, RocketMQ, etc.), it can listen for user change events in the current user group, thereby capturing real-time changes in the attributes or status of the current user group. This enables the immediate triggering of subsequent dynamic user group calculations based on an event-driven mechanism, effectively avoiding the response delay problem of traditional batch processing methods and achieving real-time updates of the current user group.
[0030] S102. Determine the scope of influence of the current user group affected by the execution of the user change event.
[0031] The scope of influence of the current user group refers to the set of users in the current user group affected by the current user change event when the user change event occurs. In other words, it refers to the set of all users in the user group that need to be recalculated according to the rules (conditional expressions) of the current user group when the user change event occurs. For example, users directly affected by the user change event (such as users whose attributes are modified), users who have a relationship or dependency with the directly affected users (users in the same department or project group), and other users who meet or no longer meet the user group rules due to changes in the rule conditions.
[0032] Specifically, the impact range of the user change event on the current user group can be determined by matching and calculating the conditional expression corresponding to the user change event. By determining the impact range, the degree of impact of the user change event on the current user group can be quantified. This allows for the use of appropriate update methods to recalculate the current user group based on the degree of impact. It also ensures that user groups within the current user group affected by the user change event are re-evaluated, thereby avoiding unnecessary calculations and data processing, reducing system resource consumption, improving the efficiency of dynamic user group updates, and achieving flexibility in updating the current user group.
[0033] S103. If the scope of influence is greater than a preset range, perform a full update on the current user group to generate a dynamic user group.
[0034] The preset range is a critical value that is set in advance to measure the extent of the impact. The amount of user data affected can be determined based on the total amount of data in the current user group. For example, the preset range can be 90% of the total amount of data in the current user group.
[0035] Dynamic user groups refer to user groups generated after the current user group is dynamically updated in real time following the detection of user change events.
[0036] Specifically, when the scope of impact is greater than the preset range, it indicates that the amount of user data affected in the current user group is large, that is, the number of user groups that need to be recalculated is large, and the impact of the user change event is wide enough. Therefore, performing a full update on the current user group can ensure a comprehensive update of the current users and improve the consistency and accuracy between the dynamic user group and the corresponding conditional expression.
[0037] S104. If the scope of influence is less than or equal to the preset scope, the current user group under the scope of influence is incrementally updated based on the user change event to generate a dynamic user group.
[0038] Specifically, when the affected range is less than or equal to the preset range, it indicates that the amount of user data affected in the current user group is small, meaning that the number of user groups that need to be recalculated is small. Therefore, an incremental update strategy is adopted to update only the affected user groups, avoiding a full scan and repeated calculation of the current user group, reducing computational complexity and execution time, improving the update efficiency and real-time performance of the current user group, improving the real-time performance and efficiency of generating dynamic user groups, and improving the management efficiency of dynamic user groups.
[0039] In summary, the dynamic user group generation method provided by this invention monitors user change events of the current user group and captures real-time changes in the attributes or status of the current user group. This enables the immediate triggering of subsequent dynamic user group calculations based on an event-driven mechanism, effectively avoiding the response delay problem of traditional batch processing methods and achieving real-time updates of the current user group. Furthermore, it determines the scope of influence of the user change event on the current user group. By determining the scope of influence, the degree of impact of the user change event on the current user group can be quantified, allowing for the use of appropriate update methods to recalculate the current user group based on the degree of influence. It also ensures that user groups within the current user group affected by the user change event are re-evaluated, thereby avoiding unnecessary calculations and data processing and reducing system resources. This approach reduces resource consumption, improves the efficiency of dynamic user group updates, and enables greater flexibility in updating the current user group. When the impact range exceeds a preset range, a full update of the current user group is performed to generate a dynamic user group, ensuring a comprehensive update of the current user group and improving the consistency and accuracy between the dynamic user group and its corresponding conditional expression. When the impact range is less than or equal to a preset range, incremental updates of the current user group within the impact range are performed based on user change events to generate a dynamic user group. This avoids a full scan and redundant calculation of the current user group, reducing computational complexity and execution time, improving the efficiency and real-time performance of updating the current user group, and enhancing the real-time performance and efficiency of generating dynamic user groups, thereby improving the efficiency of dynamic user group management.
[0040] In one specific implementation, user behavior events or attribute changes are collected in real time through data tracking or system integration, and these events are reported to a message queue or event bus. The collected user change events are filtered in real time to identify characteristic events that meet predefined conditions or affect the current user group status. Based on the field information carried by the event, associated dynamic user group rules are matched, and the set of rules that need to be recalculated is filtered. Based on the event content and rule conditions, the specific users or organizational units that may be affected are located from the user data table. Based on the affected rules and data, incremental condition matching is performed on the relevant users or organizations, user group affiliation is updated in real time, and the change results are stored for subsequent authorization or push notifications.
[0041] In some embodiments of the present invention, such as Figure 2 As shown, the current user group is configured with user characteristic condition expressions; step S102 includes: S201. Obtain the event field value carried in the user change event; S202. Substitute the event field value into the user feature condition expression and perform a Boolean operation to obtain a Boolean result; S203. The range of the current user group corresponding to the user feature condition expression that affects the flipping of the Boolean result or the Boolean result being true is determined as the range of influence.
[0042] The current user group is configured with user characteristic condition expressions, which are logical expressions used to define the qualifications of user group members. These expressions can be composed of a series of conditions, including user attributes (such as name, age, job title, etc.) and specific values or ranges of these attributes.
[0043] Event field values refer to specific data values associated with user change events, used to describe the characteristics of user change events and to trigger further processing or calculations.
[0044] Specifically, since the Boolean result remains unchanged, it indicates that it is not affected by the user change event and no recalculation is required. When the Boolean result flips or changes from false to true, it indicates that it is affected by the user change event. Only then will the user corresponding to the user change event be added to or removed from the dynamic user group. Therefore, the range of the current user group corresponding to the user feature condition expression that affects the Boolean result flipping or the Boolean result being true is determined as the scope of influence. Understandably, in this embodiment, the scope of influence is determined by matching the user feature condition expression of the current user group with the event field value of the user change event and determining the scope of influence based on the matching result. This achieves automated determination of the scope of influence and improves the efficiency of determining the scope of influence.
[0045] In one specific implementation, the scope of impact is determined as follows: Real-time monitoring of user-related behavioral events (such as user registration, login, information modification, and behavior records) is used, and user change events are generated upon event triggering. Then, an event center is used to uniformly collect, distribute, and buffer user change events, ensuring reliable event transmission, asynchronous processing, and scalability. Next, conditional expressions are configured for the stored and managed current user groups, including table names, field names, matching conditions, and combinational logic, and can be centrally managed and updated in real-time through the configuration center. Upon receiving a user change event, the amount of data related to the affected users, i.e., the scope of impact, is calculated based on the conditional expressions.
[0046] In some embodiments of the present invention, such as Figure 3 As shown, step S103 includes: S301. Based on the mapping relationship between the user feature condition expression and the preset database table, convert the user feature condition expression into multiple SQL query statements; S302. Perform structured optimization processing on the SQL query statement to generate multiple optimized SQL query statements; S303. In the database corresponding to the SQL query statement, each of the optimized SQL query statements is executed in parallel to generate the dynamic user group.
[0047] SQL (Structured Query Language) query statements refer to instructions that transform user records obtained from user characteristic condition expressions retrieved from pre-defined database tables.
[0048] Specifically, when the image range is large, the user feature condition expression is converted into multiple SQL query statements based on the mapping relationship between the user feature condition expression and the preset database table. This allows for rapid calculation of the current user group through distributed parallel execution of multiple SQL query statements. The SQL query statements are then structured and optimized to generate multiple optimized SQL query statements, improving execution efficiency and reducing computational resource consumption. Each optimized SQL query statement is executed in parallel within the database corresponding to the SQL query statements, further increasing the generation speed of dynamically generated groups. In this embodiment, a distributed batch computation method based on SQL is used to perform a full update of the current user group. Compared to traditional annotations, this distributed computation method based on SQL significantly improves the speed of the full update by handling complex user feature condition expressions.
[0049] In one specific implementation, based on user change events, a distributed batch computing method based on SQL is adopted. The database cluster executes optimized SQL query statements in parallel. Specifically, this involves: reading all user characteristic condition expressions of the current user group, parsing and preprocessing them; dynamically converting the condition expressions into executable SQL query statements based on the definition of the user characteristic condition expressions and the mapping relationship between fields and database tables; performing structured optimization on the generated SQL and executing the SQL in parallel to obtain the calculation results.
[0050] It is worth noting that the generated dynamic data group can also be compared with the current user group, and the storage can be modified according to the comparison results. That is, the new calculation results are compared with the historical results, and the incrementally added, reduced or changed user records are stored differently for subsequent authorization, message push and other uses.
[0051] In some embodiments of the present invention, the structured optimization process in step S102 includes at least one of the following: S401. Remove invalid and conflicting conditions from the SQL query statement; S402. Convert the join operation in the SQL query statement that does not need to return column data in the preset database table into a semi-join in the WHERE clause; S403. Before executing the multi-table join operation in the SQL query statement, filter the database tables in the preset database tables that meet the preset filtering conditions. S404. Store the high-frequency subqueries in the SQL query statement that have been reused more than the threshold into a temporary table; S405. Adjust the execution order of the SQL query statements so that the database table with fewer rows drives the database table with more rows; S406. The deep pagination in the SQL query statement adopts the ID cursor pagination mechanism; S407. Cache the SQL query statement and mark the cached items in the SQL query statement whose execution time exceeds a preset time threshold for manual optimization; S408. Visualize the SQL query statements whose execution cost is higher than the preset cost.
[0052] Specifically, removing invalid and conflicting conditions from SQL query statements can avoid invalid calculations and improve execution efficiency; converting JOIN operations in SQL query statements that do not need to return column data from a preset database table into semi-joins or EXISTS conditions in the WHERE clause can eliminate redundant JOIN nodes. Before multi-table joins, pushdownable filtering conditions are encapsulated into derived tables to pre-reduce intermediate result sets. For high-frequency subqueries reused more than a threshold within the same rule set, session-level temporary tables are automatically created and indexed for subsequent reuse. Based on cost estimation results, the dimension table with the fewest rows is selected as the driving table, and STRAIGHT_JOIN hints are used to fix the execution plan, enabling a small table to drive a large table. For deep pagination scenarios, the LIMIT offset method is abandoned, and cursor pagination based on the last largest sort key is adopted, making pagination performance independent of page depth. The parsed SQL template is hashed and cached, and manual marking is triggered when the execution time exceeds a preset threshold for subsequent indexing or rewriting optimization. For long-term large rules with an average execution time greater than the second threshold and an update frequency lower than the third threshold, materialized views are automatically created and atomically refreshed after the full validation task is completed, trading space for time. By optimizing SQL query statements, the SQL query statements are optimized, computational resource consumption is reduced, and the accuracy and efficiency of dynamic user group calculations are improved.
[0053] In some embodiments of the present invention, step S104 includes: S501. Obtain the memory condition expression corresponding to the current user group under the influence range; S502. Recursively traverse the Boolean values corresponding to the memory condition expression; S503. Based on the Boolean value, incrementally update the current user group under the influence range to generate a dynamic user group.
[0054] In-memory condition expressions are conditional expressions constructed and processed in memory. They are used to evaluate in real time whether a user qualifies for a specific user group. They consist of a series of logical operators (such as AND, OR, NOT) and conditions (such as attribute value comparisons), organized in a tree structure in memory for rapid evaluation and updating. These in-memory condition expressions are compiled and stored in memory according to the user group definition for quick access and evaluation.
[0055] Specifically, when the impact range is small, the memory condition expression for the current user group corresponding to the impact range is retrieved from memory. This memory condition expression is then recursively traversed, and a Boolean value is evaluated for each node. Based on the Boolean value evaluation result, the user groups within the impact range are incrementally updated. By processing the condition expression in memory, access to the database or file system is reduced, thereby lowering system resource consumption. Furthermore, it enables rapid response to user group changes, achieving real-time updates of user groups. Incremental updates dynamically adjust only the changed parts, reducing unnecessary calculations for user groups and significantly improving the efficiency and accuracy of generating dynamic user groups.
[0056] It is worth noting that dynamically generated groups can also be queried in the database standby using a deeply optimized pagination method, avoiding a full scan and redundant calculation of the database master, and significantly reducing the consumption of database and computing resources.
[0057] In some embodiments of the present invention, step S503 includes: S601. Cache the repeated expressions and corresponding intermediate results in the memory condition expressions corresponding to the current user group under the influence range to obtain cached data; S602. Using a short-circuit judgment method, calculate the current user group under the influence range based on the Boolean value and the cached data to obtain the calculation result; S603. The memory condition expression for the current user group in the calculation result is split into multiple sub-expressions; S604. Using a multi-threaded or parallel streaming approach, perform batch calculations on multiple sub-expressions to generate the dynamic user group.
[0058] Specifically, duplicate expressions and their intermediate results in the memory condition expression corresponding to the current user group within the affected scope are cached to obtain cached data, avoiding redundant calculations. A short-circuit judgment method is used to calculate the current user group within the affected scope based on Boolean values and the cached data, obtaining calculation results and quickly skipping non-compliant branches to reduce invalid matching calculations. The memory condition expression corresponding to the current user group in the calculation results is split into multiple sub-expressions. A multi-threaded or parallel streaming approach is used to batch calculate multiple sub-expressions, generating dynamic user groups, fully utilizing CPU resources, and improving the execution efficiency of incremental calculations. Through cached data and short-circuit methods, the logic in incremental calculations is specifically optimized, effectively improving computational efficiency and the real-time performance of user group calculation results.
[0059] In some embodiments of the present invention, after step S103 or step S104, the method further includes: S701. Perform a full update of the dynamic user group through a timed scheduler.
[0060] Specifically, during periods of low system access pressure (such as off-peak hours at night), a timed scheduler, such as XXLJOB, can be used to perform a full update of dynamic user groups. This enables a full data consistency check of all dynamic user groups, ensuring the consistency between the user group status and the corresponding conditional expressions during long-term operation.
[0061] In some embodiments of the present invention, after step S103 or step S104, the method further includes: S801. Based on the difference between the dynamic user group and the current user group, publish the corresponding user group change event.
[0062] Specifically, based on the difference between the dynamic user group and the current user group, a corresponding user group change event is published. The user group change event is published to the event bus or message queue for downstream systems or services to subscribe to and respond to, such as for subsequent authorization or push usage. It is naturally adapted to microservice and streaming processing scenarios, and is easy to link with existing big data analysis, real-time risk control and other systems. It has good scalability and system compatibility.
[0063] To better implement the dynamic user group generation method in the embodiments of the present invention, based on the dynamic user group generation method, the corresponding method is as follows: Figure 4 As shown, this embodiment of the invention also provides a dynamic user group generation device, the dynamic user group generation device 400 comprising: Listening unit 401 is used to listen for user change events in the current user group; The determining unit 402 is used to determine the scope of influence of the current user group affected by the execution of the user change event; The first update unit 403 is used to perform a full update on the current user group and generate a dynamic user group when the scope of influence is greater than a preset range. The second update unit 404 is used to incrementally update the current user group under the influence range based on the user change event when the influence range is less than or equal to the preset range, thereby generating a dynamic user group.
[0064] The dynamic user group generation device 400 provided in the above embodiments can implement the technical solutions described in the above dynamic user group generation method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above dynamic user group generation method embodiments, and will not be repeated here.
[0065] like Figure 5 As shown, the present invention also provides an electronic device 500. The electronic device 500 includes a processor 501, a memory 502, and a display 503. Figure 5 Only some components of the electronic device 500 are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0066] In some embodiments, processor 501 may be a central processing unit (CPU), microprocessor, or other data processing chip, used to run program code stored in memory 502 or process data, such as the dynamic user group generation method of the present invention.
[0067] In some embodiments, processor 501 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 501 may be local or remote. In some embodiments, processor 501 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, inter-cloud, multi-cloud, or any combination thereof.
[0068] In some embodiments, memory 502 may be an internal storage unit of electronic device 500, such as a hard disk or memory of electronic device 500. In other embodiments, memory 502 may also be an external storage device of electronic device 500, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on electronic device 500.
[0069] Furthermore, the memory 502 may include both internal storage units of the electronic device 500 and external storage devices. The memory 502 is used to store application software and various types of data installed on the electronic device 500.
[0070] In some embodiments, display 503 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 503 is used to display information from electronic device 500 and to display a visual user interface. Components 501-503 of electronic device 500 communicate with each other via a system bus.
[0071] In one embodiment, when processor 501 executes the dynamic user group generation program in memory 502, the following steps may be implemented: Listen for user change events in the current user group; Determine the scope of impact of the current user group affected by the execution of the user change event; If the scope of influence is greater than a preset range, the current user group is fully updated to generate a dynamic user group; If the scope of influence is less than or equal to the preset scope, the current user group within the scope of influence is incrementally updated based on the user change event to generate a dynamic user group.
[0072] It should be understood that when the processor 501 executes the dynamic user group generation program in the memory 502, in addition to the functions mentioned above, it can also perform other functions, as detailed in the description of the corresponding method embodiments above.
[0073] Furthermore, this embodiment of the invention does not specifically limit the type of electronic device 500 mentioned. Electronic device 500 can be a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, or other portable electronic device. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic device can also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the invention, electronic device 500 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0074] Accordingly, this application also provides a computer-readable storage medium for storing a computer-readable program or instruction. When the program or instruction is executed by a processor, it can implement the steps or functions of the dynamic user group generation method provided in the above-described method embodiments.
[0075] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.), and the computer program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0076] The dynamic user group generation method, apparatus, and storage medium provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for generating dynamic user groups, characterized in that, include: Listen for user change events in the current user group, where the current user group is configured with user characteristic condition expressions; Obtain the event field value carried in the user change event; Substitute the event field value into the user characteristic condition expression and perform a Boolean operation to obtain a Boolean result; The range of the current user group corresponding to the user feature condition expression that causes the Boolean result to be flipped is determined as the scope of influence. If the scope of influence is greater than a preset range, the current user group is fully updated to generate a dynamic user group; If the scope of influence is less than or equal to the preset scope, the current user group within the scope of influence is incrementally updated based on the user change event to generate a dynamic user group.
2. The dynamic user group generation method according to claim 1, characterized in that, When the scope of influence exceeds a preset range, a full update is performed on the current user group to obtain a dynamic user group, including: Based on the mapping relationship between the user feature condition expression and the preset database table, the user feature condition expression is converted into multiple SQL query statements; The SQL query statement is subjected to structured optimization processing to generate multiple optimized SQL query statements; In the database corresponding to the SQL query statement, each of the optimized SQL query statements is executed in parallel to generate the dynamic user group.
3. The dynamic user group generation method according to claim 2, characterized in that, The structured optimization process includes at least one of the following: Remove invalid and conflicting conditions from the SQL query statement; The join operation in the SQL query statement that does not need to return column data in the preset database table is converted into a semi-join in the WHERE clause; Before executing the multi-table join operation in the SQL query statement, the database tables in the preset database tables that meet the preset filtering conditions are filtered. Store the high-frequency subqueries in the SQL query statement that are reused more than the threshold into a temporary table; Adjust the execution order of the SQL query statements so that the database table with fewer rows drives the database table with more rows; The deep pagination in the SQL query statement uses an ID cursor pagination mechanism; The SQL query statements are cached, and cached items whose execution time exceeds a preset time threshold are marked for manual optimization. Visualize the SQL queries whose execution cost is higher than a preset cost.
4. The dynamic user group generation method according to claim 2, characterized in that, The step of incrementally updating the current user group within the affected scope based on the user change event to generate a dynamic user group includes: Obtain the memory condition expression corresponding to the current user group within the scope of influence; Recursively traverse the Boolean values corresponding to the memory condition expression; Based on the Boolean value, the current user group within the scope of influence is incrementally updated to generate a dynamic user group.
5. The dynamic user group generation method according to claim 4, characterized in that, The step of incrementally updating the current user group within the scope of influence based on the Boolean value to generate a dynamic user group includes: The repeated expressions and corresponding intermediate results in the memory condition expressions corresponding to the current user group under the influence range are cached to obtain cached data. Using a short-circuit judgment method, the current user group within the scope of influence is calculated based on the Boolean value and the cached data to obtain the calculation result; The memory condition expression for the current user group in the calculation result is split into multiple sub-expressions; The dynamic user group is generated by batch calculating multiple sub-expressions using a multi-threaded or parallel streaming approach.
6. The dynamic user group generation method according to claim 1, characterized in that, Following the generation of dynamic user groups, the following is also included: The dynamic user group is fully updated using a timed scheduler.
7. The dynamic user group generation method according to claim 1, characterized in that, Following the generation of dynamic user groups, the following is also included: Based on the difference between the dynamic user group and the current user group, a corresponding user group change event is published.
8. A dynamic user group generation device, characterized in that, include: The listening unit is used to listen for user change events in the current user group, wherein the current user group is configured with user characteristic condition expressions. The determining unit is used to obtain the event field value carried in the user change event; Substitute the event field value into the user characteristic condition expression and perform a Boolean operation to obtain a Boolean result; The range of the current user group corresponding to the user feature condition expression that causes the Boolean result to be flipped is determined as the scope of influence. The first update unit is used to perform a full update on the current user group and generate a dynamic user group when the scope of influence is greater than a preset range. The second update unit is used to incrementally update the current user group under the influence range based on the user change event when the influence range is less than or equal to the preset range, thereby generating a dynamic user group.
9. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the dynamic user group generation method according to any one of claims 1 to 7.