Data query method and device, equipment and medium

By using the cache table of the preset query wrapper in the cloud management platform to determine whether there are the same query parameters in multi-threaded query, the system resource occupation problem caused by long-term non-management process data query is solved, and efficient and accurate data query is achieved.

CN120470028APending Publication Date: 2025-08-12JINAN INSPUR DATA TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510558338.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

In cloud management platforms, the long-term non-management process data query service leads to excessive system resources occupied and the inability to ensure data accuracy in real time, especially in high concurrency scenarios, which may cause system stuck.

Method used

Determine whether the same query parameters exist on the multi-threaded query based on the cache table of the preset query wrapper. If it exists, the cache result will be multiplexed. If it does not exist, the query will be executed and cached to avoid repeated operations.

Benefits of technology

It effectively reduces the repeated operations of multi-threaded concurrent queries, reduces system resource consumption, improves query efficiency, and ensures the consistency and accuracy of results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470028A_ABST
    Figure CN120470028A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and device, equipment and a medium, and the method comprises the steps: determining a plurality of same query feature identifiers of a plurality of threads in each data query scene, and judging whether the threads execute query parameters of the same query feature identifiers to perform data query based on a cache table of a preset query wrapper, if yes, the cached query result is directly called, and repeated query is avoided; and if not, executing data query and caching a query result for subsequent query of the same feature identifier. By means of the method, repeated operation during multi-thread concurrent query is effectively reduced, system resource consumption is reduced, query efficiency is improved, and meanwhile consistency and accuracy of results under the same query condition are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computers, and in particular to a data query method, apparatus, device, and medium. Background Art

[0002] In cloud management platform business scenarios, it's common to read data from non-management processes, such as obtaining a list of system files or using specific commands to parse data in a specific file format. These queries are typically time-consuming, and to ensure data accuracy, real-time data at the time of the query is required. For example, parsing system directory file formats or creating new virtual machines based on virtual machine template files are essential. When business usage is low, these queries have minimal impact on the system. However, as business scales, when the number of query files exceeds a thousand, or when thousands of people are simultaneously parsing virtual machine template files, the management platform consumes significant computing resources to process these repetitive processes. In severe cases, this can even cause the system to freeze and become unresponsive to other business operations.

[0003] Currently, related technologies mainly use query caching to address time-consuming non-management process data queries in cloud management platforms. However, due to the cache update frequency limit, this approach cannot guarantee data accuracy in real time. Summary of the Invention

[0004] The present disclosure provides a data query method, apparatus, device, and medium. Addressing the issue of data accuracy being unable to be guaranteed in real time during data queries in related technologies, the present disclosure utilizes a cache table based on a preset query wrapper to accurately determine whether query threads with identical query parameters exist during multi-process data queries. This method reuses cached query results to avoid duplicate queries, and executes and caches queries without cached results. This effectively reduces duplicate operations in multi-threaded concurrent queries, lowers system resource consumption, improves query efficiency, and ensures the consistency and accuracy of results under the same query conditions.

[0005] A first aspect embodiment of the present disclosure proposes a data query method, including: determining multiple query feature identifiers in a data query scenario, each query feature identifier in the multiple query feature identifiers is the same, and the multiple query feature identifiers are query feature identifiers corresponding to query parameters of each thread in multiple threads; based on the query feature identifiers stored in a cache table of a preset query wrapper, determining whether there is a first thread that uses a first query parameter to query data, and the first query feature identifier corresponding to the first query parameter is the same as each query feature identifier; if the first thread exists, using a first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier; if the first thread does not exist, performing data query according to a query interface stored in the query wrapper in combination with a second query parameter to obtain a second query result, and using the second query result as a query result corresponding to a third query feature identifier other than the second query feature identifier in the multiple query feature identifiers, and the second query parameter is a query parameter corresponding to the second query feature identifier in the multiple query feature identifiers.

[0006] A second embodiment of the present disclosure provides a data query device, including:

[0007] a determining unit, configured to determine a plurality of query feature identifiers in a data query scenario, wherein each of the plurality of query feature identifiers is the same and the plurality of query feature identifiers are query feature identifiers corresponding to query parameters of each of the plurality of threads;

[0008] a checking unit, configured to determine whether there is a first thread that uses the first query parameter to perform data query based on the query feature identifier stored in the cache table of the preset query wrapper, wherein the first query feature identifier corresponding to the first query parameter is the same as each query feature identifier;

[0009] a first query unit, configured to use, if the first thread exists, a first query result corresponding to the first query feature identifier stored in the cache table as a query result corresponding to each query feature identifier;

[0010] The second query unit is used to, if the first thread does not exist, perform data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, so as to use the second query result as a query result corresponding to a third query feature identifier other than the second query feature identifier among the multiple query feature identifiers, and the second query parameter is a query parameter corresponding to the second query feature identifier among the multiple query feature identifiers.

