A relational retrieval method, system, storage medium and terminal device

By presetting object index list and relationship index list, combined with inverted index and hash bucketing technology, the problem of high complexity in relational graph retrieval in the existing technology is solved, and low memory consumption and efficient relationship retrieval is achieved.

CN113590653BActive Publication Date: 2025-05-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110076932.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-20
Publication Date
2025-05-27
Estimated Expiration
2041-01-20

AI Technical Summary

Technical Problem

When storing relationship diagrams, the search complexity of the prior art is high and cannot reach the level of industrial applications. Especially for the retrieval of related nodes for nodes, the complexity increases sharply, O(N).

Method used

By presetting the object index list and relationship pair index list of the relationship graph, using inverted index and hash bucketing technology to reduce the retrieval complexity, adopt array storage method, determine the array identification and position identification through the index information of the target object, and quickly find the relationship pair.

Benefits of technology

A relationship search method with low memory consumption and extremely fast search speed is realized, reducing the complexity of the search process, especially in large-scale user relationship maps, which significantly improves the search efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113590653B_ABST
    Figure CN113590653B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a relationship retrieval method, system, storage medium and terminal device, which are applied to the field of information processing technology. In the relationship retrieval system, an object index list and a relationship pair index list of a relationship graph are preset in advance. In this way, when retrieving the relationship object of any target object, the array identifier of the first array in the object index list and the position identifier of the first index information in the first array can be determined according to the first index information of the target object, and then the first position index of the target object can be found in the relationship pair index list according to the array identifier and the position identifier, and then the relationship pair of the target object can be found in the relationship pair list, and the relationship object of the target object can be determined based on the relationship pair found. In this process, it is only necessary to determine the array identifier of the first array and the position identifier of the first index information in the first array, and then perform the corresponding search, and the complexity of the retrieval process is relatively low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information processing, and in particular, to a relationship retrieval method, system, storage medium, and terminal device. Background Art

[0002] A relationship graph is the most direct tool for describing a community relationship chain, which consists of nodes and edges. Nodes represent relationship chain objects, and edges represent the degree of closeness of the connection between two objects. It can be applied to various applications, such as user friend recommendation or product recommendation applications.

[0003] In the prior art, when storing a relationship graph, each pair of nodes and the relationship information between the nodes in the relationship graph can be stored in the form of an array. For example, StellarGraph in the industry. The construction of the array consumes less memory, so the construction of the storage method of the relationship graph also consumes less memory. Generally, a 32-bit value in a unit only occupies 4 bytes. However, when retrieving the associated nodes of a certain node, the retrieval complexity increases linearly, reaching O(N), which cannot meet the industrial application level. Summary of the Invention

[0004] Embodiments of the present invention provide a relationship retrieval method, system, storage medium, and terminal device, which implement a relationship retrieval method with a relatively low computational complexity.

[0005] On the one hand, an embodiment of the present invention provides a relationship retrieval method, including:

[0006] Obtaining first index information of a target object;

[0007] Determining an array identifier of a first array in a pre-set object index list where the first index information is located, and determining a position identifier of the first index information in the first array; the object index list includes multiple object index arrays of a relationship graph, and each object index array includes index information of multiple objects;

[0008] In a pre-set relationship pair index list, in a second array corresponding to the array identifier, searching for a first position index corresponding to the position identifier; the relationship pair index list includes multiple relationship pair position index arrays of a relationship graph, and each relationship pair position index array includes position indexes of multiple relationship pairs in a pre-set relationship pair list respectively;

[0009] Searching for a relationship pair corresponding to the first position index in the relationship pair list;

[0010] Outputting a relationship object of the target object, where the relationship object of the target object is an object other than the target object in the found relationship pair.

[0011] Another aspect of the embodiments of the present invention provides a relationship retrieval system, including:

[0012] An index acquisition unit, configured to acquire first index information of a target object;

[0013] An identifier determination unit, configured to determine an array identifier of a first array in a preset object index list where the first index information is located, and determine a position identifier of the first index information in the first array; the object index list includes multiple object index arrays of a relationship graph, and each object index array includes index information of multiple objects;

[0014] A relationship pair index unit, configured to search for a first position index corresponding to the position identifier at a corresponding position in a second array in a preset relationship pair index list and corresponding to the array identifier; the relationship pair index list includes multiple relationship pair position index arrays of the relationship graph, and each relationship pair position index array includes position indexes of multiple relationship pairs in a preset relationship pair list;

[0015] A relationship pair unit, configured to search for a relationship pair corresponding to the first position index in the relationship pair list;

[0016] An object output unit, configured to output a relationship object of the target object, where the relationship object of the target object is an object other than the target object in the searched relationship pair.

[0017] Another aspect of the embodiments of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores multiple computer programs, and the computer programs are adapted to be loaded and executed by a processor to perform the relationship retrieval method as described in one aspect of the embodiments of the present invention.

[0018] Another aspect of the embodiments of the present invention further provides a terminal device, including a processor and a memory;

[0019] The memory is configured to store multiple computer programs, and the computer programs are used to be loaded and executed by the processor to perform the relationship retrieval method as described in one aspect of the embodiments of the present invention; the processor is configured to implement each computer program in the multiple computer programs.

