Data query method

By analyzing query requests in the graph database and partitioning based on node density and logical relationships, the problem of low data query efficiency in the graph database is solved, and efficient and accurate data retrieval is achieved.

CN119106153AActive Publication Date: 2024-12-10WEBANK (CHINA)
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411331871.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-10
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

Data query efficiency in graph databases is low, computing resources are consumed, and existing methods require access to a large amount of data, resulting in poor performance.

Method used

By analyzing the data query request, extracting the subject, object and predicate, using the partition structure of the graph database to identify the target data partition, partitioning based on the node density and logical relationship, accurately locate the target data, and reduce the data retrieval range.

Benefits of technology

It improves the accuracy and efficiency of data query, optimizes query performance, and achieves fast and accurate data retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106153A_ABST
    Figure CN119106153A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of computers, and particularly relates to a data query method, a data query device, a computer readable medium, electronic equipment and a computer program product. The method comprises the steps that a data query request is analyzed to obtain a query condition, the query condition comprises one or more of a subject, an object and a predicate, and the predicate is used for representing the logic relation between the subject and the object; a target data partition in a graph database is determined according to the query condition, the graph database comprises a first-level data partition obtained by performing region division according to the compactness relation between the nodes, and the first-level data partition comprises a second-level data partition obtained by performing region division according to the logic relation between the nodes; and retrieving a data query result matched with the query condition in the target data partition. The data query efficiency can be improved, and the resource consumption in the data query process can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a data query method, a data query device, a computer-readable medium, an electronic device, and a computer program product. Background Art

[0002] A graph database is a database system designed specifically for processing graph data. Its core advantage lies in efficient data relationship management. Compared with traditional relational databases, graph databases use nodes (Vertex) and edges (Edge) to represent data entities and their relationships, which makes it more efficient and intuitive when processing highly related data structures.

[0003] When you need to query data from a graph database, a simple and direct method is to load the data file completely into memory and search for the corresponding query results in memory. However, using this query method requires accessing a large amount of data to retrieve the required information, resulting in low query efficiency and high consumption of computing resources. Summary of the invention

[0004] The purpose of the present application is to provide a data query method, a data query device, a computer-readable medium, an electronic device, and a computer program product, aiming to improve the efficiency of data query and reduce the resource consumption of the data query process.

[0005] According to one aspect of an embodiment of the present application, a data query method is provided, the method comprising: parsing a data query request to obtain a query condition, the query condition comprising one or more of a subject, an object and a predicate, the predicate being used to represent a logical relationship between the subject and the object; determining a target data partition in a graph database according to the query condition, the graph database comprising a primary data partition obtained by dividing the area according to a closeness relationship between nodes, the primary data partition comprising a secondary data partition obtained by dividing the area according to a logical relationship between nodes; and retrieving a data query result matching the query condition in the target data partition.

[0006] According to one aspect of an embodiment of the present application, a data query device is provided, the device comprising:

[0007] A parsing module, configured to parse the data query request to obtain a query condition, wherein the query condition includes one or more of a subject, an object, and a predicate, wherein the predicate is used to represent a logical relationship between the subject and the object;

[0008] A partitioning module is configured to determine a target data partition in a graph database according to the query condition, wherein the graph database includes a primary data partition obtained by regional division according to a closeness relationship between nodes, and the primary data partition includes a secondary data partition obtained by regional division according to a logical relationship between nodes;

[0009] The retrieval module is configured to retrieve data query results matching the query condition in the target data partition.

[0010] In some embodiments of the present application, based on the above technical solution, the partition module may further include:

[0011] A pattern graph acquisition module is configured to acquire a complete pattern graph stored in a graph database, wherein nodes in the complete pattern graph are used to represent subjects or objects, and edges in the complete pattern graph are used to represent predicates;

[0012] A closeness determination module is configured to traverse the complete pattern graph to obtain a closeness relationship between nodes, wherein the closeness relationship includes an importance parameter and a dependency parameter, wherein the importance parameter is used to indicate the importance of each node in the complete pattern graph, and the dependency parameter is used to indicate the degree of dependency between any two nodes;

[0013] A core node selection module is configured to select a preset number of core nodes from the complete pattern graph according to the importance parameter, wherein the core nodes are a plurality of nodes having the highest importance parameters in the complete pattern graph;

[0014] The node allocation module is configured to allocate each node in the complete pattern graph to a primary data partition centered on the core node according to the dependency parameters.

[0015] In some embodiments of the present application, based on the above technical solution, the complete pattern graph is a directed graph, and the compactness determination module includes:

[0016] A shortest path set acquisition module is configured to determine the shortest path between two nodes according to the direction of the predicate to obtain the shortest path set of the complete pattern graph;

[0017] A distribution ratio statistics module is configured to count the distribution ratio of each node in the shortest path set to obtain a coreness parameter of the node;

[0018] The importance parameter determination module is configured to determine the importance parameter of the node according to the coreness parameter and the number of instances of the node.

[0019] In some embodiments of the present application, based on the above technical solution, the shortest path set acquisition module is further configured to: traverse the complete pattern graph to obtain a node pair consisting of any two nodes; determine all node pair paths with the node pair as the starting point and end point according to the direction of the predicate; compare the lengths of the node pair paths to obtain the shortest path set of the node pairs.

[0020] In some embodiments of the present application, based on the above technical solution, the distribution ratio statistics module is further configured as follows: for a selected node pair, counting the number of all shortest paths in the shortest path set to obtain the first path number; for a selected node, counting the number of shortest paths in the shortest path set that contains the selected node to obtain the second path number; obtaining the ratio of the second path number to the first path number to obtain the distribution ratio of the selected node in the shortest path set of the selected node pair; accumulating the distribution ratios corresponding to each node and each node pair to obtain the coreness parameter of the node.

[0021] In some embodiments of the present application, based on the above technical solution, the distribution ratio statistics module is further configured to: normalize the coreness parameter of the node to obtain the normalized coreness of the node; normalize the number of instances of the node to obtain the normalized number of instances of the node; add the normalized coreness and the normalized number of instances to obtain the importance parameter of the node.

[0022] In some embodiments of the present application, based on the above technical solution, the compactness determination module includes:

[0023] A length acquisition module is configured to acquire, for a selected node pair, the length of the shortest path of the selected node pair;

[0024] A dependency parameter determination module is configured to determine the dependency parameters of the node pair based on the importance parameters of each node on the shortest path and the length of the shortest path, wherein the dependency parameters are positively correlated with the importance parameters of the starting point on the shortest path, negatively correlated with the importance parameters of other nodes on the shortest path except the starting point, and negatively correlated with the length of the shortest path.

