Query processing method and device, equipment, medium and product

By running the data read and write service and the distance computing service in different subthread pools, the problem of thread blocking during index retrieval based on DiskANN algorithm is solved, and query efficiency is improved.

CN119917723APending Publication Date: 2025-05-02BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411999075.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

During the index search process based on DiskANN algorithm, thread blockage may occur in high concurrent query scenarios, affecting the query progress.

Method used

The query request is broken down into two parts: data read and write service and distance computing service, and run in different subthread pools respectively to avoid threads being unable to perform other tasks when waiting for the I/O operation to complete.

Benefits of technology

By asynchronously decoupling I/O operations, the concurrency performance and query efficiency of the server are improved, and the thread blocking problem is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917723A_ABST
    Figure CN119917723A_ABST
Patent Text Reader

Abstract

The invention provides a query processing method and device, equipment, a medium and a product, and relates to the technical field of computers, in particular to the field of cloud computing and intelligent search. According to the specific implementation scheme, a DiskANN algorithm-based query request sent by a client is received, and the query request comprises a user identifier and a query parameter; loading an index file corresponding to the user identifier; decomposing a query request into two parts, namely a data read-write service and a distance calculation service; respectively operating the data read-write service and the distance calculation service in different sub-thread pools, and carrying out query operation according to the query parameters to obtain a query result; and returning the query response to the client. According to the method, the problem of thread blockage in the index retrieval process based on the DiskANN algorithm is solved, and the index query efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to cloud computing and intelligent search in the field of computer technology, and in particular to a query processing method, device, equipment, medium and product. Background Art

[0002] With the popularity of mobile smart devices, text, pictures, videos and other information on the Internet have exploded. Faced with this massive amount of information, Disk-Approximate Nearest

[0003] Approximate Nearest Neighbor (DiskANN) algorithm is a new graph search algorithm that is widely used. Its advantage is that it makes full use of the computer's disk and input / output (I / O) resources to achieve retrieval of ultra-large-scale vector data at a relatively low memory cost.

[0004] In the prior art, when performing index retrieval based on the DiskANN algorithm, in the application scenario of high-concurrency queries on multiple index vectors, the disk needs to read and write data frequently, which may cause thread blocking problems due to slow I / O operations, thereby affecting the overall query progress. Summary of the invention

[0005] The present disclosure provides a query processing method, apparatus, device, medium and product.

[0006] According to a first aspect of the present disclosure, a query processing method is provided, comprising:

[0007] Receiving a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and a query parameter;

[0008] Loading the index file corresponding to the user identifier;

[0009] Decomposing the query request into two parts: data reading and writing service and distance calculation service;

[0010] The data reading and writing service and the distance calculation service are respectively run in different sub-thread pools, and query operations are performed according to the query parameters to obtain query results;

[0011] The query response is returned to the client.

[0012] According to a second aspect of the present disclosure, a query processing device based on the DiskANN algorithm is provided, comprising:

[0013] A first receiving unit, configured to receive a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and a query parameter;

[0014] A first processing unit, used to load the index file corresponding to the user identifier;

[0015] A second processing unit, used for decomposing the query request into two parts: a data reading and writing service and a distance calculation service;

[0016] A third processing unit is used to run the data reading and writing service and the distance calculation service in different sub-thread pools respectively, and perform a query operation according to the query parameters to obtain a query result;

[0017] The first sending unit is used to return the query response to the client.

[0018] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0019] at least one processor; and

[0020] a memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.

[0022] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the first aspect.

[0023] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program, wherein the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the electronic device executes the method described in the first aspect.

[0024] The technology disclosed in the present invention solves the problem of thread blocking during index retrieval. By receiving a query request based on the DiskANN algorithm sent by a client, loading the index file corresponding to the user identifier in the query request, and then decomposing the query request into two parts: data reading and writing service and distance calculation service, and running these two parts in different sub-thread pools, and then performing query operations according to the query parameters in the query request, finally obtaining the query results, and returning the query response to the client. This method solves the problem of thread blocking in the index retrieval process based on the DiskANN algorithm and improves query efficiency.

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