[0020] It can be seen that in the method of this embodiment, the object index list and the relationship pair index list of the relationship graph are preset in the relationship retrieval system. In this way, when retrieving the relationship objects of any target object, the array identifier of the first array in the object index list and the position identifier of the first index information in the first array can be determined according to the first index information of the target object. Then, the first position index where the target object is located can be found in the relationship pair index list according to the array identifier and the position identifier. Furthermore, the relationship pair where the target object is located can be found in the relationship pair list, and the relationship objects of the target object can be determined based on the found relationship pair. In this process, only after determining the array identifier of the first array and the position identifier of the first index information in the first array, corresponding searches can be performed, and the complexity of the retrieval process is relatively low. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 is a schematic diagram of a relationship retrieval method provided by an embodiment of the present invention;

[0023] Figure 2 is a flowchart of a relationship retrieval method provided by an embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of determining a relationship pair in an embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of presetting an object index list and a relationship pair index list in an embodiment of the present invention;

[0026] Figure 5 is a schematic diagram of presetting an object index list and a relationship pair index list for relationship pairs of multiple groups in an embodiment of the present invention;

[0027] Figure 6 is a flowchart of presetting an object index list and a relationship pair index list in an application embodiment of the present invention;

[0028] Figure 7 is a flowchart of a method for retrieving the relationship users of any user in an application embodiment of the present invention;

[0029] Figure 8 is a schematic diagram of a distributed system to which the relationship retrieval method in another application embodiment of the present invention is applied;

[0030] Figure 9 It is a schematic diagram of the block structure in another application embodiment of the present invention;

[0031] Figure 10 It is a schematic diagram of the structure of a relationship retrieval system provided by an embodiment of the present invention;

[0032] Figure 11 It is a schematic diagram of the structure of a terminal device provided by an embodiment of the present invention. Detailed implementation manners

[0033] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0034] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0035] An embodiment of the present invention provides a relationship retrieval method, which mainly retrieves the relationship objects of the target object. For example Figure 1 As shown, the relationship retrieval system of this embodiment can implement relationship retrieval according to the following steps:

[0036] Obtain the first index information of the target object; determine the array identifier of the first array in the pre-set object index list where the first index information is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays of the relationship graph, and each object index array includes index information of multiple objects; in the second array corresponding to the array identifier in the pre-set relationship pair index list, search for the first position index corresponding to the position identifier at the corresponding position; the relationship pair index list includes multiple relationship pair position index arrays of the relationship graph, and each relationship pair position index array includes position indexes of multiple relationship pairs in the pre-set relationship pair list respectively; search for the relationship pair corresponding to the first position index in the relationship pair list; output the relationship object of the target object, where the relationship object of the target object is the object other than the target object in the found relationship pair.

[0037] In the actual application process, the above relationship retrieval can be applied to the relationship graph applied by any relationship chain, such as the relationship graph of the community user relationship chain, or the relationship graph of the commodity relationship chain, or the relationship graph of the movie relationship chain, or the relationship graph of the paper relationship chain, etc., and the target object and the relationship object also vary with different applications. For example, when the above relationship retrieval is applied to the relationship graph of the community user relationship chain, the target object is specifically the target user, and the relationship object is specifically other users associated with the target user, etc.

[0038] In addition, the above relationship retrieval system can be applied only to the server, and the server retrieves the retrieval request initiated by the user through the terminal; in another case, the relationship retrieval system can be applied only to the terminal device, and the user can initiate a retrieval request through the terminal device and the terminal device performs the retrieval.

[0039] In the process of the above relationship retrieval, only after determining the array identifier of the first array and the position identifier of the first index information in the first array, corresponding searches can be performed, and the complexity of the retrieval process is relatively low.

[0040] An embodiment of the present invention provides a relationship retrieval method, which is mainly the method executed by a relationship retrieval system. The flowchart is as Figure 2 shown, including:

[0041] Step 101, obtain the first index information of the target object.

[0042] It can be understood that in one case, the user can operate on the user interface displayed on any terminal device. In response to the user's operation on the user interface, the terminal device will initiate a retrieval request, which is used to request the retrieval of relationship objects related to the target object. The retrieval request includes the identification information of the target object, etc. Then, after receiving the retrieval request, the relationship retrieval system can first obtain the first index information of the target object according to the retrieval request and perform the following steps to obtain the relationship object and return it to the terminal device. In another case, the relationship retrieval system can initiate the retrieval of the relationship objects of any target object and directly push the obtained relationship objects to the terminal device for display.

[0043] Here, the first index information refers to the information that, in order to associate various information of the target object with the target object, associates various information through a certain kind of information of the target object and uniquely identifies the target object, and this kind of information of the target object is the first index information.

[0044] In a specific embodiment, the first index information can be the identification information of the target object, or a value obtained by performing a certain calculation on the identification information of the target object, such as a hash value obtained by hash calculation. Other information can also be used as the first index information.

[0045] Step 102: Determine the array identifier of the first array in the preset object index list where the first index information is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays of the relationship graph, and each object index array includes the index information of multiple objects. Among them, each object index array can include multiple identical index information, and the index information of each object is the information used to uniquely identify each object.