[0025] In some embodiments of the present application, based on the above technical solution, the dependency parameter is also negatively correlated with the closeness parameter of the two adjacent nodes on the shortest path, and the closeness parameter is used to weight the importance parameters of other nodes on the shortest path except the starting point.

[0026] In some embodiments of the present application, based on the above technical solution, the method for determining the closeness parameter includes: obtaining the number of instances of the starting node and the number of instances of the ending node in two adjacent nodes; determining the closeness parameter of the two adjacent nodes based on the number of instances of the starting node, the number of instances of the ending node and the total number of nodes in the complete pattern graph.

[0027] In some embodiments of the present application, based on the above technical solution, when the number of instances of the end node is zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph; when the number of instances of the end node is not zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph, positively correlated with the number of instances of the starting node, and negatively correlated with the number of instances of the end node.

[0028] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data query method in the above technical solution is implemented.

[0029] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to implement a data query method as in the above technical solution.

[0030] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the data query method in the above technical solution is implemented.

[0031] In the technical solution provided in the embodiment of the present application, by intelligently parsing the data query request, key query conditions, including subject, object and predicate, are extracted to accurately capture the logical relationship of the query. Then, the solution uses the partition structure of the graph database to first identify the first-level data partition based on node density, and then further refine it to the second-level data partition based on logical relationship, so as to efficiently locate the target data. The embodiment of the present application not only improves the accuracy and efficiency of the query, but also optimizes the query performance by reducing the data retrieval scope, and finally realizes the fast and accurate retrieval of results that match the query conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0033] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.

[0034] Figure 2 A flow chart of a data query method in one embodiment of the present application is shown.

[0035] Figure 3 A schematic diagram of the principle framework of the data query method in an embodiment of the present application is shown.

[0036] Figure 4 A flow chart of a method for dividing a region into primary data partitions in one embodiment of the present application is shown.

[0037] Figure 5 A schematic diagram of an RDF schema graph in an application scenario of an embodiment of the present application is shown.

[0038] Figure 6 The corresponding relationship between the pattern diagram and the number of instances in an application scenario of the embodiment of the present application is shown.

[0039] Figure 7 The first-level data partition division result of the pattern diagram in an application scenario of an embodiment of the present application is shown.

[0040] Figure 8 The diagram shows a partitioning result formed by copying data on a primary data partition in an application scenario according to an embodiment of the present application.

[0041] Fig. 9 The structural block diagram of the data query device provided in an embodiment of the present application is schematically shown.

[0042] Fig.10 The structure block diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0043] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.

[0044] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the present application.

[0045] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0046] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0047] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0048] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.

[0049] like Figure 1As shown, the system architecture 100 may include a terminal device 110, a network 120 and a server 130. The terminal device 110 may include various electronic devices such as smart phones, tablet computers, laptops, desktop computers, smart speakers, smart wearable devices, smart vehicle-mounted devices, and smart payment terminals. The server 130 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The network 120 may be a communication medium of various connection types that can provide a communication link between the terminal device 110 and the server 130, such as a wired communication link or a wireless communication link.

[0050] According to the implementation requirements, the system architecture in the embodiment of the present application can have any number of terminal devices, networks and servers. For example, the server 130 can be a server group composed of multiple server devices. In addition, the technical solution provided in the embodiment of the present application can be applied to the terminal device 110, can also be applied to the server 130, or can be implemented by the terminal device 110 and the server 130 together, and the present application does not make any special restrictions on this.

[0051] The following is a detailed description of the technical solutions such as the data query method, data query device, computer-readable medium, electronic device, and computer program product provided by the present application in conjunction with specific implementation methods.

[0052] Figure 2 A flowchart of a data query method in one embodiment of the present application is shown. The data query method can be performed by Figure 1 The terminal device or server shown in the figure can also be executed by Figure 1 The terminal device and the server shown in the figure jointly execute. The present application embodiment takes the data query method executed by the terminal device as an example to illustrate. Figure 2 As shown, the data query method may include the following steps S210 to S230.

[0053] S210: Parse the data query request to obtain query conditions, where the query conditions include one or more of a subject, an object, and a predicate, where the predicate is used to represent a logical relationship between the subject and the object.

[0054] S220: Determine the target data partition in the graph database according to the query conditions, the graph database includes a primary data partition obtained by regional division according to the closeness relationship between nodes, and the primary data partition includes a secondary data partition obtained by regional division according to the logical relationship between nodes.

[0055] S230: Retrieve data query results matching the query condition in the target data partition.

[0056] The embodiment of the present application intelligently parses data query requests and extracts key query conditions, including subject, object, and predicate, to accurately capture the logical relationship of the query. Then, the solution uses the partition structure of the graph database to first identify the first-level data partition based on node density, and then further refine it to the second-level data partition based on logical relationships, so as to efficiently locate the target data. The embodiment of the present application not only improves the accuracy and efficiency of the query, but also optimizes the query performance by reducing the data retrieval scope, and finally achieves the rapid and accurate retrieval of results that match the query conditions.

[0057] In one embodiment of the present application, the graph database stores data in the form of Resource Description Framework (RDF).

[0058] RDF is a standard model for describing resources on the Internet, which constitutes one of the basic technologies of the semantic web. The basic unit of RDF information is a triple, also called a statement, which consists of the following three parts (hereinafter referred to as a triple).

[0059] Subject: The resource or entity being described.

[0060] Predicate: describes the attributes or relationships of the subject.

[0061] Object: The attribute value of a subject or another resource that has a relationship with the subject.

[0062] For example, a triple can be represented as "Harry Potter, author, JK Rowling", where Harry Potter is the subject, the author is the predicate, and JK Rowling is the object.

[0063] In order to store, manage and query the ever-increasing amount of RDF data, many RDF storage and query engines have emerged. Apache Spark is a popular big data computing engine, and one research direction is to use it to query RDF data efficiently. The platform uses in-memory data structures that can be used to store RDF data, provide higher efficiency, and support effective distributed query answering.

[0064] A simple and direct way to use Spark for RDF query is to store all triples in RDF as a single large file in HDFS, load it into memory when querying, and search for the corresponding answer in memory. However, using this method, a large amount of data needs to be accessed to retrieve the required information, resulting in poor query performance.

[0065] In response to this problem, some RDF horizontal and vertical partitioning schemes have appeared in the related technologies of this application, attempting to minimize the amount of data to be accessed during RDF queries. However, these schemes are relatively simple horizontal or vertical partitioning schemes, such as hash partitioning based on the subject in the triple. This technology can work well in the following scenarios: queries with multiple relationships radiating outward from a central entity, without accessing data across multiple partitions. However, the performance is low in queries involving complex relationships between multiple subjects.

