Search task processing method and device based on thread pool and medium
By concurrently performing the core sub-tasks and edge sub-tasks of route information search tasks in the thread pool, the problems of long search time and outdated information in the existing technology are solved, and more efficient and accurate search results are achieved.
Patent Information
- Application Number
- CN202510118254.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-01-24
AI Technical Summary
In the prior art, when searching for route information, the overall search time is long, and due to the unstable response of third-party API interfaces and dynamic changes in route information, the information may be outdated and the accuracy of search results may be reduced.
Using a thread pool-based search task processing method, the core subtasks and edge subtasks are generated, and these tasks are performed concurrently using the thread pool. Whenever a return result is received from a core subtask or edge subtask, the initial return result list is updated until all return results are integrated after the core subtask is completed to obtain the final result.
It shortens the overall search time, improves search efficiency, and helps improve the accuracy of the final return results of the search task.
Smart Images

Figure CN120029773A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of task processing, and in particular to a thread pool-based search task processing method, device and medium. Background Art
[0002] The route information includes flight number, airline, aircraft model, flight departure time, flight arrival time, ticket information, etc. When searching for route information, a search task consisting of one or several subtasks is often generated based on the departure address and destination address input by the target user. For example, the search task is "search for ticket information directly from the departure address to the destination address", and the subtasks corresponding to the search task may include but are not limited to "search for flights directly from the departure address to the destination address", "search for flights from the departure address to the destination address via the transit address", "search for ticket prices for each flight" and "query the number of remaining tickets for each flight". In the process of obtaining the return results of the search task, a thread will be created to execute each subtask in sequence. When all subtasks are executed, the return results corresponding to all subtasks are integrated to obtain the return results corresponding to the search task.
[0003] However, the above method also has the following technical problems:
[0004] The above method needs to execute each subtask in sequence. When all subtasks are completed, the return results of all subtasks will be integrated to obtain the return results corresponding to the search task. The overall search time is long and the execution of subtasks requires the allocation of API interfaces of third-party service providers (such as airlines). The response time of third-party API interfaces may be unstable. The execution time of subtasks is too long, which further prolongs the overall search time, resulting in low overall search efficiency. In addition, route information changes dynamically, especially in the event of flight delays, cancellations or fare changes. If the execution time interval between subtasks is long, some information may become outdated, reducing the accuracy of the return results of the search task. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is:
[0006] According to a first aspect of the present invention, a thread pool-based search task processing method is provided, wherein the search task is a task for searching for relevant information from a target departure address to a target arrival address, and the method comprises the following steps:
[0007] S1. When receiving the target departure address and target arrival address input by the target user, a search task is generated and the core subtask identifier A and the edge subtask identifier list B corresponding to the search task are obtained. 1 , B2 , ..., B i , ..., B m}, B i is the ith edge subtask identifier corresponding to the search task, the value of i ranges from 1 to m, and m is the number of edge subtask identifiers corresponding to the search task, wherein the search task is composed of several subtasks, the core subtask corresponding to the search task is the subtask that must be completed among the several subtasks that make up the search task, and the edge subtask corresponding to the search task is the subtask other than the core subtask among the several subtasks that make up the search task.
[0008] S2: Let the thread pool allocate m+1 threads to concurrently execute the core subtasks corresponding to A and B 1 , B 2 , ..., B i , ..., B m The corresponding edge subtask.
[0009] S3, obtain the initial return result list C corresponding to the search task = {C 0 , C 1 , C 2 , ..., C i , ..., C m}, C 0 is the initial return result corresponding to A, C i For B i The corresponding initial return result, where C 0 , C 1 , C 2 , ..., C i , ..., C m Initially both are NULL.
[0010] S4. Update C and determine C each time the update is completed. 0 Is it NULL and go to step S5, where when the thread corresponding to A is executed, let C 0 =A 0 So that C is updated, A 0 The output or return value generated after the thread corresponding to A completes the core subtask corresponding to A. i When the corresponding thread is finished, let C i =B 0 i So that C is updated, B 0 i For B i The corresponding thread completes B i The output or return value generated by the corresponding edge subtask.
[0011] S5, when C0 When not NULL, C 0 , C 1 , C 2 , ..., C i , ..., C m Perform integration processing to obtain the final return result corresponding to the search task.
[0012] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the aforementioned method.
[0013] According to a third aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned method when executing the computer program.
[0014] The present invention has at least the following beneficial effects:
[0015] The present invention provides a search task processing method, device and medium based on a thread pool. When receiving a target departure address and a target arrival address input by a target user, the method generates a search task and obtains a core subtask and an edge subtask corresponding to the search task, wherein the search task is a task for searching for relevant information from the target departure address to the target arrival address, and the relevant information includes route information. The core subtask is a subtask that must be completed among several subtasks constituting the search task. The edge subtask corresponding to the search task is other subtasks except the core subtask among several subtasks constituting the search task. The thread pool allocates several threads to concurrently execute the core subtask and each edge subtask. Whenever a return result of a core subtask is received, the initial return result corresponding to the core subtask identifier in the initial return result list is replaced with the return result of the core subtask so that the initial return result list is updated. Whenever a return result of an edge subtask is received, the initial return result corresponding to the edge subtask identifier in the initial return result list is replaced with the return result of the edge subtask so that the return result list is updated. After each update of the initial return result list, it is determined when Whether the initial return result corresponding to the core subtask identifier in the previous initial return result list is NULL, if it is NULL, all the initial return results in the initial return result list are integrated to obtain the final return result corresponding to the search task. It can be understood that when the return result of the core subtask is received, the return result of the core subtask and the return result of the currently received edge subtask are integrated to obtain the final return result corresponding to the search task. It can be seen that the present invention is based on the thread pool technology to concurrently execute the core subtask and all edge subtasks. There is no need to create an additional thread for the search task to execute all subtasks in sequence, which can shorten the overall search time. When the return result of the core subtask is received, the return result of the core subtask and the return result of the currently received edge subtask are integrated to obtain the final return result corresponding to the search task. There is no need to wait until all subtasks are executed and then integrate the return results of all subtasks to obtain the final return result corresponding to the search task, which further shortens the overall search time, improves the overall search efficiency, and is beneficial to improving the accuracy of the final return result corresponding to the search task. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1A flowchart of a thread pool-based search task processing method provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0019] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar tasks, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, 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 "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0020] An embodiment of the present invention provides a thread pool-based search task processing method, wherein the search task is a task for searching for relevant information from a target departure address to a target arrival address, and the method comprises the following steps: Figure 1 As shown:
[0021] S1. When receiving the target departure address and target arrival address input by the target user, a search task is generated and the core subtask identifier A and the edge subtask identifier list B corresponding to the search task are obtained. 1 , B 2 , ..., B i , ..., B m}, B i is the ith edge subtask identifier corresponding to the search task, the value of i ranges from 1 to m, and m is the number of edge subtask identifiers corresponding to the search task, wherein the search task is composed of several subtasks, the core subtask corresponding to the search task is the subtask that must be completed among the several subtasks that make up the search task, and the edge subtask corresponding to the search task is the subtask other than the core subtask among the several subtasks that make up the search task.
[0022] Specifically, the number of core subtasks corresponding to the search task is 1.
[0023] Specifically, the core subtask identifier is a unique identifier of the core subtask; the core subtask can be understood as a subtask whose result directly affects the success of the entire search task. If the core subtask is not completed, the entire search task will fail.
[0024] Specifically, the edge subtask identifier is the unique identity identifier of the edge subtask; the edge subtask can be understood as a subtask whose result does not directly affect the success of the entire search task, but only plays an auxiliary role in the search task. Even if the edge subtask is not completed, it will not cause the failure of the entire search task.
[0025] Specifically, there is no dependency relationship between the core subtask and any edge subtask.
[0026] Specifically, there is no dependency relationship between any two edge subtasks.
[0027] Specifically, the relevant information from the target departure address to the target arrival address includes but is not limited to the route information, transportation methods, route planning, weather information, accommodation information, visa information, baggage regulations, and user preferences from the target departure address to the target arrival address. The route information includes but is not limited to the flight number, airline, aircraft model, flight departure time, flight arrival time, and air ticket information.
[0028] S2: Let the thread pool allocate m+1 threads to concurrently execute the core subtasks corresponding to A and B 1 , B 2 , ..., B i , ..., B m The corresponding edge subtasks can be understood as: let the thread pool allocate m+1 threads to execute the core subtasks corresponding to A and B at the same time 1 , B 2 , ..., B i , ..., B m The corresponding edge subtask.
[0029] Specifically, m+1 threads and A, B 1 , B 2 , ..., B i , ..., B m They correspond one to one.
[0030] Specifically, a thread pool is a technology for managing and reusing threads. It creates a certain number of threads in advance and keeps all threads in an "idle" state, waiting for tasks to be assigned. When a task needs to be executed, the thread pool selects an idle thread from the pool to execute the task, that is, allocates an idle thread to execute the task. After the task is completed, the thread returns to the thread pool and prepares to execute the next task.
[0031] Specifically, there is no dependency between the core subtask and any edge subtask, and there is no dependency between any two edge subtasks. In order to allocate m+1 threads to the thread pool to concurrently execute the core subtask corresponding to A and B 1 , B 2 , ..., B i , ..., B m The corresponding edge subtasks provide implementation conditions so that each thread can run independently of other threads, which helps to improve search efficiency. At the same time, the thread pool is used to manage thread resources to reduce the overhead of thread creation and destruction, thereby improving performance.
[0032] S3, obtain the initial return result list C corresponding to the search task = {C 0 , C 1 , C 2 , ..., C i , ..., C m}, C 0 is the initial return result corresponding to A, C i For B i The corresponding initial return result, where C 0 , C 1 , C 2 , ..., C i , ..., C m Initially both are NULL.
[0033] S4. Update C and determine C each time the update is completed. 0 Is it NULL and go to step S5, where when the thread corresponding to A is executed, let C 0 =A 0 So that C is updated, A 0 The output or return value generated after the thread corresponding to A completes the core subtask corresponding to A. i When the corresponding thread is finished, let C i =B 0 i So that C is updated, B 0 i For B i The corresponding thread completes B i The output or return value generated by the corresponding edge subtask.
[0034] S5, when C 0 When not NULL, C 0 , C 1 , C 2 , ..., C i , ..., C mPerform integration processing to obtain the final return result corresponding to the search task.
[0035] Specifically, the integration process can be understood as converting C 0 , C 1 , C 2 , ..., C i , ..., C m The process of aggregating, filtering, sorting, and optimizing to produce a unified and complete final result.
[0036] Specifically, when C 0 When it is NULL, continue to wait for C to be updated; it can be understood as: when C 0 If it is NULL, no processing is performed.
[0037] Specifically, in C 0 , C 1 , C 2 , ..., C i , ..., C m While performing integration processing to obtain the final return result corresponding to the search task, the execution of unfinished edge subtasks is stopped.
[0038] Through the above steps, the core subtask and all edge subtasks are executed concurrently based on the thread pool technology. There is no need to create an additional thread for the search task to execute all subtasks in sequence, which can shorten the overall search time. When the return result of the core subtask is received, the return result of the core subtask and the return result of the currently received edge subtask are integrated to obtain the final return result corresponding to the search task. At the same time, the execution of unfinished edge subtasks is stopped. There is no need to wait until all subtasks are executed and then integrate the return results of all subtasks to obtain the final return result corresponding to the search task. This further shortens the overall search time, improves the overall search efficiency, and is beneficial to improving the accuracy of the final return result corresponding to the search task.
[0039] In a specific embodiment, step S5 is replaced by the following steps S10-S20:
[0040] S10, when C 0 When it is not NULL, the current time point is used as the key update time point D corresponding to A and the current C is immediately copied as the first return result list E corresponding to the search task = {E 0 , E 1 , E 2 ,……,E i ,……,E m}, E 0 is the first returned result corresponding to A, E i For Bi The corresponding first returned result.
[0041] S20, based on E i Get the final return result corresponding to the search task.
[0042] Specifically, in step S20, the following steps S21-S24 are included:
[0043] S21, traverse E, when E i When NULL, B i as the unfinished subtask identifier to obtain the unfinished subtask identifier list F={F 1 , F 2 , ..., F j , ..., F n}, F j is the jth unfinished subtask identifier, the value of j ranges from 1 to n, and n is the number of unfinished subtask identifiers.
[0044] S22, obtain F according to the preset importance weight mapping list G corresponding to the search task j The corresponding waiting time weight H j , G={G 1 , G 2 , ..., G i , ..., G m}, G i =(B i , G 0 j ), G j For B j The corresponding preset importance weight mapping combination, G 0 j G j Medium B j The corresponding preset importance weights, where F j =B i When G 0 j As H j .
[0045] Specifically, G. 0 j The value range is [0, 1].
[0046] Specifically, the preset importance weight is a preset weight representing the importance of the edge subtask. The larger the preset importance weight, the higher the importance of the edge subtask corresponding to the edge subtask identifier corresponding to the preset importance weight, and the more important the edge subtask. In a specific application scenario, the preset importance weight mapping list corresponding to the search task can be set by technical personnel in this field according to actual needs, and will not be repeated here.
[0047] S23, obtain the candidate waiting time list K corresponding to F = {K 1 , K 2 , ..., K j , ..., K n} and K 1 , K 2 , ..., K j , ..., K n The largest candidate waiting time in K is taken as the target waiting time MB. j F j The corresponding candidate waiting time, K j Meet the following conditions:
[0048] K j =H j ×T, T is the preset maximum waiting time, wherein, in a specific practical application, the preset maximum waiting time can be set by those skilled in the art according to actual needs, for example, 10s, 20s, which will not be repeated here.
[0049] S24, when the predicted time point YC arrives, 0 , C 1 , C 2 , ..., C i , ..., C m Perform integration processing to obtain the final return results corresponding to the search task. YC meets the following conditions:
[0050] YC=D+MB.
[0051] Through the above steps, when the return result of the core subtask is received, the current time point is recorded as the key update time point, and the initial return result list at this moment is copied as the first return result list. When the first return result is NULL, it means that the edge subtask corresponding to the first return result has not been completed. Since the result of the edge subtask does not directly affect the success of the entire search task, it is only a subtask that plays an auxiliary role in the search task. Even if the edge subtask is not completed, it will not cause the failure of the entire search task. Therefore, at this time, according to the preset importance weight mapping list, the waiting time weight corresponding to the unfinished subtask identifier is obtained. The larger the waiting time weight, the higher the importance of the unfinished subtask. The product of the waiting time weight corresponding to the unfinished subtask identifier and the preset maximum waiting time is used as the unfinished subtask identifier. The corresponding candidate waiting time is used, and the maximum candidate waiting time is used as the target waiting time. When the time point obtained by adding the key update time point and the target waiting time is reached, all the initial return results in the initial return result list at this time are integrated to obtain the final return result corresponding to the search task. The overall search time can be determined according to the importance of the unfinished tasks, and the search task will not fail. There is no need to create an additional thread for the search task to execute all subtasks in sequence. After all subtasks are completed, the return results of all subtasks are integrated to obtain the final return result corresponding to the search task. This shortens the overall search time, improves the overall search efficiency, is conducive to improving the accuracy of the final return result corresponding to the search task, and can also obtain a more comprehensive final return result.
[0052] In a specific embodiment, step S23 is replaced by the following steps S100-S200:
[0053] S100, according to the starting address pair Q corresponding to the search task and the preset address pair weight mapping list U, obtain the target address pair weight W corresponding to Q, where Q includes the target starting address and the target arrival address, U={U 1 , U 2 , ..., U g , ..., U h},U g =(U g1 , U g2 ), U g is the gth preset address pair weight combination, g ranges from 1 to h, h is the number of preset address pair weight combinations, U g1 For U g The preset address pair in U g2 For U g1 The corresponding preset address pair weight, U g1 The preset departure address and the preset arrival address are included in Q. When the target departure address in Ug1 The preset departure address in Q is the same as that in U and the destination address in Q is the same as that in U g1 If the preset destination address is the same as that in g2 As W.
[0054] Specifically, U g2 The value range is [0, 1].
[0055] Specifically, the preset address pair weight is used to indicate the importance of the search task corresponding to the preset address pair. The larger the preset address pair weight, the higher the importance of the search task corresponding to the preset address pair, and the more important the search task. In a specific application scenario, the preset address pair weight is set by technical personnel in this field according to actual needs. For example: the higher the click-through rate of the search task corresponding to the preset address pair, the greater the weight of the preset address pair; the ratio of the click-through rate of the search task corresponding to the preset address pair to the click-through rate of all search tasks, the greater the weight of the preset address pair; the higher the popularity of the preset departure address and the preset arrival address in the preset address pair, the greater the weight of the preset address pair, which will not be repeated here.
[0056] S200, obtain the waiting time list P corresponding to F = {P 1 , P 2 , ..., P j , ..., P n} and P 1 , P 2 , ..., P j , ..., P n The maximum waiting time in the candidate is taken as MB, P j F j The corresponding waiting time, P j Meet the following conditions:
[0057] P j =W×H j ×T.
[0058] Through the above steps, according to the starting address pair corresponding to the search task and the preset address pair weight mapping list, the weight of the target address pair corresponding to the starting address pair corresponding to the search task is obtained. The larger the weight of the target address pair, the higher the importance of the search task. The product of the target address pair weight, the waiting time weight corresponding to the unfinished subtask identifier and the preset maximum waiting time is used as the candidate waiting time corresponding to the unfinished subtask, and the maximum candidate waiting time is used as the target waiting time. When the time point obtained by adding the key update time point to the target waiting time arrives, all the initial return results in the initial return result list at this time are integrated to obtain the final return result corresponding to the search task. The overall search time can be determined according to the importance of the search task and the importance of the unfinished task, and the search task will not fail. There is no need to create an additional thread for the search task to execute all subtasks in sequence. After all subtasks are executed, the return results of all subtasks are integrated to obtain the final return result corresponding to the search task, which shortens the overall search time, improves the overall search efficiency, and is conducive to improving the accuracy of the final return result corresponding to the search task, and can also obtain a more comprehensive final return result.
[0059] In a specific embodiment, step S2 also includes:
[0060] At the same time, the thread pool is instructed to allocate another thread to execute a target user type label acquisition task. The target user type label acquisition task is a user type label acquired based on the historical search data of the target user, including: efficiency type and comprehensive type.
[0061] Specifically, the target user type label can be obtained by inputting the target user's historical search data into the classification model.
[0062] Specifically, when the target user type label is efficiency type, it means that the target user expects to get search results faster.
[0063] Specifically, when the target user type label is comprehensive, it means that the target user expects to obtain more comprehensive search results.
[0064] Replace step S5 with S51-S54:
[0065] S51, when C 0 If it is not NULL and the corresponding result of the target user type label acquisition task has not been received, 0 , C 1 , C 2 , ..., C i , ..., C m Perform integration processing to obtain the final return result corresponding to the search task.
[0066] Specifically, the return result corresponding to the target user type label acquisition task can be understood as: the output or return value generated after the thread completes the target user type label acquisition task.
[0067] S52, when C 0 When it is not NULL and the corresponding return result of the received target user type label acquisition task is efficiency type, 0 , C 1 , C 2 , ..., C i , ..., C m Perform integration processing to obtain the final return result corresponding to the search task.
[0068] S53, when C 0 When it is not NULL and the returned result corresponding to the received target user type label acquisition task is comprehensive, the current time point is used as the key update time point D corresponding to A and the current C is immediately copied as the first returned result list E corresponding to the search task = {E 0 , E 1 , E 2 ,……,E i ,……,E m}, E 0 is the first returned result corresponding to A, E i For B i The corresponding first returned result.
[0069] S54, based on E i Get the final return result corresponding to the search task.
[0070] Through the above steps, the target user type label is obtained to determine whether the target user expects to obtain search results faster or more comprehensive search results. When the initial return result corresponding to the core subtask identifier in the initial return result list is not NULL, it means that the core subtask has been completed at this moment, and all the initial return results in the initial return result list can be integrated to obtain the final return result corresponding to the search task. If the target user type label is efficiency, it means that the target user expects to obtain search results faster, then all the initial return results in the initial return result list are directly integrated to obtain the final return result corresponding to the search task, so that the target user can obtain search results faster; if the target user type label is comprehensiveness, it means that the target user expects to obtain more comprehensive search results. At this time, the current time point is recorded as the key update time point, and the initial return result list at this time is copied as the first return result list. The target waiting time is obtained according to the first return result list. When the time point obtained by adding the key update time point and the target waiting time arrives, all the initial return results in the initial return result list at this time are integrated to obtain the final return result corresponding to the search task, so that the target user can obtain more comprehensive search results, which is conducive to improving user experience.
[0071] In a specific embodiment, after step S1 and before step S2, the following steps are also included:
[0072] Get the data transmission duration SC corresponding to the target user. SC meets the following conditions:
[0073] SC=SC1-SC2, SC1 is the time point when the target departure address and the target arrival address input by the target user are received, and SC2 is the time point when the target departure address and the target arrival address are input by the target user.
[0074] Replace step S5 with the following steps S501-S503:
[0075] S501, when C 0 Not NULL and SC>SC 0 When C 0 , C 1 , C 2 , ..., C i , ..., C m Perform integration processing to obtain the final return result corresponding to the search task, SC 0 It is a preset data transmission time. In a specific practical application, the preset data transmission time can be set by a technician in this field according to actual needs, for example: 30ms, 50ms, which will not be repeated here.
[0076] S502, when C 0is NULL and SC ≤ SC 0 When this is the case, take the current time point as the critical update time point D corresponding to A and immediately copy the current C as the first return result list E = {E 0 , E 1 , E 2 , ……, E i , ……, E m}, where E 0 is the first return result corresponding to A, and E i is the first return result corresponding to B i .
[0077] S503. Based on E i Obtain the final return result corresponding to the search task.
[0078] Through the above steps, according to the time points of the target departure address and the target arrival address input by the target user and the time points of the target departure address and the target arrival address input by the target user, obtain the data transmission duration corresponding to the target user. When the data transmission duration is greater than the preset data transmission duration, it indicates that the network speed of the target user is slow. At this time, after receiving the return result of the core sub-task, immediately directly integrate all the initial return results in the initial return result list to obtain the final return result corresponding to the search task, avoiding the situation that the time point when the user receives the final return result is too late due to the too slow network speed of the target user. When the data transmission duration is not greater than the preset data transmission duration, it indicates that the network speed of the target user has increased. At this time, record the current time point as the critical update time point, and copy the current initial return result list as the first return result list. Obtain the target waiting duration according to the first return result list. When the time point obtained by adding the critical update time point and the target waiting duration arrives, integrate all the initial return results in the initial return result list at this time to obtain the final return result corresponding to the search task, enabling the target user to obtain a more comprehensive search result, which is beneficial to improving the user experience.
[0079] In a specific embodiment, in step S1, the following steps S01 - S03 are further included to obtain A and B:
[0080] S01. Obtain the sub-task identifier list V = {V 1 , V 2 , ……, V e , ……, V f}, where V e is the e-th sub-task identifier corresponding to the search task, and the value of e ranges from 1 to f, where f is the number of sub-task identifiers corresponding to the search task.
[0081] Specifically, the sub-task identifier is the unique identity identifier of the sub-task.
[0082] Specifically, there is no dependency between any two subtasks.
[0083] Specifically, f = m + 1.
[0084] S02. Obtain V e The corresponding impact level label X e , X e is a label representing the level of impact on the search task when the subtask corresponding to V e is not completed, including: primary label, secondary label, tertiary label, and quaternary label. Among them, in a specific application scenario, the impact level label corresponding to the subtask identifier can be obtained according to a trained neural network model. The neural network model is trained based on historical data, user feedback, and real-time performance metrics to obtain the trained neural network model, which will not be elaborated here.
[0085] Specifically, the impact represented by the primary label is: the search task cannot be completed and the result is invalid; the impact represented by the secondary label is: the search task can be completed, but the result is not comprehensive enough or some information is missing; the impact represented by the tertiary label is: the search task can be completed, the result is relatively comprehensive, but some details may be incomplete; the impact represented by the quaternary label is: the search task can be completed and the result is not affected.
[0086] S03. If X e is the first label, then take V e as A, and take the other subtask identifiers in V 1 , V 2 , ……, V e , ……, V f except V e as the edge subtask identifiers to obtain B.
[0087] Through the above steps, each time a search task is generated, the impact level label corresponding to the subtask identifier is dynamically obtained, and the core subtask and edge subtasks are determined according to the impact level label corresponding to the subtask identifier. Compared with statically and automatically determining the core subtask and edge subtasks according to manual determination or predefined rules, fixed algorithms, or pre-set priority lists, it can flexibly handle different scenarios, avoid human errors and biases, and at the same time ensure that the impact level label corresponding to the subtask is the most accurate.
[0088] In a specific embodiment, before step S22, the following steps S001 - S004 are also included to obtain G 0 j :
[0089] S001. Obtain the preset impact weight list Y = {Y 1 , Y2 , Y 3 , Y 4}, where Y 1 is the preset influence weight corresponding to the first-level label, Y 2 is the preset influence weight corresponding to the secondary influence label, Y 3 is the preset influence weight corresponding to the third-level label, Y 4 The preset influence weights corresponding to the four-level labels.
[0090] Specifically, Y 1 >Y 2 >Y 3 >Y 4 , wherein those skilled in the art know that Y 1 , Y 2 , Y 3 , Y 4 The specific value of is set by those skilled in the art according to actual needs, for example: 1 =10, Y 2 =7,Y 3 =4,Y 4 =1, no further details will be given here.
[0091] S002, when X e When it is a first-level label, Y 1 As V e The corresponding intermediate influence weight Z e , when X e When it is a secondary tag, Y 2 As Z e , when X e When it is a third-level label, Y 3 As Z e , when X e When it is a level 4 label, Y 4 As Z e , to obtain the intermediate influence weight list Z corresponding to V = {Z 1 , Z 2 , ..., Z e , ..., Z f}.
[0092] S003, based on the softmax function Z 1 , Z 2 , ..., Z e , ..., Z f Process and obtain the normalized weight list Z corresponding to Z 0 = {Z 0 1 , Z 0 2 , ..., Z 0e , ..., Z 0 f}, Z 0 e Z e The corresponding normalized weights.
[0093] S004, when B j =V e When Z 0 e As G 0 j .
[0094] Through the above steps, an intermediate influence weight list is obtained according to the preset influence weight list, all intermediate influence weights in the intermediate influence weight list are normalized to obtain normalized weights, and the preset importance weights are determined based on the normalized weights, ensuring that the weight evaluation of all subtasks has a consistent standard, which can avoid inconsistencies and subjective biases caused by human judgment.
[0095] The present invention provides a search task processing method, device and medium based on a thread pool. When receiving a target departure address and a target arrival address input by a target user, the method generates a search task and obtains a core subtask and an edge subtask corresponding to the search task, wherein the search task is a task for searching for relevant information from the target departure address to the target arrival address, and the relevant information includes route information. The core subtask is a subtask that must be completed among several subtasks constituting the search task. The edge subtask corresponding to the search task is other subtasks except the core subtask among several subtasks constituting the search task. The thread pool allocates several threads to concurrently execute the core subtask and each edge subtask. Whenever a return result of a core subtask is received, the initial return result corresponding to the core subtask identifier in the initial return result list is replaced with the return result of the core subtask so that the initial return result list is updated. Whenever a return result of an edge subtask is received, the initial return result corresponding to the edge subtask identifier in the initial return result list is replaced with the return result of the edge subtask so that the return result list is updated. After each update of the initial return result list, it is determined when Whether the initial return result corresponding to the core subtask identifier in the previous initial return result list is NULL, if it is NULL, all the initial return results in the initial return result list are integrated to obtain the final return result corresponding to the search task. It can be understood that when the return result of the core subtask is received, the return result of the core subtask and the return result of the currently received edge subtask are integrated to obtain the final return result corresponding to the search task. It can be seen that the present invention is based on the thread pool technology to concurrently execute the core subtask and all edge subtasks. There is no need to create an additional thread for the search task to execute all subtasks in sequence, which can shorten the overall search time. When the return result of the core subtask is received, the return result of the core subtask and the return result of the currently received edge subtask are integrated to obtain the final return result corresponding to the search task. There is no need to wait until all subtasks are executed and then integrate the return results of all subtasks to obtain the final return result corresponding to the search task, which further shortens the overall search time, improves the overall search efficiency, and is beneficial to improving the accuracy of the final return result corresponding to the search task.
[0096] In a specific application scenario, the thread pool-based search task processing method can be used to search for air ticket information from a target departure address to a target arrival address. When applied to searching for air ticket information from a target departure address to a target arrival address, the search task generated when receiving the target departure address and target arrival address input by the target user can be: "Query the air ticket information from the target departure address to the target arrival address"; the subtasks corresponding to the search task can include: "Query the flight ID that directly reaches the target arrival address from the target departure address and the fare and number of remaining tickets corresponding to the flight ID", "Query the flight ID that reaches the target arrival address from the target departure address via the intermediate station address and The search task is to find the flight ID that directly reaches the target arrival address from the target departure address and the fare information and number of remaining tickets corresponding to the flight ID, query the flight ID that reaches the target arrival address from the neighboring address of the target departure address and the fare information and number of remaining tickets corresponding to the flight ID, and query the flight ID that reaches the neighboring address of the target arrival address from the target departure address and the fare information and number of remaining tickets corresponding to the flight ID. The core subtask of the search task is to query the flight ID that directly reaches the target arrival address from the target departure address and the fare and number of remaining tickets corresponding to the flight ID, and the other subtasks are edge subtasks. The thread pool is allocated 4 threads to concurrently execute the core subtask and each edge subtask, wherein each thread executes the core subtask. When executing the core subtask and the edge subtask, the airline's database can be accessed as needed to obtain the return results of the core subtask and each edge subtask. The return result can be understood as the output or return value generated after the thread completes the core subtask or the edge subtask. When the thread completes the core subtask, the initial return result corresponding to the core subtask identifier in the initial return result list is replaced with the return result of the core subtask, so that the initial return result list is updated. When the thread completes each edge subtask, the initial return result corresponding to the edge subtask ID in the initial return result list is replaced with the return result of the edge subtask, so that the initial return result list is updated. After each update of the initial return result list is completed, it is necessary to determine whether the core subtask is completed, that is, to determine whether the initial return result corresponding to the core subtask identifier in the return result list is NULL. If the return result corresponding to the core subtask identifier in the initial return result list is not NULL, it means that the core subtask has been completed at this time. There is no need to determine whether there are any unfinished edge subtasks. All initial return results in the initial return result list at this time are directly integrated and processed to obtain the final return result corresponding to the search task. If the return result corresponding to the core subtask identifier in the initial return result list is NULL, it means that the core subtask has not been completed at this time and needs to continue waiting.
[0097] In a specific application scenario, if the return result corresponding to the core subtask identifier in the initial return result list is not NULL, it means that the core subtask has been completed at this time, and the time point at this time is used as the key update time point, and the initial return result list at this time is immediately copied as the first return result list. If there is a NULL value in the first return result list, it means that some edge subtasks have not been completed. These unfinished edge subtask identifiers are used as unfinished subtask identifiers, and the waiting time weight corresponding to each unfinished subtask identifier is obtained based on the preset importance weight corresponding to the edge subtask identifier preset according to actual needs. The preset importance weight corresponding to the edge subtask identifier is a preset weight indicating the importance of the edge subtask. The larger the preset importance weight, the higher the importance of the edge subtask corresponding to the edge subtask identifier corresponding to the preset importance weight, and the more important the edge subtask is, that is, the larger the waiting time weight corresponding to the unfinished subtask identifier, the higher the importance of the unfinished subtask, and the more important the unfinished subtask is. For example: if the importance of the unfinished subtask corresponding to "querying the flight identifier from the target departure address through the intermediate station address to the target arrival address and the fare information and the number of remaining tickets corresponding to the flight identifier" is higher than that of "querying the temporary flight from the target departure address The importance of the unfinished subtask corresponding to "query the flight ID from the target departure address to the target arrival address through the intermediate station address, and the fare information and the number of remaining tickets corresponding to the flight ID" is greater than the waiting time weight corresponding to the unfinished subtask ID of "query the flight ID from the target departure address to the target arrival address through the intermediate station address, and the fare information and the number of remaining tickets corresponding to the flight ID". The product of the waiting time weight and the maximum waiting time is taken as the unfinished task. The candidate waiting time corresponding to the subtask identifier proves that the greater the waiting time weight, the longer the candidate waiting time of the corresponding subtask, but it cannot exceed the preset maximum waiting time. At this time, the maximum candidate waiting time is taken as the target waiting time, and the sum of the target waiting time and the key update time point is taken as the predicted time point. When the predicted time point arrives, all the initial return results in the initial return result list at this time are integrated and processed to obtain the final return result corresponding to the search task. It is possible to wait until the most important edge subtask is completed before obtaining the final return result corresponding to the search task, so that the final return result obtained is more comprehensive.
[0098] In a specific application scenario, the weight of the target address pair corresponding to the search task is obtained according to the starting address pair and the preset address pair weight mapping list corresponding to the search task. The preset address pair weight mapping list includes several preset address pair weight combinations. The preset address pair weight combination includes the preset address pair and the weight corresponding to the preset address pair. The preset address pair includes a preset departure address and a preset arrival address. The preset address pair weight is used to indicate the importance of the search task corresponding to the preset address pair. The larger the preset address pair weight, the higher the importance of the search task corresponding to the preset address pair corresponding to the preset address pair weight, and the more important the search task. The preset address pair weight is set by technicians in this field according to actual needs. For example: if the number of users searching for information related to the preset departure place and the preset arrival place in the first preset address pair is the largest in the historical time period, then the preset address pair weight corresponding to the first preset address pair is set to the maximum value, or the preset address pair weight in the current first preset address pair is set to the maximum value. Assuming that the geographical areas corresponding to the departure point and the preset destination point are the most popular, then the weight of the preset address pair corresponding to the first preset address pair is set to the maximum value; based on the weight of the target address pair corresponding to the search task and the weight of the waiting time corresponding to each unfinished subtask identifier, the waiting time corresponding to each unfinished subtask identifier is obtained, and the maximum waiting time among the waiting times corresponding to all unfinished subtask identifiers is used as the target waiting time, and the sum of the target waiting time and the key update time point is used as the predicted time point. When the predicted time point is arrived, all the initial return results in the initial return result list at this time are integrated and processed to obtain the final return result corresponding to the search task, and the waiting time after receiving the return result of the core subtask is determined according to the importance of different search tasks. The time to obtain the final result of the search task can be flexibly adjusted, which can improve the efficiency of obtaining the final return result corresponding to the search task and avoid waste of resources.
[0099] In a specific application scenario, when the return result corresponding to the core subtask identifier in the initial return result list is not NULL and the return result corresponding to the target user type label acquisition task has not been received, it means that the core subtask has been completed but it is not known what kind of result the target user expects. At this time, all the initial return results in the initial return result list can be directly integrated to obtain the final return result corresponding to the search task; when the return result corresponding to the core subtask identifier in the initial return result list is not NULL and the return result corresponding to the received target user type label acquisition task is efficiency-type, it means that the core subtask has been completed and the target user expects to get the search result faster. At this time, all the initial return results in the initial return result list can be directly integrated to obtain the final return result corresponding to the search task, which is conducive to improving user experience. When the return result corresponding to the core subtask identifier is not NULL and the return result corresponding to the received target user type label acquisition task is comprehensive, it means that the core subtask has been completed and the target user expects to obtain more comprehensive search results. The time point at this time is used as the key update time point, and the initial return result list at this time is immediately copied as the first return result list. The target waiting time is further obtained according to the first return result list, and the maximum candidate waiting time is taken as the target waiting time. The sum of the target waiting time and the key update time point is used as the predicted time point. When the predicted time point arrives, all the initial return results in the initial return result list at this time are integrated and processed to obtain the final return result corresponding to the search task. The final return result corresponding to the search task can be obtained after the most important edge subtask is completed, so that the final return result obtained is more comprehensive, which is also conducive to improving user experience.
[0100] In a specific application scenario, when the return result corresponding to the core subtask identifier in the initial return result list is not NULL and the data transmission time corresponding to the target user is greater than the preset data transmission time, it means that the core subtask has been completed and the user's network speed is relatively slow. At this time, all the initial return results in the initial return result list are directly integrated and processed to obtain the final return result corresponding to the search task, which is beneficial to improving user experience. When the return result corresponding to the core subtask identifier in the initial return result list is not NULL and the data transmission time corresponding to the target user is not greater than the preset data transmission time, it means that the core subtask has been completed and the user's network speed is relatively fast. The time point at this time is used as the key update time point, and the initial return result list at this time is immediately copied as the first return result list. According to the first return result list, the target waiting time is further obtained, the maximum candidate waiting time is set as the target waiting time, and the sum of the target waiting time and the key update time point is used as the predicted time point. When the predicted time point arrives, all the initial return results in the initial return result list at this time are integrated and processed to obtain the final return result corresponding to the search task. The final return result corresponding to the search task can be obtained after the most important edge subtask is completed, so that the obtained final return result is more comprehensive, which is also beneficial to improving user experience.
[0101] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store a computer program related to a method in a method embodiment, and the computer program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0102] An embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method provided in the above embodiment when executing the computer program.
[0103] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0104] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are only for illustration, not for limiting the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention.
Claims
1. A search task processing method based on thread pool, characterized in that: The search task is a task for searching for relevant information from a target departure address to a target arrival address, and the method comprises the following steps: S1. When receiving the target departure address and target arrival address input by the target user, a search task is generated and the core subtask identifier A and the edge subtask identifier list B corresponding to the search task are obtained. i , ..., B m }, B i is the ith edge subtask identifier corresponding to the search task, i ranges from 1 to m, and m is the number of edge subtask identifiers corresponding to the search task, wherein the search task is composed of several subtasks, the core subtask corresponding to the search task is the subtask that must be completed among the several subtasks that make up the search task, and the edge subtask corresponding to the search task is the subtask other than the core subtask among the several subtasks that make up the search task; S2, let the thread pool allocate m+1 threads to concurrently execute the core subtasks corresponding to A and B1, B2, ..., B i , ..., B m The corresponding edge subtask; S3, obtain the initial return result list C corresponding to the search task = {C 0 , C1, C2, ..., C i , ..., C m }, C 0 is the initial return result corresponding to A, C i For B i The corresponding initial return result, where C 0 , C1, C2, ..., C i , ..., C m Initially, they are all NULL; S4. Update C and determine C each time the update is completed. 0 Is it NULL and go to step S5, where when the thread corresponding to A is executed, let C 0 =A 0 So that C is updated, A 0 The output or return value generated after the thread corresponding to A completes the core subtask corresponding to A. i When the corresponding thread is finished, let C i =B 0 i So that C is updated, B 0 i For B i The corresponding thread completes B i The output or return value generated by the corresponding edge subtask; S5, when C 0 When not NULL, C 0 , C1, C2, ..., C i , ..., C m Perform integration processing to obtain the final return result corresponding to the search task.
2. The thread pool-based search task processing method according to claim 1, characterized in that: The core subtask identifier is the unique identifier of the core subtask.
3. The thread pool-based search task processing method according to claim 1, characterized in that: The edge subtask identifier is the unique identifier of the edge subtask.
4. The thread pool-based search task processing method according to claim 1, characterized in that: There is no dependency between the core subtask and any edge subtask.
5. The thread pool-based search task processing method according to claim 1, characterized in that: There is no dependency between any two edge subtasks.
6. The thread pool-based search task processing method according to claim 1, characterized in that: Step S5 is replaced by the following steps S10-S20: S10, when C 0 When it is not NULL, the current time point is used as the key update time point D corresponding to A and the current C is immediately copied as the first return result list E corresponding to the search task = {E 0 , E1, E2, ..., E i ,……,E m }, E 0 is the first returned result corresponding to A, E i For B i The corresponding first returned result; S20, based on E i Get the final return result corresponding to the search task.
7. The thread pool-based search task processing method according to claim 6, characterized in that: In step S20, the following steps S21-S24 are included: S21, traverse E, when E i When NULL, B i as the unfinished subtask identifier to obtain an unfinished subtask identifier list F={F1, F2, . . . , F j , ..., F n }, F j is the jth unfinished subtask identifier, where j ranges from 1 to n, and n is the number of unfinished subtask identifiers; S22, obtain F according to the preset importance weight mapping list G corresponding to the search task j The corresponding waiting time weight H j , G={G1,G2,……,G i , ..., G m }, G i =(B i , G 0 j ), G j For B j The corresponding preset importance weight mapping combination, G 0 j G j Medium B j The corresponding preset importance weights, where F j =B i When G 0 j As H j ; S23, obtain the candidate waiting time list K corresponding to F = {K1, K2, ..., K j , ..., K n } and K1, K2, ..., K j , ..., K n The largest candidate waiting time in K is taken as the target waiting time MB. j F j The corresponding candidate waiting time, K j Meet the following conditions: K j =H j ×T, T is the preset maximum waiting time; S24, when the predicted time point YC arrives, 0 , C1, C2, ..., C i , ..., C m Perform integration processing to obtain the final return results corresponding to the search task. YC meets the following conditions: YC=D+MB.
8. The thread pool-based search task processing method according to claim 7, characterized in that: G 0 j The value range is [0, 1].
9. A non-transitory computer-readable storage medium, characterized in that: The storage medium stores a computer program, which is loaded and executed by a processor to implement the thread pool-based search task processing method as described in any one of claims 1 to 8.
10. An electronic device, comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the thread pool-based search task processing method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Data retrieval method and system
CN103186563A
Social media data acquisition method and system
CN112667901A
Parallel task scheduling method and device, computer equipment and storage medium
CN113010286A
Information pushing method and device, equipment and storage medium
CN117453994A
Search task processing method, electronic equipment and storage medium
CN120029772A
Cited By
Search task processing method, electronic equipment and storage medium
CN120029772A
A search task processing method, electronic device and storage medium
CN120029772B