[0046] In this embodiment, in the relationship retrieval system, for a relationship graph, the object index list of the relationship graph is preset in the local storage space. Among them, the relationship graph is the most direct tool for describing the community relationship chain, which is composed of nodes and edges. Nodes represent relationship chain objects, and edges represent the degree of closeness between two objects. Each of the above objects corresponds to a node in the relationship graph, and the relationship between any two objects (i.e., a relationship pair) corresponds to an edge in the relationship graph.

[0047] Specifically, the relationship retrieval system can first take the remainder of a preset value by the first index information, and the obtained remainder is the array identifier of the first array, or the value obtained after performing other calculations on the first index information is the array identifier of the first array; then search for the first index information in the first array of the object index list and determine the position of the first index information in the first array, and then the position identifier can be obtained. Here, the first array is specifically an object index array in the object index list, and one or more first index information can be included in the first array.

[0048] Step 103, in the preset relationship pair index list, and in the second array corresponding to the determined array identifier, search for the first position index at the position corresponding to the determined position identifier; the relationship pair index list includes multiple relationship pair position index arrays of the above relationship graph, and each relationship pair position index array includes the position indexes of multiple relationship pairs in the preset relationship pair list. Wherein, any relationship pair refers to two objects with a relationship, and the position index of the relationship pair refers to the information used to uniquely identify the position of a certain relationship pair in the relationship pair list.

[0049] In this embodiment, in the relationship retrieval system, a relationship pair index list of the relationship graph will also be preset in the local storage space for a relationship graph. Specifically, the relationship retrieval system will first locate the second array in the relationship pair index list according to the determined array identifier, and the second array is specifically a certain relationship pair position index array in the relationship pair index list; then according to the determined position identifier, locate the corresponding position in the second array, and the first position index can be obtained.

[0050] It should be noted that the number of object index arrays in the object index list is the same as the number of relationship pair position index arrays in the relationship pair index list, and there are arrays with the same array identifier between the two lists, and the information of the same object is stored at the same position in the two arrays with the same array identifier. For example, there are 3 object index arrays in the object index list, and the corresponding array identifiers are 1, 2, and 3 respectively. There are also 3 relationship pair position index arrays in the relationship pair index list, and the corresponding array identifiers are 1, 2, and 3 respectively. Then the number of elements in the object index array with the array identifier of 1 is the same as the number of elements in the relationship pair position index array with the array identifier of 1, and the elements at the same position are the information of the same object.

[0051] Step 104, search for the relationship pair corresponding to the first position index in the preset relationship pair list.

[0052] In this embodiment, in the relationship retrieval system, for a relationship graph, a list of relationship pairs of the relationship graph is pre - set in the local storage space, and the above - mentioned object index list and relationship - pair index list can be obtained from a list of relationship pairs.

[0053] The list of relationship pairs includes information of multiple relationship pairs in the above - mentioned relationship graph. The information of each relationship pair includes index information of each object, and the index information of each object can represent information of a node in the relationship graph. The information of the relationship pair can also include relationship information between the objects in the relationship pair, and the relationship information between any two objects can represent information of an edge in the relationship graph.

[0054] Since the information of a relationship pair in the list of relationship pairs corresponds to a position, that is, the two objects with a relationship in a relationship pair both correspond to the same position, and thus correspond to the same position index. In this way, after knowing a certain position index, such as the first position index, the index information of each object in the corresponding relationship pair can be retrieved from the corresponding position in the list of relationship pairs.

[0055] Step 105: Output the relationship objects of the target object. The relationship objects of the target object are the objects other than the target object in the relationship pair found in the above - mentioned step 104.

[0056] For example Figure 3 As shown, for the first index information of the target object being 9520, first, determine the array identifier of the first array according to the first index information. Specifically, take the remainder of 9520 divided by the pre - set value N_Ceil, and the remainder is 0, that is, the array identifier of the first array is 0. Then determine the position identifier of the position where 9520 is located in the object index array 0 of the pre - set object index list, specifically 0, 1, and 4. Then, from the relationship - pair position index array 0 of the relationship - pair index list, determine the first position indexes of positions 0, 1, and 4, that is, 0, 1, and 2. Finally, find the relationship pairs represented by the first position indexes 0, 1, and 2 in the list of relationship pairs, specifically (9520, 3222), (9520, 9570), and (9520, 1899). Then the relationship objects of the target object are the objects represented by these index information 3222, 9570, and 1899. In this process, the complexity of retrieving the relationship objects of the target object is O(M / N_Ceil), where M is the number of objects included in the list of relationship pairs. Therefore, when the pre - set value N_Ceil is large enough, the retrieval complexity can be reduced to O(1).

[0057] It should be noted that Figure 3The position index in the list of relationship pairs shown is not directly stored in the relationship retrieval system. When it is necessary to store the position index of an object in the relationship pair index list, the corresponding position index needs to be obtained from the relationship pair list first and then stored in the relationship pair index list. Figure 3 The position indexes of the respective relationship pairs in the relationship pair list are shown to facilitate the explanation of the process of presetting the relationship pair index list.