[0026] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0027] Figure 1 is a scene graph that can implement the query method based on the DiskANN algorithm of the embodiment of the present disclosure;

[0028] Figure 2 is a schematic diagram of a first embodiment of the present disclosure;

[0029] Figure 3 is a schematic diagram of a second embodiment of the present disclosure;

[0030] Figure 4 is a schematic diagram of a fourth embodiment of the present disclosure;

[0031] Figure 5 is a schematic diagram of an eighth embodiment of the present disclosure;

[0032] Figure 6 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0033] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art 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.

[0034] With the popularity of mobile smart devices, text, pictures, videos and other information on the Internet have exploded. In order to respond to users' information search needs more quickly and quickly match and search in massive data in a short time, vector retrieval has become a research hotspot in academia and industry. As a hard disk-based graph search algorithm, DiskANN has the advantage of making full use of the computer's disk and I / O resources to achieve index retrieval of ultra-large-scale vector data at a relatively low memory cost.

[0035] In the index retrieval process based on the DiskANN algorithm, the utilization of I / O resources is a key factor in determining the index retrieval speed. In the existing query methods based on the DiskANN algorithm, when performing index retrieval in the vector database, the inconsistency between the I / O operation speed and the calculation speed in the memory is not taken into account, and the I / O resources are not fully utilized. In the high-concurrency batch query retrieval scenario commonly seen in practical applications (a large number of users initiate query services at the same time), the server may face read and write requests for multiple query vectors to be retrieved, and the I / O operation speed may be slow. The thread cannot perform other tasks while waiting for the I / O operation to complete, which leads to thread blocking and other problems, which will greatly affect the overall query speed.

[0036] Based on the technical problems in the above-mentioned background technology, the technical conception process of the present invention is as follows: when studying the query processing method, the inventors targeted the situation where the I / O operation speed is relatively slow and the thread cannot execute other tasks while waiting for the I / O operation to be completed. They found that the read and write services and the distance calculation services can be processed by two thread pools respectively, so that the main thread used for distance calculation can execute subsequent tasks without waiting for the I / O read and write operations, thereby improving the overall retrieval efficiency.

[0037] Based on the above technical concept, the present disclosure provides a query processing method, which receives a query request including a user identifier and query parameters based on the DiskANN algorithm sent by a client, and then decomposes the query request into two parts: a data read and write service and a distance calculation service. Then, the data read and write service and the distance calculation service are respectively run in different sub-thread pools, and query operations are performed according to the query parameters to obtain query results. Finally, the query response is returned to the client. This method solves the problem of thread blocking in the index retrieval process based on the DiskANN algorithm and improves query efficiency.

[0038] Figure 1 is a scene graph that can implement the query method based on the DiskANN algorithm of the embodiment of the present disclosure, such as Figure 1As shown, the scenario includes at least a client 101 and a server 102, wherein the client 101 and the server 102 are connected in communication, the client 101 is held by a user, and the user can operate the client 101, and the client 101 can be a smart phone, a laptop computer, a tablet computer or other device.

[0039] Optionally, the communication connection between the above-mentioned devices can be a wireless connection or a wired connection. The wired connection can be Ethernet, and the devices are connected through network cables (such as Category 5eEnhanced (Category 5e), Category 6 (Category 6, Cat6)). It can also be serial communication, for example, including RS-232, RS-485 and other standards. It can also be fiber optic communication, such as a metropolitan area network (MAN) and a wide area network (WAN). Wireless communication can be a wireless local area network, Bluetooth, Zigbee protocol, cellular network, low-power wide area network. For scenarios in remote areas, satellite communication can also be used.

[0040] The server 102 is used to receive the query request sent by the client 101, obtain the query result according to the query request, and finally return the query response to the client 101.

[0041] The user sends a query request based on the DiskANN algorithm to the server 102 through the client 101. The server 102 first loads the index file corresponding to the user identifier based on the user identifier and query parameters carried in the query request, and then decomposes the query request into two parts: a data reading and writing service and a distance calculation service. The data reading and writing service and the distance calculation service are then run in different sub-thread pools respectively, and then a query operation is performed according to the query parameters to obtain the query results, and finally a query response carrying the query results is returned to the client 101.