[0011] The third aspect embodiment of the present disclosure proposes an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor, when used to run the computer program, executes the method described in the first aspect embodiment of the present disclosure.

[0012] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the first aspect embodiment of the present disclosure.

[0013] The fifth aspect embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in the first aspect embodiment of the present disclosure when executed by a processor.

[0014] In summary, the data query method provided by this disclosure determines multiple identical query feature identifiers for multiple threads in each data query scenario. Based on a cache table in a preset query wrapper, it determines whether a thread has already executed a data query using query parameters with the same query feature identifier. If so, the cached query result is directly called to avoid duplicate queries. If not, the data query is executed and the query result is cached for subsequent queries with the same feature identifier. This effectively reduces duplicate operations during multi-threaded concurrent queries, lowers system resource consumption, improves query efficiency, and ensures the consistency and accuracy of results under the same query conditions.

[0015] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0017] Figure 1 A flowchart of a data query method provided by an embodiment of the present disclosure;

[0018] Figure 2 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0019] Figure 3 A schematic diagram of a specific data query method provided by an embodiment of the present disclosure;

[0020] Figure 4 A schematic diagram of the structure of a data query device provided by an embodiment of the present disclosure;

[0021] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0022] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0023] In cloud management platform business scenarios, it's common to read data from non-management processes, such as obtaining a list of system files or using specific commands to parse data in a specific file format. These queries are typically time-consuming, and to ensure data accuracy, real-time data at the time of the query is required. For example, parsing system directory file formats or creating new virtual machines based on virtual machine template files are essential. When business usage is low, these queries have minimal impact on the system. However, as business scales, when the number of query files exceeds a thousand, or when thousands of people are simultaneously parsing virtual machine template files, the management platform consumes significant computing resources to process these repetitive processes. In severe cases, this can even cause the system to freeze and become unresponsive to other business operations.

[0024] Currently, there are three main solutions to the above problems in related technologies: first, adopt an optimized query process, such as narrowing the query scope by setting conditions and using more efficient parsing commands; second, increase the query cache, update all data within the query range to the memory or memory-based database, and directly obtain it from the cache during query, and the cache is updated according to the established rules; third, implement a current limiting strategy, that is, limit the number of concurrent accesses.

[0025] The data query solutions mentioned above all have limitations. Solution 1 relies on finding efficient query optimization methods. If such methods are unavailable, implementation becomes difficult and objectively unfeasible. Solution 3, while preventing excessive use of system computing resources, cannot guarantee that all requests will be responded to, inevitably leading to some requests being ignored. Solution 2, while a mainstream solution, struggles to guarantee data accuracy and timeliness in real time due to cache update frequency.

[0026] To address the technical issues in related technologies, the present invention provides a data query method that determines multiple identical query feature identifiers for multiple threads in each data query scenario. Based on a cache table in a preset query wrapper, the method determines whether a thread has already executed a data query using query parameters with the same query feature identifier. If so, the cached query result is directly called to avoid duplicate queries. If not, the data query is executed and the query result is cached for subsequent queries with the same feature identifier. This effectively reduces duplicate operations during multi-threaded concurrent queries, lowers system resource consumption, improves query efficiency, and ensures the consistency and accuracy of results under the same query conditions.

[0027] The data query method disclosed in this paper can be applied to business scenarios developed in Java, and is particularly suitable for query businesses with lengthy processes and time-consuming processing. In complex environments with multi-threaded concurrent access, the data query method disclosed in this paper can significantly reduce system resource consumption and greatly improve system operating efficiency and stability.

[0028] The embodiments of the present disclosure will be described in detail below.

[0029] like Figure 1 As shown, an embodiment of the present disclosure provides a data query method, comprising the following steps:

[0030] Step 101 : determining a plurality of query feature identifiers in a data query scenario, wherein each query feature identifier in the plurality of query feature identifiers is the same and the plurality of query feature identifiers are query feature identifiers corresponding to query parameters of each thread in a plurality of threads.

[0031] In some embodiments, in a data query scenario, each thread carries specific query parameters when performing a data query. In order to facilitate management and distinguish different query requests, a corresponding query feature identifier is generated for each query parameter.

[0032] The same query feature identifiers of multiple threads in the present disclosure mean that the query parameters of these threads are determined to have the same query features under certain rules, which may be due to the same key query conditions, such as querying the same database table, the same filtering conditions, etc.

[0033] Step 102: Based on the query feature identifiers stored in the cache table of the preset query wrapper, determine whether there is a first thread that uses the first query parameter to query data, and the first query feature identifier corresponding to the first query parameter is the same as each query feature identifier.

[0034] In some embodiments, a cache table of a preset query wrapper is used to store relevant information of previous queries, including query feature identifiers and corresponding query results. The present disclosure can check whether the cache table contains the same query feature identifier (i.e., the first query feature identifier) as the query feature identifier of the current multiple threads. If so, it indicates that a thread (i.e., the first thread) is currently querying data using the same query parameters.