[0058] In addition, it should be noted that in order to implement the retrieval method in the above embodiments, it is necessary to preset an object index list, a relationship pair index list, and a relationship pair list of the same relationship graph in the relationship retrieval system in advance. Generally, when storing the relationship information between objects, it can be stored through the relationship pair list. The relationship pair list can include the information of multiple relationship pairs, and the information of each relationship pair includes the index information corresponding to the two objects with a relationship respectively, and can also include the relationship information between the two objects. The object index list and the relationship pair index list are obtained from the relationship pair list and preset in the relationship retrieval system. Specifically, when the relationship retrieval system presets the object index list and the relationship pair index list, it can include:

[0059] First, determine the array identifier of each object in the object index list according to the index information of each object in the relationship pairs in the preset relationship pair list; then, according to the array identifier corresponding to each object, store the index information and position index of each object in the corresponding arrays of the object index list and the relationship pair index list at the same position. Among them, when determining the array identifier of each object in the object index list, the preset value can be taken modulo by the index information of each object, and the remainder obtained is the array identifier corresponding to each object. In this way, the number of arrays included in the object index list and the relationship pair index list respectively is the preset value.

[0060] In addition, since the position index of each object needs to be stored in the relationship pair position index array of the relationship pair index list, before storing the position index, the relationship retrieval system will first obtain the corresponding position index according to the position where the information of each object is stored in the relationship pair list. Among them, the information of the same object can be stored at one or more positions in the relationship pair list. In this way, an object can correspond to one or more position indexes, and all these position indexes need to be stored in the relationship pair index list.

[0061] For example, for example Figure 4As shown, the index information 9520 and 3222 of two objects in a certain relationship pair in the relationship pair list are respectively modulo-divided by the preset value N_Ceil (assumed to be 10). The remainders obtained are 0 and 2 respectively. Then, the index information 9520 and 3222 of these two objects are respectively placed in the arrays with array identifiers 0 and 2 in the object index list, and are respectively placed in the first position, and the position identifier is 0. Then, the position indexes 0 of the relationship pairs corresponding to these two objects are respectively placed in the arrays with array identifiers 0 and 2 in the relationship pair index list, and are respectively placed in the first position.

[0062] Furthermore, in order to improve the rate of the process of presetting the object index list and the relationship pair index list, the relationship pairs in the preset relationship pair list can be divided into multiple groups. Then, for each group of relationship pairs in the multiple groups, perform the above steps of determining the array identifier of each object in the object index list respectively and storing the index information and position index of each object, to obtain the object index sub-list and the relationship pair index sub-list corresponding to each group. Then, merge the object index sub-lists corresponding to the multiple groups respectively to form the preset object index list, and merge the relationship pair index sub-lists corresponding to the multiple groups respectively to form the above-mentioned preset relationship pair index list. Among them, multiple processes can be started simultaneously. These processes respectively perform the above steps of determining the array identifier of each object in the object index list respectively and storing the index information and position index of each object in parallel for the multiple groups, and the processing of each group does not interfere with each other. The rate of presetting the object index list and the relationship pair index list is well improved, and at least several times can be increased.

[0063] Among them, because the relationship pairs in the relationship pair list are grouped, the positions of the relationship pairs in the corresponding groups are different from their positions in the relationship pair list. And what needs to be stored in the preset relationship pair index list is the position index of each object in the relationship pair list. Therefore, in this embodiment, after the relationship pairs in the relationship pair list are divided into multiple groups, it is also necessary to determine the start position index of each group in the relationship pair list. In this way, when performing the above step of storing the position index of each object for each group of relationship pairs, it is necessary to first obtain the position index of each object in the relationship pair list as: the sum of the relative position index of each object in the corresponding group and the start position index, and then store the position index of each object in the relationship pair list to obtain the relationship pair index sub-list of each object corresponding group.

[0064] Furthermore, when the relationship retrieval system merges the object index sub-lists corresponding to multiple groups to form a preset object index list, specifically, the elements in the object index arrays with the same array identifier between the object index sub-lists corresponding to each group can be merged into one object index array; when merging the relationship pair index sub-lists corresponding to multiple groups to form a preset relationship pair index list, specifically, the elements in the relationship pair position index arrays with the same array identifier between the relationship pair index sub-lists corresponding to each group are merged into one relationship pair position index array; where the position of the elements in the relationship pair position index array corresponding to each group in the merged relationship pair position index array is the same as the position of the elements in the object index array corresponding to each group in the merged object index array.

[0065] For example Figure 5 As shown, the relationship pairs in the relationship pair list are divided into N groups, and the start position index and end position index of each group in the relationship pair list are determined. For example, the start position index and end position index of group 1 are 0 and 4 respectively, and the start position index and end position index of group 2 are 5 and 9 respectively; for each group, the corresponding object index sub-list and relationship pair index sub-list can be obtained according to the above method, and then the object index sub-list and the relationship pair index sub-list are merged.

[0066] Among them, when obtaining the relationship pair index sub-list corresponding to a certain group, it is necessary to first determine the position index of each object in the relationship pair list in the group, and then store it in the corresponding position index. For example, for the position index of object 1451 in the relationship pair list, specifically: the relative position index (0, 1, and 2) of object 1451 in group 2 plus the start position index 5 of group 2, to obtain the position index of object 1451 in the relationship pair list as 5, 6, and 7; the relative position index (3 and 4) of object 1451 in group 1 plus the start position index 0 of this group 1, to obtain the position index of object 1451 in the relationship pair list as 3 and 4.