[0066] In view of the problems existing in the above related technologies, the embodiments of the present application can effectively divide RDF data, which can effectively put highly related data together, minimize the amount of data access during query, and maintain a balanced distribution. During query, according to the division information of RDF data, the general query statement is converted into a SQL statement that Spark can recognize, thereby improving the query performance.

[0067] As mentioned above, RDF is based on triples of the form of "subject, predicate, object". They record the relationship between the subject and the object through the predicate. An RDF dataset contains two types of information: classes and the relationship between them, and instances and the relationship between them.

[0068] Both types of information are represented by triples. For example, "teacher, teaching, student" means that the type "teacher" and the type "student" have a "teaching" relationship, which represents the relationship between classes. "Lao Wang, teaching, Xiao Li" means that the instance "Lao Wang" and the instance "Xiao Li" have a "teaching" relationship, which represents the relationship between instances. Among them, the class is the generalization of the instance, and the instance is the concretization of the class, or the instance is derived from the class. We can say that the instance "Lao Wang" is derived from the type "teacher".

[0069] Classes and the relationship information between classes form the RDF Schema Graph, where the nodes of the schema graph are classes and the edges are the relationships between classes. Instances and the relationship information between instances form the RDF Instance Graph, where the nodes of the instance graph are instances and the edges are the relationships between instances.

[0070] The purpose of URI design is to provide unique, globally recognizable identifiers for resources on the Internet. These resources can be web pages, documents, images, videos, and any content that can be accessed through the Internet, or they can be abstract concepts, entities, or relationships. In the triple structure of RDF, URI can appear in the position of subject (subject, s), predicate (predicate, p), or object (object, o). RDF uses URI to uniquely refer to an instance, relationship, or type. Continuing with the above example, "teacher, teaching, student", "Lao Wang, teaching, Xiao Li", will all be uniquely identified by URI.

[0071] In the data query method provided in the embodiment of the present application, the RDF data set can be abstracted into two interrelated graphs, namely the pattern graph and the instance graph. The embodiment of the present application will first use a certain algorithm to select the k most important pattern nodes from the pattern graph as core nodes, each core node corresponds to a primary data partition, and then according to the dependency algorithm, the remaining nodes are assigned to the core nodes they mainly depend on.

[0072] Additionally, the algorithm attempts to balance the data distribution across all partitions. This approach essentially attempts to keep commonly queried nodes together while maintaining a balanced data distribution.

[0073] Subsequently, based on the above partitioning method, a secondary partitioning scheme was implemented to split the instances in the primary data partition into secondary data partitions to further reduce the data access for query answering.

[0074] In order to improve the query efficiency, some key indexes are designed. Finally, a query execution module is provided, which accepts SPARQL queries and converts them into spark sql using the generated indexes and data statistics, and then sends them to spark for execution.

[0075] Figure 3 The schematic diagram of the principle framework of the data query method in the embodiment of the present application is shown. Figure 3 As shown, the input of the embodiment of the present application is an RDF dataset, which is divided into different primary data partitions and secondary data partitions, and then these data partitions are stored separately on HDFS. After that, the solution accepts a SPARQL query, and according to the previous partition information, converts the SPARQL into spark sql that can be recognized by spark, and gives it to spark for query. HDFS (Hadoop Distributed File System) is a distributed file system, part of the Apache Hadoop project, used to store and process large amounts of data on commercial hardware clusters. HDFS is designed for large-scale data processing.

[0076] Continue to refer Figure 3 As shown, when storing RDF data, the data partitioner module is responsible for dividing the RDF data set into multiple first-level data partitions partition 1, partition 2, ... On this basis, each first-level data partition can be further divided into multiple second-level data partitions VP 1, VP2, ... At the same time, index information Indexes corresponding to the data partition structure can be constructed, which may specifically include the first-level data partition index SchemaIndex, the second-level data partition index VPIndex, and the instance index InstanceIndex. After the partitioning is completed, it is stored in the HDFS system in the manner of saving one HDFS file for each second-level data partition.

[0077] When performing RDF data query, the partition query module partition finder is responsible for parsing the query statement query, and calculating the primary data partition and secondary data partition where the data to be queried is located based on the query statement query and index information. The query statement translation module sql translator constructs the search statement sql based on the query statement query and the calculated data partition information, and then sends it to the big data computing engine Spark for execution, and finally outputs the query result answer.

[0078] Figure 4 A flow chart of a method for dividing a primary data partition into regions in one embodiment of the present application is shown. Figure 4 As shown, based on the above embodiments, the region division method of the primary data partition may include the following steps S410 to S440.

[0079] S410: Obtain a complete pattern graph stored in a graph database, where nodes in the complete pattern graph are used to represent subjects or objects, and edges in the complete pattern graph are used to represent predicates.

[0080] S420: traverse the complete pattern graph to obtain the closeness relationship between nodes. The closeness relationship includes an importance parameter and a dependency parameter. The importance parameter is used to indicate the importance of each node in the complete pattern graph, and the dependency parameter is used to indicate the degree of dependency between any two nodes.

[0081] S430: Selecting a preset number of core nodes from the complete pattern graph according to the importance parameter, where the core nodes are a plurality of nodes with the highest importance parameters in the complete pattern graph.

[0082] S440: Allocate each node in the complete pattern graph to a primary data partition centered on the core node according to the dependency parameters.

[0083] Taking the RDF pattern graph as an example, the most important K nodes are selected from the RDF pattern graph as the core nodes of each partition (one core node corresponds to one partition) according to the importance parameter, and the remaining nodes are assigned to the core nodes they mainly depend on according to the dependency parameter to construct the partition. In simple terms, a core node plus a group of nodes that mainly depend on it constitute a partition.

[0084] In an RDF graph dataset, the characteristics of a core node are that, first, this node has a higher core degree than other nodes in the RDF pattern graph, and second, the number of instances corresponding to this node is greater than the number of instances of other nodes.

[0085] In one embodiment of the present application, the complete pattern graph is a directed graph, and the method for determining the importance parameter includes: determining the shortest path between two nodes according to the direction of the predicate to obtain the shortest path set of the complete pattern graph; counting the distribution ratio of each node in the shortest path set to obtain the coreness parameter of the node; determining the importance parameter of the node based on the coreness parameter and the number of instances of the node.

[0086] In an application scenario of an embodiment of the present application, the core degree of a node in an RDF pattern graph can be quantified by calculating how many of the shortest paths between all other node pairs pass through the node. In other words, the higher the degree of participation of a node in the shortest paths between other nodes in the RDF pattern graph, the more important it is.

[0087] Figure 5 A schematic diagram of an RDF schema diagram in an application scenario of an embodiment of the present application is shown. Figure 5 As shown, it is obvious through experience that node D is the most important. The quantitative basis is that in the RDF pattern graph, except for node D, many of the shortest paths between other nodes pass through node D, while for other nodes, the shortest paths passing through them are much less.