[0035] Step 103: If the first thread exists, the first query result corresponding to the first query feature identifier stored in the cache table is used as the query result corresponding to each query feature identifier.

[0036] In some embodiments, if the same query signature is found in the cache table, it means that a thread is currently performing the same data query. In this case, there is no need to perform the actual query again. Instead, the query is simply waited for the first thread's data query to complete, and the first data query result is cached in the cache table. The first query result in the cache table is then returned as the query result for the current multiple threads, thus saving a significant amount of query time and system resources.

[0037] It is understandable that multiple threads refer to threads that initiate query requests for the same resources and the same conditions during the period when the first thread performs data query. Before the first thread completes the query, they share the result of the first triggered access and no longer perform the actual query operation. In other words, after the first thread starts the data query operation, the present disclosure sets the object targeted by its query to a fixed state. During the period before the first thread completes this data query, if there are other threads that initiate query requests for the same resource with exactly the same query conditions, these requests will not trigger a new query process. The system will return the result obtained from the first triggered access (i.e., the query initiated by the first thread) as the result of all subsequent query requests with the same conditions, so as to ensure that the query results for the same resources and the same conditions are consistent within this time period.

[0038] Step 104: If the first thread does not exist, perform data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, and use the second query result as the query result corresponding to the third query feature identifier other than the second query feature identifier in the multiple query feature identifiers, and the second query parameter is the query parameter corresponding to the second query feature identifier in the multiple query feature identifiers.

[0039] In some embodiments, when searching in the cache table, if no record with the same query signature is found, it can be determined that this is a new query request. The query signature is generated based on the query parameters and is used to uniquely identify a query request.

[0040] Once a new query request is identified, a new thread (the second thread) is started. This thread performs the actual data query based on the query interface stored in the query wrapper. The query interface can be a database query statement, such as an SQL query statement, or an API call interface, such as an interface for calling a third-party service. The data query is also performed based on specific query parameters (the second query parameters).

[0041] While the second thread is querying data, all other threads except the second thread will enter a blocked state, waiting for the second thread to complete the data query. This is to avoid multiple threads performing the same query operation at the same time, thereby reducing the waste of system resources.

[0042] When the second thread completes the data query and obtains the second query result, it will store the query feature identifier and the corresponding query result in the cache table. In this way, if there is a subsequent query request for the same query, the result can be directly obtained from the cache table without having to perform the actual query operation again.

[0043] After the remaining waiting threads learn that the second thread's query has completed, they will directly obtain the second query result from the cache table and use it as their own corresponding query result. This avoids repeated queries and improves query efficiency.

[0044] In summary, the data query method proposed in the present disclosure includes: determining multiple query feature identifiers in a data query scenario, each query feature identifier in the multiple query feature identifiers is the same, and the multiple query feature identifiers are query feature identifiers corresponding to the query parameters of each thread in multiple threads; based on the query feature identifiers stored in the cache table of a preset query wrapper, determining whether there is a first thread that uses the first query parameter to perform data query, and the first query feature identifier corresponding to the first query parameter is the same as each query feature identifier; if the first thread exists, using the first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier; if the first thread does not exist, performing data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, and using the second query result as the query result corresponding to the third query feature identifier other than the second query feature identifier in the multiple query feature identifiers, and the second query parameter is the query parameter corresponding to the second query feature identifier in the multiple query feature identifiers. This effectively avoids repeated execution of the same query in high-concurrency scenarios, reduces waste of system resources, and improves query efficiency. Especially for slow query operations, the use of caching mechanisms can significantly shorten query response time, improve the overall performance and stability of the system, and also ensure the responsiveness of all user requests.

[0045] Figure 2 The following further illustrates a flow chart of a data query method proposed in the present disclosure. Figure 1 The illustrated embodiment further explains, Figure 2 The following steps may be included.

[0046] Step 201: Determine a query parameter for each of multiple threads in a data query scenario.

[0047] Step 202: perform keyword extraction on each query parameter to obtain a query feature identifier corresponding to each query parameter.

[0048] In some embodiments, when multiple threads are concurrently querying data, the present disclosure requires that the query parameters carried by each thread when initiating a data query be clearly defined. Query parameters determine the specific content and conditions of the query. For example, in a database query, these may include information such as filter conditions, sorting rules, and query fields. Query parameters may be the same or different for different threads, and accurately obtaining query parameters is essential for subsequent processing.

[0049] In order to effectively reduce the cache range, the present disclosure adopts a keyword-based query parameter division strategy. Specifically, it is to extract keywords for each query parameter, and use the extracted keywords as the query feature identifier corresponding to the query parameter. The uniqueness of this division method is that it is not divided according to the resource objects in the actual sense, but defines the queried resources based on the keywords involved in the query. For example, when performing the operation of "querying for 5 files whose file names start with Test", the "querying for 5 files whose file names start with Test" is regarded as the queried resource as a whole, rather than the actual 5 files as the queried resources.