[0067] In addition, during the process of merging the object index sub - list and the relationship pair index sub - list, for example, two object index sub - lists 1 and 2 and two relationship pair index sub - lists 11 and 22 are obtained. Each object index sub - list contains 3 object index arrays, and each relationship pair index sub - list contains 3 relationship pair position index arrays. In object index sub - list 1, the object index array 1 corresponding to a certain array identifier is [a, b, c, d, e], while in object index sub - list 2, the object index array 2 corresponding to the same array identifier is [f, g, h, i, j]. In relationship pair index sub - list 11, the relationship pair position index array 11 corresponding to the same array identifier is [a1, b1, c1, d1, e1], while in relationship pair index sub - list 22, the relationship pair position index array 22 corresponding to the same array identifier is [f2, g2, h2, i2, j2]. During the merging process, there is no specific limitation on the positions of the elements in the object index arrays of object index sub - lists 1 and 2, as long as they are consistent with the positions of the elements in the relationship pair position index arrays with the same array identifier in relationship pair index sub - lists 11 and 22. For example, if the merged object index array is [a, b, c, d, e, f, g, h, i, j], then the merged relationship pair position index array is [a1, b1, c1, d1, e1, f2, g2, h2, i2, j2]; if the merged object index array is [f, g, h, i, j, a, b, c, d, e], then the merged relationship pair position index array is [f2, g2, h2, i2, j2, a1, b1, c1, d1, e1].

[0068] It can be seen that in the method of this embodiment, the object index list and the relationship pair index list of the relationship graph are preset in the relationship retrieval system. In this way, when retrieving the relationship objects of any target object, the array identifier of the first array in the object index list and the position identifier of the first index information in the first array can be determined according to the first index information of the target object. Then, the first position index where the target object is located can be found in the relationship pair index list based on the array identifier and the position identifier. Furthermore, the relationship pair where the target object is located can be found in the relationship pair list, and the relationship objects of the target object can be determined based on the found relationship pair. In this process, only after determining the array identifier of the first array and the position identifier of the first index information in the first array, corresponding searches can be performed, and the complexity of the retrieval process is relatively low.

[0069] The following uses a specific application example to illustrate the relationship retrieval method of the present invention. The method of this embodiment is applied to a server, that is, the above - mentioned relationship retrieval system is applied to a server, and in the relationship graph applied in this embodiment, as long as the relationship represented by any edge refers to a user relationship, and the object represented by any node refers to a user, such as Figure 6 As shown, the method of this embodiment mainly includes the following two parts:

[0070] (1) The server pre - sets a list of relationship pairs among various users in advance. The list of relationship pairs includes information of multiple user relationship pairs. The information of each user relationship pair includes the index information of two users with a relationship, and may also include relationship information between the two users, etc. As Figure 6 shown, the server can preset an object index list and a relationship pair index list in the server through the following steps:

[0071] Step 201, the server divides multiple user relationship pairs in the preset list of relationship pairs into multiple groups, and determines the start - position index of the user relationship pairs in each group in the list of relationship pairs.

[0072] For each user relationship pair in each group, perform the following steps 202 and 203 respectively to obtain an object index sub - list and a relationship pair index sub - list.

[0073] Step 202, the server determines the array identifier of each user in the object index sub - list according to the index information of each user in the user relationship pair within any group. For example, by taking the remainder of the preset value with the index information of the user, the obtained remainder is the array identifier.

[0074] Step 203, the server stores the index information and position index of each user in the corresponding arrays of the object index sub - list and the relationship pair index sub - list respectively, and at the same position, according to the array identifier corresponding to each user. In this way, the object index sub - list and the relationship pair index sub - list corresponding to this group can be obtained.

[0075] Among them, the position index of each user is specifically the sum of the relative position index of each user in the corresponding group and the start - position index of the corresponding group in the list of relationship pairs.

[0076] Step 204, the server merges the object index sub - lists corresponding to each group to form an object index list, merges the relationship pair index sub - lists corresponding to each group to form a relationship pair index list, and pre - sets them in the relationship retrieval system. Among them, the specific merging method is as described in the above - mentioned embodiments and will not be elaborated here.

[0077] (2) As Figure 7 shown, the server can retrieve the related users of any user according to the following steps:

[0078] Step 301, the server initiates to recommend related users of a certain user (i.e., the target user) for the terminal device. First, the server obtains the first index information of the target user. For example, it can be the identification information of the target user or the hash value obtained by performing a hash calculation on the identification information of the target user.

[0079] Step 302, the server determines the array identifier of the first array in the pre-set object index list where the first index information is located, and determines the position identifier of the first index information in the first array.

[0080] Step 303, the server searches for the first position index corresponding to the position identifier at the corresponding position in the second array in the pre-set relationship pair index list and corresponding to the array identifier.

[0081] Step 304, the server searches for the user relationship pair corresponding to the first relationship pair index in the pre-set relationship pair list, takes the users other than the target user in the found user relationship pair as relationship users, and recommends the information of the relationship users to the terminal device.