[0088] In one embodiment of the present application, determining the shortest path between two nodes according to the direction of the predicate to obtain the shortest path set of the complete pattern graph may include: traversing the complete pattern graph to obtain a node pair consisting of any two nodes; determining all node pair paths with the node pair as the starting point and the end point according to the direction of the predicate; and comparing the lengths of the node pair paths to obtain the shortest path set of the node pairs.

[0089] For example, let all the first-level nodes in the pattern graph be topLevelNodes. The first level means that no other nodes point to it. Figure 5 Node A, Node B and Node C in are the first-layer nodes.

[0090] Traverse topLevelNodes and set the current node to currentNode.

[0091] Traverse all nodes in the next level of the current node, set as nextLevelNode, for each nextLevelNode, form a separate path path with the upper level node. For example, the upper level is node 1, and the lower level is node 2 and node 3, thus forming node pair path 12 and node pair path 13, and adding path path to the path set pathList.

[0092] Set nextLevelNode as currentNode and repeat the above steps until there is no node in the next level. At this time, the path set pathList contains all possible paths from all nodes in the first level to all nodes in the last level.

[0093] Traverse all node pairs and search for paths that contain both nodes from the path set pathList. In these paths, copy the two nodes and the nodes between them as a node pair path pairPath and add them to the node pair path set pairPathList. Each node pair corresponds to a node pair path set pairPathList.

[0094] The node pair path set pairPathList is deduplicated, and the size of the deduplicated set is all the paths between the two nodes. Then the shortest path is obtained by comparison and set as the shortest path set shortestPathList.

[0095] In one embodiment of the present application, counting the distribution ratio of each node in the shortest path set to obtain the coreness parameter of the node may further include: for a selected node pair, counting the number of all shortest paths in the shortest path set to obtain the first path number; for a selected node, counting the number of shortest paths in the shortest path set that include the selected node to obtain the second path number; obtaining the ratio of the second path number to the first path number to obtain the distribution ratio of the selected node in the shortest path set of the selected node pair; accumulating the distribution ratios corresponding to each node and each node pair to obtain the coreness parameter of the node.

[0096] In an application scenario of an embodiment of the present application, for any node n in the RDF pattern graph, its coreness can be expressed as:

[0097]

[0098] Among them, β st represents the total number of shortest paths from node s to node t, βst (n) is the number of these shortest paths that pass through node n.

[0099] β st The number of paths in the shortest path set shortestPathList can be obtained by counting the number of paths in the shortest path set shortestPathList according to the above embodiment.

[0100] β st The method for determining (n) may include, for example, creating a hash table throughPathsMap, where the key is the node and the value is the number of paths in shortestPathList that pass through the node. Traverse shortestPathList, set the currently traversed shortestPath, and for each node that the path passes through, obtain the value corresponding to the node from throughPathsMap. If the value does not exist, set it to 1. If the value exists, add 1 to the value. For any node n, obtain the value corresponding to the node from throughPathsMap. If the value exists, it means the number of paths β that pass through n among all the shortest paths between the node pairs. st (n). If value does not exist, then β st (n) is 0.

[0101] In one embodiment of the present application, determining the importance parameter of a node based on the coreness parameter and the number of instances of the node may include: normalizing the coreness parameter of the node to obtain the normalized coreness of the node; normalizing the number of instances of the node to obtain the normalized number of instances of the node; and adding the normalized coreness and the normalized number of instances to obtain the importance parameter of the node.

[0102] When a node is a necessary node for more shortest paths, its coreness is higher. However, the coreness is affected by the number of nodes and the number of connections between nodes in the RDF graph. In order to make fair comparisons in graphs of different sizes and densities and facilitate subsequent calculations, the coreness value needs to be converted to a unified scale.

[0103] For example, in the embodiment of the present application, the coreness parameter may be normalized according to the following formula:

[0104]

[0105] Where CLevel(n) represents the original value of the core level of node n; N represents the set of all nodes in the RDF pattern graph; Indicates the minimum value of CLevel among all pattern nodes; Represents the maximum value of CLevel among all pattern nodes; the denominator represents the maximum range of CLevel values, and the numerator represents the difference between the CLevel value of the current node n and the minimum CLevel value among all nodes. The unified result can be scaled to between 0 and 1.

[0106] In this way, the interference of node scale and node density can be ignored. Even if the original core degree values ​​calculated on different RDF sets vary greatly, the core degree of each node can be reasonably evaluated on a unified scale in the end.

[0107] Similar to the coreness parameter, the embodiment of the present application can normalize the number of node instances according to the following formula:

[0108]

[0109] Where Entity(n) represents the number of instances corresponding to the pattern node n; N represents the set of all nodes in the RDF pattern graph; Indicates the minimum number of instances of all pattern nodes; max(Entity(u)) indicates the maximum number of instances of all pattern nodes.

[0110] On this basis, the importance parameter of the pattern node can be expressed as follows:

[0111] IM(n)=normalCLevel(n)+normalEntity(n)

[0112] According to the importance formula, the importance of each pattern node is calculated, the k nodes with the highest importance are selected (k can be specified by the user), and k first-level partitions are divided: p1, p2, p3...p k .

[0113] In one embodiment of the present application, a method for determining a dependency parameter includes: for a selected node pair, obtaining the length of the shortest path of the selected node pair; determining the dependency parameter of the node pair based on the importance parameters of each node on the shortest path and the length of the shortest path, the dependency parameter is positively correlated with the importance parameter of the starting point on the shortest path, negatively correlated with the importance parameters of other nodes on the shortest path except the starting point, and negatively correlated with the length of the shortest path.

[0114] In one embodiment of the present application, the dependency parameter is also negatively correlated with the closeness parameter of two adjacent nodes on the shortest path, and the closeness parameter is used to weight the importance parameters of other nodes on the shortest path except the starting point.

[0115] In an application scenario of the embodiment of the present application, the two nodes n can be calculated according to the following formula: k and n m The dependency parameter DEP(n k , n m ).

[0116]

[0117] Among them, minPath(n k , n m ) represents n k With n m The shortest path of the two nodes, the longer the path, the worse the dependency between the two nodes. The square is used to magnify the path length, which means that the longer the path, the faster the dependency value will drop. This design helps the algorithm give priority to nodes connected by shorter paths when partitioning data, so that relevant data can be located and accessed faster during query processing; IM(n k ) indicates the importance of the starting node; It represents the cumulative decay of importance from the starting node to the ending node. The importance decays along the path from the starting node to the ending node. It decays once after each intermediate node. The decay ratio is equal to the closeness parameter between the current node and the next node. i ))The higher the value, the greater the contribution to the final dependency, but this contribution is negative. The more important it is, the more likely it is to disperse the direct dependency from the starting point to the end point. The closeness between the intermediate node and the next node contributes positively to the final dependency. The greater the closeness, the easier it is to be associated with the query, and the more likely it is to be assigned to the same partition; It indicates the importance of the end node relative to the start node.