[0042] The present disclosure provides a query processing method, apparatus, device, medium and product, which are applied to the field of cloud computing and intelligent search in the field of computer technology, so as to solve the problem of thread blocking in the index retrieval process based on the DiskANN algorithm, thereby improving query efficiency.

[0043] The following specific embodiments are used to describe in detail the technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0044] Figure 2is a schematic diagram of the first embodiment of the present disclosure, referring to Figure 2 The query processing method shown in the figure can be configured as a query processing device based on the DiskANN algorithm, which can be located in an electronic device, and the electronic device can be, for example, a mobile phone, a cloud server, a server cluster, a computer, a laptop computer, a tablet computer, etc. The specific type of the electronic device is not limited in the present disclosure. The query processing method based on the DiskANN algorithm can include the following steps:

[0045] S201. Receive a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and query parameters.

[0046] In this solution, when a user needs to query text, pictures, audio, video and other information through the client, he usually needs to input his query requirements into the client in the form of natural language description or pictures, and select the query restriction parameters in the client. Then, based on the client's deep neural network algorithm, the query requirements in different forms are converted into vectors to obtain the query vector, which is used to send a query request to the server. Then, based on the query vector and query restriction parameters received in the query request, the server retrieves the target vector close to the query vector from the vector database based on the DiskANN algorithm to obtain the query results. After the server returns the query results to the client, the user can view the query results on the client.

[0047] In this step, in response to the query request based on the DiskANN algorithm sent by the client, the server receives the query request and obtains the user identifier corresponding to the client carried in the query request, as well as the query parameters including the query vector and the query restriction parameter. It should be understood that the server supports multiple clients to send query requests to the server at the same time.

[0048] Among them, the query vector is obtained by the client based on the deep neural network algorithm according to the query requirements input by the user, and is used to obtain the target vector corresponding to the query requirements, and then obtain the query results; the query restriction parameter is the parameter selected by the user on the client to configure the performance of the query process.

[0049] Optionally, the query restriction parameter may be a restriction parameter on the performance of the query process, such as the query precision, the recall rate, the expected number of results returned, etc. For example, the query restriction parameter may be the size of the candidate list, the maximum number of connections of nodes in the Vamana graph, the ratio of cached nodes to original data, the maximum number of I / O requests per query iteration, etc.

[0050] Exemplarily, the larger the maximum number of I / O requests for each query iteration in the query restriction parameter selected by the user, the higher the matching degree between the obtained query result and the user demand, but the query speed will also decrease accordingly.

[0051] S202: Load the index file corresponding to the user identifier.

[0052] In this step, for a query request sent by a client, in order to match and obtain a target vector corresponding to a query vector, it is necessary to load multiple index files corresponding to the user identifier carried in the query request.

[0053] The index file includes the original data stored on the disk.

[0054] It should be understood that in the subsequent query operation based on the query parameters, multiple vectors corresponding to the original data in the index file need to be loaded, including the graph index vector and the product quantization (PQ) index vector pre-constructed based on all the original data corresponding to the user identifier.

[0055] S203, decomposing the query request into two parts: data reading and writing service and distance calculation service.

[0056] In this step, in order to effectively solve the thread blocking problem caused by the inconsistency between the I / O operation speed and the calculation speed in the memory in the high-concurrency batch query retrieval scenario, the query request sent by each client needs to be decomposed into data reading and writing services and distance calculation services.

[0057] Among them, the data reading and writing service refers to the I / O operations and write operations on the index file; the distance calculation service refers to the service in which the central processing unit (CPU) calculates the distance between the query vector and multiple vectors in the index file based on the DiskANN algorithm according to the query parameters carried in the query request.

[0058] Optionally, the distance calculation service includes at least the following processes:

[0059] In the preliminary query phase, the distance calculation service calculates the distance of several vectors that are relatively close to the query vector based on the query vector sent by the client and the PQ index vector obtained by loading. The distance calculation service can obtain the query candidate queue for precise query.

[0060] In the precise query phase, the distance calculation service queries the candidate queue based on the query vector sent by the client, loads multiple acquired raw data and searches the graph corresponding to the raw data, and calculates the distance to the target vector closest to the query vector.