[0082] It can be seen that in this embodiment, mainly through the inverted index and hash bucket technology, a relationship retrieval method with low memory consumption and extremely fast retrieval speed is realized. Among them, the hash bucket technology mainly divides data into N data buckets by hashing the data and according to the first few bits or the hash value at the end of the data. In this embodiment, mainly in the process of pre-setting the object index list and the relationship pair index list, the index information of the user relationship pairs and the index information of the users in the relationship pair list are respectively divided into multiple arrays, effectively reducing the retrieval range of the final user relationships, specifically within the range of one array; at the same time, the inverted index is an index method used to store the mapping of the storage position of a certain word in a document or a group of documents under full-text search. In this embodiment, mainly in the process of retrieving the relationship users of the user, through the first index information of the user and the pre-set object index list and relationship pair index list, the first position index can be obtained, and the bucket index can be effectively mapped back to the index position of the original relationship pair list. Therefore, the original relationship pair list can be stored in an array manner to achieve the purpose of solving the memory overhead.

[0083] In the specific practice process, for 1.8 million users and 270 million user relationship pairs, using the method of this embodiment and the method in the prior art, in the process of retrieving the relationship users of the user, the results shown in Table 1 below can be obtained. It can be seen that the relationship retrieval method of this embodiment consumes less time and memory both in terms of pre-setting various lists and in actual retrieval, especially the retrieval time consumption for relationship users is relatively small:

[0084]

[0085] Table 1

[0086] The following uses another specific application example to illustrate the relationship retrieval method in the present invention. The relationship retrieval system in the embodiments of the present invention is mainly a distributed system 100, which may include a client 300 and multiple nodes 200 (any form of computing device accessing the network, such as a server or a user terminal), and the client 300 and the nodes 200 are connected in the form of network communication.

[0087] Taking the distributed system as a blockchain system as an example, refer to Figure 8 FIG. is an optional structural schematic diagram of the distributed system 100 provided by the embodiments of the present invention applied to a blockchain system, formed by multiple nodes 200 (any form of computing device accessing the network, such as a server or a user terminal) and a client 300. A peer-to-peer (P2P) network is formed between the nodes. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In a distributed system, any machine such as a server or a terminal can join and become a node. A node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.

[0088] Refer to Figure 8 FIG. shows the functions of each node in the blockchain system, and the functions involved include:

[0089] 1) Routing, a basic function of a node, used to support communication between nodes.

[0090] In addition to the routing function, a node may also have the following functions:

[0091] 2) Application, which is used to be deployed in the blockchain, implement specific services according to actual business needs, record the data related to the implemented functions to form record data, carry a digital signature in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes verify the source and integrity of the record data successfully, the record data is added to a temporary block.

[0092] For example, in this embodiment, the application in the node also includes code for implementing the relationship retrieval function. The relationship retrieval function mainly includes:

[0093] Obtain the first index information of the target object; determine the array identifier of the first array in the preset object index list where the first index information is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays, and each object index array includes index information of multiple objects; in the second array corresponding to the array identifier in the preset relationship pair index list, search for the first position index at the position corresponding to the position identifier; the relationship pair index list includes multiple relationship pair position index arrays, and each relationship pair position index array includes the position indexes of multiple relationship pairs in the preset relationship pair list respectively; search for the relationship pair corresponding to the first position index in the relationship pair list; output the relationship object of the target object as the object other than the target object in the found relationship pair.

[0094] 3) A blockchain includes a series of blocks that are sequentially connected in the order of generation time. Once a new block is added to the blockchain, it will not be removed again. The block records the record data submitted by nodes in the blockchain system.

[0095] See Figure 9 This is an optional schematic diagram of the block structure provided by the embodiment of the present invention. Each block includes the hash value of the transaction records stored in this block (the hash value of this block), and the hash value of the previous block. Each block is connected to form a blockchain through the hash value. In addition, the block may also include information such as the timestamp when the block is generated. A blockchain is essentially a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.

[0096] The embodiment of the present invention also provides a relationship retrieval system, and its structural schematic diagram is as Figure 10 shown, and specifically may include:

[0097] An index acquisition unit 10 is configured to obtain the first index information of the target object.

[0098] An identifier determination unit 11 is configured to determine the array identifier of the first array in the preset object index list where the first index information obtained by the index acquisition unit 10 is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays of the relationship graph, and each object index array includes index information of multiple objects.

[0099] When determining the array identifier of the first array, the identifier determination unit 11 is specifically configured to perform a remainder operation on a preset value using the first index information, and the obtained remainder is the array identifier of the first array.

[0100] The relationship pair index unit 12 is configured to search for a first position index corresponding to the position identifier at a corresponding position in a second array that is in a preset relationship pair index list and corresponds to the array identifier determined by the identifier determination unit 11; the relationship pair index list includes multiple relationship pair position index arrays of the relationship graph, and each relationship pair position index array includes position indexes of multiple relationship pairs in a preset relationship list respectively.

[0101] The relationship pair unit 13 is configured to search for a relationship pair corresponding to the first position index determined by the relationship pair index unit 12 in the relationship pair list.

[0102] The object output unit 14 is configured to output a relationship object of the target object, and the relationship object of the target object is an object other than the target object in the relationship pair found by the relationship pair unit 13.

[0103] Further, the relationship retrieval system of this embodiment may further include:

[0104] The preset unit 15 is configured to determine array identifiers of the respective objects in an object index list according to index information of the respective objects in relationship pairs in a preset relationship pair list, where the relationship pair list includes information of multiple relationship pairs, and the information of each relationship pair includes index information corresponding to two objects respectively; according to the array identifiers corresponding to the respective objects, store the index information and position indexes of the respective objects in corresponding arrays of the object index list and the relationship pair index list at the same position. In this way, the above-mentioned identifier determination unit 11 and relationship pair index unit 12 will perform searches in the object index list and relationship pair index list preset by the preset unit 15 respectively.

[0105] When determining the array identifiers of the respective objects in the object index list according to the index information of the respective objects in relationship pairs in the preset relationship pair list, the preset unit 15 is specifically configured to perform a remainder operation on a preset value using the index information of the respective objects, and the obtained remainder is the array identifier corresponding to the respective objects.

[0106] Further, the preset unit 15 is further configured to divide the relation pairs in the relation pair list into multiple groups; for each relation pair in each of the multiple groups, perform the steps of determining the array identifiers of the respective objects in the relation pair in the object index list and storing the index information and position index information of each object, to obtain an object index sub-list and a relation pair index sub-list corresponding to each group; merge the object index sub-lists corresponding to each group to form the preset object index list, and merge the relation pair index sub-lists corresponding to each group to form the preset relation pair index list.

[0107] Wherein, the preset unit 15 is further configured to determine the start position index of each group in the relation pair list; then when performing the step of storing the position index of each object for each relation pair in each group, it is specifically configured to obtain the position index of each object in the relation pair list as: the sum of the relative position index of each object in the corresponding group and the start position index; store the position index of each object in the relation pair list to obtain the relation pair index sub-list of each corresponding group of each object.

[0108] Wherein, when the preset unit 15 merges the object index sub-lists corresponding to each group to form the preset object index list, it is specifically configured to merge the elements in the object index arrays with the same array identifier between the object index sub-lists corresponding to each group into one object index array; when merging the relation pair index sub-lists corresponding to each group to form the preset relation pair index list, it is specifically configured to merge the elements in the relation pair position index arrays with the same array identifier between the relation pair index sub-lists corresponding to each group into one relation pair position index array; wherein, the position of the elements in the relation pair position index array corresponding to each group in the merged relation pair position index array is the same as the position of the elements in the object index array corresponding to each group in the merged object index array.

[0109] In the relationship retrieval system of this embodiment, an object index list and a relationship pair index list of the relationship graph are preset in advance. In this way, when retrieving the relationship object of any target object, the identification determination unit 11 can first determine the array identification of the first array in the object index list according to the first index information of the target object, and the position identification of the first index information in the first array. Then, the relationship pair index unit 12 can find the first position index where the target object is located in the relationship pair index list according to the array identification and the position identification. Furthermore, the relationship pair unit 13 can find the relationship pair where the target object is located in the relationship pair list. Finally, the object output unit 14 can determine the relationship object of the target object based on the found relationship pair. In this process, only after determining the array identification of the first array and the position identification of the first index information in the first array, corresponding searches are performed, and the complexity of the retrieval process is relatively low.

[0110] An embodiment of the present invention further provides a terminal device, and its structural schematic diagram is as Figure 11 shown. The terminal device may vary greatly due to configuration or performance differences, and may include one or more central processing units (CPUs) 20 (for example, one or more processors) and a memory 21, and one or more storage media 22 for storing application programs 221 or data 222 (for example, one or more mass storage devices). Among them, the memory 21 and the storage media 22 may be transient storage or persistent storage. The program stored in the storage media 22 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations for the terminal device. Further, the central processing unit 20 may be configured to communicate with the storage media 22 and execute a series of instruction operations in the storage media 22 on the terminal device.

[0111] Specifically, the application program 221 stored in the storage media 22 includes an application program for relationship retrieval, and this program may include the index acquisition unit 10, the identification determination unit 11, the relationship pair index unit 12, the relationship pair unit 13, the object output unit 14, and the preset unit 15 in the above relationship retrieval system, which will not be elaborated here. Further, the central processing unit 20 may be configured to communicate with the storage media 22 and execute a series of operations corresponding to the application program for relationship retrieval stored in the storage media 22 on the terminal device.

[0112] The terminal device may further include one or more power supplies 23, one or more wired or wireless network interfaces 24, one or more input / output interfaces 25, and / or one or more operating systems 223, such as WindowsServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, and so on.

[0113] The steps performed by the relationship retrieval system in the above method embodiments may be based on the Figure 11 structure of the terminal device shown.

[0114] Another aspect of the embodiments of the present invention further provides a computer-readable storage medium storing a plurality of computer programs, which are adapted to be loaded and executed by a processor to perform the relationship retrieval method performed by the above relationship retrieval system.

[0115] Another aspect of the embodiments of the present invention further provides a terminal device, including a processor and a memory; the memory is used to store a plurality of computer programs, and the computer programs are used to be loaded and executed by the processor to perform the relationship retrieval method performed by the above relationship retrieval system; the processor is used to implement each of the computer programs in the plurality of computer programs.

[0116] According to one aspect of the present application, there is also provided a computer program product or a computer program, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the relationship retrieval method provided in various optional implementations performed by the above relationship retrieval system.