[0118] Finally, the dependency between two nodes is the importance of the end node (relative to the start node) divided by the square of the distance between the two nodes. As the distance between the two nodes increases, the dependency between the two nodes decreases rapidly. The higher the importance of the end node, the higher the dependency between the two nodes, and vice versa.

[0119] In one embodiment of the present application, a method for determining a closeness parameter may include: obtaining the number of instances of a starting node and the number of instances of an ending node in two adjacent nodes; and determining the closeness parameters of two adjacent nodes based on the number of instances of the starting node, the number of instances of the ending node, and the total number of nodes in the complete pattern graph.

[0120] In one embodiment of the present application, when the number of instances of the end node is zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph; when the number of instances of the end node is not zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph, positively correlated with the number of instances of the starting node, and negatively correlated with the number of instances of the end node.

[0121] For example, suppose two adjacent nodes are n k and n m , they are connected by predicate p, n k The number of instances of Entity(n k ), through the predicates p and n k Connected n m The number of instances of Entity(p(n k , n m )), the total number of nodes in the RDF pattern graph is size(S).

[0122] If Entity(p(n k , n m )) is 0, then n connected by predicate p k and n m The tightness is:

[0123]

[0124] Ensure that a meaningful value can be calculated even in the absence of an instance. At this time, the density depends on the number of nodes in the entire pattern graph. The larger the pattern graph (the more nodes), the lower the density. This is easy to understand. The larger the graph, the more complex the relationships, and the less dense a single relationship is.

[0125] If Entity(p(n k , n m )) is not 0, then n connected by predicate p k and n m The tightness is:

[0126]

[0127] Figure 6 The corresponding relationship between the pattern diagram and the number of instances in an application scenario of the embodiment of the present application is shown. Figure 6 For example, if you want to find a person, the fastest way is to find the people contained in Building X, because the search space is only 30, and the search speed is the fastest. If you search through Country A, the search space is 1.3 billion, and the search speed is very slow. From this, we can determine that the inclusion relationship between buildings and people is the closest, and the inclusion relationship between countries and people is the least close. Therefore, it can be concluded that The larger the value of kThrough the predicates p and n m The closer the relationship is

[0128] Based on the dependencies of the top K nodes with the highest importance and the remaining nodes, as well as the upper limit value of the pattern nodes in each partition, determine which partition the remaining nodes should be assigned to

[0129] Since the data distribution may be significantly affected by the characteristics of the dataset. For example, if most of the instance data is only associated with a few pattern nodes, it may lead to data skew, that is, a large amount of data accumulates in a single partition. Therefore, set an upper limit on the number of pattern nodes for each partition: limit_size = the total number of nodes in the pattern graph is size(S) / the number of partitions k. limit_size can ensure the balanced distribution of data among partitions

[0130] Traverse the nodes in the pattern graph other than the top K core nodes with the highest importance, denoted as n i , calculate its dependencies with each core node; select the first-level data partition corresponding to the core node with the greatest dependency as the candidate partition, denoted as p i , denote the core node of this partition as Denote p i The existing number of pattern nodes of p is size(p). If size(p) < limit_size, then add the pattern node n i , and all the pattern nodes on the path between it and to the current partition p i . In other words, if a pattern node is assigned to a certain partition, then all the intermediate pattern nodes logically connecting this node to the partition core node will also be included in this partition. Ensure that during query, those pattern nodes and their related data entities with close logical connections can be stored together, improving the data cohesion and reducing the cross-partition data retrieval during query, thereby improving the query efficiency

[0131] Add the pattern node n i , and all the instances corresponding to the pattern nodes on the path between it and to the current partition. If size(p) >= limit_size, then select the partition with the second-largest dependency as the candidate partition, and repeat the above step until a partition with sufficient space and a high enough dependency between its core node and the current node is selected

[0132] After the first-level partition is completed, check the pattern nodes in each partition. If this node has an attribute association with the nodes in other partitions, data copying needs to be performed

[0133] Figure 7The first-level data partitioning result of the pattern diagram in an application scenario of the embodiment of the present application is shown. Figure 7 As shown, a schema graph is divided into three first-level data partitions.

[0134] It can be seen that the F node of partition1 and the G node of partition2, the D node of partition1 and the P node of partition3, the L node of partition2 and the Q node of partition3 are all associated with each other. At this time, the data of the associated nodes should be copied and placed in the associated partitions.

[0135] Figure 8 The embodiment of the present application shows the partitioning result of copying data in a primary data partition in an application scenario. Figure 8 As shown, for attribute-related data, there are copies in two related primary data partitions, which can ensure the integrity of the data and the effectiveness of the query.

[0136] On the basis of completing the primary data partition, the primary data partition can be divided into regions according to the logical relationship represented by the predicate to form a secondary data partition.

[0137] For example, the embodiment of the present application can split the triples in each primary data partition into multiple secondary data partitions according to the predicate. Figure 8 The first-level data partition partition1 in contains predicates p1, p2, p3, and p8, and is eventually split into four second-level data partitions p1, p2, p3, and p8.

[0138] Each predicate corresponds to a secondary data partition, generating a separate file and storing it on HDFS. This design allows only the secondary data partitions related to the query predicate to be loaded during query, greatly reducing the amount of data access.

[0139] If an instance is connected to other nodes in different partitions through different predicates, then there will be a copy of this instance in each secondary data partition to ensure that the information of the instance can be directly obtained when querying these partitions without cross-partition search. The complete information that may have been obtained by cross-partition query can now be obtained through the copy in the local partition, reducing the amount of data that must be accessed when querying. Therefore, although there is some redundancy in data storage, the efficiency of data access is greatly improved.

[0140] Continue to refer Figure 3 As shown, in the data storage part, in order to speed up the query calculation process, some indexes need to be established so that the necessary sub-partitions can be directly located during query execution.

[0141] Since the above partitioning method is based on the schema of the RDF dataset, we can first establish a mapping relationship between the schema node and its corresponding primary data partition, which is called the schema index. The index structure is as follows:

[0142] Schema Node->Partition ID

[0143] Person 1

[0144] Professor 1

[0145] Publication 2

[0146] Secondly, the primary data partition is split into multiple secondary data partitions, and a mapping relationship between the mode node and the corresponding secondary data partition is established, which is called the secondary data partition index (VP Index). The index structure is as follows:

[0147] Schema Node->Vertical Partitions

[0148] Person advisor,affiliatedOf,subClassOf

[0149] Professor advisor,subClassOf