[0050] Specifically, in an optional embodiment of the present disclosure, the present disclosure can generate a query feature value identifier based on the incoming query. If multiple query parameters are passed in, the query parameters are connected in the order of the passed in query parameters (for example, using "-" to connect), and the connected string is used as the query feature identifier of this query.

[0051] Step 203: Determine whether the cache table stores the first query feature identifier, and based on the determination result, determine whether there is a first thread that uses the first query parameter to perform data query.

[0052] In some embodiments, if the first query feature identifier is stored in the cache table, it is determined that the first thread exists; if the first query feature identifier is not stored in the cache table, it is determined that the first thread does not exist.

[0053] The cache table stores previously queried information. By checking whether there is a record in the cache table with the same signature as the current query (here, the first signature), we can determine whether another thread is currently performing the same query (i.e., whether the first thread exists). If the signature exists in the cache table, it indicates that a thread is already performing the same query; if not, it indicates that this is a new query request.

[0054] In some embodiments, before determining whether there is a first thread that uses a first query parameter to query data based on a query feature identifier stored in a cache table of a preset query wrapper, the method includes: generating an initialization cache table in the query wrapper based on the query parameters and query results in the query wrapper corresponding to the data query scenario, the initial cache table including a correspondence between the query feature identifier and the query result corresponding to the query feature identifier and a request counter, and the query feature identifier is obtained through the query parameter; when using the first query parameter to query data, determining the first query feature identifier corresponding to the first query parameter and the initial query result corresponding to the first query feature identifier; storing the first query feature identifier and the initial query result in the initial cache table, and initializing the request counter in the initial cache table to obtain an initial counting result; using the query interface stored in the query wrapper in combination with the first query parameter to query data to obtain a first query result, and updating the initial query result in the initial cache table to the first query result to obtain a cache table.

[0055] The present disclosure can be created based on the query parameters and query results in the query wrapper corresponding to the data query scenario. An initial cache table structure is established in the query wrapper. This table records the relationship between the query feature identifier and the corresponding query result, and also includes a request counter. For example, when the first query request comes in, the query feature identifier is generated based on its query parameters, and the corresponding initial query result is created for it (which may be empty and will be updated later), and the request counter is initialized at the same time.

[0056] Specifically, in an optional embodiment of the present disclosure, a request cache object (i.e., a cache table) can be initialized in a query wrapper. The request cache object is constructed in a Key-Value format, where the key is a string type, which is a request identifier (i.e., a query feature identifier) constructed based on the query parameters, and the value is the data result type returned by the query interface (i.e., the query result) and the request counter.

[0057] When the first query parameter is used to query data, the key value (i.e., the first query feature identifier) is stored in the cache table, and a value object (i.e., the initial query result) is created. The query result object (i.e., the query result in the cache table in this disclosure) is set to empty, and the query counter is initialized to 1 (i.e., the initial count result).

[0058] Get the query interface object in the query wrapper, determine the query interface based on the query interface object, and use the query interface and query parameters to execute the actual slow query process;

[0059] After the slow query is successful, the slow query result (i.e., the first query result) is obtained, and based on the first query feature identifier, the corresponding value object (i.e., the initial query result) is obtained from the cache table, and the initial query result is updated to the first query result. After completion, other waiting threads (i.e., multiple threads in this disclosure) are woken up.

[0060] In some embodiments, based on the query parameters and query results in the query wrapper corresponding to the data query scenario, before generating the initialization cache table in the query wrapper, it includes: obtaining the query parameters, query interface and query results for data query under multiple data query scenarios; constructing a query wrapper corresponding to each data query scenario according to the query parameters, query interface and query results, and storing the query interface in the query wrapper. The query wrapper is a programming component for optimizing query operations.

[0061] Before generating the initial cache table, we first need to obtain the query parameters, query interfaces, and query results required for data queries in multiple data query scenarios. Based on this information, we construct a query wrapper for each data query scenario. The query wrapper serves as a programming component for optimizing query operations, integrating and managing query-related resources and logic. The query interface is the code snippet that actually executes the query operation, which is stored in the query wrapper for subsequent invocation.

[0062] Specifically, in an optional embodiment of the present disclosure, the present disclosure needs to identify the slow query interface (i.e., the query interface) and the return data type (i.e., the query result) for the slow query scenario (i.e., the scenario of performing regular data queries in each query scenario). Then, the identified query parameters, query interface, and returned query result are used as initialization parameters of the query wrapper to create a new query wrapper (QueryWrapper). After the query wrapper is constructed, the query interface is saved in the query wrapper, that is, the query interface is saved as a slow query interface object in the query wrapper.

[0063] After constructing the query wrapper, the present disclosure can replace the original slow query call process with the constructed query wrapper, call the query interface provided by the query wrapper, use the original slow query parameters as the query parameters of the query wrapper, and trigger the data query.