[0117] Those of ordinary skill in the art can understand that all or part of the steps in the above various methods can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.

[0118] The above has introduced in detail a relationship retrieval method, system, storage medium and terminal device provided by the embodiments of the present invention. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A relational retrieval method, characterized in that, it includes: Obtain the first index information of the target object; Determine the array identifier of the first array in the pre-set object index list where the first index information is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays of the relational graph, and each object index array includes index information of multiple objects; In the pre-set relational pair index list, and in the second array corresponding to the array identifier, search for the first position index corresponding to the position identifier; the relational pair index list includes multiple relational pair position index arrays of the relational graph, and each relational pair position index array includes the position indexes of multiple relational pairs in the pre-set relational pair list respectively; Search for the relational pair corresponding to the first position index in the relational pair list; Output the relational object of the target object, and the relational object of the target object is the object other than the target object in the found relational pair.

2. The method according to claim 1, characterized in that, The step of determining the array identifier of the first array in the pre-set object index list where the first index information is located specifically includes: Taking the remainder of the pre-set value by the first index information, and the obtained remainder is the array identifier of the first array.

3. The method according to claim 1 or 2, characterized in that, Before obtaining the first index information of the target object, the method further includes: Determine the array identifier of each object in the object index list respectively according to the index information of each object in the relational pairs in the pre-set relational pair list, the relational pair list includes information of multiple relational pairs, and the information of each relational pair includes the index information corresponding to two objects respectively; According to the array identifiers corresponding to each object respectively, store the index information and position index of each object in the corresponding arrays of the object index list and the relational pair index list respectively and at the same position.

4. The method according to claim 3, characterized in that, The step of determining the array identifier of each object in the object index list respectively according to the index information of each object in the relational pairs in the pre-set relational pair list specifically includes: Taking the remainder of the pre-set value by the index information of each object, and the obtained remainder is the array identifier corresponding to each object.

5. The method according to claim 3, characterized in that, Before determining the array identifier of each object in the object index list respectively according to the index information of each object in the relational pairs in the pre-set relational pair list, the method further includes: Dividing the relational pairs in the relational pair list into multiple groups; For each group of relational pairs in the multiple groups, execute the steps of determining the array identifier of each object in the relational pair in the object index list respectively and storing the index information and position index of each object, to obtain the object index sub-list and the relational pair index sub-list corresponding to each group; Merge the object index sub - lists corresponding to each of the groups to form the preset object index list, and merge the relationship pair index sub - lists corresponding to each of the groups to form the preset relationship pair index list.

6. The method according to claim 5, wherein, after dividing the relationship pairs in the relationship pair list into multiple groups, it further includes: determining the start - position index of each group in the relationship pair list; For the relationship pairs in each group, perform the step of storing the position indexes of each object, specifically including: Obtain the position indexes of each object in the relationship pair list as: the sum of the relative position index of each object in the corresponding group and the start - position index; Store the position indexes of each object in the relationship pair list to obtain the relationship pair index sub - list of each object's corresponding group.

7. The method according to claim 6, wherein, The step of merging the object index sub - lists corresponding to each of the groups to form the preset object index list specifically includes: Merge the elements in the object index arrays with the same array identifier among the object index sub - lists corresponding to each of the groups into one object index array; The step of merging the relationship pair index sub - lists corresponding to each of the groups to form the preset relationship pair index list specifically includes: Merge the elements in the relationship - pair position index arrays with the same array identifier among the relationship pair index sub - lists corresponding to each of the groups into one relationship - pair position index array; wherein, the position of the elements in the relationship - pair position index array corresponding to each group in the merged relationship - pair position index array is the same as the position of the elements in the object index array corresponding to each group in the merged object index array.

8. A relationship retrieval system, wherein, it includes: An index acquisition unit, configured to acquire the first index information of a target object; An identifier determination unit, configured to determine the array identifier of the first array in the preset object index list where the first index information is located, and determine the position identifier of the first index information in the first array; the object index list includes multiple object index arrays of a relationship graph, and each object index array includes index information of multiple objects; A relationship - pair index unit, configured to search for the first position index corresponding to the position identifier in the second array corresponding to the array identifier in the preset relationship - pair index list; the relationship - pair index list includes multiple relationship - pair position index arrays of the relationship graph, and each relationship - pair position index array includes the position indexes of multiple relationship pairs in the preset relationship - pair list respectively; A relationship - pair unit, configured to search for the relationship pair corresponding to the first position index in the relationship - pair list; An object output unit, configured to output the relationship object of the target object, and the relationship object of the target object is the object other than the target object in the found relationship pair.

9. A computer - readable storage medium, wherein, The computer-readable storage medium stores a plurality of computer programs, and the computer programs are adapted to be loaded and executed by a processor to perform the relationship retrieval method according to any one of claims 1 to 7.

10. A terminal device, characterized in that it includes a processor and a memory; the memory is used to store a plurality of computer programs, and the computer programs are used to be loaded and executed by a processor to perform the relationship retrieval method according to any one of claims 1 to 7; the processor is used to implement each of the computer programs in the plurality of computer programs.

Citation Information

Patent Citations

  • Crossing method for performing label mapping based on HASH

    CN101917347A

  • Object data association index system, system construction method and system application method

    CN107346315A