[0150] Publication publicationResearch,orgPublication,subClassOf

[0151] Finally, a mapping relationship between the instance and its corresponding pattern node is established, which is called the instance index. The index structure is as follows:

[0152] Instance->Schema Node

[0153] Rosa Person

[0154] Robert Person

[0155] Doc WangProfessor

[0156] Book x Publication

[0157] Paper y Publication

[0158] The above three types of indexes are stored in HDFS.

[0159] Continue to refer Figure 3 As shown, in the data query part, data query can be initiated based on SPARQL.

[0160] SPARQL is a standard RDF graph matching language recommended by W3C. It matches data in RDF graphs by defining a graph pattern. This pattern consists of triples, each of which contains a subject, a predicate, and an object.

[0161] For example, SELECT * WHERE {xiaowang advisor? professors} means to query xiaowang’s advisors; another example, SELECT * WHERE {laoliteacherOf? students} means to query laoli’s students.

[0162] The query processing module accepts SPARQL input by the user, parses it, automatically converts it into Sql, and then calls the SparkSql interface for query.

[0163] Variables refer to placeholders or undetermined specific values ​​used in SPARQL queries. They start with a question mark (?). For example, xiaowang advisor? professors in the "professors" column is a variable that represents the advisor to be found. In SPARQL queries, these variables represent the actual data items that the queryer wants to match or retrieve, but the specific values ​​are unknown when the query is defined. When this query is executed, the SPARQL engine will try to match these variables with the actual nodes in the RDF graph to find all triple combinations that meet the conditions.

[0164] Create a query partition information structure to record all primary data partitions and secondary data partitions that need to be accessed during query execution.

[0165] Extract all triples (one or more) in the query, and set the variables of known types and their corresponding types as variableSchemaMap. Since the query may involve multiple triples, multiple triples may have the same variables. VariableSchemaMap is used to facilitate these variables to share the same Schema.

[0166] Traverse all triples and set a single triple to be p(n i.1 ,n i.2 ), the goal is to find the primary data partition and secondary data partition corresponding to the triple.

[0167] Assume ni.1 ,n i.2 The instance in is nodeInstances;

[0168] Extract i.1 ,n i.2 The variables in are set to variables;

[0169] Assume n i.1 ,n i.2 The corresponding schema node is schemaNodes;

[0170] If p == rdf:type, then n i.2 is a schema node, add it to schemaNodes. i.1 Belongs to variables, then its corresponding schema is n i.2 ,Will <n i.1 、n i.2 >Add variableSchemaMap. The rdf:type attribute in RDF indicates that a resource belongs to a certain type, for example: <live>rdf:type <book>Indicates that "To Live" is an instance of the Book class.

[0171] If p == rdf:type is not satisfied, the composition of the triple can be divided into the following cases.

[0172] ? xadvisor y, predicate and object are known, subject is unknown (advisor is an example of a predicate).

[0173] x advisor? y, subject and predicate are known, object is unknown.

[0174] x? ? y, subject is known, predicate and object are unknown.

[0175] ? x? y, object is known, subject and predicate are unknown.

[0176] x? y, subject and object are known, but predicate is unknown.

[0177] In the above cases, at least one of x and y is an instance (or both are). If x is not a variable, x is searched by the instance index and added to schemaNodes. If y is not a variable, y is searched by the instance index and its corresponding schema is added to schemaNodes.

[0178] There is also a situation where multiple triples are extracted from the query, for example, two triples, the first triple is: ?xrdf:type y, and the second triple is: ?x advisor? y.

[0179] There are the same variable ?x in two triples. The schemaode corresponding to the ?x variable can be determined through the first triple. According to the above logic, <?xy> will be added to the variableSchemaMap. When processing the second triple, the corresponding schema can be directly obtained from the variableSchemaMap and added to the schemaNodes.

[0180] Traverse schemaNodes, find the first-level partition ID corresponding to the schema node through the schema index, and add it to the partitions variable.

[0181] schemaNodes may contain multiple schema nodes, and partitions may contain multiple partitions. For example, in the above x?y, x and y are divided into different first-level partitions. In this case, according to the partitioning method, the instance data of x and y can be found in both partitions. At this time, the smallest partition is selected (based on the number of instances contained in the partition, the larger the number), as the final partition selected, because the smaller the partition, the higher the query efficiency.

[0182] If the predicate is a variable, the corresponding secondary data partition (one or more) is searched in the secondary data partition index (VP Index) through the schema node in schemaNodes; if the predicate is not a variable, it itself is the secondary data partition.

[0183] For example, the query statement is as follows:

[0184] SELECT ? X WHERE {

[0185] ? X rdfs:type Publication.

[0186] ? X publicationAuthor AssistantProfessor0.

[0187] }

[0188] It contains two triples. The first triple indicates that the type of the object to be queried (?X) is a publication (Publication), and the second triple indicates that the author of the publication (?X) is AssistantProfessor0. In general, we want to query publications whose author is AssistantProfessor0.

[0189] The first triple satisfies the condition p == rdf:type, so Publication is a schemanode, and is added to schemaNodes. i.1 It belongs to the condition of variables. Therefore, the schema corresponding to the variable X is Publication. Add <? X, Publication> to variableSchemaMap. Find the primary data partition corresponding to Publication (assuming it is p1) through the primary data partition index (Schema Index). Since the predicate is determined (rdf:type), it can be directly concluded that the corresponding secondary data partition is type.

[0190] In the second triple, AssistantProfessor0 is an instance. The SchemaNode corresponding to the AssistantProfessor0 instance can be found through the instance index and added to schemaNodes. According to the primary data partition (assuming it is p2) corresponding to the Schema Node corresponding to AssistantProfessor0, it can be directly concluded that the corresponding secondary data partition is publicationAuthor.

[0191] To generate the final SQL query, each triple in the query is converted into a SQL subquery. The table name in each subquery FROM clause corresponds to a vertical subpartition table based on the predicate. The parsed primary and secondary data partition information is used to locate this table. Then, if the query involves multiple triples and contains common variables, all subqueries are joined using their common variables.

[0192] Traverse each triple in the query and convert it into a SQL subquery based on the triple information and its parsed partition information.

[0193] The construction method of the SQL from clause includes: determining the table to be queried according to the confirmed primary data partition and secondary data partition. For example, the primary partition corresponding to the first triple is p1, and the vertical partition is type, so the from clause is: from p1_type. The primary partition corresponding to the second triple is p2, and the vertical partition is publicationAuthor, so the from clause is: from p2_publicationAuthor.