[0064] Step 204: If the first thread exists, the first query result corresponding to the first query feature identifier stored in the cache table is used as the query result corresponding to each query feature identifier.

[0065] In some embodiments, if there is a first thread and the data query process of the first thread is not completed, multiple threads are adjusted to enter a blocking state, and the initial count result of the request counter in the cache table is adjusted to the first count result; when the data query process is completed, multiple threads are adjusted to enter a data query state, and each thread obtains the first query result stored in the cache table in turn according to the order in which the query parameters are input, and adjusts the first count result of the request counter in the cache table in turn until the first count result reaches the target value, and then clears the first query feature identifier and the first query result stored in the cache table.

[0066] When it is determined that the same query feature identifier exists in the cache table (i.e., there is a first thread) and the data query process of the first thread has not been completed, the current multiple threads are adjusted to a blocked state, waiting for the first thread to complete the query. At this time, it is also necessary to adjust the technical result of the request count to the first count result (i.e., adjust the first count result according to the number of the current multiple threads). Once the first thread completes the query and updates the query result in the cache, these blocked threads will be awakened and enter the data query state, and then obtain the query results from the cache table in sequence, and adjust the first count result of the request counter. When the first count result reaches the target value (usually 0, indicating that all threads using the cache result have been obtained), the corresponding query feature identifier and query result in the cache table are cleared to release cache space. The present disclosure directly uses the query result in the cache table as the query result of the current multiple threads, avoiding repeated execution of query operations and improving query efficiency.

[0067] In an optional embodiment of the present disclosure, the present disclosure may verify the key value collection of the cache table in the query wrapper based on the query feature identifier, verify whether the first query feature identifier exists in the table, and perform the following processing based on the existence:

[0068] If it exists in the cache table, obtain the corresponding value in the cache table (the first data query result), take the query counter therein and perform a +1 operation, and then set the thread to a blocked state, waiting for other threads to wake up; when the data query process of the first thread has been completed, according to the query feature value ID, obtain the corresponding first query result and query counter from the cache table, and set the query counter -1; check the query counter, if the value is 0 (that is, the target value), remove the cache record corresponding to the query feature identifier; if it is not 0, continue (there is concurrency control here, and there will be no update abnormality problems for the query counter and query result).

[0069] Step 205: If the first thread does not exist, perform data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, and use the second query result as the query result corresponding to the third query feature identifier in the multiple query feature identifiers except the second query feature identifier.

[0070] In some embodiments, if the first thread does not exist, the second query feature identifier is determined, and the second query parameter corresponding to the second query feature identifier is used to query data; an initial query result corresponding to the second query feature identifier is created; the second query feature identifier and the initial query result are stored in a cache table, and the request counter in the cache table is initialized to obtain an initial count result; the query interface stored in the query wrapper is used in combination with the second query parameter to query data, and the thread corresponding to the third query result is adjusted to enter a blocked state and the initial count result of the request counter in the cache table is adjusted to the second count result; when the data query process is completed, the second query result is obtained, and the initial query result in the cache table is updated to the second query result; the thread corresponding to the third query result is adjusted to enter a data query state, and according to the input order of the query parameters corresponding to the third query feature identifier, each thread obtains the second query result stored in the cache table in turn, and adjusts the second count result of the request counter in the cache table in turn until the second count result reaches the target value, and then the second query feature identifier and the second query result stored in the cache table are cleared.

[0071] If the signature identifier corresponding to the current query does not exist in the cache table, the actual data query operation is performed based on the query interface stored in the query wrapper and the query parameters of the current thread (here set as the second query parameters). After obtaining the query result (the second query result), it is used as the query result for other threads with the same query signature identifier (the third query signature identifier).

[0072] Specifically, the present disclosure can store the key value (i.e., the second query feature identifier) into the cache table, and at the same time create a value object (i.e., the initial query result), set the query result object therein to be empty, and initialize the query counter to 1 (i.e., the initial count result); obtain the query interface object in the query wrapper, determine the query interface according to the query interface object, use the query interface and query parameters to execute the actual slow query process, and adjust the thread corresponding to the third query result to enter a blocked state and the initial count result of the request counter in the cache table to the second count result (i.e., determine the second count result according to the thread corresponding to the third query result); after the slow query is successful, obtain the slow query result (i.e., the second query result), obtain the corresponding value object (i.e., the initial query result) from the cache table based on the second query feature identifier, update the initial query result to the second query result, and wake up other waiting threads after completion (i.e., adjust the thread corresponding to the third query result to enter the data query state). After waking up the thread, the corresponding query result acquisition step can be specifically referred to step 204, which will not be repeated here.

[0073] In summary, the data query method proposed in this disclosure can greatly reduce the encroachment of slow queries on system computing resources in high-concurrency scenarios, reduce the impact of platform services on system stability, and at the same time take into account user experience. That is, it ensures the responsiveness of all user requests during slow queries in concurrent scenarios, and optimizes the query speed from N slow query times to at most 1 slow query time.

