Data retrieval method, device and storage medium
By creating a search database in the data retrieval device and processing the base database data in batches, the problem of inefficient data retrieval in the prior art is solved, and a more efficient feature matching and data retrieval process is achieved.
Patent Information
- Application Number
- CN202411177398.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-08-26
AI Technical Summary
When faced with a large number of and diverse base database data, the existing data retrieval methods are inefficient, especially in the process of feature comparison, resulting in low retrieval efficiency.
By creating a search database in the data retrieval device, obtaining the database data identification and characteristics in batches, and performing feature comparison and analysis in the device memory, determining the matching target database data characteristics, and then sending it to the database database for data Search processing to optimize the search process.
It significantly improves the efficiency of data retrieval, reduces the interactive process between the search device and the base database, and improves the speed of feature matching and data retrieval.
Smart Images

Figure CN118689901B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data retrieval method, device and storage medium. Background Art
[0002] Data retrieval refers to extracting the basic data stored in the database according to user needs.
[0003] At present, in the specific application scenarios of data retrieval, it is usually necessary to extract features from the underlying database data (text, images, audio, video, etc.) to obtain the underlying database features, and store the underlying database features and the underlying database data in a corresponding manner in the database, so that when performing subsequent tasks such as target recognition and target detection on the target object, the target features of the target object can be compared and analyzed with the underlying database features in the database to determine similar underlying database features and corresponding underlying database data to complete data retrieval.
[0004] However, when faced with data retrieval from a large amount of diverse database data, even existing methods that use feature comparison technology to accelerate the retrieval process are still inefficient. Summary of the invention
[0005] The present application at least provides a data retrieval method, apparatus, device and computer-readable storage medium.
[0006] In a first aspect, the present application provides a data retrieval method, which is applied to a data retrieval device, wherein the data retrieval device is in communication with a preset base database, and the data retrieval method comprises: in response to a received data retrieval request, creating a retrieval database based on base data identifiers and base data features of base data obtained from the base database, wherein the base data identifiers and base data features of the same base data correspond to each other; performing feature comparison and analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database, to obtain target base data features that match the features to be retrieved; sending the target base data identifier in the retrieval database corresponding to the target base data feature to the base database for data search processing, to obtain the target base data returned by the base database based on the target base data identifier.
[0007] In one embodiment, in response to a received data retrieval request, creating a retrieval database based on base data identifiers and base data features of base data obtained from the base database, includes: in response to receiving the data retrieval request, acquiring the base data identifiers and the base data features from the base database in batches based on the data capacity of the data retrieval device to create the retrieval database; performing feature comparison analysis on the feature to be retrieved and the base data features of each base data to obtain a target base data feature similar to the feature to be retrieved, includes: performing feature similarity calculation on the feature to be retrieved and the features of each base data in the retrieval database to obtain feature similarity; in response to the feature similarity being greater than a preset similarity threshold, determining the corresponding base data feature as the target base data feature that matches the feature to be retrieved.
[0008] In one embodiment, the creation of the retrieval database by acquiring the base database data identifiers and the base database data features in batches from the base database based on the data capacity of the data retrieval device includes: acquiring the base database data identifiers and base database data features of a number of base database data corresponding to the data capacity of the data retrieval device from the base database in batches, the base database data identifiers including base database identifiers and object identifiers; applying for memory resources and creating the retrieval database based on the memory resources, the retrieval database including a base database container, an object container and a feature value array, the base database container being used to cache the base database identifiers, the object container being used to cache the object identifiers, and the feature value array being used to cache the base database data features.
[0009] In one embodiment, the base library container includes the base library identifier and sub-base library information, the sub-base library information includes the object container, the object container includes an object information array, the object information array includes the object identifier and the feature value array corresponding to the object identifier; the feature comparison analysis based on the acquired features to be retrieved and the base library data features of each base library data in the retrieval database to obtain the target base library data features that match the features to be retrieved includes: comparing and analyzing the features to be retrieved and the base library data features of each base library data in the feature value array to obtain the target base library data features that match the features to be retrieved; determining the corresponding target object identifier based on the target base library data features, and determining the target base library data identifier based on the target object identifier.
[0010] In one embodiment, after obtaining in batches from the base database the base database data identifiers and base data features of a number of base data corresponding to the data capacity of the data retrieval device, the method further comprises: searching for the existence of a historical base database identifier identical to the obtained base database identifier; in response to the absence of the historical base database identifier, applying for the memory resources and creating a retrieval database corresponding to the obtained base database identifier; traversing the obtained object identifiers and searching for the existence of a historical object identifier identical to the currently traversed object identifier; in response to the absence of the historical object identifier, storing the currently traversed object identifier and the corresponding base database data features in the retrieval database.
[0011] In one embodiment, after the searching for whether there is a historical base library identifier that is identical to the acquired base library identifier, the method further includes: in response to the existence of the historical base library identifier, determining a target historical base library in a vacant state in the historical base library corresponding to the historical base library identifier; storing the acquired base library identifier, the object identifier, and the base library data feature in the target historical base library; and in response to the existence of a historical object identifier that is identical to the object identifier in the target historical base library, updating and replacing the historical object identifier based on the object identifier.
[0012] In one embodiment, the feature comparison analysis is performed based on the acquired features to be retrieved of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved, including: determining the target base in the retrieval database based on the data retrieval request; performing similarity calculation on the features to be retrieved and the base data features of each base data in the target base to obtain the feature similarity between the features to be retrieved and the base data features of each base data in the target base; and determining the target base data features based on the feature similarity and a preset similarity threshold.
[0013] In one embodiment, the target base stock data identifier corresponding to the target base stock data feature in the retrieval database is sent to the base stock database for data search processing to obtain the target base stock data returned by the base stock database based on the target base stock data identifier, including: sending the target base stock data identifier corresponding to the target base stock data feature to the base stock database, so that the base stock database performs search processing based on the received target base stock data identifier, obtains the target base stock data corresponding to the target base stock data identifier, and returns the target base stock data to the data retrieval device; performing result display processing on the target base stock data returned by the base stock database.
[0014] The second aspect of the present application provides a data retrieval device, including: an acquisition module, used to create a retrieval database in response to a received data retrieval request based on a base database data identifier and base database data features of base database data obtained from the base database, wherein the base database data identifier and base database data features of the same base database data correspond to each other; a feature comparison module, used to perform feature comparison analysis based on the acquired features to be retrieved of the data to be retrieved and the base database data features of each base database data in the retrieval database, to obtain target base database data features that match the features to be retrieved; a retrieval module, used to send a target base database data identifier corresponding to the target base database data feature in the retrieval database to the base database for data search processing, to obtain the target base database data returned by the base database based on the target base database data identifier.
[0015] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned data retrieval method.
[0016] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which implement the above-mentioned data retrieval method when the program instructions are executed by a processor.
[0017] The above scheme, in response to the received data retrieval request, creates a retrieval database based on the base data identifier and base data features of the base data obtained from the base database, the base data identifier and base data features of the same base data correspond, the identifier and features of the base data in the base database are obtained and stored in the retrieval device, and the interaction process between the retrieval device and the base database can be reduced when performing feature retrieval later, thereby improving the retrieval efficiency. Feature comparison and analysis are performed based on the retrieved features of the data to be retrieved and the base data features of each base data in the retrieval database, and the target base data features that match the features to be retrieved are obtained. Feature-based matching can improve the retrieval efficiency. The target base data identifier corresponding to the target base data features in the retrieval database is sent to the base database for data search processing, and the target base data returned by the base database based on the target base data identifier is obtained, thereby completing data retrieval. The present application optimizes the data retrieval process and improves the data retrieval efficiency by performing feature matching in the retrieval device and then sending the feature matching results to the base database for data retrieval.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0020] Figure 1 is a flowchart of an exemplary embodiment of the data retrieval method of the present application;
[0021] Figure 2 is a schematic diagram of an exemplary application scenario in the data retrieval method of the present application;
[0022] Figure 3 is an exemplary data batch retrieval flow chart in the data retrieval method of the present application;
[0023] Figure 4 is a schematic diagram of an exemplary feature storage scheme in the data retrieval method of the present application;
[0024] Figure 5 is a detailed memory diagram of an exemplary feature storage scheme in the data retrieval method of the present application;
[0025] Figure 6 It is a flowchart of data insertion in the data retrieval method of the present application;
[0026] Figure 7 It is a schematic diagram of the process of data updating in the data retrieval method of the present application;
[0027] Figure 8 It is a schematic diagram of the process of deleting data or a base database in the data retrieval method of the present application;
[0028] Fig. 9 is a schematic diagram of the data retrieval process in the data retrieval method of the present application;
[0029] Fig.10 It is a schematic diagram of the data query process in the data retrieval method of the present application;
[0030] Fig.11 is a block diagram of a data retrieval device shown in an exemplary embodiment of the present application;
[0031] Fig.12 It is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0032] Fig.13 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0033] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0034] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0035] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0036] See also Figure 1 , Figure 1 is a flow chart of an exemplary embodiment of the data retrieval method of the present application. The method is applied to a data retrieval device, and the data retrieval device is in communication connection with a preset base database. Figure 2 As shown, Figure 2 It is a schematic diagram of an exemplary application scenario in the data retrieval method of the present application.
[0037] The base database is usually set in the external storage medium of the data retrieval device, such as a common storage device such as a server, which can be considered as the base database in the server. The base database is mainly used to store base data (including but not limited to image data, text data, audio data and other data forms, and the following text mainly uses image data as an example for explanation). For example, the base database stores base data (images), feature information of base data (image features), and other information (such as storage address, base data size, etc., which are not limited here), which belongs to long-term storage and helps to display detailed search results.
[0038] The data retrieval device may include but is not limited to a mobile phone, a computer, a smart wearable device, a server, etc., which are not limited here. The data retrieval device is provided with a feature storage and retrieval system, which can be used to run the data retrieval method of the present application. The feature storage and retrieval system can store the acquired data in the device memory, which is a temporary storage. In addition, feature comparison acceleration hardware ( Figure 2 (not shown) such as HiSilicon MAU (matrix operation unit), to achieve fast feature comparison and retrieval.
[0039] In the data flow of the specific implementation process, one thread may be responsible for inserting the base database data and the feature values of the base database data into the base database, and another thread may be responsible for synchronizing the feature values in the base database to the feature storage and retrieval system of the data retrieval device according to the retrieval task. After the retrieval task is completed, the data in the feature storage and retrieval system can be deleted or updated.
[0040] Specifically, the data retrieval method of the present application may include the following steps:
[0041] Step S110, in response to the received data retrieval request, a retrieval database is created based on the base database data identifier and base database data feature obtained from the base database, and the base database data identifier and base database data feature of the same base database data correspond to each other.
[0042] The data retrieval request refers to the retrieval of the acquired data to be retrieved. The data retrieval request may be actively generated by the data retrieval device, or may be received by the data retrieval device from an external device, which is not limited here.
[0043] The base database can refer to the above description. Usually, it is an external storage device that has a communication connection with the data retrieval device, which will not be elaborated here. The base database stores base data, and the base data can be stored in the base database in the form of base data identifiers, base data features, and base data. Base data features refer to features extracted from base data (for example, image features are extracted for base image data, text features are extracted for base text data, and audio features are extracted for base audio data, etc.). Among them, the base data identifier and base data feature of the same base data correspond. That is, it represents that the corresponding base data features can be found in the base database according to the base data identifier, and the corresponding base data can also be found according to the base data identifier (for details, please refer to the data storage method of key-value pairs in the database. This is the basic principle of the database and will not be elaborated here).
[0044] The retrieval database refers to the database created by the data retrieval device based on its own memory resources, which can be considered as the base database in the data retrieval device. For example, the data capacity of the retrieval database is usually smaller than that of the base database. For example, the memory of some edge devices is usually set in MB, and the common computer memory is usually set in GB, while the server where the base database is located is usually stored in TB.
[0045] Specifically, after the data retrieval device receives a data retrieval request, it obtains the base data identifier and base data characteristics of the base data from the base database, and creates a retrieval database based on the data retrieval device's own memory resources to store the obtained base data identifier and base data characteristics.
[0046] It should also be noted that even if the data retrieval device does not receive a data retrieval request, it can periodically obtain the base data identifier and base data features of the base data from the base database and cache them in its own memory, and it can also periodically clean up the base data identifier and base data features cached in its own memory, which will not be elaborated here.
[0047] Step S120, performing feature comparison analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database, to obtain the target base data features that match the features to be retrieved.
[0048] It should be noted that, in the specific implementation process, the present application may be to perform feature extraction processing on the acquired data to be retrieved, obtain the features to be retrieved of the data to be retrieved, and then perform retrieval processing on the features to be retrieved; or it may be to directly obtain the features to be retrieved of the data to be retrieved and perform retrieval processing, which is not limited here.
[0049] Combined with the above steps, the retrieval process performed in the data retrieval device is mainly that the feature retrieval module in the data retrieval device will compare and analyze the acquired features to be retrieved with the base data features cached in the retrieval database, such as calculating the feature similarity between the features to be retrieved and the features of each base data (which may include but is not limited to cosine similarity calculation, cosine distance calculation, and Euclidean distance calculation, etc., which are not limited here). According to the feature similarity, several base data features that match the features to be retrieved can be determined, that is, the target base data features (which can be 0, 1, or more, which are not limited here).
[0050] Exemplarily, the method for determining the target base database data feature from each base database data feature based on feature similarity can be based on a preset TOPN algorithm to select N base database data features with greater feature similarity from each base database data feature as the target base database data feature. The TOPN algorithm is an algorithm for finding the first N largest or smallest elements in a large data set, thereby being able to efficiently determine the target data from a large batch of data. Alternatively, based on a preset similarity threshold, base database data features with feature similarity greater than a similarity threshold are selected from each base database data feature as the target base database data feature. Alternatively, the TOPN algorithm and the similarity threshold screening method are combined to select N base database data features with greater feature similarity from each base database data feature, and the base database data features with feature similarity greater than the similarity threshold in the N base database data are selected as the target base database data feature. Alternatively, several base database data features whose feature similarity is greater than a similarity threshold may be first selected from each base database data feature, and then N base database data features with greater similarity may be selected from several base database data features based on the TOPN algorithm as target base database data features. Any of the above methods may be selected for execution and is not limited here.
[0051] Step S130, sending the target base database data identifier corresponding to the target base database data feature in the retrieval database to the base database for data search processing, and obtaining the target base database data returned by the base database based on the target base database data identifier.
[0052] In conjunction with the above steps, each base database data has a corresponding base database data identifier and base database data feature. Therefore, the target base database data feature determined from the retrieval database through the above retrieval process also has its corresponding target base database data identifier.
[0053] It should be noted that, through the aforementioned steps, the data retrieval device obtains the base data identifier and base data features of the base data from the base database and caches them in the retrieval database created by the data retrieval device based on its own memory; then the data retrieval device compares and analyzes the features to be retrieved of the acquired data to be retrieved with the features of each base data in the retrieval database to obtain the target base data features. These steps are all based on the memory resources of the data retrieval device, and it can be understood that the read and write speed of the memory is usually significantly greater than the read and write speed of the server hard disk, that is, the data processing efficiency based on the retrieval database is better than the data processing efficiency based on the base database. Therefore, the data retrieval device of the present application caches the base data identifier and base data features of the base data from the base database into its own memory, and compares and analyzes the features to be retrieved of the data to be retrieved with the base data features in the memory based on its own memory. Compared with the traditional data retrieval method (feature comparison analysis and data retrieval in the base database), the data retrieval method of the present application significantly improves the data retrieval efficiency.
[0054] After the data retrieval device determines the target base database data characteristics, it can send the retrieval results (such as the target base database data identifier, the target base database data characteristics) to the base database. After receiving the retrieval results, the base database can perform data search processing based on the target base database data identifier, such as performing table lookup processing in the data table of the base database to obtain the target base database data corresponding to the target base database data identifier, and then return the target base database data to the corresponding data retrieval device. After the data retrieval device receives the target base database data returned by the base database, the data retrieval process is completed.
[0055] It can be seen that the present application divides the traditional data retrieval process (data retrieval in the base database) into two parts. First, the data retrieval device obtains the base data identifier and base data features from the base database based on its own memory resources for caching, and retrieves the features to be retrieved to obtain the retrieval results; second, the retrieval results are sent to the base database, and the base database performs data search based on the retrieval results, eliminating the process of feature matching retrieval in the base database in the traditional method, and then obtains the target base data, and returns the target base data to the corresponding data retrieval device to complete the data retrieval. Specifically, the data retrieval device responds to the received data retrieval request, creates a retrieval database based on the base data identifier and base data features of the base data obtained from the base database, the base data identifier and base data features of the same base data correspond, and the identifier and features of the base data in the base database are obtained and stored in the retrieval device. When performing feature retrieval later, the interaction process between the retrieval device and the base database can be reduced, thereby improving the retrieval efficiency. Based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database, feature comparison and analysis are performed to obtain the target base data features that match the features to be retrieved. Feature-based matching can improve retrieval efficiency. The target base data identifier corresponding to the target base data feature in the retrieval database is sent to the base database for data search processing to obtain the target base data returned by the base database based on the target base data identifier, thereby completing data retrieval. The present application optimizes the data retrieval process and improves data retrieval efficiency by performing feature matching in the retrieval device and then sending the feature matching results to the base database for data retrieval.
[0056] On the basis of the above-mentioned embodiments, the embodiment of the present application describes the steps of creating a retrieval database based on the base data identifier and base data features of the base data obtained from the base database in response to the received data retrieval request, and performing feature comparison analysis between the features to be retrieved and the base data features of each base data to obtain target base data features similar to the features to be retrieved. Specifically, the method of this embodiment includes the following steps:
[0057] In response to receiving a data retrieval request, base database data identifiers and base database data features are obtained in batches from the base database based on the data capacity of the data retrieval device to create a retrieval database; feature similarity is calculated between the feature to be retrieved and each base database data feature in the retrieval database to obtain feature similarity; in response to the feature similarity being greater than a preset similarity threshold, the corresponding base database data feature is determined as a target base database data feature that matches the feature to be retrieved.
[0058] In conjunction with the above-mentioned embodiments, it can be understood that in common data retrieval scenarios, retrieval is usually performed in a large amount of data, and based on the data capacity gap between the base database and the data retrieval device, it is difficult to cache all the base data in the base database into the memory of the data retrieval device. Therefore, the present application adopts a batch acquisition method, so that after receiving a data retrieval request, the data retrieval device obtains a certain number of base data identifiers and base data features from the base database in batches based on its own data capacity (which can be determined by the memory occupancy of the data retrieval device) and imports them into the retrieval database of the feature storage and retrieval system for caching, thereby solving the problem that the data retrieval device has limited device memory relative to the base database.
[0059] If the amount of data stored in the base database is small, for example, the amount of data to be obtained from the base database is smaller than the amount of data that can be processed by the data retrieval device at present, a one-time acquisition can be performed.
[0060] Then, the data retrieval device can perform feature similarity calculation based on the cached base data features in the retrieval database and the acquired features to be retrieved, and obtain the feature similarity between the features to be retrieved and the features of each base data in the retrieval database. Subsequently, the target base data features that match the features to be retrieved can be determined from the base data features of the retrieval database based on the TOPN algorithm and / or similarity threshold with reference to the above example.
[0061] Furthermore, if there is no target base data feature matching the feature to be retrieved in the base data features acquired in the current batch, the base data identifier and base data features of subsequent batches can be acquired from the base database. When acquiring the base data identifier and base data features from the base database in each batch, they can be acquired sequentially according to the storage sequence of each base data in the base database, or they can be acquired randomly or specifically, which is not limited here. To illustrate by way of example, there are 100 pieces of base data in the base database. If it is determined based on the memory situation of the data retrieval device that the feature storage and retrieval system only supports processing 50 pieces of base data in each batch, the base data in the base database can be divided into two batches for acquisition, that is, the data retrieval device acquires the base data identifiers and base data features of 50 base data from the base database in the first batch, and performs feature comparison and analysis with the features to be retrieved; if there are no features in the base data features of the first batch of 50 base data that match the features to be retrieved, these cached features can be deleted and the base data identifiers and base data features of the second batch of 50 base data can be acquired from the base database.
[0062] It should be noted that, still taking the above example, if there are features in the base data features of the 50 base data in the first batch that match the features to be retrieved, you can choose to pause or stop obtaining the base data features identified by the base data of the second batch from the base database based on the actual task conditions (for example, whether a batch quantity threshold is set, whether a feature quantity threshold for the target base data features to be obtained is set, etc.); or you can continue to obtain the base data features identified by the base data of the second batch from the base database.
[0063] Based on the above embodiment, the embodiment of the present application describes the steps of obtaining the base database data identifier and base database data features from the base database in batches based on the data capacity of the data retrieval device to create a retrieval database. Specifically, the method of this embodiment includes the following steps:
[0064] Obtain base database data identifiers and base database data features of base database data in batches in a quantity corresponding to the data capacity of the data retrieval device, the base database data identifiers including base database identifiers and object identifiers; apply for memory resources and create a retrieval database based on the memory resources, the retrieval database including a base database container, an object container, and a feature value array, the base database container is used to cache base database identifiers, the object container is used to cache object identifiers, and the feature value array is used to cache base database data features.
[0065] It should be noted that the corresponding number of the data capacity of the data retrieval device may refer to a number that matches its data capacity, or a number that is smaller than its data capacity, which is not limited here.
[0066] The data retrieval device of the present application mainly obtains the base data identifier and base data feature of the base data from the base database for caching, while the complete base data (such as base image data) remains in the base database. Transmitting the base data identifier and base data feature, and performing comparative analysis based on the feature, reduces the amount of data processing and improves the data processing efficiency compared to the traditional method of transmitting and comparing the complete base data.
[0067] It should also be noted that the database data identifier includes the database id (dbId) and the object id (objId). The database may include one or more sub-databases, and the database identifier can be used to find the corresponding sub-database. Each sub-database may include one or more database data. The object refers to the data object, and the object identifier can be used to find the corresponding database data. In this way, data retrieval can be realized in the database.
[0068] For example, in the specific implementation process, reference may be made to Figure 3 As shown, Figure 3 This is an exemplary data batch retrieval flow chart in the data retrieval method of the present application. Among them, after receiving the data retrieval request, the feature retrieval module of the data retrieval device can send a data query request to the base database. After receiving the data query request, the base database will return the corresponding dbId, objId and feature to obtain the base data identifier and base data features of the base data in batches from the base database. The feature retrieval module will perform a storage operation on the dbId, objId and feature sent by the base database, so that the dbId, objId and feature are cached in the feature storage and retrieval system (if there is no available retrieval database, it is necessary to apply for memory resources to create a new retrieval database in the feature storage and retrieval system. If there is an available retrieval database, it can be directly stored in the retrieval database). Among them, the retrieval database can also include one sub-retrieval library or multiple sub-retrieval libraries.
[0069] It should also be noted that the search database may include a database map (dbMap for short), an object map (objMap for short) and a feature array (feature array). The database map container can be used to cache database identifiers, the object map container can be used to cache object identifiers, and the feature array can be used to cache database data features.
[0070] For example, reference may be made to Figure 4 As shown, Figure 4 This is a schematic diagram of an exemplary feature storage scheme in the data retrieval method of the present application. When the data retrieval device caches the acquired base data identifier and base data feature, it can refer to Figure 4 The storage structure shown is cached.
[0071] Among them, the base database container dbMap is an associative container of base database identifiers and base database information. In the implementation process based on the C++ development environment, STL unordered_multimap can be used. The main reasons for choosing STL unordered_multimap include: allowing key values (dbId) to be repeated, and repeated key values (dbId) represent different sub-base databases under the same retrieval database. Sub-base databases can avoid the inability to apply for large blocks of memory base databases due to memory fragmentation, and can effectively avoid memory peaks and memory copies when the base database is expanded. In addition, its time complexity for insertion and search is O(1), which is more efficient.
[0072] The object container objMap (dbx-objMap, base database x-object container) is an associative container for object identification and object information in the retrieval database. In the implementation process based on the C++ development environment, STL unordered_map can be used. The reason for choosing STL unordered_multimap is that the time complexity of insertion and search is O(1), which is fast. Multiple sub-base libraries of the same retrieval database can share a DBx-objMap. For example, base library 1 and sub-base library 1 share base library 1-object container (DB1-objMap) for easy and fast search. It should be noted that in other development environments, other types of Maps can also be used for data storage, which will not be repeated here. The object container can include several data objects obj and their corresponding characteristic values.
[0073] The feature array is used to store the features of the underlying database data obtained by the data retrieval device. The reason for designing it as an array structure is to ensure that the eigenvalues are stored continuously in the memory, such as eigenvalue 1, eigenvalue 2, eigenvalue 3, etc. The eigenvalues in different eigenvalue arrays can be the same or different, and there is no limitation here. In addition, most feature matching acceleration hardware (matrix operation units, such as HiSilicon MAU) require that the input eigenvalues be stored continuously in the memory to form an eigenvalue matrix to accelerate the feature matching process.
[0074] On the basis of the above embodiments, the embodiment of the present application describes the steps of performing feature comparison analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved. Specifically, the method of this embodiment includes the following steps:
[0075] Perform feature comparison analysis on the feature to be retrieved and the base database data features of each base database data in the feature value array to obtain the target base database data features that match the feature to be retrieved; determine the corresponding target object identifier based on the target base database data features, and determine the target base database data identifier based on the target object identifier.
[0076] In combination with the above-mentioned embodiment, the base library container includes a base library identifier and sub-base library information (or base library information), the sub-base library information includes an object container, the object container includes an object information array, the object information array includes an object identifier and a feature value array corresponding to the object identifier.
[0077] For example, reference may be made to Figure 5 As shown, Figure 5 It is a detailed memory diagram of an exemplary feature storage scheme in the data retrieval method of the present application. Figure 5 Yes Figure 4The storage structure shown is described in more detail by way of example and mainly includes five elements.
[0078] 1. The base database container dbMap is an associative container of base database identifiers and base database information. STLunordered_multimap can be used for implementation.<dbId, dbInfo*> , the key value is the base database identifier dbId, and the value is the dbInfo* base database information pointer, which is used to point to the corresponding base database information dbInfo. Each Node node points to a sub-base database memory.
[0079] 2. The base database information dbInfo may include the base database identifier dbId, the sub-base database capacity MaxobjNum, the similarity threshold similarity, the current number of objects objNum, the object information array pointer pObj and the object container objMap. The object information array pointer pObj is used to point to the first address of the object information array objArray.
[0080] 3. The object container objMap is an associative container of the object identifier objId and the object information. All sub-base libraries under the same dbId can be shared. Specifically, the syntax of the shared base library in the C++ development environment, STL shared_ptr and unordered_map, can be used to implement it. I will not go into details here. For example, shared_ptr <unordered_map<objId, {pDBInfo*,objIndex}> >. The key value of objMap is the object identifier objId, and the value is the base database information pointer and the index position of the object in the base database. The Node node in objMap can point to the objects in all sub-base databases under the base database corresponding to the current dbId.
[0081] 4. The object information array objArray is used to store object information objInfo. Each element in the object information array represents an object information, which may include the object identifier objId and the feature value memory address featurePtr corresponding to the object identifier. Among them, featurePtr points to a node in the feature value array featureArray. By designing the object information as an array structure, memory for storing object information can be continuously applied to reduce memory fragmentation. The length of the object information array is the sub-base library capacity MaxobjNum, and the number of valid objects in the object information array is objNum. For example, if objNum=6, 6 objects (obj1 to obj6) can be stored in the object information array.
[0082] 5. The feature value array featureArray can be used to continuously store all feature values in the sub-base library (i.e., the base library data features). The feature value array is equivalent to having a certain correspondence with the object information array. The length of the feature value array is the sub-base library capacity MaxobjNum, and the number of valid objects in the feature value array is objNum. The order of elements in the featureArray array is consistent with the order of elements in objArray.
[0083] Combined with the above data storage structure, the feature retrieval process in the data retrieval device is exemplarily described. The similarity between the feature to be retrieved and each base database data feature in the feature value array is calculated, and the target base database data feature in the feature value array that matches the feature to be retrieved is determined based on the feature similarity; then, referring to the above data storage structure, the target object identifier objId corresponding to the target base database data feature and the target base database data identifier dbId corresponding to objId are determined; then, dbId and objId are sent as retrieval results to the base database, and the base database searches for the target base database based on dbId, and then searches for the target object (i.e., target base database data) in the target base database based on objId and returns it.
[0084] Based on the above embodiment, the embodiment of the present application describes the steps after obtaining the base database data identifiers and base database data features of the base database data corresponding to the data capacity of the data retrieval device in batches from the base database. Specifically, the method of this embodiment includes the following steps:
[0085] Find out whether there is a historical base database identifier that is the same as the acquired base database identifier; in response to the absence of a historical base database identifier, apply for memory resources and create a retrieval database corresponding to the acquired base database identifier; traverse the acquired object identifiers, and find out whether there is a historical object identifier that is the same as the currently traversed object identifier; in response to the absence of a historical object identifier, store the currently traversed object identifier and the corresponding base database data features in the retrieval database.
[0086] In conjunction with the foregoing embodiment, when the data retrieval device obtains the base database data identifier and base database data features from the base database in the first batch, the base database data identifier and base database data features may not exist in the current data retrieval device, that is, there is no corresponding retrieval database for storing these data. Therefore, it is necessary to create a retrieval database to store these acquired data based on the memory resources of the data retrieval device. When the data retrieval device obtains the base database data identifier and base database data features from the base database in subsequent batches, the acquired data may be the same as the data that has been acquired and stored in the retrieval database before. In order to avoid problems such as redundant data acquisition and redundant storage, when the data retrieval device obtains these data from the base database, the data retrieval device needs to search its own retrieval database for whether there is a historical base database identifier that is the same as the currently acquired base database identifier.
[0087] Combination Figure 6 To explain, Figure 6 It is a flow chart of data insertion in the data retrieval method of the present application, which includes the process of inserting and storing the base database data identifier and base database data feature obtained from the base database by the data retrieval device.
[0088] First, two concepts involved in this embodiment are explained: the total capacity of the base database and the granularity of the sub-base database. The total capacity of the base database: is the total capacity of the base database of the preset retrieval database, which is used to pre-apply for the base database object memory and the retrieval result memory. The total capacity of the base database can be divided among multiple sub-base databases of the retrieval database. When the sub-base database is expanded, it should not exceed the total capacity of the base database. The granularity of the sub-base database: is the size of the block granularity applied for the base database memory block of the retrieval database. The unit is the number of objects, not the memory size (for example, when a data object obj is obtained and needs to be stored, a memory size of a sub-base database granularity is applied). The granularity of the sub-base database needs to be set in advance. The sub-base database can be used to avoid the failure of applying for large blocks of base database memory due to memory fragmentation, and to avoid memory peaks and memory copies when the base database is expanded.
[0089] Exemplarily, after the data retrieval device obtains the base data identifier (base data identifier and object identifier) and base data features of the base data from the base database, it first searches its own retrieval database (such as dbMap) to find out whether there is a historical base data identifier (a base data identifier obtained previously, that is, an existing base data identifier) that is the same as the obtained base data identifier dbId.
[0090] If there is no identical historical base database identifier, it indicates that there will be no redundancy problem in the current data retrieval device, so memory resources are applied for and a sub-base database corresponding to the current base database identifier is created for subsequent feature retrieval. In the process of creating a sub-base database, the current sub-base database capacity must first be set to the maximum value of the sub-base database granularity and the number of data objects currently acquired. Sub-base database related memory is applied according to the sub-base database capacity, such as: pDBInfo, objMap, objArray, featureArray, etc.
[0091] Then, the acquired bottom database data features are traversed and based on the object identifier objId of the currently traversed bottom database data features, a search is performed in the object container objMap created before the database search to see if there is a historical object identifier (that is, an existing objId) that is the same as the currently traversed object identifier. If not, an insert operation is performed (the currently traversed object identifier objId and the corresponding bottom database data features are stored in the currently created sub-bottom database). In addition, after traversing the acquired object identifiers, the corresponding bottom database identifiers dbId and pDBInfo need to be inserted into the dbMap of the currently created bottom database to end the data insertion and storage process. If it exists, the corresponding pDBInfo and objIndex are found based on the historical object identifier, and the feature values are updated and replaced.
[0092] To further illustrate, when inserting data in the above process, if the total capacity of the base database is sufficient, the objId and other information are copied to the object information array objArray, the base database data features are copied to the feature value array featureArray, and the object index objIndex is added, and the index related information is copied to the feature value array featureArray.<objId,{pDBInfo*,objIndex}> Insert it into the object container objMap to implement Figure 4 The storage structure shown is used for data storage; if the base storage capacity of the retrieval database is insufficient, an error message is generated and returned, and the process is terminated early.
[0093] Based on the above embodiment, the embodiment of the present application describes the steps after searching whether there is a historical base stock identifier that is the same as the acquired base stock identifier. Specifically, the method of this embodiment includes the following steps:
[0094] In response to the existence of a historical base database identifier, a target historical base database in a vacant state is determined in the historical base database corresponding to the historical base database identifier; the acquired base database identifier, object identifier and base database data features are stored in the target historical base database; in response to the existence of a historical object identifier that is identical to the object identifier in the target historical base database, the historical object identifier is updated and replaced based on the object identifier.
[0095] The above-mentioned embodiment is used for explanation. The above-mentioned embodiment explains that in the process of storing the acquired base database data identifier and base database data feature, there is no execution situation in which there is a historical base database identifier that is the same as the acquired base database data identifier.
[0096] This embodiment mainly illustrates the execution of a historical base database identifier that is identical to the acquired base database data identifier during the process of storing the acquired base database data identifier and base database data feature. In the execution of this embodiment, the data update operation is mainly performed when a historical base database identifier that is identical to the acquired base database data identifier is found.
[0097] For example, reference may be made to Figure 7 , Figure 7 It is a flow chart of data updating in the data retrieval method of the present application, which includes the process in which the data retrieval device updates the previously stored data with the base database data identifier and base database data feature obtained from the base database. If there is the same historical base database identifier, it indicates that there may be redundancy problems in the current data retrieval device, so there is no need to create a sub-base database separately, and the previously acquired data can be updated based on the currently acquired data. First, each sub-base database in the current retrieval database can be traversed first, and the sub-base databases with remaining storage space in each sub-base database (the sub-base databases in the free state) can be screened out and stored in the base database vector DBVector, so as to search and call these sub-base databases to avoid memory waste. It should be noted that the data obtained by the data retrieval device from the base database each time and / or each sub-base database in the data retrieval device may be the same or different, and some sub-base databases in the data retrieval device are already full, and some sub-base databases are not full (that is, there is free space). If the length Size of DBVector is greater than 0, it means that there is a bottom database in DBVector where the bottom database data feature can be inserted; if the length Size of DBVector is less than or equal to 0, it means that there is no bottom database in DBVector where the bottom database data feature can be inserted, and a new bottom database needs to be created. You can refer to the above embodiment and Figure 6 The method of creating a new base database and storing the data characteristics of the base database is not described here.
[0098] Then, based on the base database identifier of each base database data feature currently obtained, the sub-base database (target historical base database) corresponding to the base database identifier in the retrieval database is found, and then based on the object identifier of the base database data feature, the corresponding historical object identifier is found in the corresponding target historical base database, and the feature value corresponding to the historical object identifier is updated and replaced based on the current base database data feature. If the corresponding historical object identifier is not found in the corresponding target historical base database, the current base database data feature can be inserted and stored with reference to the execution method of the aforementioned embodiment. It should also be noted that the process of updating or inserting features into an existing base database (target historical base database) includes: finding unfilled sub-base databases from all existing sub-base databases, traversing the input targets (i.e., base database data features), and filling these sub-base databases one by one. If there are still remaining targets to be inserted after filling all sub-base databases, a new sub-base database is created with reference to the aforementioned embodiment, and the process of the aforementioned embodiment is performed in the same manner. And if the object id does not exist, the base database data feature currently traversed is inserted. When inserting a new feature, if the total base database capacity is insufficient, an abnormal information is printed and the process ends. When the traversal is completed, the process ends.
[0099] The specific process may be: traverse each acquired bottom library data feature, since each sub-bottom library can share an objMap, the objMap of any sub-bottom library can be searched and the objId of the currently traversed bottom library data feature can be searched in the objMap to see if it already exists (whether there is a historical object identifier); if it already exists, the corresponding pDBInfo and object index are found according to the objId to determine the corresponding historical feature, and the historical feature corresponding to the objId is updated and replaced based on the currently traversed bottom library data feature; if it does not exist and the total capacity of the bottom library is sufficient, and there is a free sub-bottom library, the currently traversed bottom library data feature is inserted into the sub-bottom library and stored according to the data storage structure provided in the aforementioned embodiment. After the data is successfully inserted, the remaining capacity of the sub-bottom library needs to be reduced accordingly until the sub-bottom library is no longer free and then the DBVector is removed.
[0100] Based on the above embodiments, the present application embodiment describes the data or base database deletion step of the data retrieval device. For example, after each data retrieval task is completed, the base database data features cached in the data retrieval device can be deleted, and / or the retrieval database can be deleted to release memory resources. Figure 8 As shown, Figure 8 1 is a flow chart of data or base database deletion in the data retrieval method of the present application. Specifically, the method of this embodiment includes the following steps:
[0101] In response to the received data deletion request (which may be an external input received by the data retrieval device or generated internally by the data retrieval device, and the data deletion request shall at least include the object to be deleted (features to be deleted), and may also include the base database identifier dbId and / or object identifier objId of the object to be deleted), check from the dbMap of the retrieval database whether the dbId to which the object to be deleted belongs exists. If not, print the exception information and end the data deletion process; if so, determine whether the number of objects in the sub-base database corresponding to the dbId that match the object to be deleted (data objects with the same objId) is 0. If it is 0, delete the entire retrieval database. If not 0, delete the objects in the sub-base database that match the object to be deleted.
[0102] If the retrieval database is deleted, the execution process may include: traversing all sub-bases, releasing the memory resources occupied by featureArray, objArray, and pDBInfo, and assigning a null value to objMap. Deleting all sub-base nodes corresponding to the dbId of the object to be deleted in dbMap. After the traversal is completed, the deletion process is terminated.
[0103] If the data object with the specified dbId is to be deleted, the execution process may include: randomly selecting an objMap in a sub-base library, traversing the objId of the object to be deleted in the objMap, and searching whether there is the same objId in the objMap. If not, print the exception information; if so, find the base library information pDBInfo and object index corresponding to the objId. Then determine whether the object to be deleted is the last data object in pDBInfo. If it is, the number of valid targets in pDBInfo is minus 1; if not, the last object information of the objArray in pDBInfo replaces the index position of the object to be deleted, and the address of the feature to be deleted pointed to by the index position of the object to be deleted remains unchanged. The last feature value of the featureArray in pDBInfo is copied to replace the index position of the object to be deleted, the number of valid data objects in pDBInfo is minus 1, and the objId is deleted from objMap. When the traversal is completed, terminate this data deletion process. It should be noted that in the data deletion process, the data should be deleted from the last data in the array in sequence. If it is not deleted in order, it may cause memory fragmentation, that is, some empty positions will appear in the array. Therefore, in this embodiment, the deletion starts from the last object. If the object to be deleted is not the last one, after deleting the object to be deleted, the last object is replaced with an empty position (the empty position left by the object to be deleted), and the position where the original last object was located is deleted-1. In this way, after deleting the object to be deleted, the last data object in the current array is migrated to the empty position left by the object to be deleted, and the original position of the last data object is deleted, thereby achieving the effect of deleting the last data object in the array.
[0104] It should be noted that the specific implementation process of this embodiment may be: after each data retrieval task is completed, the cached data or the base database may be deleted by referring to the above method; or when the target base database data features that match the features to be retrieved are not retrieved in the current batch, it is necessary to refer to the above method to delete the cached data or delete the base database in order to obtain the base database data identifier and base database data features of subsequent batches; or if there is a specified data deletion task at present, the cached data or the base database may be deleted by referring to the above method, which will not be elaborated here.
[0105] On the basis of the above embodiments, the embodiment of the present application describes the steps of performing feature comparison analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved. Specifically, the method of this embodiment includes the following steps:
[0106] Based on the data retrieval request, a target base database in the retrieval database is determined; similarity is calculated between the feature to be retrieved and the base database data features of each base database data in the target base database to obtain feature similarity between the feature to be retrieved and the base database data features of each base database data in the target base database; based on the feature similarity and a preset similarity threshold, the target base database data features are determined.
[0107] In conjunction with the foregoing embodiment, the data retrieval process in the data retrieval device is mainly described in an exemplary manner in the present embodiment. It is understandable that the retrieval database of the data retrieval device can actually be composed of a plurality of sub-bases. In order to improve retrieval efficiency, before performing data retrieval, a target base that needs to perform data retrieval can be specified by a data retrieval request.
[0108] For example, reference may be made to Fig. 9 As shown, Fig. 9 It is a flow chart of data retrieval in the data retrieval method of the present application. First, based on the data retrieval request, the features to be retrieved of the data to be retrieved and the specified target base library to be grouped. The basis for grouping can be that the base libraries to be controlled are the same and are grouped into one group, and the base library to be controlled refers to which base libraries are searched from. For example, there are data A to be retrieved and data B to be retrieved whose features to be retrieved are car image features, data C to be retrieved whose features to be retrieved are bicycle image features, and there are base library data features including car images in the first sub-base library of control and base library data features including bicycle images in the second sub-base library of control. Therefore, the features of data A to be retrieved, the features of data B to be retrieved and the first sub-base library can be grouped into one group, and the features of data C to be retrieved and the second sub-base library can be grouped into one group. Then traverse each group, and perform subsequent data retrieval processes group by group to improve data retrieval efficiency, until all groups are traversed to the end, then terminate this data retrieval process.
[0109] Among them, the specific data retrieval process may include: searching for the dbId corresponding to the feature to be retrieved in dbMap, and summarizing it in the temporarily generated base library array dbArray, judging whether the length of dbArray array is greater than 0, if not, printing abnormal information and starting the retrieval of the next group of features to be retrieved; if so, splicing the feature values of the N features to be retrieved in this group in a continuous memory, and traversing the base library array dbArray, and calculating the similarity between the base library data features in each base library and the current feature to be retrieved one by one (if there is a matrix calculation hardware unit, the matrix calculation hardware unit is used for accelerated calculation), and outputting the feature similarity matrix. Summarize the search results of each base library, record the TOPN high-scoring results of the feature similarity between the feature to be retrieved and each base library data feature, until the base library of the control is traversed. Summarize the TOPN comparison results of the N features to be retrieved one by one, and output the results greater than the similarity threshold (target base library data feature) and the base library index result (base library data identifier of the target base library data feature). Each DBInfo may have a corresponding preset similarity threshold, and the similarity thresholds of different DBInfo may be the same or different.
[0110] On the basis of the above-mentioned embodiment, the embodiment of the present application describes the steps of sending the target base database data identifier corresponding to the target base database data feature in the retrieval database to the base database for data search processing, and obtaining the target base database data returned by the base database based on the target base database data identifier. Specifically, the method of this embodiment includes the following steps:
[0111] The target base library data identifier corresponding to the target base library data feature is sent to the base library database, so that the base library database performs search processing based on the received target base library data identifier, obtains the target base library data corresponding to the target base library data identifier, and returns the target base library data to the data retrieval device; the result display processing is performed on the target base library data returned by the base library database.
[0112] In conjunction with the above-mentioned embodiment, after the data retrieval device determines the target base database data feature that matches the feature to be retrieved, the target base database data identifier (including the target base database identifier dbId and the target object identifier objId) of the target base database data feature is sent to the base database. After receiving the dbId and objId sent by the data retrieval device, the base database performs a table lookup process to find the base database corresponding to dbId in the base database, and searches for the target base database data corresponding to objId in the base database (such as base database images, base database texts, base database audio, etc.). The base database returns the target base database data to the corresponding data retrieval device to implement the data retrieval process of the data to be retrieved by the data retrieval device, and can perform result display processing on the target base database data.
[0113] Based on the above embodiments, the present application embodiment describes the data query steps of the data retrieval device. It is understandable that database operations generally include operations of adding, deleting, modifying and searching, and the data query function is generally used for troubleshooting, such as confirming whether the feature is imported, whether the imported feature value is normal, and querying the database information. Fig.10 As shown, Fig.10 : is a flow chart of data query in the data retrieval method of the present application. Specifically, the method of this embodiment includes the following steps:
[0114] Find the dbId of the current data to be found in dbMap, and determine whether dbId exists. If not, print the exception information and terminate the data search process. If it exists, find the objMap in the first sub-base, traverse the target identifier objId of the data to be found, and find whether the objId exists in objMap. If not, print the exception information and terminate the data search process. If it does not exist, find the pDBInfo and object index corresponding to the objId, and copy and output the object information. Until the current data to be found is traversed, terminate the data search process.
[0115] In summary, the data retrieval method of the present application obtains the base database data identifiers and base database data features from the base database in batches through the data retrieval device, caches them in its own memory, and calculates the feature similarity between the features to be retrieved and the base database data features based on its own memory, thereby determining the target base database data features that match the features to be retrieved, which is suitable for scenarios where the base database retrieval is large and the retrieval device memory is small, such as edge device application scenarios. And when a large number of retrieval devices need to run at the same time, each retrieval device obtains data from the base database and performs data retrieval processing within itself. Compared with the traditional data retrieval method that performs data retrieval processing in the base database, the IO processing volume of the base database is reduced, and the IO performance during operation is improved.
[0116] In addition, in the present application, the base database and the data retrieval device memory are linked. The function of the base database is to store base data (such as pictures, text, audio, etc.), feature information, and other information. It is a long-term storage and helps to display detailed retrieval results. A feature storage and retrieval system can be set up in the data retrieval device memory to store the base data features and their indexes (base data identifiers) in the device memory. This is temporary storage, and can also be combined with feature matching acceleration hardware to achieve fast feature retrieval. In the data flow, one thread is responsible for inserting the original data and the extracted feature values into the base database, and the other thread is responsible for synchronizing the features and indexes in the base database to the feature storage and retrieval system according to the retrieval task. After the retrieval task is completed, the data in the feature storage and retrieval system can be deleted or updated.
[0117] Among them, the composition of the feature storage and retrieval system mainly includes five elements: 1. The associative container of the base database id and the base database information (hereinafter referred to as the base database container). The base database id is repeated, and the repeated id represents the sub-base database under the same base database. In terms of implementation, a hash container with faster search and insertion speed can be used. 2. Base database information pointer. The base database information includes the base database id, the sub-base database capacity, the similarity threshold, the current number of objects, the object information array pointer and the object container. The object information array pointer points to the first address of the object information array. 3. The associative container of the object id and the object information (hereinafter referred to as the object container). All sub-base databases under the same base database id can share this container. In terms of implementation, a hash container with faster search and insertion speed can be used. 4. Object information array. Each element in the array represents an object information, including the object id and the object feature value memory address. The object feature value memory address points to a node in the feature value array. The length of the array is the sub-base database capacity. 5. Feature value array, which is used to continuously store all feature values in the sub-base database. The array length and object element order are consistent with the object information array.
[0118] The feature storage and retrieval system based on the present application also supports processing methods such as adding, deleting, modifying, checking and retrieving data.
[0119] It should be further explained that the execution subject of the data retrieval method may be a data retrieval device, for example, the data retrieval method may be executed by a terminal device or a server or other processing device, wherein the terminal device may be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the data retrieval method may be implemented by a processor calling a computer-readable instruction stored in a memory.
[0120] Fig.11 FIG. 1 is a block diagram of a data retrieval device shown in an exemplary embodiment of the present application. Fig.11 As shown, the exemplary data retrieval device 1000 includes: an acquisition module 1010, a feature comparison module 1020 and a retrieval module 1030. Specifically:
[0121] The acquisition module 1010 is used to create a retrieval database based on the base data identifier and base data feature of the base data obtained from the base database in response to the received data retrieval request, and the base data identifier and base data feature of the same base data correspond to each other.
[0122] The feature comparison module 1020 is used to perform feature comparison analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved.
[0123] The retrieval module 1030 is used to send the target base database data identifier corresponding to the target base database data feature in the retrieval database to the base database for data search processing, and obtain the target base database data returned by the base database based on the target base database data identifier.
[0124] In this exemplary data retrieval device, in response to the received data retrieval request, a retrieval database is created based on the base data identifier and base data feature of the base data obtained from the base database, the base data identifier and base data feature of the same base data correspond, the identifier and feature of the base data in the base database are obtained and stored in the retrieval device, and the interaction process between the retrieval device and the base database can be reduced when the feature retrieval is performed later, thereby improving the retrieval efficiency. Based on the retrieved features of the data to be retrieved and the base data features of each base data in the retrieval database, feature comparison and analysis are performed to obtain the target base data features that match the features to be retrieved, and the feature-based matching can improve the retrieval efficiency. The target base data identifier corresponding to the target base data feature in the retrieval database is sent to the base database for data search processing, and the target base data returned by the base database based on the target base data identifier is obtained, thereby completing the data retrieval. The present application optimizes the data retrieval process and improves the data retrieval efficiency by performing feature matching in the retrieval device and then sending the feature matching results to the base database for data retrieval.
[0125] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0126] The functions of each module can be found in the data retrieval method embodiment, which will not be described in detail here.
[0127] See also Fig.12 , Fig.12 1 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 100 includes a memory 101 and a processor 102, and the processor 102 is used to execute program instructions stored in the memory 101 to implement the steps in any of the above data retrieval method embodiments. In a specific implementation scenario, the electronic device 100 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 100 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0128] Specifically, the processor 102 is used to control itself and the memory 101 to implement the steps in any of the above data retrieval method embodiments. The processor 102 can also be called a CPU (Central Processing Unit). The processor 102 may be an integrated circuit chip with signal processing capabilities. The processor 102 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 102 can be implemented by an integrated circuit chip.
[0129] In this exemplary electronic device, in response to the received data retrieval request, a retrieval database is created based on the base data identifier and base data feature of the base data obtained from the base database, the base data identifier and base data feature of the same base data correspond, the identifier and feature of the base data in the base database are obtained and stored in the retrieval device, and the interaction process between the retrieval device and the base database can be reduced when the feature retrieval is performed later, thereby improving the retrieval efficiency. Based on the retrieved features of the data to be retrieved and the base data features of each base data in the retrieval database, feature comparison analysis is performed to obtain the target base data features that match the features to be retrieved, and feature-based matching can improve the retrieval efficiency. The target base data identifier corresponding to the target base data feature in the retrieval database is sent to the base database for data search processing, and the target base data returned by the base database based on the target base data identifier is obtained, thereby completing data retrieval. The present application optimizes the data retrieval process and improves the data retrieval efficiency by performing feature matching in the retrieval device and then sending the feature matching results to the base database for data retrieval.
[0130] See also Fig.13 , Fig.13 The computer-readable storage medium 110 stores program instructions 111 that can be executed by a processor, and the program instructions 111 are used to implement the steps in any of the above data retrieval method embodiments.
[0131] In this exemplary storage medium, by running the program instructions in the storage medium in response to the received data retrieval request, a retrieval database is created based on the base data identifier and base data feature of the base data obtained from the base database, the base data identifier and base data feature of the same base data correspond, the identifier and feature of the base data in the base database are obtained and stored in the retrieval device, and the interaction process between the retrieval device and the base database can be reduced when the feature retrieval is performed later, thereby improving the retrieval efficiency. Based on the retrieved features of the data to be retrieved and the base data features of each base data in the retrieval database, feature comparison analysis is performed to obtain the target base data features that match the features to be retrieved, and feature-based matching can improve the retrieval efficiency. The target base data identifier corresponding to the target base data feature in the retrieval database is sent to the base database for data search processing, and the target base data returned by the base database based on the target base data identifier is obtained, thereby completing data retrieval. The present application optimizes the data retrieval process and improves the data retrieval efficiency by performing feature matching in the retrieval device and then sending the feature matching results to the base database for data retrieval.
[0132] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0133] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0134] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0135] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. A data retrieval method, characterized in that: The method is applied to a data retrieval device, the data retrieval device is in communication connection with a preset base database, and the method comprises: In response to the received data retrieval request, a retrieval database is created based on the base database data identifier and base database data features of the base database data obtained from the base database, and the base database data identifier and the base database data features of the same base database data correspond to each other; the base database data identifier includes a base database identifier and an object identifier, and the retrieval database includes a base database container, an object container, and a feature value array, the base database container is used to cache the base database identifier, the object container is used to cache the object identifier, and the feature value array is used to cache the base database data features; the base database container includes the base database identifier and sub-base database information, the sub-base database information includes the object container, the object container includes an object information array, and the object information array includes the object identifier and the feature value array corresponding to the object identifier; Perform feature comparison and analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved; The method of performing feature comparison analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain target base data features that match the features to be retrieved includes: performing feature comparison analysis on the features to be retrieved and the base data features of each base data in the feature value array to obtain target base data features that match the features to be retrieved; determining a corresponding target object identifier based on the target base data features, and determining the target base data identifier based on the target object identifier; The target base stock data identifier corresponding to the target base stock data feature in the retrieval database is sent to the base stock database for data search processing to obtain the target base stock data returned by the base stock database based on the target base stock data identifier.
2. The method according to claim 1, characterized in that The step of creating a retrieval database based on the base database data identifier and base database data feature of the base database data obtained from the base database in response to the received data retrieval request includes: In response to receiving the data retrieval request, acquiring the base database data identifiers and the base database data features in batches from the base database based on the data capacity of the data retrieval device to create the retrieval database; The feature comparison and analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved includes: Calculate the feature similarity between the feature to be retrieved and the features of each base data in the retrieval database to obtain the feature similarity; In response to the feature similarity being greater than a preset similarity threshold, the corresponding base database data feature is determined as a target base database data feature that matches the feature to be retrieved.
3. The method according to claim 2, characterized in that The step of acquiring the base database data identifiers and the base database data features in batches from the base database based on the data capacity of the data retrieval device to create the retrieval database includes: Acquire in batches from the base database the base database data identifiers and base database data features of a number of base database data corresponding to the data capacity of the data retrieval device; Apply for memory resources and create the search database based on the memory resources.
4. The method according to claim 3, characterized in that After acquiring in batches the base database data identifiers and base database data features of a number of base database data corresponding to the data capacity of the data retrieval device, the method further comprises: Check whether there is a historical base database ID that is the same as the obtained base database ID; In response to the absence of the historical base database identifier, applying for the memory resource and creating a retrieval database corresponding to the acquired base database identifier; Traverse the acquired object IDs and check whether there is a historical object ID that is the same as the currently traversed object ID; In response to the absence of the historical object identifier, the currently traversed object identifier and the corresponding underlying database data feature are stored in the retrieval database.
5. The method according to claim 4, characterized in that After searching whether there is a historical base stock identifier that is the same as the acquired base stock identifier, the method further includes: In response to the existence of the historical base stock identifier, determining a target historical base stock in a vacant state in the historical base stocks corresponding to the historical base stock identifier; The acquired base database identifier, the object identifier and the base database data feature are stored in the target historical base database; In response to the existence of a historical object identifier identical to the object identifier in the target historical base, the historical object identifier is updated and replaced based on the object identifier.
6. The method according to claim 1, characterized in that The feature comparison and analysis based on the acquired features of the data to be retrieved and the base data features of each base data in the retrieval database to obtain the target base data features that match the features to be retrieved includes: Determine a target base database in the search database based on the data search request; Calculate the similarity between the feature to be retrieved and the base data feature of each base data in the target base database to obtain the feature similarity between the feature to be retrieved and the base data feature of each base data in the target base database; The target database data feature is determined based on the feature similarity and a preset similarity threshold.
7. The method according to claim 1, characterized in that The step of sending the target base database data identifier corresponding to the target base database data feature in the retrieval database to the base database for data search processing to obtain the target base database data returned by the base database based on the target base database data identifier comprises: Sending the target base stock data identifier corresponding to the target base stock data feature to the base stock database, so that the base stock database performs search processing based on the received target base stock data identifier, obtains the target base stock data corresponding to the target base stock data identifier, and returns the target base stock data to the data retrieval device; The target base database data returned by the base database is processed for result display.
8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