[0061] S204: Run the data reading and writing service and the distance calculation service in different sub-thread pools respectively, and perform query operations according to query parameters to obtain query results.

[0062] In this step, in order to effectively avoid the situation where the I / O operation speed is relatively slow in high-concurrency batch query retrieval scenarios and the thread cannot execute other tasks while waiting for the I / O operation to complete, the data reading and writing operations and the distance calculation service in step S203 need to be run in different thread pools respectively.

[0063] On this basis, the server can rely on the data reading and writing services and distance calculation services performed in different thread pools, and query and obtain the target vector corresponding to the client query request according to the query parameters in the query request sent by each client, and obtain the query result corresponding to the client query request. Among them, the query result includes multiple index files.

[0064] In the specific implementation of this solution, it should be understood that this step realizes asynchronous decoupling of I / O by running the data reading and writing service and the distance calculation service in different sub-thread pools. For each computing thread in the thread pool corresponding to the distance calculation service, after executing a distance calculation service, it is not necessary to wait for the completion of the data reading and writing service before continuing to execute the next distance calculation service, which saves the time for the distance calculation service to wait for the completion of the data reading and writing service and improves the concurrency performance of the server.

[0065] Furthermore, by configuring the number of threads executing the data reading and writing service to be twice the number of threads executing the distance calculation service, the execution speed of the data reading and writing service and the distance calculation service are effectively coordinated, further improving the speed of the query operation.

[0066] S205: Return the query response to the client.

[0067] In this step, after obtaining the query written corresponding to the query request of the client, the server returns a query response to the client, wherein the query response carries the query result.

[0068] Optionally, the user can view multiple index files corresponding to his query request through the query response returned by the client.

[0069] The query processing method provided in this embodiment receives a query request including a user identifier and query parameters based on the DiskANN algorithm sent by a client, then decomposes the query request into two parts: a data read and write service and a distance calculation service, and then respectively runs the data read and write service and the distance calculation service in different sub-thread pools, performs query operations according to the query parameters, obtains query results, and finally returns the query response to the client. This solves the thread blocking problem existing in the index retrieval process based on the DiskANN algorithm and improves query efficiency.

[0070] Furthermore, Figure 3 is a schematic diagram of the second embodiment of the present disclosure, referring to Figure 3 The query processing method shown in the figure is based on the above embodiment, and the index file corresponding to the user identifier is loaded in step S202, including:

[0071] S2021. Determine the index file corresponding to the user identifier, and verify the index file to determine whether the index file has been modified;

[0072] In this step, in order to avoid the query service abnormality caused by loading a damaged index file, before loading the index file corresponding to the user ID, multiple index files determined according to the user ID can be verified first, and then it is determined whether the index file has been modified based on the verification result. Specifically, if the index file is modified by other processes, it means that the index file is damaged.

[0073] Optionally, a cyclic redundancy check (CRC) may be performed on the index file to determine whether the index file has been modified.

[0074] Specifically, after determining multiple index files to be loaded in the disk according to the user identifier, a 32-bit value of each index file is calculated based on the CRC algorithm, and the 32-bit value is compared with a preset 32-bit CRC check value stored in the disk for each index file. If the 32-bit CRC value of the index file is consistent with the preset 32-bit CRC check value, it is determined that the index file has not been modified; if the 32-bit CRC value of the index file is inconsistent with the preset 32-bit CRC check value, it is determined that the index file has been modified.

[0075] Optionally, a message digest (Message-Digest Algorithm, MD5) check may be performed on the index file to determine whether the index file has been modified.

[0076] Specifically, after determining the multiple index files to be loaded in the disk according to the user identifier, a hash operation is performed on each index file based on the MD5 algorithm to obtain the verification hash value corresponding to each index file, and the hash value is compared with the preset hash value of each index file stored in the disk. If the verification hash value of the index file is consistent with the preset hash value, it is judged that the index file has not been modified; if the verification hash value of the index file is inconsistent with the preset hash value, it is judged that the index file is modified.

[0077] S2022: If it is determined that the index file has not been modified, load the index file.