[0074] based on Figures 1 to 2 The embodiment shown, as Figure 3 As shown, the present disclosure provides a schematic diagram of a specific data query method.

[0075] Reference Figure 3 In the present disclosure, when multiple threads simultaneously perform data query in a certain data query scenario, the query parameters of each thread in the multiple threads in the current data query scenario are determined; keywords are extracted for each query parameter to obtain a query feature identifier corresponding to each query parameter, and then it is determined whether a first query feature identifier identical to the query feature identifier is stored in a cache table (i.e., whether a first thread exists); if the first query feature identifier is stored in the cache table, the query calculator is first increased by 1 to obtain a first counting result, and then the multiple threads are adjusted to enter a blocking state. If the data query process of the first thread is completed, the multiple threads are awakened, i.e., the multiple threads are adjusted to enter a query state, and the first query result is obtained from the cache table in sequence according to the query parameter input order, and the first counting result of the request counter in the cache table is adjusted in sequence until the first counting result reaches a target value (i.e., the target value is 0), the first query feature identifier and the first query result stored in the cache table are cleared, and the query result corresponding to each thread is returned in sequence.

[0076] If the first query feature identifier is not stored in the cache table, it is determined that the first thread does not exist. At this time, data query is performed according to the query interface stored in the query wrapper in combination with the second query parameter, and the query calculator +1 is added to obtain the second counting result. Then, multiple threads are adjusted to enter the blocked state. If the data query process is completed, the thread corresponding to the third query result is awakened, that is, the thread corresponding to the third query result is adjusted to enter the data query state, and the second query result is obtained from the cache table in sequence according to the input order of the query parameters, and the second counting result of the request counter in the cache table is adjusted in sequence until the second counting result reaches the target value (that is, the target value is 0), and the second query feature identifier and the second query result stored in the cache table are cleared. At this time, the query result corresponding to each thread is returned in sequence.

[0077] In order to implement the data query method provided by the embodiment of the present disclosure, the embodiment of the present disclosure also provides a data query device, such as Figure 4 As shown, the data query device 400 includes:

[0078] A determining unit 410 is configured to determine a plurality of query feature identifiers in a data query scenario, wherein each of the plurality of query feature identifiers is the same and the plurality of query feature identifiers are query feature identifiers corresponding to query parameters of each of the plurality of threads;

[0079] A checking unit 420 is configured to determine whether there is a first thread that uses the first query parameter to perform data query based on the query feature identifiers stored in the cache table of the preset query wrapper, and the first query feature identifier corresponding to the first query parameter is the same as each query feature identifier;

[0080] A first query unit 430 is configured to use, if the first thread exists, the first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier;

[0081] The second query unit 440 is used to, if the first thread does not exist, perform data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, so as to use the second query result as a query result corresponding to a third query feature identifier other than the second query feature identifier among the multiple query feature identifiers, and the second query parameter is a query parameter corresponding to the second query feature identifier among the multiple query feature identifiers.

[0082] In some embodiments, the determining unit 410 is configured to: determine a query parameter of each of the multiple threads in a data query scenario; and perform keyword extraction on each query parameter to obtain a query feature identifier corresponding to each query parameter.

[0083] In some embodiments, the checking unit 420 is used to: determine whether the first query feature identifier is stored in the cache table; if the first query feature identifier is stored in the cache table, determine that the first thread exists; if the first query feature identifier is not stored in the cache table, determine that the first thread does not exist.

[0084] In some embodiments, the inspection unit 420 is used to: before determining whether there is a first thread that uses the first query parameter to query data based on the query feature identifier stored in the cache table of the preset query wrapper, generate an initialization cache table in the query wrapper based on the query parameters and query results in the query wrapper corresponding to the data query scenario, the initial cache table including the correspondence between the query feature identifier and the query result corresponding to the query feature identifier and a request counter, and the query feature identifier is obtained through the query parameter; when using the first query parameter to query data, determine the first query feature identifier corresponding to the first query parameter and the initial query result corresponding to the first query feature identifier; store the first query feature identifier and the initial query result in the initial cache table, and initialize the request counter in the initial cache table to obtain an initial counting result; use the query interface stored in the query wrapper in combination with the first query parameter to query data to obtain a first query result, and update the initial query result in the initial cache table to the first query result to obtain the cache table.

[0085] In some embodiments, the device also includes: a construction unit, which is used to obtain query parameters, query interfaces and query results for data queries in multiple data query scenarios before generating an initialization cache table in the query wrapper based on the query parameters and query results in the query wrapper corresponding to the data query scenario; construct a query wrapper corresponding to each data query scenario according to the query parameters, query interface and query results, and store the query interface in the query wrapper. The query wrapper is a programming component for optimizing query operations.

