Update method, data processing system, and computer program product
By generating an index shape diagram and back-compression and restoring and updating the shape nodes, the problem of wasted index binary tree storage space is solved, and efficient index update and storage optimization are achieved.
Patent Information
- Application Number
- CN202510559482.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-04-29
AI Technical Summary
In the prior art, the close dependence between index graphs and index binary trees leads to the need to persist in storing index binary trees when data is updated, resulting in large waste of storage space and maintenance overhead.
By generating an index shape map, the shape nodes in the index shape map represent multiple tree nodes with the same subtree shape in the index binary tree, and the target shape nodes are restored and updated by backcompression to generate a process structure diagram to realize dynamic local update of the index shape map, avoid persistent storage of the index binary tree.
Saves storage space, improves storage usage, reduces computing complexity, supports frequent update scenarios, and reduces index maintenance overhead.
Smart Images

Figure CN120086231B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data query technology, and more specifically to an updating method, a data processing system, and a computer program product. Background Art
[0002] To improve the efficiency of retrieving data from the search database, an index structure is constructed for the data stored in the search database. For example, an index binary tree can be constructed based on the data stored in the search database, and then an index graph can be constructed based on the index binary tree. This index graph enables faster data retrieval. When the data in the search database is updated, such as when data is added or deleted from the search database, the index graph needs to be updated accordingly.
[0003] While implementing the concepts of this application, the inventors discovered at least the following issues with the related art: Due to the close dependency between the index map and the index binary tree, it is often necessary to first update the index binary tree and then update the index map based on the updated index binary tree. This approach requires persistent storage of the index binary tree, resulting in wasted storage space. Summary of the Invention
[0004] In view of the above problems, the present application provides an updating method, a data processing system and a computer program product.
[0005] According to a first aspect of the present application, an update method is provided, comprising using a first computing unit to perform the following operations: receiving an update instruction from a first control unit, wherein the update instruction indicates updating an index shape graph stored in a first storage unit, the index shape graph representing multiple index vectors constructed based on multiple retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents multiple tree nodes with the same subtree shape in the index binary tree; in response to the update instruction, reading the index shape graph from the first storage unit, and performing decompression restoration on the target shape node in the index shape graph to generate a restored structure graph; processing the restored structure graph using a target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape node; updating the shape nodes in the path where the target shape node is located in the process structure graph to obtain an updated index shape graph.
[0006] A second aspect of the present application provides a data processing system, comprising: a first processor, comprising a first control unit, a first computing unit, and a first storage unit, wherein a first index shape graph is stored in the first storage unit; wherein the first computing unit is used to perform the following operations: receive an update instruction from the first control unit, wherein the update instruction indicates updating the index shape graph stored in the first storage unit, the index shape graph representing multiple index vectors constructed based on multiple retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents multiple tree nodes with the same subtree shape in the index binary tree; in response to the update instruction, the index shape graph is read from the first storage unit, and the target shape node in the index shape graph is decompressed and restored to generate a restored structure graph; the restored structure graph is processed using a target vector constructed by the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape node; the shape nodes in the path where the target shape node is located in the process structure graph are updated to obtain an updated index shape graph.
[0007] The third aspect of the present application further provides a computer program product, comprising a computer program or instructions, which implement the steps of the above method when executed by a processor.
[0008] According to an embodiment of the present application, the target shape nodes in the index shape graph are decompressed and restored to generate a restored structure graph, and then the target vector constructed by the target retrieval data included in the update instruction is used to process the restored structure graph to obtain a process structure graph containing the target shape node, and then the shape nodes in the path where the target shape node is located in the process structure graph are updated to obtain an updated index shape graph. The index shape graph can be updated without an index binary tree. Compared with first updating the index binary tree and then updating the index shape graph based on the updated index binary tree, there is no need to persistently store the index binary tree, thereby saving storage space and improving storage utilization. As a result, the technical problem of the need to persistently store the index binary tree in the prior art, which leads to a waste of storage space, is at least partially solved, and the technical effect of saving storage space and improving storage utilization is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above contents and other objects, features and advantages of the present application will become more apparent through the following description of the embodiments of the present application with reference to the accompanying drawings, in which:
[0010] Figure 1 An application scenario diagram of an updating method, a data processing system, and a computer program product according to an embodiment of the present application is shown.
[0011] Figure 2 A flow chart of an updating method according to an embodiment of the present application is shown.
[0012] Figure 3 A system principle diagram of an updating method according to an embodiment of the present application is shown.
[0013] Figure 4 A schematic diagram showing the correspondence between subtree shapes and shape codes according to an embodiment of the present application is shown.
[0014] Figure 5 A schematic diagram of combining a reduction structure diagram and a simulation path to obtain a process structure diagram according to an embodiment of the present application is shown.
[0015] Figure 6 A system schematic diagram of querying associated index vectors according to an embodiment of the present application is shown.
[0016] Figure 7 A system structure diagram of a first processor according to an embodiment of the present application is shown.
[0017] Figure 8 A system structure diagram of a data processing system according to another embodiment of the present application is shown.
[0018] Figure 9 A block diagram of an electronic device suitable for implementing an updating method according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present application.
[0020] The terms used herein are only for describing specific embodiments and are not intended to limit the present application. The terms "comprise," "include," etc. used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0021] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0022] When expressions such as "at least one of A, B, and C, etc." are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0023] In order to improve the efficiency of retrieving data from the retrieval library, an index structure is usually constructed for the data stored in the retrieval library. For example, multiple data in the retrieval library can be converted into multiple vector data, and then an index binary tree is constructed based on the multiple vector data, and then an index structure is constructed based on the index binary tree. Among them, vector data, as a mathematical expression, can characterize an object or data point through a set of ordered numerical values. Vector data, for example, includes a one-dimensional array, and the elements in the array are generally presented in numerical forms such as floating-point numbers. The numerical values can accurately reflect the position, characteristics and attributes of the object or data point in the multidimensional space. The distribution of vector data often presents an uneven trend, for example, there are high-density distribution areas and sparse distribution areas. This distribution characteristic may cause the retrieval performance to fluctuate greatly, which is not conducive to maintaining a stable and efficient retrieval state.
[0024] Methods for constructing an index structure include, for example, a tree-based method, a hash-based method, a quantization-based method, and a graph-based method.
[0025] Tree-based indexing methods reduce the search space by tracking the branches of the nearest neighbor tree that are most likely to contain the query point. For example, the KD tree (K-Dimensional Tree, abbreviated as KD-Tree) is a data structure used to index data points in a K-dimensional space. KD trees recursively partition data points into different subspaces. By continuously selecting a dimension and dividing the data points into two subtrees based on the values of that dimension, the data points in each subtree have a certain degree of order along a certain dimension. This structure improves search efficiency in operations such as nearest neighbor searches by quickly eliminating subspaces that are unlikely to contain the target point. Tree-based indexing methods are suitable for fast retrieval of low-dimensional vector data and have found widespread applications in fields such as image processing and computer vision. However, tree-based indexing methods are not suitable for retrieval of data from high-dimensional vectors because the number of tree nodes rapidly expands with increasing dimensionality, significantly increasing the memory overhead of the index.
[0026] Hash-based indexing methods use a hash function to convert continuous real values into discrete values. During this conversion process, vectors are segmented using the similarity between vectors as a key metric. Consequently, each vector is assigned to a different hash bucket based on its degree of similarity. When performing a search, the query vector, after hashing, is also assigned to the same hash bucket as similar vectors, significantly narrowing the search scope. Examples of hash-based indexing methods include Locality-Sensitive Hashing (LSH). LSH is a hash function that maps high-dimensional vectors into a low-dimensional space, ensuring that vectors with similar distances in the original high-dimensional space are more likely to be mapped to the same bucket in the hash space. By designing an appropriate hash function and hash table structure, vectors similar to the query vector can be quickly found. However, the performance of hash-based indexing methods, such as LSH, depends on the design of the hash function. Hash collisions can occur, resulting in multiple sets of vectors with low similarity being mapped to the same hash bucket, reducing search efficiency. Furthermore, the selection and calculation of the hash function incur significant computational overhead in index construction.
[0027] Quantization-based indexing methods include, for example, Product Quantization (PQ), a vector quantization indexing method whose core concepts are segmentation and clustering. Segmentation, for example, involves partitioning subspaces. The product quantization method decomposes the original vector into smaller blocks, such as subvectors, and then creates a representative code for each block to simplify the representation of each block, that is, to perform quantization encoding, thereby narrowing the potential range of values. PQ can significantly compress the memory usage of high-dimensional vectors and speed up nearest neighbor searches. Inverted Index Product Quantization (IVFPQ) is an accelerated version of PQ product quantization that can further increase search speed without compromising accuracy. However, the recall rate of quantization-based indexing methods is low.
[0028] Graph-based indexing methods include, for example, the Navigation Net (NN-Net) method. A Navigation Net is a graph-based index structure that establishes navigation relationships between data points, allowing the target vector to be quickly found along these navigation relationships during searches. Hierarchical Navigable Small World Graphs (HNSW) are hierarchical navigation graphs that employ a layered structure, stratifying edges by characteristic radius so that the average degree of each vertex across all layers remains constant. However, graph-based indexing methods such as HNSW are relatively slow to construct and may not be suitable for large-scale datasets. Furthermore, parameter tuning is difficult, making HNSW more difficult to use.
[0029] When searching for data, the data to be searched can be converted into a vector form, and then the vector distance between the converted vector and multiple vector data converted from multiple data in the search library can be calculated. The vector distance is used to represent the similarity between the vectors. For example, the vector distance calculation method can include calculating Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, cosine similarity and distance, haversine distance, Hamming distance, Jaccard index and distance, etc.
[0030] In the process of realizing the concept of the present application, the inventors found that there are at least the following problems in the related art: when updating the index structure, the related method usually needs to update the index binary tree first, and then update the index structure based on the updated index binary tree. This method requires persistent storage of the index binary tree to ensure that the index binary tree can be read when the index structure needs to be updated. However, persistent storage of the index binary tree will lead to unnecessary waste of resources. The reason is that: on the one hand, when the amount of data stored in the retrieval library is large, after extracting the feature vectors of a large amount of data, a large number of high-dimensional index vectors will be obtained, and the index binary tree constructed based on a large number of high-dimensional index vectors will usually occupy a large storage space. On the other hand, the index shape graph is usually used to retrieve data, and the index binary tree is not used. The index binary tree is generally only used when updating the index structure. Therefore, the utilization rate of the index binary tree is low. In this case, persistent storage of the index binary tree will lead to a waste of storage space.
[0031] In the process of realizing the concept of this application, the inventors also found that there are at least the following problems in the related technology: the update and maintenance overhead of the index binary tree is large. When the data in the retrieval library is updated frequently, the index binary tree needs to be updated frequently, thereby increasing the update and maintenance overhead of the index binary tree.
[0032] In view of this, an embodiment of the present application provides an update method, including using a first computing unit to perform the following operations: receiving an update instruction from a first control unit, wherein the update instruction indicates updating an index shape graph stored in a first storage unit, the index shape graph representing multiple index vectors constructed based on multiple retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents multiple tree nodes with the same subtree shape in the index binary tree; in response to the update instruction, reading the index shape graph from the first storage unit, and performing decompression and restoration on the target shape node in the index shape graph to generate a restored structure graph; processing the restored structure graph using a target vector constructed by the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape node; updating the shape nodes in the path where the target shape node in the process structure graph is located to obtain an updated index shape graph.
[0033] Figure 1 An application scenario diagram of an updating method, a data processing system, and a computer program product according to an embodiment of the present application is shown.
[0034] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first processor 101 and a second processor 102. The first processor 101 and the second processor 102 may exchange data to execute the updating method.
[0035] For example, the first processor 101 may receive an update instruction from the first control unit, and in response to the update instruction, read the index shape graph from the first storage unit, and perform decompression and restoration on the target shape nodes in the index shape graph to generate a restored structure graph; process the restored structure graph using a target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape nodes; and update the shape nodes in the path where the target shape nodes are located in the process structure graph to obtain an updated index shape graph. During the process of updating the index shape graph, the first processor 101 may also send an update record to the second processor 102, so that the second processor 102 can update the copy of the index shape graph stored by the second processor 102 based on the update record.
[0036] The following will be based on Figure 1 The scene described by Figures 2 to 5 The updating method of the embodiment of the present application is described in detail.
[0037] Figure 2 A flow chart of an updating method according to an embodiment of the present application is shown.
[0038] like Figure 2 As shown, the updating method of this embodiment includes operations S210 to S240.
[0039] In operation S210, an update instruction is received from the first control unit, wherein the update instruction indicates updating an index shape graph stored in the first storage unit, the index shape graph representing multiple index vectors constructed based on multiple retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents multiple tree nodes with the same subtree shape in the index binary tree.
[0040] In operation S220 , in response to the update instruction, the index shape graph is read from the first storage unit, and the target shape node in the index shape graph is decompressed and restored to generate a restored structure graph.
[0041] In operation S230 , the target vector constructed by the target retrieval data included in the update instruction is used to process the restoration structure graph to obtain a process structure graph including target shape nodes.
[0042] In operation S240 , the shape nodes in the path where the target shape node is located in the process structure graph are updated to obtain an updated index shape graph.
[0043] A search database typically stores a large amount of search data, and an index structure can be constructed based on this search data to improve search efficiency. The index structure can specifically take the form of an index shape graph. Constructing an index structure for the search data can specifically include: performing feature extraction on multiple search data to obtain search vectors corresponding to the multiple search data; compressing the search vectors to obtain multiple index vectors; constructing an index binary tree based on the multiple index vectors; and compressing the nodes of the index binary tree to obtain an index shape graph. Compression of the search vectors may include, for example, dimensionality reduction or binarization of the search vectors.
[0044] For example, in the field of autonomous driving, it may be necessary to retrieve a target image corresponding to a target vehicle from a large number of images in order to extract the target vehicle's feature information from the target image. The retrieval database can be a database containing one million images, and the retrieval data can be the image data corresponding to the one million images. To improve the efficiency of retrieval of target images from the retrieval database, an index shape graph can be constructed for the one million images.
[0045] Figure 3 A system principle diagram of an updating method according to an embodiment of the present application is shown.
[0046] in, Figure 3 The index vectors v1 to v8 shown in can be obtained based on a plurality of search data. An index binary tree can be constructed based on the index vectors v1 to v8, and an index shape graph can be constructed based on the index binary tree.
[0047] The index binary tree may include multiple levels of tree nodes, for example, the root tree node is the first level tree node, the tree nodes directly connected to the root tree node are the second level tree nodes, the tree nodes directly connected to the second level tree node are the third level tree nodes, and so on.
[0048] The index binary tree can also include associated edges between tree nodes, which can represent N-dimensional values in the index vector. For example, the associated edges between the first-level tree nodes and the second-level tree nodes are used to represent the first-dimensional values, and the associated edges between the second-level tree nodes and the third-level tree nodes are used to represent the second-dimensional values in the index vector, and so on.
[0049] like Figure 3 As shown, for an indexed binary tree, the first dimension of the edge representation in the index vector between the first-level tree node and the left-hand second-level tree node is 0, and the first dimension of the edge representation in the index vector between the first-level tree node and the right-hand second-level tree node is 1. The second dimension of the edge representation in the index vector between the left-hand second-level tree node and the leftmost third-level tree node is 0, and the third dimension of the edge representation in the index vector between the leftmost third-level tree node and the leftmost fourth-level tree node is 0. Thus, the edges between the first-level tree node and the left-hand second-level tree node, the edges between the left-hand second-level tree node and the leftmost third-level tree node, and the edges between the leftmost third-level tree node and the leftmost fourth-level tree node can represent the index vector v1 (0, 0, 0). An indexed binary tree includes multiple subtree shapes. To distinguish subtree shapes, the subtree shapes can be numbered to obtain shape codes corresponding to the subtree shapes.
[0050] Figure 4 A schematic diagram showing the correspondence between subtree shapes and shape codes according to an embodiment of the present application is shown.
[0051] like Figure 4 As shown, different subtree shapes correspond to different shape codes, and are stored in the first storage unit as shape mapping information.
[0052] After determining the subtree shapes included in the index binary tree, the index binary tree can be compressed based on the subtree shapes to generate an index shape graph. Specifically, multiple tree nodes in the index binary tree may correspond to the same subtree shape, for example Figure 3The leftmost third-level tree node and the rightmost third-level tree node of the index binary tree both have a subtree shape with a shape code of 2. Multiple tree nodes corresponding to the same subtree shape can be merged into the same shape node in the index shape graph, that is, the index binary tree is node compressed. The number of the shape node obtained after node compression is the same as the shape code of the subtree shape. Therefore, the shape of the subtree shape corresponding to the shape node can be determined by the number of the shape node. For example, if a shape node is numbered 6, it can be determined that the subtree shape corresponding to the shape node is as follows Figure 4 The shape shown encodes a subtree shape of 6.
[0053] For example: You can Figure 3 The third-level tree node on the left and the third-level tree node on the right of the index binary tree are merged into the same shape node in the index shape graph. The number of the shape node is the same as the shape code of the tree node. The merged shape node is Figure 3 The shape node numbered 2 in the index shape graph can be indexed. All the last-level tree nodes in the index binary tree can be merged into a shape node, and the code of the shape node is 1.
[0054] By compressing the nodes of the index binary tree, an index shape graph can be generated that occupies a smaller storage space than the index binary tree.
[0055] The index shape graph includes multiple levels of shape nodes, which are connected by edges. The edges between shape nodes can represent the N-dimensional values in the index vector. For example: Figure 3 The edges between the shape nodes numbered 6, 4, 3, and 1 in the index shape graph can represent the first dimension value of the index vector as 0, the second dimension value as 1, and the third dimension value as 1, respectively, thereby representing the index vector (0, 1, 1).
[0056] Furthermore, in operation S210 , when the search data in the search library is updated, for example, when the search data is added or deleted, an update instruction may be issued to indicate that the index shape graph needs to be updated.
[0057] Specifically, in operation S220, the index vector to be updated may be determined based on the update instruction. For example, the update instruction may determine that a new index vector (1, 1, 1) is required. Accordingly, the index shape graph needs to be updated so that the updated index shape graph can represent the index vector (1, 1, 1).
[0058] Therefore, in response to the update instruction, the index shape map may be first read from the first storage unit. The index shape map may be stored in the first storage unit, which may include, for example, a storage unit of a graphics processing unit (GPU) or an on-chip storage space of a field-programmable gate array (FPGA).
[0059] After reading the index shape graph, the target shape node in the index shape graph can be determined based on the index vector to be updated. For example, when adding a new index vector, the multi-dimensional values of the index vector can be matched with the multi-dimensional values represented by the multiple edges in the index vector to be updated, and the shape node where the matching is interrupted is used as the target shape node.
[0060] For example, for Figure 3 In the indexed shape graph shown, when an index vector (1,1,1) is added, the first dimension of the index vector is 1. The edge between shape nodes 6 and 5 in the indexed shape graph also represents a value of 1, indicating a numerical match. Continuing to match the second dimension of the index vector, which represents a value of 1, we find that none of the edges connected to shape node 5 represent an edge with a second dimension value of 1. Therefore, the matching is terminated, and shape node 5 can be selected as the target shape node.
[0061] After determining the target shape node, the subtree shape corresponding to the target shape node can be determined according to the target shape node number, and then the target shape node can be decompressed and restored to obtain a restored structure graph. Decompression and restoration includes: representing the subtree shape corresponding to the target shape node in the index shape graph.
[0062] For example Figure 3 As shown, for the index shape graph: the edge between the shape nodes numbered 2 and 1, which represents a value of 1, can be deleted, and a shape node 1 can be added, that is, Figure 3 The shape node numbered 1 represented by the midpoint line, and the directed edge between the shape node numbered 1 and shape node 2 represented by the dotted line is added, that is, Figure 3 The edge represented by the midpoint line. Therefore, by restoring the structure graph, the subtree shape corresponding to the target shape node can be intuitively represented.
[0063] Furthermore, in operation S230, the target search data may include search data that needs to be updated, such as data that needs to be added or deleted. The target search data may be converted into vector data, such as by extracting features from the target search data to obtain a target vector.
[0064] Processing the restored structure graph using the target vector may include: adding edges that can represent multiple dimensional values of the target vector and shape nodes for connecting the edges to the restored structure graph to obtain a process structure graph.
[0065] like Figure 3 As shown in the figure, when an index vector (1,1,1) is added, in the restored structure graph, the first dimension of the target vector is 1, which can be represented by the edge between the shape node numbered 6 (hereinafter referred to as shape node 6) and shape node 5. The second dimension of the target vector is 1, but the second dimension represented by the edge connected to shape node 5 is 0 instead of 1. Therefore, an edge connected to shape node 5 can be added to represent the second dimension value of 1, and shape nodes can be added accordingly. Furthermore, an edge and corresponding shape node need to be added to represent the third dimension value of 1. This results in the shape node numbered 1 represented by a dotted line and the edge represented by a dotted line in the process structure graph.
[0066] Furthermore, in operation S240 , the path where the target shape node is located is: among the multiple paths connecting the root shape node and the last-level shape node, at least one path including the target shape node.
[0067] For example: the target shape node is shape node 5, Figure 3 In the figure, the path where the target shape node is located may, for example, include: shape node 6, shape node 5, the edge between shape node 6 and shape node 5, and shape nodes numbered 1 and 3 represented by dotted lines and the edges represented by dotted lines; the path where shape node 5 is located may, for example, also include: shape node 6, shape node 5, the edge between shape node 6 and shape node 5, as well as shape node 2, shape node 1, the edge between shape node 5 and shape node 2, and the edge between shape node 2 and shape node 1.
[0068] Specifically, compared to the original restored structure graph, the shape nodes and edges in the process structure graph will change, e.g. Figure 3 In the process structure diagram, new shape nodes and edges are added, which are represented by dotted lines. Therefore, the subtree shapes corresponding to the shape nodes will also be updated. For example: Figure 4 The subtree shapes 5 and 6 shown no longer exist, and a new subtree shape 7 has been added. Furthermore, after updating the subtree shapes, the subtree shapes can be renumbered to obtain the updated shape encoding. When inserting or deleting retrieval data, the shape of the index binary tree will only change locally, and the affected subtree range is limited to the binary tree path corresponding to the insertion or deletion vector. Accordingly, the index shape diagram and shape encoding are only locally changed. For example, Figure 3From the index shape graph in the previous figure and the updated index shape graph, we can see that shape nodes 5 and 6 no longer exist, and a new shape node numbered 7 has been added. In addition, in the updated index shape graph, the shape code corresponding to the root shape node changes from 6 to 7. This shows that this update method does not require updating all the data in the index shape graph. This allows for dynamic partial or incremental updates of the index shape graph, avoiding the need to maintain two copies of index data, as required by mechanisms such as hot and cold backups.
[0069] This method generates a restored structure graph by decompressing and restoring the target shape nodes in the index shape graph. The restored structure graph is then processed using the target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape node. The shape nodes in the path of the target shape node in the process structure graph are then updated to obtain an updated index shape graph. This method can also update the index shape graph without requiring an index binary tree. Compared to first updating the index binary tree and then updating the index shape graph based on the updated index binary tree, this method eliminates the need for persistent storage of the index binary tree, saving storage space and improving storage utilization. Furthermore, the computational complexity is low: for a D-dimensional target vector, the computational complexity is only O(D), meaning that when a D-dimensional target vector is added or deleted, only D computation operations are required to update the shape graph. This low computational complexity supports frequent updates.
[0070] Furthermore, the number of nodes in the index binary tree may be very large, and the corresponding memory overhead for storing the index binary tree is large. To efficiently use the memory overhead, after constructing the index shape graph, the index binary tree can be deleted, and only a small amount of auxiliary data can be retained for updating the index shape graph. The small amount of auxiliary data includes, for example, the parameters required to generate the index vector, such as the parameters required for dimensionality reduction and binarization processing, the correspondence between multiple paths in the index binary tree and the index vector, and the number corresponding to the root shape node. The root shape node can be used as the entry point of the index shape graph, for example, when constructing the index shape graph, the construction starts from the root shape node.
[0071] According to an embodiment of the present application, an indexed shape graph includes multiple shape nodes and edges between the shape nodes, the multiple shape nodes are divided into N+1 levels, and form multiple paths with the edges corresponding to multiple index vectors, respectively, where N is an integer greater than 1; the index vector includes an N-dimensional index value, and the N-dimensional index value represents at least one of the following: image features, speech features, and text features.
[0072] Specifically, the index shape graph includes multiple levels of shape nodes, for example, the root shape node is a first-level shape node, the shape nodes connected to the root shape node are second-level shape nodes, and the shape nodes connected to the second-level shape nodes are third-level shape nodes. Figure 3In the updated index shape graph, the shape node numbered 7 is a first-level shape node, and the shape node numbered 4 is a second-level shape node.
[0073] The edges between shape nodes can represent the N-dimensional index value of the index vector. For example, the edge between the first-level shape node and the second-level shape node can represent the first-dimensional index value, and the edge between the second-level shape node and the third-level shape node can represent the second-dimensional index value. By traversing the edges between shape nodes, multiple edges representing the index values of all dimensions of the index vector can be determined. For example Figure 3 As shown in the updated index shape graph, the edge representing the index vector (0, 1, 1) includes the edge connecting the shape nodes numbered 7, 4, 3, and 1, in sequence. Accordingly, the path corresponding to the index vector includes the shape nodes numbered 7, 4, 3, and 1, as well as the edge connecting the shape nodes numbered 7, 4, 3, and 1, in sequence.
[0074] Specifically, the N-dimensional index value in the index vector can represent features of different modalities, for example, at least one of the following: image features, speech features, and text features.
[0075] According to an embodiment of the present application, the N-dimensional index values of the index vector may be features of multiple feature types.
[0076] For example, in an image retrieval scenario, the N-dimensional index value includes at least one of the following: image texture, image color, image brightness, the shape of the target object in the image, image depth, and image grayscale. Based on the image input by the user, a query can be performed in an index shape graph constructed from index vectors generated from image data in the image library. Once the target vector is obtained, the target image corresponding to the target vector is found and returned to the user.
[0077] For example, in the context of intelligent question-answering, the N-dimensional index value may include at least one of the following: voice volume, voice prosody, voice speed, voice intonation, and voice timbre; or the N-dimensional index value may include at least one of the following: text semantics, text length, text paragraph structure, and the frequency of the target word in the text. Based on the user's input voice or text, a query can be performed in an index shape graph constructed from index vectors generated from voice data in the voice library. Once the target vector is obtained, the target voice or text corresponding to the target vector is found and returned to the user.
[0078] The index shape graph can briefly and accurately represent the N-dimensional index value of the index vector. The index vector can accurately represent the different modal feature information of the retrieved data, thereby improving the retrieval accuracy and efficiency.
[0079] According to an embodiment of the present application, a shape node carries a shape code, and the shape code is used to characterize the subtree shape category of multiple tree nodes having the same subtree shape; performing decompression and restoration on a target shape node in an index shape graph includes: reading shape mapping information from a first storage unit, wherein the shape mapping information is used to characterize the mapping relationship between multiple subtree structures and subtree shape categories; and performing decompression and restoration on the target shape node based on the shape mapping information and the shape code of the target shape node.
[0080] Specifically, the subtree shape category is used to distinguish different subtree shapes. An indexed binary tree may include multiple subtree shapes. The subtree shapes corresponding to different tree nodes may be the same. The same subtree shape can be assigned the same number to obtain a shape code corresponding to the same subtree shape. Different shape codes can represent different subtree shapes. Shape mapping information can be stored in the first storage unit.
[0081] Furthermore, the subtree shape corresponding to the target shape node can be determined based on the shape mapping information, and decompression restoration, that is, the subtree structure restoration of the shape node, can be performed by representing the subtree shape corresponding to the target shape node in the index shape graph, thereby generating a restored structure graph.
[0082] According to an embodiment of the present application, the multiple paths in the index shape graph each include N edges; the method for determining the target shape node may be: matching the N-dimensional target value included in the target vector with the N edges of each of the multiple paths step by step to determine a reference vector that fully matches or partially matches the target vector from multiple index vectors; and determining the target shape node from the target path where the reference vector is located.
[0083] Specifically, in the index shape graph, the root shape node and the last level shape node can be connected through multiple paths. For example, Figure 3 In the index shape graph shown, path 1 may include shape node 6, shape node 4, shape node 3, shape node 1, and edges between these shape nodes; path 2 may include shape node 6, shape node 5, shape node 2, shape node 1, and edges between these shape nodes.
[0084] In each path, the N edges included in the path can represent N-dimensional values, for example Figure 3The edge between shape node 6 and shape node 4 can represent the first dimension value as 0. Matching the N-dimensional target value included in the target vector with the N edges of each of the multiple paths step by step may include: matching the N-dimensional target value included in the target vector with the N-dimensional values represented by the N edges respectively. A reference vector that completely matches the target vector may include: the N-dimensional values included in the reference vector are exactly the same as the N-dimensional target values included in the target vector, for example, the target vector is (1,1,1), and the reference vector is also (1,1,1). A reference vector that partially matches the target vector may include: the N-dimensional values included in the reference vector are partially the same as the N-dimensional target values included in the target vector, for example, the target vector is (1,1,1), and the reference vector is (1,0,0).
[0085] The target path where the reference vector is located includes multiple edges used to represent the reference vector and shape nodes connected by the multiple edges. The target shape node can be determined from the target path where the reference vector is located.
[0086] Specifically, by first matching the N-dimensional target value included in the target vector with the N edges of multiple paths step by step to determine a reference vector that fully or partially matches the target vector, and then determining the target shape node from the target path where the reference vector is located, the target shape node can be determined efficiently and accurately.
[0087] According to an embodiment of the present application, when the update instruction indicates a data insertion operation, the target shape node includes: an interruption node where a matching interruption occurs in the target path where a reference vector that partially matches the target vector is located; when the update instruction indicates a data deletion operation, the target shape node includes: a single path node in the target path where a reference vector that completely matches the target vector is located, which is connected to the adjacent shape node by only one edge.
[0088] For example: you need to add a new target vector (1,1,1) and the reference vector is (1,0,0). Figure 3 In the indexed shape graph shown, the node where the matching is interrupted is shape node 5, so shape node 5 is the target shape node. For another example, if we want to delete the target vector (0, 1, 1), the reference vector is also (0, 1, 1). The target path on which the reference vector resides includes shape nodes 6, 4, 3, and 1. Of these shape nodes, only shape node 3 is a single-path node connected to an adjacent shape node by only one edge, so shape node 3 is the target shape node.
[0089] Specifically, when adding a new target vector, a new shape node needs to be added under the interruption node, which will cause the shape codes corresponding to the interruption node and its parent shape nodes to change. When deleting a target vector, since a shape node may be connected to multiple other shape nodes, it can be included in multiple paths. Therefore, directly deleting all shape nodes in the target path may affect other paths. Therefore, only single-path nodes that are connected to adjacent shape nodes by only one edge can be deleted. After deleting a single-path node, the shape codes corresponding to the single-path node and its parent shape node will also change.
[0090] Specifically, by taking the interrupted node where the matching is interrupted in the target path where the reference vector that partially matches the target vector is located, or the single path node in the target path where the reference vector that completely matches the target vector is located and connected to the adjacent shape node by only one edge as the target shape node, it is convenient to accurately and intuitively determine the shape nodes that need to change the shape encoding, thereby improving the update efficiency.
[0091] According to an embodiment of the present application, updating the shape nodes in the path where the target shape node is located in the process structure diagram includes: updating the shape coding of the target shape node based on the shape mapping information; updating the shape coding of the shape nodes in the path where the target shape node is located step by step based on the shape mapping information and the updated shape coding of the target shape node.
[0092] Specifically, the shape code of the target shape node may be updated first.
[0093] See also Figure 3 It can be seen that compared with the restored structure diagram, the process structure diagram adds shape nodes and edges represented by dotted lines. Therefore, the shape of the subtree corresponding to the target shape node will change. Specifically, the target shape node is shape node 5, and the subtree shape originally corresponding to the target shape node is Figure 4 In the subtree shape with shape coding of 5, after adding shape nodes and edges represented by dotted lines, the subtree shape corresponding to the target shape node is no longer the subtree shape with shape coding of 5, but the subtree shape with shape coding of 4. Therefore, the shape coding of the target shape node can be updated from 5 to 4.
[0094] After the shape code of the target shape node is updated, the shape codes of the shape nodes in the path where the target shape node is located are updated step by step.
[0095] See also Figure 3It can be seen that after adding shape nodes and edges represented by dotted lines in the process structure diagram, not only the subtree shape corresponding to the target shape node will change, but also the subtree shapes corresponding to other shape nodes in the path where the target shape node is located may change. For example, the path where the target shape node is located includes shape node 6. The original root shape node, that is, the subtree shape corresponding to shape node 6 is the subtree shape with shape code 6. However, after adding shape nodes and edges represented by dotted lines in the process structure diagram, the subtree shape corresponding to the root shape node becomes Figure 4 The shape code of the subtree is 7. Therefore, the shape code of the root shape node can be updated from 6 to 7.
[0096] Furthermore, since the subtree shapes corresponding to multiple shape nodes in the path where the target shape node is located may all change, in order to improve update efficiency, the shape codes of the shape nodes in the path where the target shape node is located can be updated step by step. For example, the shape code of the root shape node can be updated first, and then the shape codes of the shape nodes at the next level can be updated in sequence.
[0097] Furthermore, by first updating the shape code of the target shape node and then gradually updating the shape codes of other shape nodes in the path where the target shape node is located, the index shape graph can be updated in an orderly and accurate manner.
[0098] According to the embodiments of the present application, since the target shape node is the source node that triggers node changes in the index shape graph, all possible changes are related to the changes of this node. The method of the embodiments of the present application only needs to update the nodes in the path where the node is located, and no full update is required, which greatly reduces the amount of calculation.
[0099] According to an embodiment of the present application, processing a restoration structure graph using a target vector constructed by target retrieval data included in an update instruction includes: constructing the target vector as a simulation path based on the construction rules of the index binary tree; combining the restoration structure graph and the simulation path, or deleting the simulation path from the restoration structure graph based on the operation type of the update operation indicated by the update instruction.
[0100] Specifically, when the update operation indicated by the update instruction is an insert operation, the restored structure diagram and the simulation path are combined; when the update operation indicated by the update instruction is a delete operation, the simulation path is deleted from the restored structure diagram (it may be that only part of the path in the simulation path is deleted).
[0101] In the case where the update operation indicated by the update instruction is an insert operation, according to the construction rules of the index binary tree, the target vector is constructed as a simulation path: based on the L-th dimension target value to the N-th dimension target value of the target vector, a simulation path consisting of at least one simulation node is constructed, wherein a matching interruption occurs between the target vector and the reference vector in the L-th dimension, and L is less than N.
[0102] Figure 5 A schematic diagram of combining a reduction structure diagram and a simulation path to obtain a process structure diagram according to an embodiment of the present application is shown.
[0103] like Figure 5 As shown in , when the target vector (1,1,1) is inserted, by searching in the index shape graph, it is found that the target vector and the reference vector have a matching interruption at the second node. Then a simulation path from the second-level node to the last-level node is constructed. Figure 4 The dotted line path in the path with the vector value (1, 1, 1) is shown in . This simulation path is then combined with the restored structure graph to obtain the process structure graph.
[0104] After obtaining the process structure diagram, the shape coding is updated. Specifically, the shape coding of the target shape node is first updated based on the shape mapping information. Then, based on the shape mapping information and the updated shape coding of the target shape node, the shape coding of the shape nodes in the path where the target shape node is located is updated step by step. When a new target vector is added, a new shape node needs to be added below the interruption node, which will cause changes to the shape coding corresponding to the interruption node and its parent shape node. Therefore, the shape coding is updated step by step upward based on the interruption node.
[0105] like Figure 5 As shown, the shape code of the target shape node is updated based on the shape mapping information. For example, the shape code of the shape node with a shape code of 5, where a matching interruption occurs, is updated to 4. This is then updated step by step upward until the root node is reached. For example, the shape code of the shape node with a shape code of 6 is updated to 7. At the same time, shape codes are added to the nodes in the simulation path, such as the nodes with shape codes of 3 and 1 in the figure. Finally, shape nodes with the same shape code are merged to obtain the updated index shape graph.
[0106] When the operation type is to delete the target vector, the simulation path can be the path generated from the root node to the last level node for the target vector. The simulation path or part of the simulation path can be directly deleted from the restored structure diagram to obtain the process structure diagram.
[0107] It should be noted that when deleting a target vector, a shape node may be connected to multiple other shape nodes and therefore included in multiple paths. Therefore, directly deleting all shape nodes in the target path may affect other paths. Therefore, only single-path nodes connected to adjacent shape nodes by only one edge can be deleted. After deleting a single-path node, the shape codes corresponding to the single-path node and its parent shape node will also change. Therefore, it is necessary to update the shape codes based on the parent node of the single-path node step by step upward.
[0108] According to an embodiment of the present application, multiple retrieval data are distributed in multiple data sets, and the multiple data sets are respectively associated with multiple paths. At least one retrieval data included in the same data set corresponds to an index vector; the query method also includes: when the update instruction indicates a data insertion operation and there is a target path in the index shape graph that completely matches the target vector, the index shape graph is not updated; and the target retrieval data is added to the target data set associated with the target path.
[0109] Specifically, the retrieval library may include multiple identical retrieval data, and multiple identical retrieval data can generate multiple identical index vectors. A data set may include one retrieval data, or it may include multiple identical retrieval data. The retrieval data included in different data sets are different. For example: data set 1 includes retrieval data 1, and the retrieval data corresponds to index vector 1; data set 2 includes retrieval data 2, and the retrieval data corresponds to index vector 2. An index vector can correspond to a path in the index shape graph. Since a data set includes at least one retrieval data, and one retrieval data corresponds to an index vector, and an index vector corresponds to a path in the index shape graph, a data set can be associated with a path, for example, a target data set is a data set associated with a target path.
[0110] Specifically, the data insertion operation involves adding new search data to the existing search library, where the target search data corresponds to the target vector. If a target path that completely matches the target vector exists in the index shape graph, this indicates that the index shape graph already includes the target vector, so there's no need to update the index shape graph. However, the search library does need to be updated, and the target search data can be directly stored in the target dataset associated with the target path.
[0111] In one embodiment, when a new search data is added, a target vector corresponding to the newly added search data is first generated. The number of the root shape node of the index shape graph can be read, and the N-dimensional values represented by the multiple edges in the index shape graph are matched with the N-dimensional index value of the target vector. All shape node numbers along the path are pushed into a pre-created stack until the path reaches the last-level shape node or the interruption node. When the path jumps to the last-level shape node (i.e., there is no jump to the interruption node), it means that the index shape graph can already represent the index vector corresponding to the newly added search data. Under this condition, there is no need to update the shape graph, and the newly added search data only needs to be added to the search data set associated with the last-level tree node.
[0112] In one embodiment, when jumping to an interruption node, the index shape map is updated, and shape mapping information for representing the mapping relationship between various subtree structures and subtree shape categories is updated.
[0113] According to an embodiment of the present application, the query method also includes: when the update instruction indicates a data deletion operation, there is a target path in the index shape graph that completely matches the target vector, and the number of retrieval data in the target data set associated with the target path is greater than a predetermined threshold (for example, greater than 1), the index shape graph is not updated; and the target retrieval data is deleted from the target data set associated with the target path.
[0114] Specifically, a dataset may only contain the target search data, so the path associated with that dataset corresponds only to the target vector. In this case, if the target search data is to be deleted, the index shape map needs to be updated. After the update, the path corresponding to the target vector will no longer exist in the index shape map. However, a dataset may contain search data other than the target search data (i.e., the number of search data in the target dataset is greater than 1). In this case, the path containing the target vector is shared by other data and cannot be deleted. In this case, the index shape map does not need to be updated, but the search library needs to be updated. In other words, only the target search data needs to be deleted from the target dataset.
[0115] According to an embodiment of the present application, the method of the embodiment of the present application also includes, while using the first computing unit to perform an index shape graph update, using the second computing unit to perform a data query operation, specifically, using the second computing unit to perform the following operations: in response to receiving a query instruction from the second control unit, querying and obtaining an associated index vector from the index shape graph copy of the second storage unit.
[0116] Figure 6 A system schematic diagram of querying associated index vectors according to an embodiment of the present application is shown.
[0117] like Figure 6As shown, when data is added or deleted, the first computing unit in the first processor can update the index shape graph, shape mapping information, and leaf node array accordingly. Correspondingly, the second computing unit in the second processor performs a data query operation. In response to receiving a query instruction from the second control unit in the second processor, the second computing unit obtains an associated index vector from the copy of the index shape graph in the second storage unit in the second processor.
[0118] The first processor may include, for example, a central processing unit (CPU) or a graphics processing unit (GPU).
[0119] The second processor may include, for example, an FPGA or a GPU. A copy of the indexed shape map may be stored in a second storage unit of the second processor. The second storage unit may include, for example, on-chip storage space of the FPGA. The on-chip storage space of the FPGA may include, for example, static random access memory (SRAM) of the FPGA. The second processor may include external off-chip memory. The off-chip memory may be used to store shape mapping information. The off-chip memory of the FPGA may include, for example, dynamic random access memory (DRAM). When the shape map is updated, the latest shape mapping information may be downloaded from the first storage unit.
[0120] The index shape graph replica also represents multiple index vectors constructed based on multiple search data. Multiple search data may correspond to one index vector. After obtaining the associated index vector from the index shape graph replica, the original search data corresponding to the associated index vector must be returned to the user. The corresponding search data can be found based on the pre-built association between the index vector and the search data.
[0121] The multiple search data are distributed in multiple data sets, which are respectively associated with the index shape graph and multiple index vectors in the index binary tree in a one-to-one correspondence. At least one search data included in the same data set corresponds to one index vector.
[0122] The association between the index vector and the dataset of the retrieved data can be achieved by associating multiple paths (or multiple last-level leaf nodes) in the index binary tree with multiple datasets in a one-to-one correspondence. After finding an associated index vector that matches the query data in the query instruction, the path or last-level leaf node corresponding to the associated index vector in the index binary tree can be found, thereby further finding the dataset associated with the associated index vector.
[0123] The location information of the last-level leaf nodes in the indexed binary tree can be stored in an ordered leaf node array. The leaf node array stores the sequentially ordered IDs of the last-level leaf nodes in the indexed binary tree. After finding an associated index vector that matches the query data in the query instruction, the last-level leaf node corresponding to the associated index vector in the indexed binary tree can be located from the leaf node array.
[0124] In order to determine which last-level leaf node the associated index vector corresponds to, it can be achieved by carrying offset information in the shape node. The offset information is, for example, Figure 3 The value in the brackets of the shape node is shown. The offset information indicates the number of the last level leaf nodes of the left subtree of the tree node corresponding to the shape node in the index binary tree. For example, Figure 3 The offset information carried by the shape node with shape code 6 can be expressed as (3). Correspondingly, in the index binary tree, the number of last-level leaf nodes of the left subtree of the tree node corresponding to the shape node with shape code 6 is 3.
[0125] In the process of querying the associated index vector, the offset information carried by the shape node can be obtained, and the target leaf node can be determined from multiple last-level leaf nodes based on the offset information. Specifically, the offset information carried by the corresponding upper-level shape nodes of multiple edges with a first value (for example, "1") in the path where the associated index vector is located can be summed to obtain a total offset. The total offset represents the horizontal position offset of the leaf node corresponding to the associated index vector relative to the first leaf node in the corresponding index binary tree. Therefore, the target leaf node can be determined from the K leaf nodes based on the total offset, that is, starting from the first leaf node, the target leaf node is located by shifting to the right by the position corresponding to the total offset.
[0126] After the index shape graph is updated, the leaf node array related to the query operation also needs to be updated accordingly in order to achieve accurate query.
[0127] The update method of the leaf node array is different in the scenarios of data insertion update and data deletion update.
[0128] When inserting and updating data in the index shape graph, assuming that when jumping to the interrupt node that matches the interrupt, the offset information corresponding to the interrupt node is p, and the number of leaf nodes of the interrupt node is e, the update of the leaf node array is divided into the following two cases: The first case: when jumping from the interrupt node to the empty node, the corresponding value of the edge is '0', then all array elements in the interval from position p to the end of the leaf node array are moved back one position, and then a newly added leaf node is inserted into position p of the leaf node array.
[0129] The second case: When jumping from the interrupt node to the empty node, the corresponding value of the edge is '1', then all array elements in the interval from position p+e to the end of the leaf node array are moved back one position, and then a newly added leaf node is inserted into position p+e of the leaf node array.
[0130] When inserting and updating data into an indexed shape graph, the leaf node array is adjusted as follows: Assuming that when jumping to the last-level shape node, the calculated offset information for the relevant shape node in this path is p, the leaf node at position p is deleted from the leaf node array, and all array elements from position p+1 to the end of the array are shifted forward one position. Because an index vector is constructed based on at least one retrieval data, the at least one retrieval data that constructs the same index vector can be considered a retrieval data set.
[0131] This application also provides a data processing system, Figure 7 A system structure diagram of a first processor according to an embodiment of the present application is shown.
[0132] like Figure 7 As shown, the first processor includes a first storage unit, a first control unit, and a first computing unit. The first storage unit stores a first index shape graph. The first control unit can send an update instruction to the first computing unit, so that the first computing unit updates based on the received update instruction to obtain an updated index shape graph.
[0133] The first storage unit stores a first index shape graph; the first calculation unit is configured to perform the following operations: receive an update instruction from the first control unit, wherein the update instruction instructs to update the index shape graph stored in the first storage unit, the index shape graph representing multiple index vectors constructed based on multiple retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents multiple tree nodes with the same subtree shape in the index binary tree; in response to the update instruction, read the index shape graph from the first storage unit, and perform decompression and restoration on the target shape node in the index shape graph to generate a restoration structure graph; process the restoration structure graph using the target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph containing the target shape node; and update the shape nodes in the path where the target shape node is located in the process structure graph to obtain an updated index shape graph. The first calculation unit performs the operation of updating the index shape graph, and reference may be made to the description of operations S210 to S240 in the aforementioned embodiment, which will not be repeated here.
[0134] Figure 8 A system structure diagram of a data processing system according to another embodiment of the present application is shown.
[0135] like Figure 8 As shown, the data processing system also includes: a second processor, the second processor includes a second control unit, a second computing unit, and a second storage unit, and the second storage unit stores a second index shape diagram; wherein the second computing unit is used to perform the following operations: in response to a query instruction issued by the second control unit, query predetermined data from the second index shape diagram, wherein the second index shape diagram is a backup of the first index shape diagram.
[0136] Specifically, the update task can be performed by the first processor, and the query task can be performed by the second processor. Specifically, the second processor can read the first index shape map from the first storage unit of the first processor, generate a backup of the first index shape map, and store the backup of the first index shape map in the second storage unit. After the second control unit issues a query instruction, the backup of the first index shape map can be read from the second storage unit, that is, the second index shape map can be read, thereby querying the predetermined data corresponding to the query instruction based on the second index shape map.
[0137] The first processor and the second processor can respectively execute the operations of updating the index shape map and querying the data, so the updating and querying can be performed synchronously without affecting each other. Specifically, the updating of the index shape map will not affect the data query operation.
[0138] Specifically, to ensure that updates and queries can be performed simultaneously without affecting each other, the shape mapping information can be rendered inaccessible to other programs until the update is complete. For example, when updating shape mapping information in off-chip memory, the shape node data in the shape mapping information need only be updated sequentially, in ascending order of shape node numbering. Since the shape mapping information data is not read by the first computing unit of the first processor, updating the shape mapping information will not affect the query operation of the first computing unit. The updated shape mapping information will only be downloaded by the first processor the next time the index shape map update program is loaded.
[0139] Furthermore, when updating the index shape graph, the newly added shape nodes are written first, and then the number of the root shape node in the index shape graph is modified. Finally, after the query operation performed by the first calculation unit based on the unupdated index shape graph is completed, the shape nodes with a reuse count of 0 are deleted. In this way, the first calculation unit can work normally during the update process of the index shape graph without interruption or waiting, achieving seamless dynamic update, and the query result can be determined based on the updated index shape graph.
[0140] According to an embodiment of the present application, the first computing unit is also used to: generate an update record and send the update record to the second processor, wherein the update record includes: node path information of newly added shape nodes and / or deleted shape nodes during the update process of the first index shape graph; the second computing unit is also used to: update the second index shape graph based on the update record after the query operation of the predetermined data is completed.
[0141] Specifically, when inserting or deleting retrieval data, the shape of the index binary tree will only change locally, and the affected subtree range is limited to the binary tree path corresponding to the insertion or deletion vector. Accordingly, the data in the index shape graph only changes locally, so the second processor does not need to copy all the data of the updated index shape graph. It only needs to update the changed data, such as the node path information of the newly added shape nodes and / or deleted shape nodes. During the process of updating the index shape graph, the changed data, such as the node path information of the newly added shape nodes and / or deleted shape nodes, can be recorded to generate an update record.
[0142] In order to ensure that the second index shape graph stored in the second storage unit is consistent with the first index shape graph, after the query operation of the predetermined data is completed, the second index shape graph can be updated based on the update record, thereby performing a query operation based on the updated index shape graph.
[0143] like Figure 8 As shown, in the first processor, feature extraction processing can be performed on the newly added or deleted data to generate a retrieval vector, which is in the form of a high-dimensional feature vector. Dimensionality reduction processing is then performed on the retrieval vector to obtain a reduced-dimensionality vector, which is then binarized to obtain a target vector. The index shape map is further updated to obtain an updated index shape map and shape mapping information. Furthermore, an update record can be generated so that the second processor can update and store the second index shape map accordingly.
[0144] When updating the data in the second processor, unlike the conventional data backup method, a partial update is performed based on the update record of the data change, without the need for full copy, which greatly improves the update efficiency.
[0145] Furthermore, when updating the second index shape map, you can first write the new shape nodes, then modify the entry shape node information. Finally, after the query operation is completed, delete the invalid shape nodes (i.e., the deleted shape nodes). Since the new shape nodes do not affect the current query, writing them can be performed first. The entry shape node serves as the entry point for the query and can be executed after writing the new shape nodes. Invalid shape nodes may be related to the current query and need to be deleted after the query operation is completed. This ensures that the update process does not affect the query process.
[0146] Furthermore, data related to the index shape graph can be written to a persistent storage space, such as a hard disk. Therefore, when the system fails or restarts, the data can be read from the persistent storage space, thereby restoring the index shape graph based on the data. The data related to the index shape graph can include, for example, dimensionality reduction parameters and quantization encoding parameters, shape mapping information, the index shape graph, the dataset, and the root shape node number.
[0147] Figure 9 A block diagram of an electronic device suitable for implementing an updating method according to an embodiment of the present application is shown.
[0148] like Figure 9 As shown, an electronic device 900 according to an embodiment of the present application includes a processor 901, which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 902 or programs loaded from a storage unit 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or related chipsets and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present application.
[0149] Various programs and data required for the operation of the electronic device 900 are stored in the RAM 903. The processor 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. The processor 901 performs various operations of the method flow according to the embodiment of the present application by executing the programs in the ROM 902 and / or the RAM 903. It should be noted that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flow according to the embodiment of the present application by executing the programs stored in one or more memories.
[0150] According to an embodiment of the present application, electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to bus 904. Electronic device 900 may also include one or more of the following components connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including devices such as a cathode ray tube (CRT), liquid crystal display (LCD), and speakers; a storage section 908 including a hard disk; and a communication section 909 including a network interface card such as a LAN card or modem. Communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to I / O interface 905 as needed. Removable media 911, such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed in drive 910 as needed, so that computer programs read from the removable media can be installed into storage section 908 as needed.
[0151] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of this application is implemented.
[0152] According to an embodiment of the present application, a computer-readable storage medium may be a non-volatile computer-readable storage medium, and may include, for example, but not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present application, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0153] The embodiments of the present application also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided in the embodiments of the present application.
[0154] The computer program executes the above functions defined in the system / device of the embodiment of the present application when the processor 901 executes the computer program. According to the embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0155] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0156] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from a removable medium 911. When the computer program is executed by the processor 901, the above-mentioned functions defined in the system of the embodiment of the present application are performed. According to the embodiment of the present application, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0157] According to an embodiment of the present application, the program code for executing the computer program provided by the embodiment of the present application can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).
[0158] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0159] Those skilled in the art will appreciate that the features described in the various embodiments of this application may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in this application. In particular, the features described in the various embodiments of this application may be combined and / or coupled in various ways without departing from the spirit and teachings of this application. All such combinations and / or couplings fall within the scope of this application.
[0160] The embodiments of the present application have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present application. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be advantageously used in combination. Without departing from the scope of the present application, those skilled in the art may make various substitutions and modifications, and these substitutions and modifications should all fall within the scope of the present application.
Claims
1. An updating method, characterized in that: The method includes performing the following operations using a first computing unit: receiving an update instruction from a first control unit, wherein the update instruction instructs updating an index shape graph stored in the first storage unit, the index shape graph representing a plurality of index vectors constructed based on a plurality of retrieval data; the index shape graph is generated based on node compression of an index binary tree, and a shape node in the index shape graph represents a plurality of tree nodes having the same subtree shape in the index binary tree; In response to the update instruction, the index shape graph is read from the first storage unit, and the target shape node in the index shape graph is decompressed and restored to generate a restored structure graph; the decompression and restoration includes: representing the subtree shape corresponding to the target shape node in the index shape graph; Processing the restored structure graph using the target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph including the target shape node; processing the restored structure graph using the target vector includes: adding edges representing multiple dimensional values of the target vector and shape nodes for connecting the edges to the restored structure graph to obtain the process structure graph; The shape nodes in the path where the target shape node is located in the process structure graph are updated to obtain an updated index shape graph.
2. The method according to claim 1, wherein: The indexed shape graph includes a plurality of shape nodes and edges between the shape nodes, the plurality of shape nodes are divided into N+1 levels and form a plurality of paths corresponding to the plurality of index vectors respectively with the edges, where N is an integer greater than 1; The index vector includes an N-dimensional index value, and the N-dimensional index value represents at least one of the following: an image feature, a voice feature, and a text feature.
3. The method according to claim 1 or 2, characterized in that The shape node carries a shape code, and the shape code is used to characterize the subtree shape category of the plurality of tree nodes having the same subtree shape; Decompressing and restoring the target shape node in the index shape graph includes: Reading shape mapping information from the first storage unit, wherein the shape mapping information is used to represent a mapping relationship between multiple subtree structures and subtree shape categories; Based on the shape mapping information and the shape code of the target shape node, the target shape node is decompressed and restored.
4. The method according to claim 3, characterized in that Updating the shape nodes in the path where the target shape node is located in the process structure diagram includes: updating the shape encoding of the target shape node based on the shape mapping information; Based on the shape mapping information and the updated shape code of the target shape node, the shape codes of the shape nodes in the path where the target shape node is located are updated step by step.
5. The method according to claim 1 or 2, characterized in that Processing the restored structure graph using the target vector constructed by the target retrieval data included in the update instruction includes: According to the construction rule of the index binary tree, construct the target vector into a simulation path; According to the operation type of the update operation indicated by the update instruction, the restoration structure graph and the simulation path are combined, or the simulation path is deleted from the restoration structure graph.
6. The method according to claim 2, characterized in that The plurality of paths in the indexed shape graph each include N edges; The method further comprises: Matching the N-dimensional target value included in the target vector with the N edges of the multiple paths step by step to determine a reference vector that fully matches or partially matches the target vector from the multiple index vectors; The target shape node is determined from the target path where the reference vector is located.
7. The method according to claim 6, characterized in that: In the case where the update instruction indicates to perform a data insertion operation, the target shape node includes: an interruption node where a matching interruption occurs in the target path where the reference vector partially matches the target vector; In the case where the update instruction indicates a data deletion operation, the target shape node includes: a single path node in the target path where the reference vector that completely matches the target vector is located, and which is connected to an adjacent shape node by only one edge.
8. The method according to claim 6, characterized in that The plurality of search data are distributed in a plurality of data sets, the plurality of data sets are respectively associated with the plurality of paths, and at least one search data included in the same data set corresponds to one index vector; The method further includes: when the update instruction indicates to perform a data insert operation and there is a target path in the index shape graph that completely matches the target vector, The index shape map is not updated; The target search data is added to the target data set associated with the target path.
9. The method according to claim 8, characterized in that The method further includes: if the update instruction indicates to perform a data deletion operation, a target path that completely matches the target vector exists in the index shape graph, and the number of retrieved data in the target data set associated with the target path is greater than a predetermined threshold, The index shape map is not updated; The target retrieval data is deleted from the target data set associated with the target path.
10. The method according to claim 1, characterized in that The index vector includes N-dimensional index values; The N-dimensional index value includes at least one of the following: image texture, image color, image brightness, shape of target object in the image, image depth, image grayscale; or The N-dimensional index value includes at least one of the following: voice volume, voice prosody, voice speed, voice intonation, and voice timbre; or The N-dimensional index value includes at least one of the following: text semantics, text length, text paragraph structure, and word frequency of the target word in the text.
11. The method according to claim 1, wherein The method further includes performing the following operations using a second computing unit: In response to receiving a query instruction from the second control unit, the associated index vector is obtained by querying the copy of the index shape map stored in the second storage unit.
12. A data processing system, characterized in that: The system comprises: The first processor includes a first control unit, a first calculation unit, and a first storage unit, wherein the first storage unit stores a first index shape graph; wherein, The first computing unit is configured to perform the following operations: receiving an update instruction from the first control unit, wherein the update instruction instructs updating an index shape graph stored in the first storage unit, the index shape graph representing a plurality of index vectors constructed based on a plurality of retrieval data; the index shape graph is generated by performing node compression on an index binary tree, and a shape node in the index shape graph represents a plurality of tree nodes having the same subtree shape in the index binary tree; In response to the update instruction, the index shape graph is read from the first storage unit, and the target shape node in the index shape graph is decompressed and restored to generate a restored structure graph; the decompression and restoration includes: representing the subtree shape corresponding to the target shape node in the index shape graph; Processing the restored structure graph using the target vector constructed from the target retrieval data included in the update instruction to obtain a process structure graph including the target shape node; processing the restored structure graph using the target vector includes: adding edges representing multiple dimensional values of the target vector and shape nodes for connecting the edges to the restored structure graph to obtain the process structure graph; The shape nodes in the path where the target shape node is located in the process structure graph are updated to obtain an updated index shape graph.
13. The system according to claim 12, wherein: The system further comprises: The second processor includes a second control unit, a second calculation unit, and a second storage unit, wherein the second storage unit stores a second index shape graph; The second computing unit is configured to perform the following operations: In response to the query instruction issued by the second control unit, predetermined data is queried from the second index shape map, wherein the second index shape map is a backup of the first index shape map.
14. The system according to claim 13, wherein: The first computing unit is further configured to: generate an update record and send the update record to the second processor, wherein the update record includes: node path information of newly added shape nodes and / or deleted shape nodes during the update of the first index shape graph; The second calculation unit is further configured to update the second index shape graph based on the update record after the query operation of the predetermined data is completed.
15. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Data processing method and device and storage medium
CN111723246A
Index establishment method and device, equipment, storage medium and computer program product
CN113312360A