[0078] In this step, for each index file to be loaded corresponding to the user identifier, if it is determined that the index file has not been modified by other processes, the index file can be directly loaded from the disk for subsequent query operations.

[0079] Optionally, if it is confirmed that the index file is modified, exception information is pushed to the client, wherein the exception information is used to indicate that the index file is modified.

[0080] Specifically, users can choose to repair or delete the modified files based on the abnormal information prompted in the client.

[0081] Optionally, after confirming that the index file has been modified, the service may repair the index file based on the pre-cached initial data.

[0082] The query processing method provided in this embodiment verifies each index file to determine whether the index file has been modified after determining multiple index files to be loaded corresponding to the user identifier in the query request. For each index file, if it is determined that the index file has not been modified, the index file is loaded, which effectively avoids the problem of query service abnormality caused by loading a damaged file and improves the security of the query process.

[0083] Furthermore, the present disclosure also provides a third embodiment of a query processing method. On the basis of the above embodiments, during the query operation process of the first embodiment and the second embodiment, read and write protection can be performed on the index file.

[0084] Specifically, during the query operation, the index file can be read and write protected. When the index file is read and write protected, other processes will be prohibited from performing read or write operations on the index file. After the query operation is completed, the read and write protection of the index file will be cancelled.

[0085] The query processing method provided in this embodiment can prevent the index file from being modified due to unexpected situations such as program errors and user misoperation by performing read-write protection on the index file during the query operation. At the same time, it can also effectively prevent malicious software or unauthorized users from illegally modifying the index file. Therefore, the setting of read-write protection can ensure the integrity of the index file, and can also effectively avoid service crashes caused by the modification of the index file during the query operation, thereby maintaining the stability of the query process.

[0086] Furthermore, Figure 4 is a schematic diagram of the fourth embodiment of the present disclosure, referring to Figure 4 The query processing method shown in the figure, based on the above embodiment, before receiving the query request based on the DiskANN algorithm sent by the client in step S201, the query processing method provided by the present disclosure further includes:

[0087] S301, receiving an index creation request sent by a client, wherein the index creation request includes a user identifier and index parameters;

[0088] In this step, when the user needs to store the original data (text, pictures, audio, video and other information) into the disk and generate an index file corresponding to the original data, the client can send an index creation request to the server. Correspondingly, the server will receive the index creation request sent by the client and obtain the user identifier and index parameters corresponding to the client carried in the query request.

[0089] The index parameters include the original data and the index creation parameters required in the index creation process. For example, the index creation parameters include the type of index to be created.

[0090] S302: Generate an index file corresponding to the user identifier based on the index parameters.

[0091] In this step, based on the index parameters carried in the indexing request and the DiskANN algorithm, multiple vectors corresponding to the original data are obtained, including a graph index vector and a PQ index vector constructed based on all the original data corresponding to the user identifier, and then an index file corresponding to the user identifier is generated, wherein the index file includes the original data.

[0092] S303: Store the index file in blocks.

[0093] In this step, the index file needs to be divided into multiple file data blocks, and the multiple file data blocks need to be stored independently in the disk.

[0094] Optionally, the index file may be evenly divided into a plurality of file data blocks according to the size of the index file, and the plurality of file data blocks may be stored independently.

[0095] Optionally, after the index file is stored in blocks, if the subsequent user needs to modify the original data in the index file, after the user modifies part of the original data, the server only needs to modify the file data block on the disk corresponding to the part of the data modified by the user, thereby improving the update efficiency of the index file.

[0096] The DiskANN algorithm provided in this embodiment is based on the above-mentioned embodiment, and further receives an index creation request including a user identifier and index parameters sent by a client, and based on the index parameters, generates an index file corresponding to the user identifier, and finally stores the index file in blocks. When the index file is damaged, the damaged file data blocks can be repaired in a targeted manner, thereby improving the repair efficiency of the damaged files and reducing the safety risks caused by the damage of the index file.

[0097] Furthermore, the present disclosure also provides a fifth embodiment of a query processing method. Based on the above embodiment, the method also includes:

[0098] If the index file is stored in blocks during the indexing process, the index file includes multiple file data blocks. Accordingly, the index file loading in step S202 or step S2022 includes:

[0099] At least two file data blocks in the index file are loaded in parallel.

[0100] The query processing method provided in this embodiment can load at least two file data blocks corresponding to one index file in parallel during the query operation after the index file is stored in blocks on the disk, so as to further improve the query efficiency.

[0101] Furthermore, the present disclosure also provides a sixth embodiment of a query processing method. Based on the above embodiment, the method also includes:

[0102] During the indexing process, the index file can be read and written protected.

[0103] Specifically, during the indexing process, you can enable read-write protection for the index file. When the index file is read-write protected, other processes will be prohibited from performing read or write operations on the index file. After the indexing is completed, the read-write protection of the index file will be canceled.

[0104] The query processing method provided in this embodiment can prevent the index file from being modified due to unexpected situations such as program errors and user misoperation by performing read-write protection on the index file during the indexing process. At the same time, it can also effectively prevent malicious software or unauthorized users from illegally modifying the index file. Therefore, the setting of read-write protection can ensure the integrity of the index file, and can also effectively avoid service crashes caused by the modification of the index file during the query operation, thereby maintaining the stability of the indexing process.

[0105] Furthermore, the present disclosure also provides a seventh embodiment of a query processing method. Based on the above embodiment, the method further includes:

[0106] According to a preset file opening quantity threshold, the number of files opened in the control system is controlled to not exceed the file opening quantity threshold.

[0107] Specifically, during the non-query operation period after the index is established, the user can open the file corresponding to the original data in the index file. In order to ensure that the system does not cause service crashes due to too many files being opened at the same time, the number of files opened in the system can be limited. During any period of system operation, the number of files opened in the control system does not exceed the file opening number threshold. The present disclosure does not limit the setting of the file opening number threshold.

[0108] Optionally, the system's file opening quantity threshold may be determined according to the quantity of clients connected to the network with the server.

[0109] Optionally, a single-client file opening number threshold may be further set for each client connected to the server. When the number of files opened by a client equals the preset single-client file opening number threshold, the client will not be able to open new files until an already opened file is closed.

[0110] The query processing method provided in this embodiment controls the number of files opened in the system by controlling the number of files opened in the system to not exceed the file opening number threshold according to a preset file opening number threshold, thereby effectively avoiding the problem of service crash caused by too many files being opened at the same time and improving the stability of system operation.

[0111] Figure 5 is a schematic diagram of the eighth embodiment of the present disclosure, referring to Figure 5 The query processing device 40 based on the DiskANN algorithm shown in the figure comprises the following units:

[0112] The first receiving unit 401 is used to receive a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and a query parameter;

[0113] The first processing unit 402 is used to load the index file corresponding to the user identifier;

[0114] The second processing unit 403 is used to decompose the query request into two parts: data reading and writing service and distance calculation service;

[0115] The third processing unit 404 is used to run the data reading and writing service and the distance calculation service in different sub-thread pools respectively, and perform a query operation according to the query parameters to obtain the query result;

[0116] The first sending unit 405 is configured to return the query response to the client.

[0117] In one possible design, the first processing unit 402 includes:

[0118] A first processing module, used to determine the index file corresponding to the user identifier, and verify the index file to determine whether the index file has been modified;

[0119] The second processing module is used to load the index file if it is determined that the index file has not been modified.

[0120] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0121] The fourth processing unit 406 is used to perform read and write protection on the index file during the query operation.

[0122] In a possible design, if the index file includes multiple file data blocks, the second processing module is specifically used to:

[0123] At least two file data blocks in the index file are loaded in parallel.

[0124] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0125] The second receiving unit 407 is used to receive an index creation request sent by the client, where the index creation request includes a user identifier and index parameters;

[0126] A fifth processing unit 408, configured to generate an index file corresponding to the user identifier based on the index parameter;

[0127] The storage unit 409 is used to store the index file in blocks.

[0128] In one possible design, the storage unit 409 includes:

[0129] A splitting module is used to evenly divide the index file into multiple file data blocks according to the size of the index file;

[0130] The storage module is used to store multiple file data blocks.