[0086] In some embodiments, the first query unit 430 is used to: if there is a first thread and the data query process of the first thread is not completed, adjust multiple threads to enter a blocking state, and adjust the initial count result of the request counter in the cache table to the first count result; when the data query process is completed, adjust multiple threads to enter a data query state, and each thread obtains the first query result stored in the cache table in turn according to the order of query parameter input, and adjusts the first count result of the request counter in the cache table in turn, until the first count result reaches the target value, and clears the first query feature identifier and the first query result stored in the cache table.

[0087] In some embodiments, the second query unit 440 is used to perform data query according to the query interface stored in the query wrapper and the second query parameter if the first thread does not exist, to obtain a second query result, so as to use the second query result as the query result corresponding to the third query feature identifier in the plurality of query feature identifiers other than the second query feature identifier, including: if the first thread does not exist, determining the second query feature identifier, and performing data query using the second query parameter corresponding to the second query feature identifier; creating an initial query result corresponding to the second query feature identifier; storing the second query feature identifier and the initial query result in a cache table, and initializing the request counter in the cache table to obtain an initial count result; using the query The query interface stored in the wrapper performs data query in combination with the second query parameter, and adjusts the thread corresponding to the third query result to enter a blocking state and the initial count result of the request counter in the cache table to the second count result; when the data query process is completed, the second query result is obtained, and the initial query result in the cache table is updated to the second query result; the thread corresponding to the third query result is adjusted to enter a data query state, and according to the query parameter input order corresponding to the third query feature identifier, each thread obtains the second query result stored in the cache table in turn, and adjusts the second count result of the request counter in the cache table in turn, until the second count result reaches the target value, and then clears the second query feature identifier and the second query result stored in the cache table.

[0088] It should be noted that the data query device provided in the above embodiment only uses the division of the above-mentioned program modules as an example to illustrate data query. In actual applications, the above-mentioned processing can be assigned to different program modules as needed, that is, the internal structure of the data query device can be divided into different program modules to complete all or part of the above-described processing. In addition, the data query device provided in the above embodiment and the data query method embodiment provided in the embodiment of the present disclosure are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0089] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the electronic device 500 includes at least one processor 502; and a memory 501 communicatively connected to the at least one processor 502; wherein the memory 501 stores instructions that can be executed by the at least one processor 502, and the instructions are executed by the at least one processor 502 to implement the steps of the data query method described in the embodiment of the present disclosure.

[0090] Optionally, the electronic device may specifically be the data query device of the embodiment of the present disclosure, and the electronic device may implement the corresponding processes implemented by the data query device in each method of the embodiment of the present disclosure, which will not be described in detail here for the sake of brevity.

[0091] It is understood that the electronic device also includes a communication interface 503. The various components in the electronic device are coupled together through a bus system 504. It is understood that the bus system 504 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 504 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 504 .

[0092] It is understood that the memory 501 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a magnetic disk memory or a magnetic tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 501 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memories.

[0093] The methods disclosed in the above embodiments of the present disclosure can be applied to or implemented by processor 502. Processor 502 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in processor 502 or by software instructions. The above processor 502 may be a general-purpose processor, a DSP, or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc. Processor 502 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present disclosure can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium located in memory 501. Processor 502 reads information from memory 501 and, in conjunction with its hardware, completes the steps of the above method.

[0094] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, MCUs, microprocessors, or other electronic components to perform the aforementioned method.

[0095] The embodiment of the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to implement the steps of the data query method described in the embodiment of the present disclosure when executed.

[0096] The embodiments of the present disclosure further provide a computer program product, including a computer program, which implements the steps of the data query method described in the embodiments of the present disclosure when executed by a processor.

[0097] Optionally, the computer-readable storage medium can be applied to the data query device in the embodiment of the present disclosure, and the computer instructions enable the computer to execute the corresponding processes implemented by the data query device in each method of the embodiment of the present disclosure. For the sake of brevity, they are not repeated here.

[0098] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0099] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0100] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0101] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, ROM, RAM, disks or optical disks, etc. Various media that can store program codes.

[0102] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0103] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. A data query method, characterized in that: The method comprises: Determine a plurality of query feature identifiers in a data query scenario, wherein each query feature identifier in the plurality of query feature identifiers is the same, and the plurality of query feature identifiers are query feature identifiers corresponding to query parameters of each thread in the plurality of threads; determining, based on query feature identifiers stored in a cache table of a preset query wrapper, whether there is a first thread that uses a first query parameter to perform a data query, wherein a first query feature identifier corresponding to the first query parameter is the same as each of the query feature identifiers; If the first thread exists, using the first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier; If the first thread does not exist, data query is performed according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, and the second query result is used as the query result corresponding to the third query feature identifier other than the second query feature identifier in the multiple query feature identifiers, and the second query parameter is the query parameter corresponding to the second query feature identifier in the multiple query feature identifiers.

2. The method according to claim 1, characterized in that Determining multiple query feature identifiers in a data query scenario includes: Determining a query parameter for each of the multiple threads in the data query scenario; Keyword extraction is performed on each query parameter to obtain a query feature identifier corresponding to each query parameter.