[0194] The construction method of the SQL select clause includes: the ? x in the triple is composed of two parts, one is ? and the other is x, where ? represents the object to be queried and x represents the alias. The position of ? x in the triple determines which of subject / predicate / object the object to be queried is. For example, in the first triple, ? X represents that the object to be queried is subject and the alias is X, so the select clause is: select subject as X. In the second triple, ? X represents that the object to be queried is subject and the alias is X, so the select clause is: select subject as X.

[0195] The construction method of SQL's where clause includes: the subject and object in the triple, if not a variable, can be used as a query condition. For example, in the first triple, Publication corresponds to object, which can be converted to where object = "Publication". In the second triple, AssistantProfessor0 corresponds to object, which can be converted to where object = 'AssistantProfessor0'.

[0196] Concatenate the constructed from clause, select clause, and where clause into a complete select statement. For example, the select statement corresponding to the first triple is: SELECT subject AS X FROM p1_type WHERE object = "Publication". The select statement corresponding to the second triple is: SELECT subject AS X FROM p2_publicationAuthor WHERE object = "AssistantProfessor0"

[0197] The above is the case where only one secondary data partition is parsed out of the triple. If the predicate in the triple is a variable, multiple secondary data partitions may be parsed out. In this case, each secondary data partition successfully parses a sub-sql, and then multiple sqls are combined to form the final sql.

[0198] For example, if the triple is ? X ? AssistantProfessor0, the corresponding Schema Node is found in the instance index according to AssistantProfessor0, the corresponding first-level data partition p1 is found in the first-level data partition index SchemaIndex, and the corresponding second-level data partitions vp1 and vp2 are found in the second-level data partition index.

[0199] The final parsed SQL is:

[0200] select subject from p1_vp1where object='AssistantProfessor0'

[0201] union

[0202] select subject from p1_vp2where object='AssistantProfessor0'.

[0203] If a query contains multiple triples, there must be common variables between these multiple triples, and the subqueries corresponding to the multiple triples are associated with each other. Multiple subqueries should be associated based on the common variables to form a complete query. The common variables correspond to a field in each of the multiple triples, and these multiple fields serve as the association conditions for multiple select statements. When associating, give each subselect statement an alias in the order of tab0, tab1, tab2...tabn.

[0204] For example, if two triples have a common variable X, the resulting SQL is as follows:

[0205] SELECT tab1.X AS X FROM

[0206] (SELECT subject AS X FROM p1_type

[0207] WHERE object='Publication')AS tab0,

[0208] (SELECT subject AS X FROM p2_publicationAuthor

[0209] WHERE object='AssistantProfessor0')AS tab1

[0210] WHERE tab0.X=tab1.X

[0211] Finally, the generated SQL can be handed over to Spark for execution.

[0212] Based on the introduction of the above application scenarios, it can be seen that the embodiment of the present application can effectively divide RDF data, which can effectively put highly related data together, minimize the amount of data access during query, and maintain a balanced distribution. During query, according to the partition information of RDF data, the general query statement is converted into a SQL statement that can be recognized by Spark, thereby improving the query performance.

[0213] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0214] The following introduces an apparatus embodiment of the present application, which can be used to execute the data query method in the above-mentioned embodiment of the present application.

[0215] Fig. 9 The structure block diagram of the data query device provided by the embodiment of the present application is schematically shown. Fig. 9 As shown, the data query device 900 includes:

[0216] The parsing module 910 is configured to parse the data query request to obtain a query condition, wherein the query condition includes one or more of a subject, an object, and a predicate, wherein the predicate is used to represent a logical relationship between the subject and the object;

[0217] Partitioning module 920, configured to determine a target data partition in a graph database according to the query condition, the graph database including a primary data partition obtained by region division according to a closeness relationship between nodes, the primary data partition including a secondary data partition obtained by region division according to a logical relationship between nodes;

[0218] The retrieval module 930 is configured to retrieve data query results matching the query condition in the target data partition.

[0219] In some embodiments of the present application, based on the above technical solution, the partitioning module 920 may further include:

[0220] A pattern graph acquisition module is configured to acquire a complete pattern graph stored in a graph database, wherein nodes in the complete pattern graph are used to represent subjects or objects, and edges in the complete pattern graph are used to represent predicates;

[0221] A closeness determination module is configured to traverse the complete pattern graph to obtain a closeness relationship between nodes, wherein the closeness relationship includes an importance parameter and a dependency parameter, wherein the importance parameter is used to indicate the importance of each node in the complete pattern graph, and the dependency parameter is used to indicate the degree of dependency between any two nodes;

[0222] A core node selection module is configured to select a preset number of core nodes from the complete pattern graph according to the importance parameter, wherein the core nodes are a plurality of nodes having the highest importance parameters in the complete pattern graph;

[0223] The node allocation module is configured to allocate each node in the complete pattern graph to a primary data partition centered on the core node according to the dependency parameters.

[0224] In some embodiments of the present application, based on the above technical solution, the complete pattern graph is a directed graph, and the compactness determination module includes:

[0225] A shortest path set acquisition module is configured to determine the shortest path between two nodes according to the direction of the predicate to obtain the shortest path set of the complete pattern graph;

[0226] A distribution ratio statistics module is configured to count the distribution ratio of each node in the shortest path set to obtain a coreness parameter of the node;

[0227] The importance parameter determination module is configured to determine the importance parameter of the node according to the coreness parameter and the number of instances of the node.

[0228] In some embodiments of the present application, based on the above technical solution, the shortest path set acquisition module is further configured to: traverse the complete pattern graph to obtain a node pair consisting of any two nodes; determine all node pair paths with the node pair as the starting point and end point according to the direction of the predicate; compare the lengths of the node pair paths to obtain the shortest path set of the node pairs.

[0229] In some embodiments of the present application, based on the above technical solution, the distribution ratio statistics module is further configured as follows: for a selected node pair, counting the number of all shortest paths in the shortest path set to obtain the first path number; for a selected node, counting the number of shortest paths in the shortest path set that contains the selected node to obtain the second path number; obtaining the ratio of the second path number to the first path number to obtain the distribution ratio of the selected node in the shortest path set of the selected node pair; accumulating the distribution ratios corresponding to each node and each node pair to obtain the coreness parameter of the node.

[0230] In some embodiments of the present application, based on the above technical solution, the distribution ratio statistics module is further configured to: normalize the coreness parameter of the node to obtain the normalized coreness of the node; normalize the number of instances of the node to obtain the normalized number of instances of the node; add the normalized coreness and the normalized number of instances to obtain the importance parameter of the node.

[0231] In some embodiments of the present application, based on the above technical solution, the compactness determination module includes:

[0232] A length acquisition module is configured to acquire, for a selected node pair, the length of the shortest path of the selected node pair;