[0131] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0132] The sixth processing unit 410 is used to perform read-write protection on the index file during the index building process.

[0133] In a possible design, the first processing module is specifically used for:

[0134] Perform a CRC check on the index file to determine whether the index file has been modified.

[0135] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0136] The second sending unit 411 is configured to push exception information to the client if the index file is modified, where the exception information indicates that the index file is modified.

[0137] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0138] The seventh processing unit 412 is used to configure the number of threads executing the data reading and writing service to be twice the number of threads executing the distance calculation service.

[0139] In a possible design, the query processing device 40 based on the DiskANN algorithm further includes:

[0140] The eighth processing unit 413 is configured to control the number of opened files in the system to not exceed the threshold number of opened files according to a preset threshold number of opened files.

[0141] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0142] According to an embodiment of the present disclosure, the present disclosure also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.

[0143] Figure 6A schematic block diagram of an example electronic device 50 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0144] like Figure 6 As shown, the device 50 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An I / O interface 505 is also connected to the bus 504.

[0145] A number of components in the device 50 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0146] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a CPU, a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSP), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the method query processing method. For example, in some embodiments, the method query processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the method query processing method described above may be executed. Alternatively, in other embodiments, the computing unit 501 may be configured to execute the method query processing method in any other appropriate manner (eg, by means of firmware).

[0147] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0148] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0149] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (erasable programmable read-only memory (EPROM) or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0150] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0151] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LANs, WANs, and the Internet.

[0152] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0153] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0154] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A query processing method, comprising: Receiving a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and a query parameter; Loading the index file corresponding to the user identifier; Decomposing the query request into two parts: data reading and writing service and distance calculation service; The data reading and writing service and the distance calculation service are respectively run in different sub-thread pools, and query operations are performed according to the query parameters to obtain query results; The query response is returned to the client.

2. The method according to claim 1, wherein: The loading of the index file corresponding to the user identifier includes: Determine the index file corresponding to the user identifier, and verify the index file to determine whether the index file has been modified; If it is determined that the index file has not been modified, the index file is loaded.

3. The method according to claim 1 or 2, further comprising: During the query operation, the index file is read and write protected.

4. The method according to claim 2, wherein: The index file includes a plurality of file data blocks, and loading the index file includes: At least two file data blocks in the index file are loaded in parallel.

5. According to the method according to any one of claims 1 to 4, before receiving the query request based on the DiskANN algorithm sent by the client, the method further comprises: Receive an index creation request sent by a client, wherein the index creation request includes a user identifier and index parameters; Based on the index parameters, generate an index file corresponding to the user identifier; The index file is stored in blocks.

6. The method according to claim 5, wherein: The storing the index file in blocks includes: According to the size of the index file, the index file is evenly divided into a plurality of file data blocks; The multiple file data blocks are stored.

7. The method according to claim 5 or 6, further comprising: During the indexing process, the index file is read and write protected.

8. The method according to claim 2, wherein: The checking of the index file to determine whether the index file has been modified includes: Perform a CRC check on the index file to determine whether the index file has been modified.

9. The method according to claim 2 or 8, further comprising: If the index file is modified, exception information is pushed to the client, where the exception information is used to indicate that the index file is modified.

10. The method according to any one of claims 1 to 9, further comprising: The number of threads configured to execute the data reading and writing service is twice the number of threads configured to execute the distance calculation service.

11. The method according to any one of claims 1 to 10, further comprising: According to a preset file opening quantity threshold, the number of files opened in the control system is controlled to not exceed the file opening quantity threshold.

12. A query processing device based on the DiskANN algorithm, comprising: A first receiving unit, configured to receive a query request based on the DiskANN algorithm sent by a client, wherein the query request includes a user identifier and a query parameter; A first processing unit, used to load the index file corresponding to the user identifier; A second processing unit, used for decomposing the query request into two parts: a data reading and writing service and a distance calculation service; A third processing unit is used to run the data reading and writing service and the distance calculation service in different sub-thread pools respectively, and perform a query operation according to the query parameters to obtain a query result; The first sending unit is used to return the query response to the client.

13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 11.

15. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 11.