Data query method and device supporting multi-valued screening, equipment and medium
By triggering the AOP section in the SQL statement, splitting and executing query tasks with multi-value parameters concurrently, and using virtual or operating system thread pool processing, the query performance problems caused by large amounts of values in the SQL IN statement are solved, and query speed and system development efficiency are improved.
Patent Information
- Application Number
- CN202510898240.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-08-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When SQL statements contain a large number of values, it will cause excessive database query burden, excessive memory consumption, reduced query speed and even errors, especially on development platforms that do not support virtual threads.
By triggering the AOP section in the data query method, identifying multi-value parameters, splitting them into multiple subsets, and performing query subtasks concurrently, using the virtual thread pool or operating system thread pool for concurrent processing, and combining the results, and sending them to a custom or default return value processor for logical processing.
It effectively reduces the database query burden, improves query speed, avoids error reporting, and is compatible with different development platforms without modifying the original code, improving the development efficiency and flexibility of the system.
Smart Images

Figure CN120407626A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data query, and in particular, to a data query method, device, equipment and medium supporting multi-value screening. Background Art
[0002] SQL (Structured Query Language) is a standard language for managing relational databases, used to perform operations such as data query, update, insertion, and deletion. The IN statement is a conditional expression in SQL for screening data, used to determine whether the value of a certain field belongs to a specified set.
[0003] When the SQL statement contains an IN statement and the IN statement contains a large number of values, it will increase the query burden on the database, and may also cause problems such as excessive memory consumption and decreased query speed. Even in some databases, it will directly report an error because there are too many screened values. Summary of the Invention
[0004] The present invention provides a data query method, device, equipment and medium supporting multi-value screening, which can be adapted to programs developed based on different types of development platforms, reduce the amount of data queried in a single thread, and improve the query efficiency.
[0005] According to one aspect of the present invention, there is provided a data query method supporting multi-value screening, including:
[0006] When the program executes to the data query method marked with the first annotation, trigger the AOP aspect to execute the logic within the AOP aspect; wherein, the program is generated based on the first type of development platform or the second type of development platform;
[0007] In the data query method, identify the multi-value parameter marked with the second annotation and obtain the set size of the multi-value parameter;
[0008] According to the preset batch size and the set size, split the multi-value parameter into multiple subsets;
[0009] Generate multiple query subtasks according to the split subsets, and submit the query subtasks to the target thread pool for concurrent execution;
[0010] Merge the query results returned by each thread, obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0011] According to another aspect of the present invention, there is provided a data query device supporting multi-value screening, including:
[0012] An AOP aspect trigger module, which is used to trigger an AOP aspect when the program executes a data query method marked with a first annotation, so as to execute the logic within the AOP aspect; wherein, the program is generated based on a first type of development platform or a second type of development platform;
[0013] A multi-value parameter recognition module, which is used to recognize multi-value parameters marked with a second annotation within a data query method and obtain the set size of the multi-value parameters;
[0014] A parameter splitting module, which is used to split the multi-value parameters into multiple subsets according to a preset batch size and the set size;
[0015] A concurrent query module, which is used to generate multiple query subtasks according to the split subsets and submit the query subtasks to a target thread pool for concurrent execution;
[0016] A return value processing module, which is used to merge the query results returned by each thread, obtain a target query result, and send the target query result to a target return value processor for the target return value processor to perform logical processing on the target query result.
[0017] According to another aspect of the present invention, there is provided an electronic device, and the electronic device includes:
[0018] At least one processor;
[0019] And a memory communicatively connected to the at least one processor;
[0020] Wherein, the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data query method supporting multi-value screening according to any embodiment of the present invention.
[0021] According to another aspect of the present invention, there is provided a computer-readable storage medium, and the computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the data query method supporting multi-value screening according to any embodiment of the present invention when executed by a processor.
[0022] The technical solution of the embodiment of the present invention can separate cross-cutting concerns from the core business logic of the program by triggering the AOP aspect when the program executes the data query method marked with the first annotation and executing the logic within the AOP aspect. Without modifying the original code of the data query method, it can uniformly manage the function of splitting multi-valued parameters and generating query subtasks for concurrent execution, reduce code redundancy, and make the business logic clearer. Different processing methods can be provided for different data query methods according to different annotation parameters configured in the first annotation attribute, which is compatible with programs generated based on the first type of development platform and the second type of development platform. By identifying the multi-valued parameters marked with the second annotation in the data query method, obtaining the set size of the multi-valued parameters, splitting the multi-valued parameters into multiple subsets according to the preset batch size and the set size, generating multiple query subtasks based on the split subsets, and submitting the query subtasks to the target thread pool for concurrent execution, it avoids the query burden on the database in the prior art when the SQL IN statement contains a large number of values, improves the query speed through multi-threaded concurrent execution, and tries to avoid errors. Moreover, for programs that have been developed based on the second type of development platform, multi-threaded concurrent execution of data queries can also be achieved without modifying the original code, alleviating the problem of low query efficiency caused by screening a large number of values as much as possible. By merging the query results returned by each thread to obtain the target query result and sending the target query result to the target return value processor, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Moreover, the custom return value processor can support the implementation of complex services, effectively improving the development efficiency of the system.
[0023] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0025] Figure 1 It is a flowchart of a data query method supporting multi-valued screening according to Embodiment 1 of the present invention;
[0026] Figure 2It is a flowchart of another data query method supporting multi-value screening provided by Embodiment 2 of the present invention;
[0027] Figure 3 It is a flowchart of another data query method supporting multi-value screening provided by Embodiment 3 of the present invention;
[0028] Figure 4 It is a schematic structural diagram of a data query device supporting multi-value screening provided by Embodiment 4 of the present invention;
[0029] Figure 5 It is a schematic structural diagram of an electronic device implementing the data query method supporting multi-value screening of the embodiments of the present invention. Detailed implementation manners
[0030] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data used may be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] Figure 1 It is a flowchart of a data query method supporting multi-value screening provided by Embodiment 1 of the present invention. This embodiment is applicable to the case of splitting multi-value parameters included in an SQL IN statement, so as to perform data query using multi-threaded concurrency. This method can be executed by a data query device supporting multi-value screening. The data query device supporting multi-value screening can be implemented in the form of hardware and / or software, and is generally configured in a computer or processor with data processing capabilities. As Figure 1 shown, the method includes:
[0034] S110. When the program executes to the data query method marked with the first annotation, an AOP aspect is triggered to execute the logic within the AOP aspect.
[0035] Among them, the program is generated based on the first type of development platform or the second type of development platform; the first type of development platform is a development platform that can support virtual threads and manage virtual threads, such as JDK 21 (Java SE 21), and JDK 21 is one of the versions of the JAVA Development Kit, which can support and manage virtual threads; the second type of development platform is a development platform that does not support virtual threads, such as JDK 8, JDK 11, JDK 17, etc., but is not limited thereto.
[0036] The advantage of this setting is that it does not limit the data query function that supports multi-value filtering to only the development platforms that support virtual threads, but can also be compatible with the second type of development platform, enabling traditional development platforms that do not support virtual threads to also solve the problem of excessive values in the SQL IN statement through the same method.
[0037] Among them, the data query method includes a SQL IN statement, and the SQL IN statement includes multi-value parameters. The IN statement is an operator in SQL, and its purpose is to filter data in the WHERE clause to determine whether the value of a certain field exists in the given value list.
[0038] In an optional example, the SQL IN statement can be, for example:
[0039] SELECT * FROM customers; WHERE NAME = 'Zhang San'; AND ADDRESS IN ('AAA', 'BBB', …, 'ZZZ');
[0040] Among them, ADRESS can be used as a multi-value parameter. For example, ADRESS can include 10,000 parameters for filtering.
[0041] Optionally, AOP (Aspect-Oriented Programming) is a programming paradigm used to separate cross-cutting concerns from business logic, thereby improving the modularity and maintainability of the code.
[0042] Optionally, the first annotation can be a custom annotation. For example, the custom annotation SplitIn is used as the first annotation, and the attributes of the first annotation are configured with a thread pool name (poolName), a batch size (size), and a configured return value handler (ResultHandler); the thread pool name is used to specify the thread pool for executing the split data query task, the batch size is used to specify the number of multi-value parameters that can be processed at a time in each thread, and the return value handler is used to further process the results obtained from the data query. The specific parameters of the thread pool name, batch size, and return value handler configured in the attributes of the first annotation can be applied to the logic within the AOP aspect.
[0043] Optionally, the first annotation can be marked on the data query method that needs to split multi-value parameters. The first annotation can be used as the entry point of the AOP aspect, that is, bind the first annotation to the AOP aspect. When the program executes to the data query method, the AOP aspect is triggered to execute the logic inside the AOP aspect.
[0044] The advantage of this setting is that: the cross-cutting concerns can be separated from the core business logic of the program, and the function of splitting multi-value parameters and generating query subtasks for concurrent execution can be uniformly managed without modifying the original code of the data query method. Moreover, by adding the first annotation to the data query method, different processing methods can be provided for different data query methods according to the different annotation parameters configured in the attributes of the first annotation. By setting the AOP aspect, code redundancy can be reduced and the business logic can be made clearer.
[0045] Optionally, the logic inside the AOP aspect is used to split the multi-value parameters according to the batch size, generate multiple query subtasks according to the split results, send the query subtasks to the thread pool for execution, and finally merge the query results returned by all threads and send them to the specified return value handler for further processing. That is, steps S120 - S150 can be the processing logic inside the AOP aspect.
[0046] S120. Inside the data query method, identify the multi-value parameters marked with the second annotation and obtain the set size of the multi-value parameters.
[0047] Optionally, the second annotation can be a custom annotation. For example, the second annotation can be batchFiled. The second annotation is marked on the multi-value parameters that need to be processed in the data query method. The second annotation is only marked on the data query method marked with the first annotation. The second annotation is used to specify the specific parameters that need to be split. Thus, when the internal logic of the AOP aspect is executed, the multi-value parameters that need to be split can be determined according to the position where the second annotation is located.
[0048] Continuing with the previous example, when the parameters in the SQL IN statement include NAME and ADRESS, and ADRESS contains a large number of values, at this time, the second annotation can be marked on ADRESS, so that when the second annotation is recognized, it is determined that the ADRESS parameter needs to be split.
[0049] Optionally, the set size of the multi-value parameter can refer to the actual number of values contained in the multi-value parameter in the SQL IN statement. For example, ADRESS can include 10,000 parameters for screening, then the set size is 10,000. This is only for illustrative purposes here.
[0050] S130. Split the multi-value parameter into multiple subsets according to the preset batch size and set size.
[0051] Optionally, according to the batch size, the multi-value parameter can be split. Specifically, subsets can be divided starting from the first element of the multi-value parameter set, and the number of elements in each subset is equal to the batch size. When the number of remaining elements is less than or equal to the batch size, the remaining parameter values are grouped into one subset to end the subset division. For example, if the batch size is 100 and the multi-value parameter set has 500 elements, it will be split into 5 subsets, with 100 elements in each subset.
[0052] S140. Generate multiple query subtasks according to the split subsets, and submit the query subtasks to the target thread pool for concurrent execution.
[0053] Optionally, each query subtask includes an SQL IN statement, and each subset obtained by splitting is used as the multi-value parameter in the SQL IN statement of the query subtask, so that each query subtask meets the batch size requirement.
[0054] It can be understood that a process is the basic unit for the operating system to allocate and schedule resources, and a thread is the execution unit in a process. For traditional operating system-level threads, threads need to be mapped to processes in the operating system. If thread switching is to be performed, it is actually a process switch in the operating system. Thread switching must pass through the scheduler in the kernel mode. Even for thread switching within the same process, it is necessary to enter the kernel mode. After the kernel completes the context switch and then returns to the user mode, which leads to the need for switching between the kernel mode and the user mode when traditional operating system-level threads switch. Frequent switching will cause a large amount of CPU time to be consumed on state saving and restoration, rather than on actual business logic. Especially in high-concurrency scenarios, the performance will decline to a certain extent.
[0055] Furthermore, to avoid frequent switching between the kernel mode and the user mode, the present invention proposes to develop a program containing SQL IN statements based on the first type of development platform. Thus, by virtue of the characteristics of the first type of development platform, virtual threads are used to concurrently execute data query operations. Although when the program is generated based on JAVA development toolkits such as JDK 8, JDK 11, and JDK 17, virtual threads are not supported, the present invention is still compatible with programs generated based on the second type of development platform. Although it is necessary to perform switching between operating system-level threads, it can also effectively solve the query performance problem caused by a large number of values in the SQL IN statement.
[0056] Optionally, when the program is generated based on the first type of development platform, since the first type of development platform can support and maintain virtual threads, the target thread pool is a virtual thread pool; while the second type of development platform does not support virtual threads. Therefore, when the program is generated based on the second type of development platform, the target thread pool is a traditional operating system-level thread.
[0057] Optionally, when the program is generated based on the first type of development platform, it can be determined whether a valid virtual thread pool name has been injected into the attributes of the first annotation. If so, the corresponding virtual thread pool is determined as the target thread pool according to the virtual thread pool name in the attributes of the first annotation; if not, the pre-created default virtual thread pool is directly determined as the target thread pool.
[0058] Optionally, when the program is generated based on the second type of development platform, virtual threads cannot be generated under the second type of development platform. Therefore, it is necessary to obtain a valid operating system-level thread pool name in the attributes of the first annotation. If it can be obtained, the target thread pool is directly determined according to the operating system-level thread pool name. Otherwise, concurrent data query operations cannot be performed, the aspect logic may not be entered, and an error handling is performed.
[0059] The advantage of such a setting is that it avoids the query burden on the database in the prior art when the SQL IN statement contains a large number of values, improves the query speed through the multi-threaded concurrent execution method, and tries to avoid errors. Moreover, for programs that have been developed based on the second type of development platform, multi-threaded concurrent execution of data queries can also be achieved without modifying the original code, and the problem of low query efficiency caused by screening a large number of values is alleviated as much as possible.
[0060] S150. Merge the query results returned by each thread to obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0061] Among them, after triggering the AOP aspect, it may further include:
[0062] Determine whether the attributes of the first annotation contain a custom return value processor;
[0063] If so, obtain an instance of the custom return value processor in the container as the target return value processor;
[0064] If not, obtain an instance of the default return value processor in the container as the target return value processor.
[0065] Optionally, the AOP aspect is implemented based on the Spring framework, and the container can be used to implement functions such as reading configurations to create Bean instances and maintaining dependencies between Beans.
[0066] Optionally, if a custom return value processor is pre-injected into the attributes of the first annotation, directly use the custom return value processor to perform a query operation on the query result. The custom return value processor prescribes the data processing methods in advance, such as sorting, deduplication, normalization, etc., but this is not limited here.
[0067] The advantage of this setting is that it is friendly to the subsequent development and maintenance process. If it is necessary to adjust the data processing logic, only the implementation class of the corresponding return value processor needs to be modified, without large-scale modification, improving the development efficiency.
[0068] Furthermore, a default return value processor class can be pre-implemented in the container, that is, an instance of the default return value processor is created. If a custom return value processor is not injected into the attributes of the first annotation, use the default return value processor to receive and process the target query result. The specific data processing logic of the default return value processor can be specified by defining the default return value processor class. For example, the default return value processor can directly return the target query result to the caller without any additional processing operations on the target query result. The default return value processor can also pre-set specified processing methods and return the processing result to the caller, which is not limited here.
[0069] Optionally, determine the target return value processor according to the injection situation of the return value processor value in the attributes of the first annotation, and send the merged target query result to the target return value processor. The target return value processor can process the target query result according to its specified data processing logic and return the final query result obtained after processing to the caller.
[0070] Optionally, the purpose of configuring the return value processor in the attributes of the first annotation is as follows: Since different data query methods may correspond to different business logics, based on the requirements of the business itself, after obtaining the query results from the database, different businesses may need to appropriately process the query results. By configuring the return value processor in the attributes of the first annotation, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Moreover, the custom return value processor can support the implementation of complex businesses, effectively improving the development efficiency of the system.
[0071] The technical solution of the embodiment of the present invention can separate the cross-cutting concerns from the core business logic of the program by triggering the AOP aspect and executing the logic within the AOP aspect when the program executes to the data query method marked with the first annotation. This allows for the unified management of the function of splitting multi-valued parameters and generating query subtasks for concurrent execution without modifying the original code of the data query method, reducing code redundancy and making the business logic clearer. Different processing methods can be provided for different data query methods according to different annotation parameters configured in the attributes of the first annotation, which is compatible with programs generated based on the first type of development platform and the second type of development platform. By identifying the multi-valued parameters marked with the second annotation within the data query method, obtaining the set size of the multi-valued parameters, splitting the multi-valued parameters into multiple subsets according to the preset batch size and the set size, generating multiple query subtasks based on the split subsets, and submitting the query subtasks to the target thread pool for concurrent execution, the query burden on the database caused by a large number of values in the SQL IN statement in the prior art can be avoided. The query speed can be increased through multi-threaded concurrent execution, and errors can be avoided as much as possible. Moreover, for programs that have been developed based on the second type of development platform, multi-threaded concurrent execution of data queries can also be achieved without modifying the original code, alleviating the problem of low query efficiency caused by screening a large number of values as much as possible. By merging the query results returned by each thread, obtaining the target query result, and sending the target query result to the target return value processor, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Moreover, the custom return value processor can support the implementation of complex businesses, effectively improving the development efficiency of the system.
[0072] Embodiment 2
[0073] Figure 2It is a flowchart of a data query method supporting multi-value screening provided in the second embodiment of the present invention. Based on the above embodiment, this embodiment specifically illustrates the process of executing the data query method supporting multi-value screening in a program developed based on the first type of platform. As Figure 2 shown, the method includes:
[0074] S210. When the program executes the data query method marked with the first annotation, trigger the AOP aspect to execute the logic within the AOP aspect.
[0075] Optionally, steps S230 - S290 can be the logic within the AOP aspect.
[0076] S220. When the program executes the data query method marked with the first annotation, create a default virtual thread pool.
[0077] It can be understood that when the program is generated based on the first type of development platform, the first type of development platform supports and can manage virtual threads, and the actual consumption of creating a virtual thread pool is very small. Therefore, regardless of whether the thread pool name has been injected into the first annotation, a virtual thread pool can be pre-created, thereby improving the speed of subsequent multi-threaded concurrent processing at a small resource cost.
[0078] S230. Within the data query method, identify the multi-value parameter marked with the second annotation and obtain the set size of the multi-value parameter.
[0079] S240. According to the preset batch size and the set size, split the multi-value parameter into multiple subsets.
[0080] S250. Determine whether the attribute of the first annotation contains a valid virtual thread pool name; if so, execute step S260; if not, execute step S270.
[0081] Among them, determining whether the attribute of the first annotation contains a valid virtual thread pool name may include:
[0082] When the attribute of the first annotation includes a pre-injected virtual thread pool name and the virtual thread pool name is recognized in the context, it is determined that the attribute of the first annotation contains a valid virtual thread pool name;
[0083] Otherwise, it is determined that the attribute of the first annotation does not contain a valid virtual thread pool name.
[0084] S260. Obtain the target thread pool according to the virtual thread pool name in the attribute; execute S280.
[0085] S270. Obtain the default virtual thread pool as the target thread pool; execute S280.
[0086] S280. Generate multiple query subtasks according to the split subsets, and submit the query subtasks to the target thread pool for concurrent execution.
[0087] S290. Merge the query results returned by each thread to obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0088] In the technical solution of the embodiment of the present invention, when the program executes the data query method marked with the first annotation, the AOP aspect is triggered, and the logic in the AOP aspect is executed. In this way, the cross-cutting concerns can be separated from the core business logic of the program. By establishing a default virtual thread pool in advance, virtual thread guarantee can be provided for the concurrent execution of multiple threads, avoiding error reporting caused by the thread pool name not passed in the first annotation or an incorrect virtual thread pool name passed in. By detecting whether the attributes of the first annotation contain valid virtual thread names according to the context, and then determining the target thread pool, and submitting the query subtasks to the target thread pool for concurrent execution, the data query tasks can be concurrently executed using virtual threads based on the characteristics of the first type of development platform, solving the problem of large performance overhead caused by the need to switch back and forth between the user mode and the kernel mode during the creation, destruction, and synchronization of traditional operating system-level threads. Using virtual threads can improve query performance and solve the problem of low query performance or even database error reporting due to the SQL IN statement containing too many values. By merging the query results returned by each thread to obtain the target query result and sending the target query result to the target return value processor, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Moreover, the custom return value processor can support the implementation of complex services, effectively improving the development efficiency of the system.
[0089] Embodiment III
[0090] Figure 3 The flowchart of a data query method supporting multi-value filtering provided by Embodiment III of the present invention. On the basis of the above embodiment, this embodiment specifically illustrates the process of executing the data query method supporting multi-value filtering in a program developed based on the second type of platform. As Figure 3 shown, the method includes:
[0091] S310. When the program executes the data query method marked with the first annotation, trigger the AOP aspect to execute the logic within the AOP aspect.
[0092] Optionally, steps S320 - S380 can be the logic within an AOP aspect.
[0093] S320. In the data query method, identify the multi - valued parameter marked with the second annotation and obtain the size of the set of multi - valued parameters.
[0094] S330. According to the preset batch processing size and the set size, split the multi - valued parameter into multiple subsets.
[0095] S340. Determine whether the attributes of the first annotation contain a valid traditional thread pool name; if so, execute step S350; if not, execute step S360.
[0096] Optionally, the traditional thread pool can be an operating - system - level thread provided by a second - type development platform that does not support virtual threads.
[0097] Optionally, determining whether the attributes of the first annotation contain a valid traditional thread pool name can include:
[0098] When the attributes of the first annotation include a pre - injected traditional thread pool name and the traditional thread pool name is recognized in the context, it is determined that the attributes of the first annotation contain a valid traditional thread pool name;
[0099] Otherwise, it is determined that the attributes of the first annotation do not contain a valid traditional thread pool name.
[0100] S350. Obtain the target thread pool according to the traditional thread pool name in the attributes; execute S370.
[0101] S360. Exit the execution of the logic within the AOP aspect.
[0102] Optionally, when a valid traditional thread pool name is not provided in the first annotation, concurrent processing cannot be performed, and an error can be reported at this time.
[0103] S370. Generate multiple query sub - tasks according to the split subsets and submit the query sub - tasks to the target thread pool for concurrent execution.
[0104] S380. Merge the query results returned by each thread, obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0105] In the technical solution of the embodiment of the present invention, when the program executes a data query method marked with a first annotation, the AOP aspect is triggered, and the logic within the AOP aspect is executed. In this way, cross-cutting concerns can be separated from the core business logic of the program. By establishing a default virtual thread pool in advance, virtual thread guarantees can be provided for the concurrent execution of multiple threads, avoiding error reporting caused by the thread pool name not passed in the first annotation or an incorrect thread pool name passed in. By determining whether the attributes of the first annotation contain a valid traditional thread pool name, and obtaining the target thread pool according to the traditional thread pool name in the attributes when it contains, programs developed based on the second type of development platform can be compatible. Without modifying the code, multi-threaded concurrent execution can also be achieved, improving the query efficiency as much as possible, and solving the problem that the SQL IN statement contains too many values, resulting in low query performance or even an error reported by the database itself for not supporting too many values. By merging the query results returned by each thread, obtaining the target query result, and sending the target query result to the target return value processor, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Moreover, the custom return value processor can support the implementation of complex services, effectively improving the development efficiency of the system.
[0106] Embodiment 4
[0107] Figure 4 It is a schematic structural diagram of a data query device supporting multi-value screening provided by Embodiment 4 of the present invention. As Figure 4 shown, the device includes: an AOP aspect trigger module 410, a multi-value parameter identification module 420, a parameter splitting module 430, a concurrent query module 440, and a return value processing module 450.
[0108] The AOP aspect trigger module 410 is used to trigger the AOP aspect when the program executes a data query method marked with a first annotation to execute the logic within the AOP aspect; wherein, the program is generated based on the first type of development platform or the second type of development platform.
[0109] The multi-value parameter identification module 420 is used to identify multi-value parameters marked with a second annotation within the data query method and obtain the set size of the multi-value parameters.
[0110] The parameter splitting module 430 is used to split the multi-value parameters into multiple subsets according to a preset batch size and the set size.
[0111] The concurrent query module 440 is used to generate multiple query sub-tasks according to the split subsets and submit the query sub-tasks to the target thread pool for concurrent execution.
[0112] The return value processing module 450 is used to merge the query results returned by each thread, obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0113] In the technical solution of the embodiment of the present invention, when the program executes the data query method marked with the first annotation, the AOP aspect is triggered, and the logic within the AOP aspect is executed. In this way, the cross-cutting concerns can be separated from the core business logic of the program, enabling unified management of the function of splitting multi-valued parameters and generating query subtasks for concurrent execution without modifying the original code of the data query method, reducing code redundancy, making the business logic clearer, and providing specific processing methods for different data query methods according to different annotation parameters configured in the first annotation attribute, being compatible with programs generated based on the first type of development platform and the second type of development platform. By identifying the multi-valued parameters marked with the second annotation in the data query method, obtaining the set size of the multi-valued parameters, splitting the multi-valued parameters into multiple subsets according to the preset batch size and the set size, generating multiple query subtasks based on the split subsets, and submitting the query subtasks to the target thread pool for concurrent execution, it avoids the query burden on the database in the case of a large number of values in the SQL IN statement in the prior art, improves the query speed through multi-threaded concurrent execution, and tries to avoid errors. Moreover, for programs that have been developed based on the second type of development platform, multi-threaded concurrent execution of data queries can also be achieved without modifying the original code, alleviating the problem of low query efficiency caused by screening a large number of values as much as possible. By merging the query results returned by each thread, obtaining the target query result, and sending the target query result to the target return value processor, the data query logic and the result processing logic can be decoupled, and the result processing logic is abstracted into a pluggable policy component, enabling the system to dynamically switch the processing logic to adapt to diverse business requirements. Additionally, the custom return value processor can support the implementation of complex services, effectively improving the development efficiency of the system.
[0114] Based on the above embodiments, it may further include a virtual thread pool creation module, which is specifically used for: when the program is generated based on the first type of development platform, while the program executes the data query method marked with the first annotation.
[0115] Create a default virtual thread pool.
[0116] Based on the above embodiments, it may further include a target thread pool selection module, which can be used for: when the program is generated based on the first type of development platform.
[0117] Determine whether the attributes of the first annotation contain a valid virtual thread pool name;
[0118] If so, obtain the target thread pool according to the virtual thread pool name in the attributes;
[0119] If not, obtain the default virtual thread pool as the target thread pool.
[0120] Based on the above embodiments, the target thread pool selection module, when the program is generated based on the first type of development platform, can be further specifically used for:
[0121] When the attributes of the first annotation include a pre-injected virtual thread pool name and the virtual thread pool name is recognized in the context, it is determined that the attributes of the first annotation contain a valid virtual thread pool name;
[0122] Otherwise, it is determined that the attributes of the first annotation do not contain a valid virtual thread pool name.
[0123] Based on the above embodiments, the target thread pool selection module, when the program is generated based on the second type of development platform, can be used for:
[0124] Determine whether the attributes of the first annotation contain a valid traditional thread pool name;
[0125] If so, obtain the target thread pool according to the traditional thread pool name in the attributes;
[0126] If not, exit the execution of the logic within the AOP aspect.
[0127] Based on the above embodiments, it may further include a target return value processor selection module, specifically used for:
[0128] Determine whether the attributes of the first annotation contain a custom return value processor;
[0129] If so, obtain an instance of the custom return value processor in the container as the target return value processor;
[0130] If not, obtain an instance of the default return value processor in the container as the target return value processor.
[0131] Based on the above embodiments, the data query method includes an SQL IN statement, and the SQL IN statement includes multi-value parameters.
[0132] The data query device supporting multi-value filtering provided by the embodiments of the present invention can execute the data query method supporting multi-value filtering provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.
[0133] Embodiment Five
[0134] Figure 5 FIG. 2 shows a schematic structural diagram of an electronic device 10 that can be used to implement embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0135] As Figure 5 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0136] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0137] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the data query method supporting multi-value screening described in the embodiments of the present invention. That is:
[0138] When the program executes the data query method marked with the first annotation, an AOP aspect is triggered to execute the logic within the AOP aspect; wherein, the program is generated based on a first type of development platform or a second type of development platform.
[0139] Within the data query method, identify the multi-valued parameter marked with the second annotation and obtain the set size of the multi-valued parameter.
[0140] According to the preset batch processing size and the set size, split the multi-valued parameter into multiple subsets.
[0141] Generate multiple query subtasks based on the split subsets and submit the query subtasks to the target thread pool for concurrent execution.
[0142] Merge the query results returned by each thread to obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
[0143] In some embodiments, the data query method supporting multi-valued filtering can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by the processor 11, one or more steps of the data query method supporting multi-valued filtering described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the data query method supporting multi-valued filtering in any other suitable manner (e.g., by means of firmware).
[0144] The various embodiments of the systems and techniques described above in this article can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGA), application-specific integrated circuits (ASIC), application-specific standard products (ASSP), systems-on-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a dedicated or general-purpose programmable processor, and can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0145] A computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing device, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0146] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0147] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0148] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected with each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0149] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0150] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.
[0151] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A data query method supporting multi-value filtering, characterized in that, Including: When the program executes the data query method marked with the first annotation, trigger the aspect-oriented programming (AOP) aspect to execute the logic within the AOP aspect; wherein, the program is generated based on the first type of development platform or the second type of development platform; Within the data query method, identify the multi-valued parameter marked with the second annotation and obtain the set size of the multi-valued parameter; According to the preset batch processing size and the set size, split the multi-valued parameter into multiple subsets; Generate multiple query subtasks based on the split subsets and submit the query subtasks to the target thread pool for concurrent execution; Merge the query results returned by each thread, obtain the target query result, and send the target query result to the target return value processor for the target return value processor to perform logical processing on the target query result.
2. The method according to claim 1, wherein When the program is generated based on the first type of development platform, when the program executes the data query method marked with the first annotation, it further includes: Create a default virtual thread pool.
3. The method according to claim 1, characterized in that, When the program is generated based on the first type of development platform, after triggering the AOP aspect, it further includes: Determine whether the attribute of the first annotation contains a valid virtual thread pool name; If so, obtain the target thread pool according to the virtual thread pool name in the attribute; If not, obtain the default virtual thread pool as the target thread pool.
4. The method according to claim 3, characterized in that, Determining whether the attribute of the first annotation contains a valid virtual thread pool name includes: When the attribute of the first annotation includes a pre-injected virtual thread pool name and the virtual thread pool name is recognized in the context, it is determined that the attribute of the first annotation contains a valid virtual thread pool name; Otherwise, it is determined that the attribute of the first annotation does not contain a valid virtual thread pool name.
5. The method according to claim 1, wherein When the program is generated based on the second type of development platform, after triggering the AOP aspect, it further includes: Determine whether the attribute of the first annotation contains a valid traditional thread pool name; If so, obtain the target thread pool according to the traditional thread pool name in the attribute; If not, exit the execution of the logic within the AOP aspect.
6. The method according to claim 1, characterized in that, After triggering the AOP aspect, it further includes: Determine whether the attribute of the first annotation contains a custom return value processor; If so, obtain an instance of the custom return value processor in the container as the target return value processor; If not, obtain an instance of the default return value processor in the container as the target return value processor.
7. The method according to claim 1, wherein The data query method includes an SQL IN statement, and the SQL IN statement includes multi-valued parameters.
8. A data query device supporting multi-value filtering, characterized in that, Including: An AOP aspect trigger module, configured to trigger the AOP aspect when the program executes the data query method marked with the first annotation to execute the logic within the AOP aspect; wherein, the program is generated based on the first type of development platform or the second type of development platform; A multi-valued parameter identification module, configured to identify the multi-valued parameter marked with the second annotation within the data query method and obtain the set size of the multi-valued parameter; A parameter splitting module, configured to split the multi-valued parameter into multiple subsets according to the preset batch processing size and the set size; A concurrent query module, configured to generate multiple query subtasks based on the split subsets and submit the query subtasks to the target thread pool for concurrent execution; A return value processing module is configured to merge the query results returned by each thread, obtain a target query result, and send the target query result to a target return value processor for the target return value processor to perform logical processing on the target query result.
9. An electronic device, characterized in that, The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the multi-value filtering supported data query method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a processor to implement the multi-value filtering supported data query method according to any one of claims 1-7 when executed.
Citation Information
Patent Citations
Data parallel query method and device, storage medium and computer equipment
CN117762979A
Data query method and device, storage medium and electronic equipment
CN120086253A