3. The method according to claim 1, characterized in that The determining, based on the query feature identifier stored in the cache table of the query wrapper, whether there is a first thread that uses the first query parameter to query data includes: Determining whether the first query feature identifier is stored in the cache table; If the first query feature identifier is stored in the cache table, determining that the first thread exists; If the first query feature identifier is not stored in the cache table, it is determined that the first thread does not exist.

4. The method according to claim 1, wherein Before determining whether there is a first thread that uses the first query parameter to query data based on the query feature identifier stored in the cache table of the preset query wrapper, the method includes: Based on the query parameters and query results in the query wrapper corresponding to the data query scenario, generating an initialization cache table in the query wrapper, the initialization cache table including a correspondence between a query feature identifier and a query result corresponding to the query feature identifier, and a request counter, the query feature identifier being obtained through the query parameters; When performing a data query using a first query parameter, determining a first query feature identifier corresponding to the first query parameter and an initial query result corresponding to the first query feature identifier; Storing the first query feature identifier and the initial query result in the initial cache table, and initializing the request counter in the initial cache table to obtain an initial counting result; The query interface stored in the query wrapper is used in combination with the first query parameter to perform data query to obtain a first query result, and the initial query result in the initial cache table is updated to the first query result to obtain the cache table.

5. The method according to claim 1, wherein Before generating an initialization cache table in the query wrapper based on the query parameters and query results in the query wrapper corresponding to the data query scenario, the method includes: Obtain query parameters, query interfaces, and query results for data queries in multiple data query scenarios; A query wrapper corresponding to each data query scenario is constructed according to the query parameters, the query interface, and the query result, and the query interface is stored in the query wrapper. The query wrapper is a programming component for optimizing query operations.

6. The method according to claim 1, characterized in that If the first thread exists, using the first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier includes: If the first thread exists and the data query process of the first thread is not completed, adjusting the multiple threads to enter a blocked state, and adjusting the initial counting result of the request counter in the cache table to the first counting result; When the data query process is completed, the multiple threads are adjusted to enter the data query state. According to the query parameter input order, each thread obtains the first query result stored in the cache table in turn, and adjusts the first count result of the request counter in the cache table in turn until the first count result reaches the target value, and then clears the first query feature identifier and the first query result stored in the cache table.

7. The method according to claim 1, characterized in that If the first thread does not exist, performing a data query according to the query interface stored in the query wrapper in combination with the second query parameter to obtain a second query result, and using the second query result as a query result corresponding to a third query feature identifier other than the second query feature identifier among the multiple query feature identifiers includes: If the first thread does not exist, determining a second query feature identifier, and performing a data query using a second query parameter corresponding to the second query feature identifier; Creating an initial query result corresponding to the second query feature identifier; Storing the second query feature identifier and the initial query result in the cache table, and initializing the request counter in the cache table to obtain an initial counting result; Using the query interface stored in the query wrapper and combining the second query parameter to perform data query, and adjusting the thread corresponding to the third query result to enter a blocked state and the initial count result of the request counter in the cache table to the second count result; When the data query process is completed, a second query result is obtained, and the initial query result in the cache table is updated to the second query result; Adjust the thread corresponding to the third query result to enter the data query state. According to the query parameter input order corresponding to the third query feature identifier, each thread obtains the second query result stored in the cache table in turn, and adjusts the second counting result of the request counter in the cache table in turn until the second counting result reaches the target value, clearing the second query feature identifier and the second query result stored in the cache table.

8. A data query device, characterized in that: The device comprises: a determining unit, configured to determine a plurality of query feature identifiers in a data query scenario, wherein each of the plurality of query feature identifiers is the same and the plurality of query feature identifiers are query feature identifiers corresponding to query parameters of each thread in the plurality of threads; a checking unit, configured to determine whether there is a first thread that uses a first query parameter to perform data query based on the query feature identifier stored in the cache table of the preset query wrapper, wherein the first query feature identifier corresponding to the first query parameter is the same as each of the query feature identifiers; a first query unit, configured to use, if the first thread exists, the first query result corresponding to the first query feature identifier stored in the cache table as the query result corresponding to each query feature identifier; A second query unit is configured to, if the first thread does not exist, perform a data query based on the query interface stored in the query wrapper in combination with a second query parameter to obtain a second query result, and use the second query result as a query result corresponding to a third query feature identifier among the multiple query feature identifiers except the second query feature identifier, wherein the second query parameter is a query parameter corresponding to the second query feature identifier among the multiple query feature identifiers.

9. An electronic device, characterized in that: include: a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the data query method according to any one of claims 1-7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the data query method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data query method and device

    CN112395316A

  • Data query method and device, computer equipment and storage medium

    CN113886426A

  • Data query method, data query device, equipment, storage medium and product

    CN119311736A

  • Query request processing method and device

    CN119884170A