Multi-element relation graph data storage and query method based on bit matrix model
By serializing multivariate relation graph data into triples using the metagraph model and RDF-star syntax, and combining this with the bit matrix model for storage and retrieval, the problems of storage space and retrieval efficiency of multivariate relation graph data are solved, achieving efficient management of multivariate relation graph data.
Patent Information
- Application Number
- CN202310550066.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-05-16
AI Technical Summary
Existing bit matrix RDF databases suffer from excessive data volume and complexity when managing multivariate relation graph data, leading to increased storage space consumption and decreased retrieval performance. Furthermore, the index structure cannot distinguish between binary and multivariate relations, resulting in unnecessary retrieval overhead.
The metagraph model and RDF-star syntax are used to serialize multivariate relation graph data into triples or embedded triples, and the data is modeled and stored using a bit matrix model. Matrix partitioning is used to manage entity data under the same predicate, and a multivariate entity predicate index is built to accelerate queries.
It effectively reduces the storage space requirements of multivariate relation graph data and improves query performance, especially the retrieval efficiency when the predicate is unknown.
Smart Images

Figure CN116610673B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of knowledge graph query, in particular to a storage and query technology of multi-element relationship graph data. BACKGROUND
[0002] A knowledge graph is essentially a semantic network that reveals the relationship between entities, and formally describes real-world things such as objects, events, situations, and concepts, and the interrelationships between things in the form of a graph. As the application range of knowledge graphs expands, the complexity of the knowledge they describe gradually deepens. For example, in some scenarios such as equity financing, there may be multiple entities involved in the relationship. However, the current mainstream knowledge graph adopts RDF (Resource Description Framework) which is a binary entity association representation mode. RDF was released by the World Wide Web Consortium (W3C) in 2004, aiming to solve the standardization problem of multi-source data fusion in the semantic web, but its representation ability for a large number of complex multi-element relationships is weak. RDF can be represented by a graph composed of vertices and edges, where the resource being stated is called the subject, the attribute of the resource in the statement and the attribute value are called the predicate and the object respectively. Among them, the attribute value object can be another resource subject, or a literal such as a string, an integer, etc.
[0003] The bit matrix model was mainly proposed to meet the modeling needs of large-scale RDF data. In the bit matrix, each row represents an entity, and each column represents a triple. When modeling, triples with the same predicate are stored together, i.e., a sub-matrix. The bit matrix model has a simple structure, strong expressiveness, and can well reflect the graph characteristics of RDF data. The compact data structure provides a compressed representation that supports efficient operations. In addition, deep operations such as path retrieval can be well performed on this structure.
[0004] However, existing bit matrix RDF databases can only parse and manage data in the standard triple format, so when managing multi-element relationship graph data, the original triple relationship in the data needs to be transformed, such as RDF instantiation. This will result in an increase in data volume and data complexity, thus occupying more storage space, so that the traditional RDF storage engine needs additional join operations or reasoning steps during the retrieval process. In addition, the index structure of the existing bit matrix RDF database cannot distinguish between binary relationships and multi-element relationships, resulting in unnecessary retrieval overhead and decreased retrieval performance. SUMMARY
[0005] The technical problem solved by this invention is that existing technologies for large-scale bit matrix RDF database modeling suffer from excessively high data volume and complexity, resulting in excessive storage space consumption. This leads to traditional bit matrix RDF database storage engines requiring additional join operations or inference steps during retrieval. Furthermore, the index structure of existing bit matrix RDF databases cannot distinguish between binary and multivariate relations, resulting in low retrieval efficiency. To address these problems, this invention provides a method for storing and querying multivariate relation graph data based on a bit matrix model, specifically employing the following technical solution:
[0006] In a first aspect, the present invention provides a method for storing multivariate relation graph data based on bit matrices, applicable to the storage and indexing of multivariate relation graph data, comprising the following steps:
[0007] A metagraph model is used to represent the set of entities in multi-dimensional relations, and the multi-dimensional relation graph data is serialized into triples or embedded triples.
[0008] The triplet or embedded triplet data is modeled and stored using a bit matrix model, and entity data participating in binary and multi-ary relations under the same predicate is managed using a matrix partitioning method.
[0009] Construct a multi-entity predicate index to establish the association between entities and predicates in binary and multi-entity relations.
[0010] Furthermore, a meta-graph model is used to represent the entity set in multi-way relations, representing the multi-way relation graph data, and serializing the multi-way relation graph data into triples or embedded triples, including:
[0011] Multi-relationships are represented using a metagraph model, and the set of entities participating in multi-relationships is represented by the meta-point structure in the metagraph model.
[0012] Turtle syntax is used to represent the subject or object in a triplet multivariate relation as multiple entities;
[0013] The edges contained in the meta node are described as embedded triples using the RDF-star syntax, which are used to represent the internal relations among multiple entities participating in a multivariate relation.
[0014] Furthermore, a bit matrix model is used to model and store the triplet or embedded triplet data, and a matrix partitioning approach is used to manage entity data participating in binary and multi-way relations under the same predicate, including:
[0015] Convert each entity in the triplet and the embedded triplet as a whole into an integer identifier ID;
[0016] The sub-storage matrix corresponding to each predicate is divided into two regions: binary and multivariate. Each region is further divided into two copies stored in order of subject ID and object ID.
[0017] Furthermore, each entity in the triple and the embedded triple as a whole are converted into an integer identifier ID, including:
[0018] For URI entities, the URI prefix is converted into a prefix identifier ID through hash calculation and then concatenated with the URI suffix. The ID corresponding to the URI entity is then obtained through hash calculation.
[0019] For literal entities, their corresponding IDs are obtained by performing hash calculations on the literals;
[0020] For embedded triples, the IDs corresponding to the subject, predicate, and object are calculated separately, and the three IDs are concatenated and hashed to obtain the overall ID of the embedded triple.
[0021] Furthermore, the multi-dimensional entity predicate index includes an entity predicate storage array and an entity predicate retrieval mapping table, wherein:
[0022] Construct an entity predicate storage array using entities and binary and multi-ary relation predicates associated with entities as the basic storage units;
[0023] A key-value storage structure is adopted, with the entity ID as the key and the offset of the entity in the entity predicate storage array as the value, to construct an entity predicate retrieval mapping table.
[0024] Furthermore, using entities and their associated binary and multi-ary relational predicates as the basic storage unit, the processing of entities within this basic storage unit includes:
[0025] The entity ID serves as the basic unit header, followed by a multi-predicate offset identifier, which indicates the offset of the multi-predicate associated with the entity relative to the entity ID. The multi-predicate offset identifier is followed by the binary predicate data associated with the entity. The binary predicate data is followed by the multi-predicate data. The multi-predicate data is followed by the end identifier 0. The end identifier is followed by the other entity predicate information, and this cycle continues until all entities have been processed.
[0026] Furthermore, a key-value storage structure is adopted, using the entity ID as the key and the offset of the entity in the entity predicate storage array as the value, to construct an entity predicate retrieval mapping table, including:
[0027] During the construction of the entity predicate storage array, obtain the offset of the entity ID in the array;
[0028] The entity ID itself is used as the corresponding hash value. The remainder of the hash value is calculated by taking the remainder of the entity predicate retrieval mapping table size to obtain the mapping position of the entity ID in the mapping table. The offset information corresponding to the entity is then stored at the position.
[0029] Secondly, the present invention provides a method for querying multivariate relation graph data based on a bit matrix model, which is based on the aforementioned multivariate relation graph data storage method and includes:
[0030] Parse the query statement to identify the query type and query pattern;
[0031] Predicates and their storage matrix can be obtained directly based on the query type and query mode, or based on the multi-entity predicate index.
[0032] Select the search area based on the query type, execute the query, and connect the result sets of each query mode to return the final query result.
[0033] Furthermore, the query types include binary relation queries and multi-relation queries;
[0034] Binary relation queries are constructed from ordinary triples in the query graph described in the SPARQL query statement;
[0035] Multi-relation queries include multi-relation to entity queries, entity to multi-relation queries, entity to entity queries, and multi-relation to multi-relation queries, among which:
[0036] Multi-relation to entity query retrieves the set of other participating entities associated with the multi-relation based on known entities and predicates;
[0037] Entity-to-multi-relation query: Query all multi-relationships associated with a known constant entity.
[0038] Entity-to-entity query retrieves the multi-relationships associated with a known entity and searches for other related entities based on the entity to which the multi-relationship belongs.
[0039] The multi-relation query method retrieves the set of entities participating in a known multi-relation and then queries the corresponding multi-relation based on the set of participating entities.
[0040] Furthermore, predicates and their storage matrix can be obtained directly based on the query type and query pattern, or obtained based on the multi-entity predicate index, including:
[0041] For query patterns where the predicate is known, obtain the corresponding identifier ID based on the predicate, and then obtain the storage submatrix associated with the predicate in the bit matrix model based on the identifier ID.
[0042] For query patterns where the predicate is unknown, obtain the corresponding identifier ID based on the known subject or object, obtain the associated predicate information based on the known subject ID or object ID, and obtain the associated storage submatrix based on the associated predicate ID.
[0043] The beneficial technical effects of the present invention are as follows:
[0044] (1) The present invention combines the metagraph model, Turtle and RDF-star syntax to represent the multivariate relation graph, which not only meets the representation requirements of existing multivariate relation graph data, but also achieves compatibility with traditional RDF triples;
[0045] (2) In addition, the present invention extends the underlying storage structure of the bit matrix model and adopts a bit matrix storage strategy of partitioning binary relation and multi-relation data, which effectively reduces the storage space required for storing multi-relation graph data in traditional bit matrix databases and improves the performance of querying multi-relation graph data.
[0046] (3) Finally, the present invention constructs a multi-entity predicate index, which can effectively improve the retrieval efficiency when the predicate is unknown in multi-relation queries. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0048] Figure 1 This is a schematic diagram of the storage and query method for multivariate relation graph data based on bit matrix provided by the present invention;
[0049] Figure 2 This is a schematic diagram of the storage process for multivariate relation graph data based on bit matrices provided by the present invention;
[0050] Figure 3 This is a schematic diagram of the construction process of the bit matrix storage structure provided by the present invention;
[0051] Figure 4 This is a schematic diagram of the query process for multivariate relational graph data based on bit matrices provided by the present invention. Detailed Implementation
[0052] To further explain the present invention, preferred embodiments of the present invention are described below in conjunction with examples. However, it should be understood that these descriptions are only for further illustrating the features and advantages of the present invention, and are not intended to limit the scope of the claims of the present invention.
[0053] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method for storing and querying multivariate relational graph data based on bit matrices. Figure 1 This is a schematic diagram illustrating the storage and query process of multivariate relation graph data based on bit matrices provided by the present invention. Figure 2 and Figure 3 This is a further detailed demonstration of the storage process; Figure 4 This is a further detailed demonstration of the query process.
[0054] Firstly, embodiments of the present invention provide a method for storing multivariate relational graph data based on bit matrices. For example... Figure 2 As shown, the method is applied to the storage and indexing of multivariate relation graph data, including:
[0055] Step S101: Use a metagraph model to represent the entity set in the multivariate relation, and serialize the multivariate relation graph data into triples and embedded triples;
[0056] Step S102: Convert the subject, predicate, object, and embedded triple in the triple as entities and compress them into integer identifiers ID through the URI-ID mapping table;
[0057] Step S103: The triplet data converted into integer identifier IDs is stored in the bit matrix physical storage structure. Each predicate's corresponding sub-storage matrix is divided into two regions: a binary region and a multi-variable region. Each region is further divided into two copies, one ordered by subject ID and the other ordered by object ID.
[0058] Step S104: Construct a multi-entity predicate index based on the triple data converted into integer identifier IDs. Establish the association between entities and predicates in binary and multi-entity relations through key-value storage and array structure to accelerate queries when predicates are unknown.
[0059] In this embodiment, step S101 uses a metagraph model to represent the entity set in a multivariate relation, and combines Turtle and RDF-star syntax to serialize the multivariate relation graph data into triples and embedded triples for representation.
[0060] More specifically, the metagraph model offers greater flexibility in representing multivariate relation knowledge compared to ordinary graphs and hypergraphs. A vertex in a metagraph model can be described as a set of attributes, while an edge consists of a source vertex or source meta-vertex, a target vertex or target meta-vertex, a directed identifier, and a set of attributes. What distinguishes the metagraph model from other graph models is its meta-point structure, which can be represented by a set of attributes and meta-plots. A meta-plot can be viewed as a subgraph of the entire metagraph, containing vertices, edges, or other meta-vertices. Specifically, in multivariate relation graph representation, the meta-point structure from the metagraph model is introduced, using meta-vertices to encompass entities and the relationships between them to represent multivariate relations.
[0061] Currently, most relation graphs are represented using RDF. RDF data serialization methods mainly include RDF / XML, N-Triples, Turtle, RDFa, and JSON-LD. Among these, Turtle syntax is widely used due to its compactness and high readability. In the triple serialization part of the multivariate relation graph, combined with some Turtle syntax, an entity list format is used. This means that entities contained in the metapoint are grouped into a series of entity sets using commas (,) within the relation, indicating that the subject or object of the triple multivariate relation consists of multiple entities.
[0062] Meanwhile, the edges (relational entities) contained within the meta-nodes are described as embedded triples using RDF-star syntax. RDF-star is an extension of the RDF 1.1 standard, primarily aimed at providing a more efficient serialization syntax for representing RDF edge information. RDF-star uses "<<" and ">>" symbols to enclose triples, treating them as complete entities. These enclosed triples are called embedded triples and can thus function as subjects or objects in other triple relations. Here, RDF-star syntax is used to represent internal relations among multiple entities participating in multi-level relations.
[0063] In this embodiment, step S102 involves converting the subject, predicate, object, and embedded triple in the triple as entities into integer identifiers (IDs) through a URI-ID mapping table and then compressing and storing them.
[0064] Resource entities in RDF can be mainly divided into URIs and literals. Converting URIs and literals into identifiers (IDs) can reduce storage space usage and improve system efficiency.
[0065] Generally, a URI consists of three parts: hostname, identifier, and relative URI. The hostname stores the resource path, the identifier indicates that a URI points to a specific resource, and the relative URI contains no naming convention information, only describing the resource name. A relative URI may also contain path or identifier information. Different URIs may have the same hostname and identifier. Therefore, utilizing the hierarchical nature of URIs, URIs can be converted into identifiers (IDs) for compressed storage, reducing space consumption. The URI-ID mapping table is divided into a prefix mapping table and a suffix mapping table. In the prefix and suffix mapping tables, the prefix and suffix identifier IDs increase with the number of newly added resource entities in each mapping table.
[0066] For a URI entity, taking "http: / / www.example.com / people / bob" as an example, the system first establishes a mapping between the URI prefix and the prefix identifier ID in the prefix mapping table using a hash algorithm. That is, "http: / / www.example.com / people" corresponds to the prefix identifier 1. Then, the prefix identifier ID is concatenated with the URI suffix to obtain "1 / people". The system then establishes a mapping relationship between the concatenated URI and the suffix identifier ID in the suffix mapping table. That is, "1 / people" corresponds to the suffix identifier 1.
[0067] For literals, such as a string or an integer, the literal is treated as having an empty prefix, and the mapping between the literal and the suffix identifier ID is established directly as the suffix.
[0068] For RDF-star's embedded triples, which represent the entire triple relation as an entity, the entity ID can be divided into subject ID, predicate ID, and object ID based on the position of each entity resource in the triple. The IDs of the subject, predicate, and object in the triple are calculated separately, and then the triple ID is calculated based on these three IDs to represent it. (The last sentence appears to be incomplete and possibly refers to a different context.) <subject1predicate1object1>For example, first, the ID of each entity is obtained from the prefix and suffix URI-ID mapping table according to the hash algorithm of each entity URI or literal in the triple, such as subject1, predicate1 and object1 corresponding to 1, 2 and 3 respectively; and the string "#< " and the three IDs are spliced to represent the whole triple, that is, "#<123", the character'' is used to indicate that the subsequent part is the URI suffix to facilitate division, and "<" is a character that will not appear in the URI suffix, which can distinguish the triple identifier and the URI of other entities.
[0069] In this embodiment, the step S103 stores the triple data converted into ID in the bit matrix physical storage structure. Wherein, each predicate corresponding sub-storage matrix is divided into two areas of binary and multi-element, and each area is further divided into two copies of subject ID ordered and object ID ordered storage.
[0070] Referring to Figure 3 , Figure 3 The flow chart for constructing the bit matrix storage structure in the process of storing multi-element relationship graph data. The system obtains the corresponding storage sub-matrix according to the predicate ID in the parsed multi-element relationship graph triple, and the sub-matrix is divided into two areas of binary and multi-element, that is, two data block linked lists of binary and multi-element.
[0071] The data block linked list is composed of multiple data blocks, which are stored in continuous space, and each data block has a fixed and same size. If the storage sub-matrix does not exist, an empty data block linked list is created.
[0072] The system determines whether the triple represents a multi-element relationship or a binary relationship according to whether the subject or object in the triple relationship contains multiple entities. If it is a multi-element relationship, the multi-element relationship data block linked list is selected. According to the subject ID and object ID in the triple, the subject and object data are respectively added to the multi-element relationship data block linked list in the subject ID and object ID ordered copy. The processing of binary relationship is the same as that of multi-element relationship, which will not be repeated here.
[0073] In this embodiment, the step S104 constructs a multi-element entity predicate index to construct the association relationship between entities and each predicate in binary and multi-element relationships, so as to speed up the query under the condition of unknown predicate.
[0074] The multi-element entity predicate index is composed of an entity predicate storage array and an entity predicate retrieval mapping table. And the entity predicate storage array and the entity predicate retrieval mapping table are divided into subject predicate and object predicate.
[0075] The entity predicate storage array stores entities and binary and multi-relational predicate associated with the entities as basic storage units. In the basic storage unit, the entity ID is taken as the basic unit header, followed by the multi-predicate offset identifier to indicate the offset of the multi-relational predicate associated with the entity relative to the entity ID; the multi-predicate offset identifier is followed by the binary relational predicate data associated with the entity; the binary relational predicate data is followed by the multi-relational predicate data; the multi-relational predicate data is followed by the end identifier 0; the end identifier is followed by other entity predicate information, and the process is repeated until all entities are processed.
[0076] The construction of the entity predicate storage array needs to convert the storage data into corresponding identifiers ID and sort them. Specifically, first, parse the graph data set with multi-relational, i.e., convert each entity resource in the graph into an integer identifier ID; and divide the parsed triple ID data into binary and multi-relational two character streams according to the relationship type, which are used to store binary and multi-relational triple data, respectively. Both binary and multi-relational two character streams are composed of subject ID, predicate ID, and object ID triplets as basic units.
[0077] Taking the subject predicate (SP) index as an example, first, sort the binary character stream and the multi-relational character stream according to the subject ID, and then execute the subsequent process similar to merging two ordered arrays, i.e., determine whether the smallest subject ID in the binary character stream is smaller than the subject ID in the multi-relational character stream. If not, it means that the smallest subject ID in the multi-relational character stream only has a multi-relational, which is inserted into the subject predicate storage array. If yes, the subject ID and its related predicate information in the binary character stream are inserted into the subject predicate storage array.
[0078] Next, determine whether there is a subject in the multi-relational character stream that is the same as the subject ID inserted in the binary character stream. If yes, it means that the subject has both binary and multi-relational associated predicates, so the multi-predicate offset identifier in the inserted subject ID is updated, and the multi-relational related predicate of the multi-relational character stream is inserted.
[0079] Repeat the above steps until the binary character stream or the multi-relational character stream is parsed, and the remaining part of the character stream is supplemented into the subject predicate storage array.
[0080] To facilitate the retrieval of the associated predicate data according to the subject or object entity ID, a key-value storage structure is adopted, taking the entity ID as the key and the corresponding offset of the entity in the entity predicate storage array as the value, to construct an entity predicate retrieval mapping table.
[0081] The construction of the entity predicate retrieval mapping table is synchronized with the construction of the entity predicate storage array. Specifically, the offset of the entity ID in the array is obtained during the construction of the entity predicate storage array; the entity ID itself is taken as its corresponding hash value, and the size of the entity predicate retrieval mapping table is taken as the modulus to obtain the mapping position of the entity ID in the mapping table, and the offset information corresponding to the entity is stored in the position.
[0082] In a second aspect, the embodiment of the present application further provides a query method of multi-element relationship graph data based on a bit matrix, which is based on the multi-element relationship graph data storage method described above. As shown in the following Figure 4 The method is applied to query analysis and query execution of multi-element relationship graph data, and includes the following steps.
[0083] Step S201: receiving and analyzing a SPARQL query statement, identifying the query type and the query mode;
[0084] Step S202: directly obtaining or obtaining the predicate and its storage matrix according to the multi-element entity predicate index according to the query type and the query mode;
[0085] Step S203: selecting a retrieval area according to the query type to execute the query, connecting the query mode result sets, and returning the final query result.
[0086] In the embodiment, the step S201 analyzes the SPARQL query statement, and identifies the query type and the query mode.
[0087] Specifically, the system reads the query statement string, and analyzes the query graph described after the "WHERE" keyword. The query graph is composed of multiple triple query modes, and the sub-query modes in the query graph can be divided into two query types, i.e., binary relationship query and multi-element relationship query. Specifically, the binary relationship query is constructed by the normal triple in the query graph described in the SPARQL query statement.
[0088] The multi-element relationship query is marked by the ":polynary" string in the multi-element relationship graph query statement, which indicates that the triple in which the predicate element is located is a multi-element relationship query mode. Otherwise, it indicates that it is a binary relationship query.
[0089] Further, by reading each triple query pattern in the query graph, it is determined whether the subject, predicate and object in each query pattern are variables, and then the polynary relationship query to which the query graph belongs is identified. The current system supports four types of basic polynary relationship queries, i.e., polynary relationship to entity, entity to polynary relationship, entity to entity and polynary relationship to polynary relationship. It should be noted that the identification of the polynary relationship query is only directed to the polynary relationship query pattern, i.e., the triple query pattern marked with the ":polynary" string.
[0090] Among them, if the subject and predicate in the triple query pattern are constants and the object is a variable, it is a polynary relationship to entity query, which aims to obtain the set of other participating entities associated with the polynary relationship according to the known entity and predicate.
[0091] If the object is a constant, the subject is a variable, and the predicate is a constant or a variable, it is an entity to polynary relationship query, which aims to query all polynary relationships associated with a certain known constant entity through the entity.
[0092] If there are two polynary relationship query patterns in the query graph, which are entity to polynary relationship query and polynary relationship to entity query respectively, and the entity to polynary relationship query pattern is connected to the polynary relationship to entity query pattern through the object public node, the two query patterns together constitute an entity to entity query, which aims to obtain the polynary relationship associated with a known entity and search for the remaining polynary relationship associated entities according to the entity belonging to the polynary relationship.
[0093] For polynary relationship to polynary relationship query, similar to entity to entity query, if the entity to polynary relationship query pattern is connected to the polynary relationship to entity query pattern through the subject public node, the two query patterns together constitute a polynary relationship to polynary relationship query. In this type of query, the set of entities participating in the known polynary relationship is obtained; all polynary relationships in which the participating entities participate are queried.
[0094] In this embodiment, the step S202 directly obtains the predicate and its storage matrix according to the query type and query pattern or according to the polynary entity predicate index.
[0095] Specifically, for the query pattern with known predicate, the identifier ID corresponding to the predicate is obtained according to the predicate, and the storage sub-matrix associated with the predicate is obtained in the bit matrix model according to the identifier ID.
[0096] For the query pattern with unknown predicate, the identifier ID corresponding to the known subject or object in the URI-ID mapping table is obtained, and the predicate information associated with the known subject or object ID is obtained in the entity predicate mapping table of the polynary entity predicate index.
[0097] The retrieval of the associated predicate is mainly performed in the entity predicate storage array part of the multi-entity predicate index. If the predicate associated in the binary relation is retrieved, the array can be traversed until the position specified by the multi-predicate offset identifier is read. If the predicate associated in the multi-relation is retrieved, the multi-relation associated predicate in the array can be jumped to the offset amount by the multi-predicate offset identifier and start to be read until the end identifier 0 is read.
[0098] After the associated predicate ID set is acquired, the storage sub-matrix associated with the predicate ID can be acquired according to the predicate ID.
[0099] In the embodiment, in step S203, the retrieval area is selected according to the query type to perform the query, and the result sets of each query mode are connected.
[0100] If the query type is a binary relation query, the retrieval is performed in the binary relation area of the sub-storage matrix corresponding to the predicate, otherwise the retrieval is performed in the multi-relation area. The specific retrieval process is as follows:
[0101] In the data block linked list, the data block size is fixed and the data in the data block is arranged in order according to the subject ID and the object ID. The data blocks are numbered, and there is a linear correlation between the maximum value or the minimum value stored in different data blocks. That is, the maximum value and the minimum value in each data block can be fitted by two lines, which represent the upper limit and the lower limit, respectively.
[0102] Since the system adopts a variable-length encoding compression strategy for integer identifiers ID, the size of the space occupied by the ID gradually increases with the increase of the ID value, so the range of the ID stored in the data block gradually decreases, and therefore a segmented broken line can be used for fitting. In this embodiment, a four-fold fitting equation is used to calculate the data block position of the ID in the data block linked list copy through the subject ID or the object ID.
[0103] Specifically, the standard for the four-fold fitting demarcation is the maximum value that can be represented by each segment in 1 to 4 bytes. Only the equation parameters of the four straight lines need to be stored during storage. The steps for using the index to find the data block containing a specific ID are as follows: first, determine the range of the ID and select the corresponding straight line equation; then, use the lower limit and upper limit straight line equations to calculate the upper limit and lower limit of the data block number; finally, perform a binary search according to the minimum value of the ID stored in the data block to locate the data block containing the ID. Since the range of the data block number between the upper limit and the lower limit is fixed, the positioning time is a constant, that is, the time complexity of locating a specific data block using this index method is O(1), and the positioning time will not increase with the increase of the data storage amount.
[0104] In the internal data block retrieval, for binary relation, to ensure the order of traversal result, the retrieval pointer is moved to the beginning of the ID continuous storage space in the corresponding data block linked list; the retrieval is performed from front to back. For multi-relation, since one entity in the participating relation is in the form of set, binary search combined with center diffusion traversal algorithm is adopted to retrieve multiple entities contained in the multi-relation.
[0105] For the join operation, since the query result set is obtained from the data block linked list, and the data in the data block linked list is stored in order based on the subject or object ID, two different join strategies are adopted according to whether the result sets of the two query patterns participating in the join are ordered according to the key value (subject ID or object ID). (1) Merge join, used for joining the result sets whose data are all ordered according to the key value. (2) Hash join, used for processing the case where the data in the result sets participating in the join are not all ordered according to the key value. Finally, the final query result is returned.
[0106] The above description of the embodiments is only used to help understand the method of the present application and its core idea. It should be noted that, for those skilled in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A method for storing multivariate relation graph data based on bit matrices, applied to the storage and indexing of multivariate relation graph data, characterized in that, Includes the following steps: A metagraph model is used to represent the set of entities in a multivariate relation, and the multivariate relation graph data is serialized into triples or embedded triples. This includes: representing the set of entities participating in the multivariate relation through the meta-node structure in the metagraph model; representing the subject or object in the triple multivariate relation as multiple entities through Turtle syntax; and describing the edges contained in the meta-node as embedded triples through RDF-star syntax, which are used to represent the internal relations among multiple entities participating in the multivariate relation. The triplet or embedded triplet data is modeled and stored using a bit matrix model. Entity data participating in binary and multivariate relations under the same predicate are managed using a matrix partitioning approach. This includes converting each entity in the triplet and the embedded triplet as a whole into an integer identifier ID. The sub-storage matrix corresponding to each predicate is divided into two regions: binary and multivariate. Each region is further divided into two copies stored in order of subject ID and object ID. A multi-entity predicate index is constructed to establish the association between entities and predicates in binary and multi-variable relations. The multi-entity predicate index includes an entity predicate storage array and an entity predicate retrieval mapping table. Specifically, the entity predicate storage array is constructed using entities and the binary and multi-variable relation predicates associated with the entities as the basic storage units. The entity predicate retrieval mapping table is constructed using a key-value storage structure, with the entity ID as the key and the offset of the entity in the entity predicate storage array as the value.
2. The method for storing multivariate relational graph data based on bit matrices according to claim 1, characterized in that, Convert each entity in the triplet and the embedded triplet as a whole into an integer identifier ID, including: For URI entities, the URI prefix is converted into a prefix identifier ID through hash calculation and then concatenated with the URI suffix. The ID corresponding to the URI entity is then obtained through hash calculation. For literal entities, their corresponding IDs are obtained by performing hash calculations on the literals; For embedded triples, the IDs corresponding to the subject, predicate, and object are calculated separately, and the three IDs are concatenated and hashed to obtain the overall ID of the embedded triple.
3. The method for storing multivariate relational graph data based on bit matrices according to claim 1, characterized in that, Using entities and their associated binary and multi-ary relational predicates as the basic storage unit, the processing of entities within this basic storage unit includes: The entity ID serves as the basic unit header, followed by a multi-predicate offset identifier, which indicates the offset of the multi-predicate associated with the entity relative to the entity ID. The multi-predicate offset identifier is followed by the binary predicate data associated with the entity. The binary predicate data is followed by the multi-predicate data. The multi-predicate data is followed by the end identifier 0. The end identifier is followed by the other entity predicate information, and this cycle continues until all entities have been processed.
4. The method for storing multivariate relational graph data based on bit matrices according to claim 1, characterized in that, A key-value storage structure is adopted, using the entity ID as the key and the offset of the entity in the entity predicate storage array as the value, to construct an entity predicate retrieval mapping table, including: During the construction of the entity predicate storage array, obtain the offset of the entity ID in the array; The entity ID itself is used as the corresponding hash value. The remainder of the hash value is calculated by taking the remainder of the entity predicate retrieval mapping table size to obtain the mapping position of the entity ID in the mapping table. The offset information corresponding to the entity is then stored at the position.
5. A method for querying multivariate relation graph data based on a bit matrix model, wherein the method is based on the multivariate relation graph data storage method as described in any one of claims 1-4, characterized in that, include: Parse the query statement to identify the query type and query pattern; Predicates and their storage matrix can be obtained directly based on the query type and query mode, or based on the multi-entity predicate index. Select the search area based on the query type, execute the query, and connect the result sets of each query mode to return the final query result.
6. The method for querying multivariate relational graph data based on a bit matrix model according to claim 5, characterized in that, The query types include binary relation queries and multi-variable relation queries; Binary relation queries are constructed from ordinary triples in the query graph described in the SPARQL query statement; Multi-relation queries include multi-relation to entity queries, entity to multi-relation queries, entity to entity queries, and multi-relation to multi-relation queries, among which: Multi-relation to entity query retrieves the set of other participating entities associated with the multi-relation based on known entities and predicates; Entity-to-multi-relation query: Query all multi-relationships associated with a known constant entity. Entity-to-entity query retrieves the multi-relationships associated with a known entity and searches for other related entities based on the entity to which the multi-relationship belongs. The multi-relation query method retrieves the set of entities participating in a known multi-relation and then queries the corresponding multi-relation based on the set of participating entities.
7. The method for querying multivariate relational graph data based on a bit matrix model according to claim 5, characterized in that, Predicates and their storage matrix can be obtained directly based on the query type and query pattern, or based on the multi-entity predicate index, including: For query patterns where the predicate is known, obtain the corresponding identifier ID based on the predicate, and then obtain the storage submatrix associated with the predicate in the bit matrix model based on the identifier ID. For query patterns where the predicate is unknown, obtain the corresponding identifier ID based on the known subject or object, obtain the associated predicate information based on the known subject ID or object ID, and obtain the associated storage submatrix based on the associated predicate ID.
Citation Information
Patent Citations
Time sequence RDF data storage and query method based on bit matrix model
CN114791967A
Semantic perception
US20150046388A1