[0233] A dependency parameter determination module is configured to determine the dependency parameters of the node pair based on the importance parameters of each node on the shortest path and the length of the shortest path, wherein the dependency parameters are positively correlated with the importance parameters of the starting point on the shortest path, negatively correlated with the importance parameters of other nodes on the shortest path except the starting point, and negatively correlated with the length of the shortest path.

[0234] In some embodiments of the present application, based on the above technical solution, the dependency parameter is also negatively correlated with the closeness parameter of the two adjacent nodes on the shortest path, and the closeness parameter is used to weight the importance parameters of other nodes on the shortest path except the starting point.

[0235] In some embodiments of the present application, based on the above technical solution, the method for determining the closeness parameter includes: obtaining the number of instances of the starting node and the number of instances of the ending node in two adjacent nodes; determining the closeness parameter of the two adjacent nodes based on the number of instances of the starting node, the number of instances of the ending node and the total number of nodes in the complete pattern graph.

[0236] In some embodiments of the present application, based on the above technical solution, when the number of instances of the end node is zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph; when the number of instances of the end node is not zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph, positively correlated with the number of instances of the starting node, and negatively correlated with the number of instances of the end node.

[0237] The specific details of the data query device provided in each embodiment of the present application have been described in detail in the corresponding method embodiment and will not be repeated here.

[0238] Fig.10 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.

[0239] It should be noted that Fig.10 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0240] like Fig.10 As shown, the computer system 1000 includes a central processing unit 1001 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 1002 (ROM) or the program loaded from the storage part 1008 to the random access memory 1003 (RAM). Various programs and data required for system operation are also stored in the random access memory 1003. The central processing unit 1001, the read-only memory 1002 and the random access memory 1003 are connected to each other through a bus 1004. The input / output interface 1005 (Input / Output interface, i.e., I / O interface) is also connected to the bus 1004.

[0241] The following components are connected to the input / output interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0242] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processor 1001, various functions defined in the system of the present application are executed.

[0243] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0244] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0245] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0246] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0247] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.

[0248] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.< / book>

Claims

1. A data query method, It is characterized in that include: Parsing the data query request to obtain a query condition, wherein the query condition includes one or more of a subject, an object, and a predicate, wherein the predicate is used to represent a logical relationship between the subject and the object; Determine a target data partition in a graph database according to the query condition, the graph database including a primary data partition obtained by regional division according to a closeness relationship between nodes, and the primary data partition includes a secondary data partition obtained by regional division according to a logical relationship between nodes; Retrieve data query results matching the query condition in the target data partition.

2. The data query method according to claim 1, It is characterized in that The area division method of the first-level data partition includes: Obtain a complete pattern graph stored in a graph database, wherein nodes in the complete pattern graph are used to represent subjects or objects, and edges in the complete pattern graph are used to represent predicates; Traversing the complete pattern graph to obtain a closeness relationship between nodes, wherein the closeness relationship includes an importance parameter and a dependency parameter, wherein the importance parameter is used to indicate the importance of each node in the complete pattern graph, and the dependency parameter is used to indicate the degree of dependency between any two nodes; Selecting a preset number of core nodes from the complete pattern graph according to the importance parameter, the core nodes being a plurality of nodes having the highest importance parameters in the complete pattern graph; Each node in the complete pattern graph is allocated to a primary data partition centered on the core node according to the dependency parameters.

3. The data query method according to claim 2, It is characterized in that The complete pattern graph is a directed graph, and the method for determining the importance parameter includes: Determine the shortest path between two nodes according to the direction of the predicate, and obtain the shortest path set of the complete pattern graph; Counting the distribution ratio of each node in the shortest path set to obtain the coreness parameter of the node; An importance parameter of the node is determined according to the coreness parameter and the number of instances of the node.

4. The data query method according to claim 3, It is characterized in that Determine the shortest path between two nodes according to the direction of the predicate, and obtain the shortest path set of the complete pattern graph, including: Traversing the complete pattern graph to obtain a node pair consisting of any two nodes; Determine all node pair paths with the node pair as the starting point and the end point according to the direction of the predicate; The lengths of the paths of the node pairs are compared to obtain a set of shortest paths of the node pairs.

5. The data query method according to claim 3, It is characterized in that Counting the distribution ratio of each node in the shortest path set to obtain the coreness parameter of the node includes: For a selected node pair, counting the number of all shortest paths in the shortest path set to obtain a first path number; For a selected node, counting the number of shortest paths in the shortest path set that include the selected node to obtain a second path number; Obtaining a ratio of the number of the second paths to the number of the first paths, and obtaining a distribution ratio of the selected node in a set of shortest paths of the selected node pairs; The distribution ratios corresponding to each node and each node pair are accumulated to obtain the coreness parameter of the node.

6. The data query method according to claim 5, It is characterized in that Determining the importance parameter of the node according to the coreness parameter and the number of instances of the node includes: Normalizing the coreness parameter of the node to obtain the normalized coreness of the node; Normalizing the number of instances of the node to obtain a normalized number of instances of the node; The normalized coreness and the normalized number of instances are added together to obtain the importance parameter of the node.

7. The data query method according to any one of claims 2 to 6, It is characterized in that The method for determining the dependency parameter includes: For a selected node pair, obtaining the length of the shortest path of the selected node pair; The dependency parameters of the node pair are determined according to the importance parameters of each node on the shortest path and the length of the shortest path, wherein the dependency parameters are positively correlated with the importance parameters of the starting point on the shortest path, negatively correlated with the importance parameters of other nodes on the shortest path except the starting point, and negatively correlated with the length of the shortest path.

8. The data query method according to claim 7, It is characterized in that The dependency parameter is also negatively correlated with the closeness parameters of two adjacent nodes on the shortest path, and the closeness parameter is used to perform weighted processing on the importance parameters of other nodes on the shortest path except the starting point.

9. The data query method according to claim 8, It is characterized in that The method for determining the compactness parameter includes: Get the instance number of the start node and the instance number of the end node in two adjacent nodes; The closeness parameter of the two adjacent nodes is determined according to the number of instances of the starting node, the number of instances of the ending node, and the total number of nodes of the complete pattern graph.

10. The data query method according to claim 9, It is characterized in that When the number of instances of the end node is zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph; when the number of instances of the end node is not zero, the closeness parameter is negatively correlated with the total number of nodes in the complete pattern graph, positively correlated with the number of instances of the starting node, and negatively correlated with the number of instances of the end node.

Citation Information

Patent Citations

  • Method for optimizing data management strategy based on data blood relationship

    CN117667352A

  • Industrial production element optimization method based on multi-dimensional database configuration

    CN118227716A

  • Optimal deallocation of instructions from a unified pick queue

    US20110078697A1

  • Adaptive range filters for range and point queries

    US20140195542A1

  • Systems and / or methods for interactive exploration of dependencies in streaming data

    US20170177546A1