Data storage method, device, electronic device, storage medium and program product

By storing the index identification and attribute information of graph data separately, and storing the index identification of nodes using the index storage space, the problem of low efficiency of graph data query is solved, and more efficient graph data query and storage is achieved.

CN118606426BActive Publication Date: 2025-03-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410225654.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-28
Publication Date
2025-03-25
Estimated Expiration
2044-02-28

AI Technical Summary

Technical Problem

In the prior art, the query efficiency of graph data is low because the topology structure and attribute values ​​of the graph are bound together, which requires the encoding and attribute values ​​of all related points and edges to be obtained at the same time when obtaining data, which increases the data volume and query time.

Method used

By storing the index identification and attribute information of the graph data separately in the index storage space and the attribute storage space, the index storage space is used to store the index identification of the node according to the connection relationship of the node in the graph data, so that the graph attribute information is not read during querying, but directly traversing the connection relationship of the node to query and traverse on the graph, reducing the call of data resources.

Benefits of technology

It improves the query efficiency of graph data, reduces the call of data resources during querying, avoids resource waste, and enhances the flexibility of graph data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606426B_ABST
    Figure CN118606426B_ABST
Patent Text Reader

Abstract

The present application discloses a data storage method, device, electronic device, storage medium and program product, which can be applied to various scenarios such as cloud technology, artificial intelligence, smart transportation, and assisted driving; the present application obtains graph data and graph data storage space, the graph data includes nodes and edges connected between nodes, and the graph data storage space includes index storage space and attribute storage space; the attribute information of the graph data is stored in the attribute storage space, and the attribute information includes node attribute information and edge attribute information; for any node, the index identifier of the node is determined according to the directional information corresponding to the node; according to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space, so as to store the graph data in the graph data storage space. In the present application, the call of data resources in the query process can be reduced, resource waste can be avoided, and the query efficiency of graph data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data storage method, device, electronic device, storage medium and program product. Background Art

[0002] In graph data related technologies, key-value storage is often used to implement graph data storage, where the key is the relationship code of the point / edge, and the value is the attribute of the point or edge. For example, the user will encode according to the primary key or built-in primary key. For example, the key code of point A is 0001, and the key code of point B is 0002, then the code of the edge from A to B is: 00010002. The attribute of A is PA, the attribute of B is PB, and the attribute of the edge from A to B is PE. Then, the key-value pairs such as 0001:PA, 0002:PB, and 00010002:PE are stored in the graph data. This storage method binds the topological structure of the graph and the corresponding attribute values ​​together. When querying any point and edge of the graph data, the codes and attribute values ​​of all related points and edges will be obtained at the same time, which will result in a large amount of data obtained, resulting in low query efficiency. Summary of the invention

[0003] The embodiments of the present application provide a data storage method, device, electronic device, storage medium and program product, which can improve the query efficiency of graph data.

[0004] An embodiment of the present application provides a data storage method, including: obtaining graph data and a graph data storage space, the graph data including nodes and edges connecting the nodes, the graph data storage space including an index storage space and an attribute storage space; storing attribute information of the graph data in the attribute storage space, the attribute information including node attribute information and edge attribute information; for any of the nodes, determining an index identifier of the node according to directional information corresponding to the node, the directional information corresponding to the node being used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information being the edge attribute information of the adjacent edge connected to the node; storing the index identifier of the node in the index storage space according to the connection relationship of the nodes in the graph data, so as to store the graph data in the graph data space.

[0005] An embodiment of the present application also provides a data storage device, including: an acquisition unit, used to acquire graph data and a graph data storage space, the graph data including nodes and edges connecting the nodes, the graph data storage space including an index storage space and an attribute storage space; an attribute storage unit, used to store attribute information of the graph data in the attribute storage space, the attribute information including node attribute information and edge attribute information; an index determination unit, used to determine, for any of the nodes, the index identifier of the node according to the directional information corresponding to the node, the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; an index storage unit, used to store the index identifier of the node in the index storage space according to the connection relationship of the nodes in the graph data, so as to store the graph data in the graph data storage space.

[0006] In some embodiments, the attribute storage unit includes a first attribute storage sub-unit and a second attribute storage sub-unit, including: the first attribute storage sub-unit is used to determine the adjacent edges to be stored connected to the node to be stored according to the connection relationship of the node to be stored in the graph data, and the node to be stored is any node in the graph data; the second attribute storage sub-unit is used to store the node attribute information of the node to be stored and the edge attribute information of the adjacent edges to be stored in adjacent positions in the attribute storage space.

[0007] In some implementations, the attribute storage unit further includes a third attribute storage subunit, including: the third attribute storage subunit is used to determine the to-be-stored node from the graph data according to the numbering sequence of the nodes in the graph data.

[0008] In some embodiments, the data storage device also includes a directionality unit, including: the directionality unit, used to use the storage location of the node attribute information in the attribute storage space and the storage location of the edge attribute information in the attribute storage space as the directionality information of the node corresponding to the node attribute information and the directionality information of the edge corresponding to the edge attribute information, respectively.

[0009] In some embodiments, the index determination unit includes a first index determination subunit, a second index determination subunit and a third index determination subunit, including: the first index determination subunit is used to obtain the index number of the node for any of the nodes; the second index determination subunit is used to use the index number of the node as the key and the directionality information corresponding to the node as the value to construct a key-value pair corresponding to the node; the third index determination subunit is used to use the key-value pair corresponding to the node as the index identifier of the node.

[0010] In some embodiments, the data storage device also includes a designated index unit, including: the designated index unit is used to establish a designated node index for the index identifier of the node corresponding to the designated query information according to the designated query information, and the designated node index is used to determine the index identifier of the node corresponding to the designated query information.

[0011] In some embodiments, the index storage unit includes a first index storage sub-unit and a second index storage sub-unit, including: the first index storage sub-unit is used to create an index array according to the connection relationship of the nodes in the graph data, the index array is used to store the index identifiers of the nodes according to the connection relationship of the nodes, and the elements in the index array correspond to the nodes; the second index storage sub-unit is used to create an adjacent node table of the nodes corresponding to the elements in the index array, and the adjacent node table is used to store index information of adjacent nodes of the nodes corresponding to the elements.

[0012] In some embodiments, the data storage device also includes a deletion unit, including: the deletion unit is used to obtain a deletion instruction for any of the nodes; according to the deletion instruction, delete the index identifier of any of the nodes from the index storage space; return the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space; according to the directional information returned by the index storage space, delete from the attribute storage space the node attribute information and the adjacent edge attribute information pointed to by the directional information returned by the index storage space.

[0013] In some embodiments, the data storage device also includes a modification unit, including: the modification unit is used to obtain a modification instruction for attribute information to be modified, the attribute information to be modified is the attribute information of any node or any edge in the graph data; according to the modification instruction and the index identifier stored in the index storage space, the directional information corresponding to the attribute information to be modified is obtained; the obtained directional information is returned to the attribute storage space; according to the directional information returned by the index storage space, the attribute information to be modified is queried from the attribute storage space; according to the modification instruction, the queried attribute information to be modified is updated to obtain the updated attribute information; according to the updated attribute information, the updated directional information is determined, and the updated directional information is used to point to the updated attribute information; according to the updated directional information, the index identifier of the node corresponding to the attribute information to be modified stored in the index storage space is updated.

[0014] In some embodiments, the updating of the to-be-modified attribute information queried according to the modification instruction to obtain the updated attribute information includes: marking the to-be-modified attribute information in the attribute storage space as a deleted state; generating updated attribute information according to the modification instruction and the to-be-modified attribute information; and determining updated directional information according to the updated attribute information includes: storing the updated attribute information at the end of the attribute storage space to determine the updated directional information.

[0015] In some embodiments, the data storage device also includes a query unit, including: the query unit is used to obtain an attribute information query instruction, the attribute information query instruction is used to query at least one of the node attribute information of at least one of the nodes of the graph data and the edge attribute information of at least one of the edges; according to the attribute information query instruction and the index identifier stored in the index storage space, the directional information corresponding to the attribute information query instruction is obtained; according to the obtained directional information, the attribute information pointed to by the directional information corresponding to the attribute information query instruction is obtained from the attribute storage space.

[0016] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores multiple instructions; the processor loads instructions from the memory to execute the steps in any data storage method provided in the embodiment of the present application.

[0017] An embodiment of the present application also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the data storage methods provided in the embodiments of the present application.

[0018] An embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in any data storage method provided in the embodiment of the present application.

[0019] The embodiments of the present application can obtain graph data and graph data storage space, wherein the graph data includes nodes and edges connected between the nodes, and the graph data storage space includes an index storage space and an attribute storage space; the attribute information of the graph data is stored in the attribute storage space, and the attribute information includes node attribute information and edge attribute information; for any of the nodes, the index identifier of the node is determined according to the directional information corresponding to the node, and the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; according to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data space.

[0020] In the present application, the index identifier and attribute information of the graph data are stored separately in the index storage space and the attribute storage space to achieve separate management of the graph index and the graph attribute, so as to improve the storage flexibility and query efficiency of the graph data. Among them, the index storage space stores the index identifier of the node corresponding to the attribute information according to the connection relationship of the nodes in the graph data. So that when querying the graph data, it is not necessary to read the graph attribute information, but to directly traverse the connection relationship of the nodes in the index storage space to query and traverse the graph. After determining the relevant data to be queried, the corresponding attribute information is obtained from the attribute storage space according to the directional information corresponding to the index identifier of the queried node, so as to reduce the call of data resources during the query process, avoid resource waste, and improve the query efficiency of the graph data. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1a It is a scenario schematic diagram of the data storage method provided in an embodiment of the present application;

[0023] Figure 1b It is a flowchart of a data storage method provided in an embodiment of the present application;

[0024] Figure 1c This is a schematic diagram of image data storage provided by an embodiment of the present application;

[0025] Figure 1d is a schematic diagram of graph data provided by an embodiment of the present application;

[0026] Figure 1e is a schematic diagram of storing data in a storage space provided in an embodiment of the present application;

[0027] Figure 2a is a flow chart of a data storage method provided by another embodiment of the present application;

[0028] Figure 2b It is a flowchart of the deletion operation provided in the embodiment of the present application;

[0029] Figure 2c It is a flowchart of the modification operation provided in the embodiment of the present application;

[0030] Figure 2d It is a flowchart of the query operation provided by the embodiment of the present application;

[0031] Figure 3 is a schematic diagram of the structure of a data storage device provided in an embodiment of the present application;

[0032] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0034] Embodiments of the present application provide a data storage method, device, electronic device, storage medium, and program product.

[0035] Among them, the data storage device can be specifically integrated in an electronic device, and the electronic device can be a terminal, server and other equipment. Among them, the terminal includes but is not limited to smart phones, tablet computers, laptops, desktop computers, smart speakers, smart watches, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc.; the server can 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 terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application is not limited here. The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.

[0036] In some embodiments, the data storage device may also be integrated into multiple electronic devices. For example, the data storage device may be integrated into multiple servers, and the data storage method of the present application may be implemented by multiple servers.

[0037] In some embodiments, the server may also be implemented in the form of a terminal.

[0038] For example, refer to Figure 1a The data storage method is integrated in a server, and the server can obtain graph data and graph data storage space, wherein the graph data includes nodes and edges connecting the nodes, and the graph data storage space includes an index storage space and an attribute storage space; the attribute information of the graph data is stored in the attribute storage space, and the attribute information includes node attribute information and edge attribute information; for any node, the index identifier of the node is determined according to the directional information corresponding to the node, and the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; according to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data space.

[0039] 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.

[0040] The following are detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. It is understood that in the specific implementation of the present application, entities such as user accounts, characters, places, events, and relationships between entities and other user-related data are involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0041] Artificial Intelligence (AI) is a technology that uses digital computers to simulate human perception of the environment, acquire knowledge, and use knowledge. This technology can enable machines to have functions similar to human perception, reasoning, and decision-making. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, smart transportation, and other major directions.

[0042] Among them, natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0043] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, Internet of Vehicles, smart transportation, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0044] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.

[0045] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0046] Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.

[0047] At present, the storage method of the storage system is: create a logical volume, and when creating a logical volume, allocate physical storage space for each logical volume. The physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume, that is, stores the data on the file system. The file system divides the data into many parts, each of which is an object. The object contains not only data but also additional information such as data identification (ID, ID entity). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.

[0048] The process of the storage system allocating physical storage space to a logical volume is as follows: based on the estimated capacity of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of independent redundant disk arrays (RAID, Redundant Array of Independent Disks), the physical storage space is pre-divided into stripes. A logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.

[0049] In this embodiment, a data storage method is provided, such as Figure 1b As shown, the specific process of the data storage method can be as follows:

[0050] 110. Obtain graph data and graph data storage space, where the graph data storage space includes index storage space and attribute storage space.

[0051] Graph data includes nodes and edges between nodes. Among them, graph data refers to data represented in the form of a graph. A graph consists of nodes (or vertices) and edges, each edge connecting two nodes, indicating a certain relationship between them. The data storage method provided in the embodiment of the present application can be applied to various data storage scenarios, so that the graph data can be data of various scenarios. For example, graph data can store data of various application scenarios such as applications, knowledge graphs, and transportation networks, wherein the graph data can represent entities with nodes, and the edges represent the relationship between entities. Specifically, the graph data can be the data of an application, in which the nodes represent the user accounts of the application, and the edges represent the relationship between user accounts; or, the graph data can be the data of a transportation network, in which the nodes represent the transportation nodes in the transportation network, and the edges represent the relationship between transportation nodes; or, the data storage method provided in the embodiment of the present application can be applied to the field of artificial intelligence, such as by organizing entities, relationships, and attributes into graph data of a knowledge graph, in which the nodes represent entities such as people, places, events, and the edges represent the relationship between entities, and the graph data can assist in tasks of various artificial intelligence scenarios such as natural language processing, such as question-answering systems, information extraction, and semantic search.

[0052] Among them, storage space refers to a space used to store data, which can be a logical space that can store and access data, and the space can be defined and implemented by software or data structure. For example, the storage space can be a combination of one or more data structures that can store and access data, such as file text storage, tree data structure, hash structure, linked list, and adjacency list. Graph data storage space refers to a space used to store graph data. In an embodiment of the present application, the graph data storage space includes two sub-storage spaces, an index storage space and an attribute storage space. The index storage space refers to a storage space used to store index identifiers of nodes in the graph data, and the attribute storage space refers to a storage space used to store attribute information in the graph data. The index storage space and the attribute storage space can be deployed on a single computer or server, or they can be deployed in cloud storage or distributed storage.

[0053] For example, Figure 1c The diagram of graph data storage shown in the figure can obtain graph data including nodes such as V1, V2, V3, V4 and V5, and obtain graph data storage space for storing the graph data. In the initial state, the data stored in the graph data storage space is empty.

[0054] 120. Store the attribute information of the graph data in the attribute storage space, where the attribute information includes node attribute information and edge attribute information.

[0055] Among them, node attribute information and edge attribute information are divided into the attribute information of nodes and the attribute information of edges of graph data. In graph data, attribute information refers to information describing the attributes of nodes or edges. The attribute information may be different in different graph data. For example, node attribute information may include the name or label, features, etc. of the node representation entity, and edge attribute information may include the features of the edge, such as the label, establishment time, length, weight or strength of the edge.

[0056] Usually, graph data is stored in a key-value storage format, where the key is the relationship code of the node / edge, and the value is the attribute of the node or edge (i.e., attribute information). Therefore, in the embodiment of the present application, the attribute information (i.e., value) of each node and each edge can be directly obtained from the key-value of the graph data, and the attribute information can be stored in the attribute storage space according to the order of the nodes and edges in the graph data. For example, Figure 1c The graph data storage schematic diagram shown can store attribute information such as attribute 1, attribute 2, attribute 3, attribute 4, etc. in the graph data in sequence in the attribute storage space.

[0057] In some implementations, the index storage space can be implemented as a stand-alone full storage deployment, and the attribute storage space device can be deployed and implemented in the form of cloud storage or distributed storage. Among them, stand-alone full storage refers to a storage method in which the entire data set is stored on a single computer or server. In stand-alone full storage, all data is stored on the same physical device. In this way, placing the topological structure of the graph on a stand-alone full storage can provide efficient graph traversal and navigation capabilities, and using cloud storage or distributed storage for attribute information can fully utilize the advantages of distributed storage systems, such as high scalability, high fault tolerance, and high performance. This can support the storage and query requirements of large-scale data.

[0058] In some implementations, the attribute information of the graph data may be stored in the attribute storage space in the form of column storage. Column storage refers to organizing and storing data in columns rather than rows, so that the attribute information of the attribute storage space can be read on demand, and only the required column data is read, avoiding scanning of unnecessary columns, thereby improving the performance of data query.

[0059] In some implementations, in the attribute storage space, the attribute information of a node and its adjacent edges can be stored in adjacent locations, so that when the attributes of a node and its adjacent edges need to be obtained, these data can be obtained through a single load or read operation, thereby improving the efficiency of data reading. At the same time, for query operations that require obtaining both node and adjacent edge attribute information at the same time, the data can be directly read at adjacent locations, thereby avoiding jumpy data access and improving the query efficiency of graph data. Specifically, the attribute information of graph data is stored in the attribute storage space, including:

[0060] According to the connection relationship of the node to be stored in the graph data, determine the adjacent edge to be stored connected to the node to be stored, where the node to be stored is any node in the graph data;

[0061] The node attribute information of the node to be stored and the edge attribute information of the adjacent edge to be stored are stored in adjacent positions in the attribute storage space.

[0062] Among them, the adjacent edges of a node refer to the edges connected to the node in the graph data.

[0063] For example, the nodes in the graph data can be used as nodes to be stored. For example, for any node V1 to be stored, it is connected to nodes V2 and V5 through edges L21 and L15 respectively. Therefore, the attribute information of the node V1 to be stored, the edge L21 and the edge L15 can be stored as {valueV1, valueL15, valueL21}, where value represents the attribute, so that the attribute information of the node V1 to be stored and the attribute information of its adjacent edges are stored in adjacent positions.

[0064] In some implementations, the graph data can be traversed in order according to the numbering order of the nodes in the graph data to determine the nodes to be stored and avoid missing nodes. At the same time, sequential traversal can simplify the data processing process, making the operation of the nodes more orderly and clear, while improving the processing efficiency and reducing the error probability. Specifically, the attribute information of the graph data is stored in the attribute storage space, and also includes:

[0065] According to the numbering order of the nodes in the graph data, the nodes to be stored are determined from the graph data.

[0066] In the graph data, each node has a unique identifier or number. Therefore, in the embodiment of the present application, the nodes in the graph data can be traversed according to the order of the identifiers or numbers of the nodes in the graph data, so that the traversed nodes are used as the nodes to be stored. Figure 1dThe graph data shown in FIG. 1 includes nodes V1, V2, V3, V4, and V5, which are connected by edges L21, L13, L15, L42, L45, and L53. According to the numbering sequence, V1 can be first used as the node to be stored, and the attribute information of the node V1 to be stored, the edge L21, the edge L13, and the edge L15 can be stored in the attribute storage space to obtain {valueV1, valueL13, valueL15, valueL21}. Then take V2 as the node to be stored, and continue to store the attribute information of the node V2 to be stored, edge L21, and edge L42 into the attribute storage space, and obtain {valueV1, valueL13, valueL15, valueL21; valueV2, valueL21; valueL42}. Similarly, continue to take V3, V4 and V5 as the nodes to be stored in sequence, and finally the attribute storage space stores {valueV1, valueL13, valueL15, valueL21; valueV2, valueL21; valueL42; valueV3, valueL13; valueL53; valueV4, valueL42; valueL45; valueV5, valueL53; valueL45}.

[0067] Since in the graph data, a node may be connected to other nodes through one or more adjacent edges. Therefore, in some embodiments, in order to efficiently store and search for data of a node and its adjacent edges, for a node to be stored with multiple adjacent edges, the edge attribute information of the multiple adjacent edges of the node to be stored can be stored in the attribute storage space according to the numbering order and / or edge direction in the graph data, so as to conveniently and quickly access the attribute information of the edge. For example, the attribute information of the node V1 to be stored in the graph data and its adjacent edges L21, L13, and L15 can be stored in the attribute storage space as: valueV1, valueL13, valueL15, valueL21, and the node V5 to be stored and its adjacent L45 and edge L53 can be stored in the attribute storage space as: valueV5, valueL53; valueL45 according to the storage order of storing the edge attribute information of the outgoing edge first and then storing the edge attribute information of the incoming edge, and according to the storage order from small to large in the numbering order.

[0068] In some embodiments, the node attribute information and edge attribute information in the graph data can be stored in the form of logs. Specifically, the attribute storage space includes a log-type storage space (i.e., a log file). Log-Structured Storage is a data storage format that records data in the form of logs and appends the data sequentially to a log file. Compared with the traditional random writing method, log-structured storage has the characteristics of sequential writing and high write throughput. For example, in an embodiment of the present application, each attribute information to be stored can be treated as a log record and sorted in a log file according to a timestamp (or other ascending number) to store all node attribute information and edge attribute information of the graph data in a log file in the form of logs.

[0069] 130. For any node, determine the index identifier of the node according to the directional information corresponding to the node.

[0070] The directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node. Among them, the directional information is information pointing to the attribute information stored in the attribute storage space. For example, the directional information may include a pointer, a reference, or other information with directional representation. The index identifier refers to an identifier or a symbol used for indexing, which is used to quickly find or access corresponding data in the index data structure.

[0071] In some embodiments, the directional information may include a pointer. For example, when storing the attribute information of the nodes and edges of the graph data in the attribute storage space, after storing the node attribute information and the adjacent edge attribute information of each node to be stored in the attribute storage space, a pointer 1 pointing to the node attribute information of the node to be stored can be generated, and a pointer 2 pointing to the adjacent edge attribute information of the node to be stored can be generated. The pointer 1 and the pointer 2 can be used as index identifiers of the nodes. It should be noted that when the node to be stored has multiple adjacent edges, that is, multiple adjacent edge attributes, a corresponding pointer can be generated for each adjacent edge attribute information, or a pointer can be generated for multiple adjacent edge attributes.

[0072] In some embodiments, a directional information may be generated for the attribute information of the adjacent edge of the node to be stored that is an outgoing edge, and a directional information may be generated for the attribute information of the adjacent edge of the node to be stored that is an incoming edge, that is, the directional information corresponding to the node includes directional information pointing to the node attribute information of the node to be stored (hereinafter referred to as node directional information), directional information pointing to the attribute information of the adjacent edge of the node to be stored that is an outgoing edge (hereinafter referred to as outgoing edge directional information), and directional information pointing to the attribute information of the adjacent edge of the node to be stored that is an incoming edge (hereinafter referred to as incoming edge directional information). For example, for the node V1 to be stored and its adjacent edges L21, L13, and L15, a node pointer 1 pointing to the attribute information of the node V1 (that is, the node directional information), an outgoing edge pointer 2 pointing to the attribute information of the outgoing edges L13 and L15 (that is, the outgoing edge directional information), and an incoming edge pointer 3 pointing to the attribute information of the incoming edge L21 (that is, the incoming edge directional information) may be generated.

[0073] In some implementations, the storage location of the attribute information can be used as directional information, so that when the attribute information of a node or edge needs to be obtained, the corresponding storage location can be directly found according to the directional information to quickly locate the required attribute data, avoiding the overhead of searching in the entire attribute storage space and improving the query efficiency of graph data. At the same time, the storage location of the attribute information is used as directional information. When the attribute information of a node or edge needs to be updated or modified, only the corresponding storage location needs to be updated without affecting other attribute data, so as to improve data consistency and reduce the possibility of data redundancy and errors. Specifically, for any node, before determining the index identifier of the node according to the directional information corresponding to the node, it also includes:

[0074] The storage position of the node attribute information in the attribute storage space and the storage position of the edge attribute information in the attribute storage space are respectively used as the directional information of the node corresponding to the node attribute information and the directional information of the edge corresponding to the edge attribute information.

[0075] The storage location in the attribute storage space can be represented by a unique identifier or address. This identifier can be a number, a string, or other forms of data, which is used to indicate the specific location of the attribute in the storage space, so that the corresponding attribute information stored in the attribute storage space can be accurately located and accessed according to the storage location. In different systems and scenarios, the storage location may be represented differently.

[0076] For example, for the node V1 to be stored and its adjacent edges L21, L13, and L15, the storage address of the node attribute information of the node V1 in the attribute storage space and the storage address of the edge attribute information of the edges L21, L13, and L15 in the attribute storage space can be used as a pointer to the node V1 and a pointer to the adjacent edges of the node V1, respectively. In practical applications, the storage address of the edge attribute information of the outgoing edges L13 and L15 in the attribute storage space can also be used as an outgoing edge pointer pointing to the attribute information of the outgoing edges L13 and L15, and the storage address of the edge attribute information of the incoming edge L21 in the attribute storage space can be used as an incoming edge pointer pointing to the attribute information of the outgoing edge L21.

[0077] In some embodiments, when storing node attribute information and edge attribute information in graph data in log form, the storage position of the attribute information in the attribute storage space can be represented by an offset value, thereby reducing the storage space occupied by the directional information and improving the storage efficiency of the graph data. In addition, when reading the attribute information in the attribute storage space according to the directional information, the attribute information at the corresponding position can be directly accessed according to the offset value to improve the efficiency of reading the attribute information of the graph data from the attribute storage space. For example, the offset value is used to represent the offset of the attribute information from the starting data. If the attribute storage space can be in the form of a log file, the storage position of the attribute information in the log file can be represented by the byte offset (i.e., the offset value) from the storage position of the attribute information in the log file to the beginning of the file.

[0078] In some implementations, the index number of the node can be used as the key and the directional information of the node can be used as the value to construct a key-value pair corresponding to the node, so as to associate the index number with the node information, facilitate the management of the node and subsequently quickly locate the corresponding node information according to the index number. Specifically, for any node, the index identifier of the node is determined according to the directional information corresponding to the node, including:

[0079] For any node, get the node index number;

[0080] Use the node index number as the key and the node's corresponding directional information as the value to construct the key-value pair corresponding to the node;

[0081] The key-value pair corresponding to the node is used as the index identifier of the node.

[0082] Among them, the index number of the node refers to the number that identifies the node in the graph data. The index number of the node is used to uniquely identify each node in the graph to facilitate fast node location and access. The index number of the node can be a unique ID generated for the graph data node, or it can be a unique attribute value of the node. For example, the index number of the node of the graph data can be represented by an integer or a string, such as numbering the nodes of the graph data in sequence as 0, 1, 2, 3, etc., or numbering the nodes of the graph data in sequence as 0001, 0002, 0003, etc. In an embodiment of the present application, the index number of the node can be the number of the node in the graph data, or it can be other custom numbers. In order to save memory, the index number of the node can be represented by an 8-byte value.

[0083] For example, the index number of the node in the graph data can be used as a key to point to a pointer with a value and an out-edge and an in-edge pointer. Specifically, taking the node V1 to be stored as an example, after the node attribute information of the node V1 to be stored and the edge attribute information of the adjacent edges L21, L13, and L15 are stored in the attribute storage space, the attribute storage space can return the node attribute information of the node V1, such as node pointer 1, and return the storage location of the edge attribute information of the adjacent edges L21, L13, and L15 in the attribute storage space, such as out-edge pointer 2 and in-edge pointer 3. The number 0001 of the node V1 can be used as the key, and the node pointer 1, out-edge pointer 2, and in-edge pointer 3 corresponding to the node V1 can be used as the value to construct a key-value pair: Key: "0001", Value: (NodePointer: 1, OutEdgePointer: 2, InEdgePointer: 3), where NodePointer: 1, OutEdgePointer: 2, InEdgePointer: 3 represent node pointer 1, out-edge pointer 2, and in-edge pointer 3, respectively. The constructed key-value pair can be used as the index identifier of node V1. Similarly, when traversing the nodes in the graph data and taking the traversed nodes as the nodes to be stored, the key-value pairs corresponding to each node in the graph data can be synchronously constructed as the index identifier of the node to obtain the index identifiers of all nodes in the graph data.

[0084] In some embodiments, in addition to being able to manage and retrieve nodes in the index storage space in the form of key-value pairs, a secondary index can also be established in the index storage space according to specified query information. The secondary index refers to an additional index established outside the primary index (Primary Index). The primary index is usually built based on the primary key (Primary Key), and the secondary index can be built based on any column or combination of columns in the table. By creating an index for the non-primary key column in the table, the query condition of the secondary index (i.e., the specified query information) can be directly located in the index storage space to the node that meets the query condition without traversing the entire index. At the same time, the secondary index can establish multiple indexes based on different query information, thereby supporting diverse query requirements and improving the flexibility and applicability of the query. Specifically, the data storage method also includes:

[0085] According to the specified query information, a specified node index is established for the index identifier of the node corresponding to the specified query information, and the specified node index is used to determine the index identifier of the node corresponding to the specified query information.

[0086] The specified query information is information specified for querying a node, and the specified query information is related to the node. The specified query information may be information such as a query type or specific query content.

[0087] For example, the specified query information may include the type of directional information, such as outgoing edge directional information or incoming edge directional information, that is, an index relationship between the type of directional information and the node containing the type of directional information in the key-value pair (that is, a specified node index) may be established, so that the key (that is, index number) of all nodes containing directional information of the corresponding type may be directly queried from the index relationship according to the type of directional information, so as to obtain the directional information in the index identifier of the node according to the key, so as to obtain the corresponding attribute information from the attribute storage space according to the directional information. Alternatively, the specified query information may include a keyword of a storage location, that is, an index relationship between the keyword and the node containing the keyword in the key-value pair (that is, a specified node index) may be established, so that the key (that is, index number) of all nodes containing the keyword may be directly queried from the index relationship according to the keyword, so as to obtain the directional information in the index identifier of the node according to the key, so as to obtain the corresponding attribute information from the attribute storage space according to the directional information. It should be noted that secondary indexes require additional storage space, and whenever the data in the index changes (such as insert, delete, or update operations), the index also needs to be updated accordingly, which increases the overhead of write operations. Therefore, when deciding whether to create a secondary index, you need to weigh the improvement in query performance and the increase in storage and write operation overhead.

[0088] For another example, the specified query information may include other information related to the node besides the directional information, such as the node name. For example, an index relationship between the node name of the node and the key (i.e., index number) of the node may be established (i.e., a specified node index), so that the key (i.e., index number) of the node corresponding to the node name may be directly queried from the index relationship according to the node name, so as to obtain the directional information in the index identifier of the node according to the key, and to obtain the corresponding attribute information from the attribute storage space according to the directional information.

[0089] 140. According to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data storage space.

[0090] For example, for each node in the graph data, after determining the index identifier of the node, the index identifier of the node can be stored in the index storage space according to the connection relationship of the nodes in the graph data and according to the graph topology structure (i.e., the connection relationship of the nodes in the graph data). Compared with the related art, in which graph data is stored by sampling key-value, the data storage method provided in the embodiment of the present application stores the index identifier and attribute information of the graph data separately in the index storage space and the attribute storage space to achieve separate management of the graph index and the graph attributes, so as to improve the storage flexibility and query efficiency of the graph data. When querying the graph data, it is possible not to read the graph attribute information, but to directly traverse the graph topology structure in the index storage space to perform queries and traversals on the graph, so as to reduce the call of data resources during the query process, avoid waste of resources, and improve the query efficiency of the graph data.

[0091] In some embodiments, the index storage space may include an adjacency list, and the index identifiers of nodes in the graph data may be stored through the adjacency list to store the topological structure of the graph data in the index storage space. The adjacency list uses an array and a linked list to represent the nodes and edges in the graph data. Each element of the array corresponds to a node, and the linked list is used to store other vertices adjacent to the node, so that a node can be quickly located through the array and its adjacent node information can be accessed, and the topological structure of the graph data is represented by the adjacency list.

[0092] In some implementations, the connection relationship of nodes in the graph data can be stored in an index array to store the topological structure of the graph data in the index storage space, so that the nodes in the graph data can be quickly located according to the topology of the graph data, thereby improving the efficiency of querying the graph data. At the same time, the adjacent nodes of each node are stored in an adjacent node table to quickly locate the adjacent nodes of the nodes in the graph data, thereby improving the query efficiency of the graph data. Specifically, according to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data storage space, including:

[0093] According to the connection relationship of the nodes in the graph data, an index array is created. The index array is used to store the index identifiers of the nodes according to the connection relationship of the nodes. The elements in the index array correspond to the nodes.

[0094] Create an adjacent node table of the node corresponding to the element in the index array, where the adjacent node table is used to store the index information of the adjacent nodes of the node corresponding to the element.

[0095] The adjacent nodes of the node corresponding to the element refer to the nodes in the graph data that are connected to the node corresponding to the element through edges. The adjacent node table can be a linked list or other table data structures.

[0096] The index information refers to information used for a node in an index storage space. For example, the index information may include a combination of one or more of an index number, an index identifier, and the like of a node.

[0097] For example, the index information may include the index number of the adjacent node. In an embodiment of the present application, the adjacency list uses an array to store the index identifier of the node, each element of the array corresponds to a node in the graph data, and the linked list is used to store the index identifiers of other nodes adjacent to the node. Each element of the array may contain the index identifier of its corresponding node, and each element of the array may also contain a pointer to a linked list pointing to its corresponding node, and the linked list stores the index number of the node connected to the node corresponding to the element. In this way, when querying graph data, the corresponding element (node) can be quickly located in the array of the adjacency list through information such as the index number to obtain the index identifier of the node. In addition, the linked list of the node corresponding to the element can also be accessed according to the pointer to the corresponding linked list contained in the element, so as to obtain the index number of the stored adjacent node from the linked list, so as to obtain the index identifier of the neighbor node according to the obtained index number. In this way, the embodiment of the present application directly maintains a pointer to its neighbor node for each node through the linked list in the adjacency list. Therefore, when querying the neighbor nodes of a node, it is not necessary to use an index, but can be directly accessed, realizing the data storage and query strategy of index-free adjacency. Therefore, through the data and linked list of the adjacency table, fast access to nodes and adjacent nodes in the graph data is realized, and the query efficiency of the graph data is improved.

[0098] Specifically, Figure 1eThe schematic diagram of storing data in the storage space shown in the figure, the attribute storage space stores attribute information in a columnar manner. The adjacency list is represented by a dot array in the index storage space. The dot array (Matrix) is a two-dimensional data structure, which is an array composed of rows and columns. Each element in the dot array corresponds to a node in the graph data, and the element stores the attribute pointer (i.e., node pointer), out-edge pointer, and in-edge pointer of the corresponding node. The index information in the linked list pointed to by each element in the dot array may include an out-edge array representing its out-edge information and an in-edge array representing its in-edge information. The out-edge array may include the index number of each node adjacent to the element corresponding to the node along the out-edge direction and the pointer of each adjacent edge (i.e., edge attribute pointer), and the in-edge array may include the index number of each node adjacent to the element corresponding to the node along the in-edge direction and the pointer of each adjacent edge (i.e., edge attribute pointer). The out-edge array and the in-edge array may also include one or more of meta information, locks, and the number of adjacent edges of the element corresponding to the node along the out-edge direction and the in-edge direction. Meta information is used to describe the attributes, characteristics, and other related information of the out-edge array and the in-edge array to help users understand and manage data. Locks are used to restrict threads accessing the array edge array to avoid race conditions and data inconsistency problems and improve the concurrent performance and stability of the program.

[0099] In some embodiments, the index information also includes an index identifier, so that the linked list of the node corresponding to the element can be accessed according to the pointer to the corresponding linked list contained in the element in the index array, so as to achieve fast access to the adjacent nodes of the node in the graph data by directly obtaining the index identifier of the stored adjacent node from the linked list, thereby improving the query efficiency of the graph data.

[0100] In some embodiments, the adjacency list of the index storage space may be stored in a tree structure. A tree structure refers to a nonlinear data structure in which each node has zero or more child nodes, and the child nodes contain their own child nodes, and so on, forming a hierarchical relationship. For example, the adjacency list may be stored in a tree structure, in which each node represents a node in the graph data, and the parent-child relationship between the nodes of the tree structure represents the connection relationship between the nodes in the graph data.

[0101] In an embodiment of the present application, the adjacency list of the index storage space can be stored by various tree structures, such as ordinary trees, B-trees / B+ trees, etc. In some embodiments, the adjacency list of the index storage space is stored in an append-only tree structure, such as an append-only B+ tree. The append-only tree structure means that only append operations can be performed, and deletion or update operations cannot be performed. Among them, the B+ tree is a self-balancing tree data structure that maintains data in order and allows search, sequential access, insertion and deletion operations with logarithmic time complexity. B+ trees are widely used in index structures of databases and file systems. Append-only tree is a data structure that only allows new data to be added at the end of the tree, but does not allow modification of existing data. This data structure is often used in scenarios where historical data needs to be retained or version control is required.

[0102] In some embodiments, the index identifier and attribute information of the graph data are stored separately in the index storage space and the attribute storage space. When deleting a node or modifying node-related information, it is necessary to delete or modify the related information in the index storage space and the attribute storage space at the same time to maintain the consistency of the graph data storage.

[0103] For example, in some implementations, after the graph data is stored in the graph data storage space, when any node in the graph data is to be deleted, the index identifier in the index storage space may be deleted first, and then the corresponding attribute information in the attribute storage space may be deleted according to the directional information corresponding to the index identifier, so as to avoid accessing unnecessary nodes and attribute information and improve the efficiency of graph data processing. Specifically, the data storage method further includes:

[0104] Get the delete instruction for any node;

[0105] According to the deletion instruction, the index identifier of any node is deleted from the index storage space;

[0106] Return the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space;

[0107] According to the directional information returned by the index storage space, the node attribute information and the adjacent edge attribute information pointed to by the directional information returned by the index storage space are deleted from the attribute storage space.

[0108] The delete instruction is an instruction for deleting a node in the graph data. The delete instruction may carry information including the index number of the node, the node name, etc. that can be used to locate the node in the index storage space.

[0109] For example, after the graph data is stored in the graph data storage space, when any node in the graph data, such as node V3, is to be deleted, the deletion operation corresponding to the deletion instruction can be decomposed into two serial operations. Specifically, first, according to the index number of node V3 carried by the deletion instruction, the element corresponding to node V3 is queried in the array of the adjacency list of the index storage space to delete the element and the linked list pointed to by the pointer in the element, and according to the index identifiers of the adjacent nodes in the linked list, the elements corresponding to these adjacent nodes (hereinafter referred to as adjacent elements) are searched in the array of the adjacency list, and the index identifier of node V3 is deleted from the linked list pointed to by these adjacent elements, so as to delete all index identifiers related to the node V3 to be deleted stored in the index space. At the same time, the directional information contained in the element of node V3 in the array of the adjacency list is returned to the attribute storage space, so that the attribute storage space searches for the corresponding node attribute information and edge attribute information according to the storage position corresponding to the directional information and deletes it, so as to delete all attribute information related to the node V3 to be deleted stored in the attribute storage space, so as to realize the deletion of the node storing the graph data in the graph data storage space.

[0110] In some embodiments, the operation of deleting the node attribute information and adjacent edge attribute information pointed to by the directional information returned by the index storage space from the attribute storage space can be performed by marking the node attribute information and adjacent edge attribute information pointed to by the directional information returned by the index storage space in the attribute storage space as a deleted state, so that the storage location of other attribute information in the attribute storage space remains unchanged, thereby eliminating the need to update the directional information of other nodes or edges, reducing system overhead and complexity.

[0111] For another example, in some implementations, after the graph data is stored in the graph data storage space, when any node in the graph data is to be modified, the attribute information of the node can be directly located and modified in the attribute storage space based on the directional information of the node determined by the index storage space, so as to avoid unnecessary traversal operations, simplify the modification process, and improve the modification efficiency. Then, based on the modified attribute information, the directional information is reversely updated to update the index identifier of the node stored in the index storage space, while ensuring the consistency of the node index identifier and the attribute information, invalid node traversal is avoided, and the efficiency of data modification is improved. At the same time, specifically, the data storage method also includes:

[0112] Obtain a modification instruction for the attribute information to be modified, where the attribute information to be modified is the attribute information of any node or any edge in the graph data;

[0113] According to the modification instruction and the index identifier stored in the index storage space, the directional information corresponding to the attribute information to be modified is obtained;

[0114] Return the acquired directional information to the attribute storage space;

[0115] According to the directional information returned by the index storage space, the attribute information to be modified is queried from the attribute storage space;

[0116] The queried attribute information to be modified is updated according to the modification instruction to obtain the updated attribute information;

[0117] Determine updated directivity information according to the updated attribute information, the updated directivity information being used to point to the updated attribute information;

[0118] According to the updated directionality information, the index identifier of the node corresponding to the attribute information to be modified stored in the index storage space is updated.

[0119] The attribute information to be modified refers to the node attribute information or edge attribute information to be modified in the graph data. It can be understood that when the attribute information to be modified is the node attribute information, the directional information corresponding to the attribute information to be modified is the node directional information of the corresponding node, and when the attribute information to be modified is the edge attribute information, the directional information corresponding to the attribute information to be modified is the edge directional information of the corresponding edge.

[0120] The modification instruction refers to an instruction for modifying the node attribute information or edge attribute information in the graph data. The modification instruction may carry information including the node index number, node name, etc. that can be used to locate the node in the index storage space.

[0121] For example, after the graph data is stored in the graph data storage space, when the information of any node in the graph data, such as node V3, is to be modified, the modification operation corresponding to the modification instruction can be decomposed into three serial operations. Specifically, first, according to the index number of node V3 carried by the modification instruction, the element corresponding to node V3 is queried in the array of the adjacency list of the index storage space, so as to return the node directivity information contained in the element to the attribute storage space, so that the attribute storage space queries the corresponding node attribute information according to the storage position corresponding to the node directivity information, and modifies the queried node attribute information according to the modification instruction to obtain the updated node attribute information, thereby modifying the attribute information stored in the attribute storage space according to the modification instruction. The storage position of the updated node attribute information in the attribute storage space is used as the updated directivity information, and the updated directivity information is returned to the index storage space, so that the index storage space updates the node directivity information contained in the element corresponding to node V3 to the updated directivity information. In this way, all the directivity information related to the attribute to be modified in the index storage space is modified according to the modification instruction to realize the modification of the graph data stored in the graph data storage space.

[0122] In some implementations, the attribute information to be modified in the attribute storage space can be marked as deleted, and the updated attribute information is stored at the end of the attribute storage space, so that the storage position of other attribute information in the attribute storage space remains unchanged, thereby not needing to update the directional information of other nodes or edges, reducing system overhead and complexity. Specifically, updating the queried attribute information to be modified according to the modification instruction to obtain the updated attribute information includes:

[0123] Mark the attribute information to be modified in the attribute storage space as deleted;

[0124] Generate updated attribute information according to the modification instruction and the attribute information to be modified;

[0125] According to the updated attribute information, the updated directivity information is determined, including:

[0126] The updated attribute information is stored at the end of the attribute storage space to determine the updated directivity information.

[0127] For example, after querying the attribute information to be modified from the attribute storage space, copy the attribute information to be modified to the memory, and mark the attribute information to be modified in the attribute storage space as deleted. The attribute storage space merges the copied attribute information to be modified with the value of the update content carried by the modification instruction to obtain the updated attribute information. The updated attribute information is added to the end of the attribute information stored in the attribute storage space, and the storage location of the updated attribute information in the attribute storage space is returned to the index storage space as the updated directional information. So that the index storage space updates the node directional information contained in the element corresponding to the node V3 to the updated directional information.

[0128] In some implementations, after the graph data is stored in the graph data storage space, when any node in the graph data is to be queried, the attribute information of the node can be directly located in the attribute storage space based on the directional information of the node determined by the index storage space, so as to avoid unnecessary traversal operations, simplify the modification process, and improve query efficiency. Specifically, the data storage method also includes:

[0129] Obtain an attribute information query instruction, where the attribute information query instruction is used to query at least one of node attribute information of at least one node of the graph data and edge attribute information of at least one edge;

[0130] According to the attribute information query instruction and the index identifier stored in the index storage space, obtaining the directional information corresponding to the attribute information query instruction;

[0131] According to the acquired directional information, the attribute information pointed to by the directional information corresponding to the attribute information query instruction is acquired from the attribute storage space.

[0132] In the embodiment of the present application, the attribute information query instruction can be used to query the node attribute information of any node in the graph data, the node attribute information of any node's adjacent nodes, or the edge attribute information of adjacent edges. The attribute information query instruction can carry information including the node index number, node name, etc. that can be used to locate the node in the index storage space.

[0133] For example, after storing the graph data in the graph data storage space, when you want to query the attribute information of any node in the graph data, such as node V3, you can query the element corresponding to node V3 in the array of the adjacency list of the index storage space according to the index number of node V3 carried by the attribute information query instruction, so as to return the node directionality information contained in the element to the attribute storage space, so that the attribute storage space queries the corresponding node attribute information according to the storage location corresponding to the node directionality information.

[0134] For another example, after storing the graph data in the graph data storage space, when you want to query the node attribute information of the adjacent nodes or the edge attribute information of the adjacent edges of any node in the graph data, such as node V3, you can query the element corresponding to node V3 in the array of the adjacency list of the index storage space according to the index number of node V3 carried by the attribute information query instruction, so as to return the node directionality information of the adjacent nodes of node V3 and the edge pointing information of the adjacent edges stored in the linked list pointed to by the element to the attribute storage space, so that the attribute storage space can query the node attribute information of the adjacent nodes or the edge attribute information of the adjacent edges of node V3 according to the storage location corresponding to the returned node directionality information and edge pointing information.

[0135] The data storage solution provided by the embodiment of the present application can be applied in various graph data storage scenarios. For example, taking the graph data of the knowledge graph as an example, the graph data and the graph data storage space are obtained, the graph data includes nodes and edges connected between the nodes, and the graph data storage space includes an index storage space and an attribute storage space; the attribute information of the graph data is stored in the attribute storage space, and the attribute information includes node attribute information and edge attribute information; for any node, according to the directional information corresponding to the node, the index identifier of the node is determined, and the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; according to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data storage space.

[0136] As can be seen from the above, the data storage method provided in the embodiment of the present application stores the index identifier and attribute information of the graph data separately in the index storage space and the attribute storage space to realize the separate management of the graph index and the graph attribute, so as to improve the storage flexibility and query efficiency of the graph data. Among them, the index storage space stores the index identifier of the node corresponding to the attribute information according to the connection relationship of the nodes in the graph data. So that when querying the graph data, it is possible to directly traverse the connection relationship of the nodes in the index storage space without reading the graph attribute information to perform queries and traversals on the graph. After determining the relevant data to be queried, the corresponding attribute information is obtained from the attribute storage space according to the directional information corresponding to the index identifier of the queried node, so as to reduce the call of data resources during the query process, avoid waste of resources, and improve the query efficiency of the graph data.

[0137] The method described in the above embodiment will be further described in detail below.

[0138] In this embodiment, the method of the embodiment of the present application will be described in detail.

[0139] like Figure 2a As shown, a specific process of a data storage method is as follows:

[0140] 210. Obtain graph data and graph data storage space, where the graph data includes nodes and edges connecting the nodes, and the graph data storage space includes index storage space and attribute storage space.

[0141] 220. Store the attribute information of the graph data in the attribute storage space, where the attribute information includes node attribute information and edge attribute information.

[0142] 230. For any node, determine the index identifier of the node according to the directional information corresponding to the node.

[0143] The directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node.

[0144] 240. According to the connection relationship of the nodes in the graph data, the index identifier of the node is stored in the index storage space to store the graph data in the graph data storage space.

[0145] For example, the graph data storage space may include the GraphIndex component (index storage space) and the GraphLog component (attribute storage space). The GraphIndex component implements the storage of graph topology and the management of secondary indexes through the Append-only B+tree method. The GraphLog component is implemented through Mmap (memory mapping technology), which can achieve high-performance read operations. Memory mapping technology is a method of mapping files or other resources to computer memory so that these resources can be accessed as efficiently as accessing memory. The GraphLog component uses a log-type storage method to store inserted data, and all uses the efficient writing method of Append, which can support fast writing.

[0146] When graph data is written or queried, it is added, deleted, modified, and queried through the two components of GraphIndex and GraphLog. For example, when graph data is written to the graph data storage space, the attribute information of the graph data is first inserted into GraphLog, and GraphLog will return the offset value of the corresponding file (or a data combination [page value + offset within the page]), and then GraphIndex uses the return value as the value, combined with the key generated by the vertex edge, as the index identifier of the node and saves it in the index of GraphIndex.

[0147] Specifically, the implementation flow of this process can be expressed as follows: UserPut(vertex)=GraphIndex.Put(key(vertex),GraphLog.Put(vertex)).

[0148] Among them, UserPut is the user's write operation, and the parameter passed in is the vertex (edge) data. The process can be decomposed into: 1. GraphLog's put operation, this operation will write the vertex (edge) data into the file and return an offset value; 2. GraphIndex's put operation, this operation will first generate a corresponding index value (key) for the user's vertex (edge) data, and then use the offset value returned by GraphIndex as the value and write it into the GraphIndex file.

[0149] In the above process, GraphIndex can first generate a unique ID for each node in the graph data (or use a unique attribute of the point), and use it as the unique identification key of the point (generally, in order to save memory, the unique identification will be represented by an 8-byte value), and then the key points to a pointer with a value and a pointer to an outgoing or incoming edge. The pointer to the value is an offset of the attribute value file, and the pointer to the outgoing or incoming edge points to a continuous piece of memory, which stores the pointer to the attribute of the edge and the value of the other end point of the edge. At the same time, in GraphIndex, the graph topology composed of linked lists and adjacency lists can be separated from the attribute values ​​in GraphLog. In this way, when querying the adjacent edges of a point, there is no need to query with an index. GraphIndex only needs to point the pointer to the memory block of the linked list of the edge to query all the adjacent edges of the point. At the same time, it can meet the needs of directly calculating and traversing the graph when traversing or calculating the graph, without using the attribute information of the graph, thereby reducing the space occupied by data in memory and reducing the pressure of disk IO. When the calculation is completed, GraphIndex returns the index value of the attribute point / edge to be obtained to GraphLog, and then the query result can be obtained by performing attribute query in GraphLog.

[0150] Obviously, the embodiment of the present application manages the topological structure and attribute information of the graph data through two groups of components, GraphIndex and GraphLog, to achieve the separation of graph topology and attributes, increase the flexibility of graph data storage, and facilitate complex queries and calculations of graphs to increase memory usage efficiency and improve query and calculation performance. Since the attribute information on the same side of the graph data only needs to be stored once, the storage overhead can be reduced. At the same time, for scenarios with reduced performance requirements, the attribute values ​​can also be stored on other clusters through a distributed design to increase the scalability of storage.

[0151] In related technologies, when traversing or calculating on a graph, sometimes it is not necessary to return the attribute values ​​of nodes or edges, but only to know the connection relationship between these points and edges in the graph topology. Therefore, if the above method is used, it is bound to generate redundant overhead. For example, a query like match(n:person{name:jack})-[..2]->(m)return m; this is a second-degree query, and its statement is to query the second-degree neighbors named jack (assuming there is only one type of edge), and then return the attributes of the second-degree neighbors; in this query, if the above technology is used, the attributes of jack's first-degree neighbors and the attributes of an edge will be returned to the memory, and then two hops will be expanded based on one edge. If the attributes of the point or edge are large, this will inevitably cause memory problems in a small memory.

[0152] However, in the embodiment of the present application, the topological structure of the graph data is stored through GraphIndex, that is, compared with the above structure, the value in the topological structure of the embodiment of the present application is an address offset of the vertex edge attribute in the GraphLog component, rather than the actual attribute value, so the size of this address offset is originally smaller than the attribute value. Therefore, when the embodiment of the present application implements the above query process, the graph can be expanded on GraphIndex to quickly find the second-degree neighbors of jack, but after querying from GraphIndex, a GraphLog address is returned. At this time, the corresponding attribute value is obtained from GraphLog according to the offset address, and the above query process can be completed efficiently.

[0153] However, when querying and locating the point name=jack, there is no information about jack when querying directly from the topological structure of the graph data. Therefore, in addition to managing and retrieving nodes in the GraphIndex in the form of key-value pairs, the embodiment of the present application also establishes a secondary index in the index storage space according to the specified query information. With the help of the secondary index made on the name attribute, the position of the point name=jack in the graph topology (the key of the point) is quickly located, thereby quickly locating the starting point, and then performing a second expansion.

[0154] In the embodiment of the present application, when the graph data is stored in the graph data storage space, one or more of a deletion operation, a modification operation, and a query operation can be performed on the graph data stored in the graph data storage space. It should be noted that the deletion operation, modification operation, and query operation in the embodiment of the present application can be performed in batches in a concurrent manner to improve the read and write throughput.

[0155] 250. According to the deletion instruction, the graph data stored in the graph data storage space is deleted.

[0156] For example, after storing graph data in the graph data storage space, you can perform a delete operation on the graph data. Figure 2b As shown in the figure, the specific deletion operation process is as follows:

[0157] 251. Get the delete instruction for any node.

[0158] 252. According to the deletion instruction, delete the index identifier of any node from the index storage space.

[0159] 253. Return the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space.

[0160] According to the directional information returned by the index storage space, the node attribute information and the adjacent edge attribute information pointed to by the directional information returned by the index storage space are deleted from the attribute storage space.

[0161] For example, the deletion operation of graph data can be expressed as follows: UserDelete(vertex) = GraphLog.Delete(GraphIndex.Delete(vertex)). The semantics of UserDelete(vertex) is to indicate that the user wants to delete a vertex point (i.e., node). This operation is decomposed into two serial operations: 1. GraphIndex deletes the index corresponding to vertex and returns the value of the attribute corresponding to this index in the log file offset; 2. GraphLog deletes the corresponding attribute value (i.e., attribute information) based on the returned offset.

[0162] 260. According to the modification instruction, the graph data stored in the graph data storage space is modified.

[0163] For example, after the graph data is stored in the graph data storage space, you can perform modification operations on the graph data. Figure 2c As shown in the figure, the specific modification operation process is as follows:

[0164] 261. Obtain a modification instruction for the attribute information to be modified, where the attribute information to be modified is the attribute information of any node or any edge in the graph data.

[0165] 262. Obtain directional information corresponding to the attribute information to be modified according to the modification instruction and the index identifier stored in the index storage space.

[0166] 263. Return the acquired directional information to the attribute storage space.

[0167] 264. According to the directional information returned by the index storage space, query the attribute information to be modified from the attribute storage space.

[0168] 265. Update the queried attribute information to be modified according to the modification instruction to obtain updated attribute information.

[0169] 266. Determine updated directional information according to the updated attribute information, where the updated directional information is used to point to the updated attribute information.

[0170] 267. Update the index identifier of the node corresponding to the attribute information to be modified stored in the index storage space according to the updated directionality information.

[0171] For example, the modification operation of graph data can be expressed as follows: UserUpdate(vertex) = GraphIndex.Update(GraphLog.Update(vertex)). The specific operation process is as follows: 1. GraphIndex first queries vertex and returns an offset value; 2. GraphLog copies the data to the memory according to the returned offset and marks the current record as deleted; 3. GraphLog merges the value copied to the memory and the value of the part to be updated, traces to the end of the file, and returns a new offset value; 4. After GraphIndex obtains the new offset value, it will index the corresponding attribute offset in the previous bit update (that is, update the directional information).

[0172] 270. According to the attribute information query instruction, a query operation is performed on the graph data stored in the graph data storage space.

[0173] For example, after the graph data is stored in the graph data storage space, you can perform query operations on the graph data. Figure 2d As shown in the figure, the specific query operation process is as follows:

[0174] 271. Obtain an attribute information query instruction, where the attribute information query instruction is used to query at least one of the node attribute information of at least one node of the graph data and the edge attribute information of at least one edge.

[0175] 272. Obtain directional information corresponding to the attribute information query instruction according to the attribute information query instruction and the index identifier stored in the index storage space.

[0176] 273. According to the acquired directional information, acquire, from the attribute storage space, the attribute information pointed to by the directional information corresponding to the attribute information query instruction.

[0177] For example, the query operation on graph data can be expressed as follows: UserRetrieve(vertex) = GraphLog.Retrieve(GraphIndex.Retrieve(vertex)). The specific operation process is as follows: 1. For example, VertexSet = GraphIndex.Retrieve(Tranversal / Computer)(Vertex). When the user performs a graph data query (including traversal / graph calculation), GraphIndex will walk on the graph according to the graph topology structure to find the ID set of points that meet the requirements. 2. For example, Properties = GraphLog.BatchGet(VertexSet), then the offsets corresponding to the set of these points are all sent to the GraphLog component, and the attribute values ​​of all points (edges) will be returned to obtain the chaxun result.

[0178] As can be seen from the above, the embodiment of the present application adopts a method of storing graph topology and graph attributes separately to realize the storage of attribute graphs, that is, the topological structure and attribute information of graph data are managed through two groups of components, GraphIndex and GraphLog, so that the graph topology is stored separately as a graph index, and the graph attributes are also stored as independent parts in another space, so as to realize the storage and query of large attribute graphs through the design of edge aggregation and separation of graph and attributes, which can greatly improve the query performance, thereby realizing the efficiency of graph calculation and complex query of graphs, and reducing the resource overhead. At the same time, through the linked list in the adjacency list, a pointer to its neighbor node is directly maintained for each node, so when querying the neighbor nodes of a node, it is not necessary to go through the index, and can be directly accessed, realizing the data storage and query strategy of index-free adjacency, and reducing the memory cache of attributes by querying attributes twice, thereby improving the memory utilization.

[0179] In order to better implement the above method, the embodiment of the present application also provides a data storage device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0180] For example, in this embodiment, the method of the embodiment of the present application is described in detail by taking the data storage device being specifically integrated in the server as an example.

[0181] For example, Figure 3 As shown, the data storage device may include an acquisition unit 310, an attribute storage unit 320, an index determination unit 330, and an index storage unit 340, as follows:

[0182] (I) Acquisition Unit 310

[0183] Used to obtain graph data and graph data storage space. Graph data includes nodes and edges connecting nodes. Graph data storage space includes index storage space and attribute storage space.

[0184] (II) Attribute storage unit 320

[0185] It is used to store the attribute information of graph data in the attribute storage space, where the attribute information includes node attribute information and edge attribute information.

[0186] In some embodiments, the attribute storage unit includes a first attribute storage subunit and a second attribute storage subunit, including: the first attribute storage subunit, used to determine the adjacent edges to be stored connected to the nodes to be stored according to the connection relationship of the nodes to be stored in the graph data, where the nodes to be stored are any nodes in the graph data; the second attribute storage subunit, used to store the node attribute information of the nodes to be stored and the edge attribute information of the adjacent edges to be stored in adjacent positions in the attribute storage space.

[0187] In some embodiments, the attribute storage unit further includes a third attribute storage subunit, including: the third attribute storage subunit is used to determine the nodes to be stored from the graph data according to the numbering order of the nodes in the graph data.

[0188] (III) Index determination unit 330

[0189] It is used to determine the index identifier of any node according to the directional information corresponding to the node. The directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space. The adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node.

[0190] In some embodiments, the data storage device also includes a directionality unit, including: a directionality unit, used to use the storage location of the node attribute information in the attribute storage space and the storage location of the edge attribute information in the attribute storage space as the directionality information of the node corresponding to the node attribute information and the directionality information of the edge corresponding to the edge attribute information, respectively.

[0191] In some embodiments, the index determination unit includes a first index determination subunit, a second index determination subunit and a third index determination subunit, including: the first index determination subunit, used to obtain the index number of the node for any node; the second index determination subunit, used to use the index number of the node as the key and the directional information corresponding to the node as the value to construct a key-value pair corresponding to the node; the third index determination subunit, used to use the key-value pair corresponding to the node as the index identifier of the node.

[0192] In some embodiments, the data storage device also includes a designated index unit, including: a designated index unit, used to establish a designated node index for the index identifier of the node corresponding to the designated query information based on the designated query information, and the designated node index is used to determine the index identifier of the node corresponding to the designated query information.

[0193] (IV) Index storage unit 340

[0194] It is used to store the index identifiers of the nodes in the index storage space according to the connection relationship of the nodes in the graph data, so as to store the graph data in the graph data storage space.

[0195] In some embodiments, the index storage unit includes a first index storage sub-unit and a second index storage sub-unit, including: the first index storage sub-unit, used to create an index array according to the connection relationship of the nodes in the graph data, the index array is used to store the index identifiers of the nodes according to the connection relationship of the nodes, and the elements in the index array correspond to the nodes; the second index storage sub-unit, used to create an adjacent node table of the nodes corresponding to the elements in the index array, and the adjacent node table is used to store the index information of the adjacent nodes of the nodes corresponding to the elements.

[0196] In some embodiments, the data storage device also includes a deletion unit, including: the deletion unit is used to obtain a deletion instruction for any node; according to the deletion instruction, delete the index identifier of any node from the index storage space; return the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space; according to the directional information returned by the index storage space, delete the node attribute information and adjacent edge attribute information pointed to by the directional information returned by the index storage space from the attribute storage space.

[0197] In some embodiments, the data storage device also includes a modification unit, including: the modification unit is used to obtain modification instructions for attribute information to be modified, where the attribute information to be modified is the attribute information of any node or any edge in the graph data; according to the modification instructions and the index identifier stored in the index storage space, the directional information corresponding to the attribute information to be modified is obtained; the obtained directional information is returned to the attribute storage space; according to the directional information returned by the index storage space, the attribute information to be modified is queried from the attribute storage space; according to the modification instructions, the queried attribute information to be modified is updated to obtain the updated attribute information; according to the updated attribute information, the updated directional information is determined, and the updated directional information is used to point to the updated attribute information; according to the updated directional information, the index identifier of the node corresponding to the attribute information to be modified stored in the index storage space is updated.

[0198] In some embodiments, the attribute information to be modified retrieved from the query is updated according to the modification instruction to obtain the updated attribute information, including: marking the attribute information to be modified in the attribute storage space as a deleted state; generating updated attribute information according to the modification instruction and the attribute information to be modified; and determining updated directional information according to the updated attribute information, including: storing the updated attribute information at the end of the attribute storage space to determine the updated directional information.

[0199] In some embodiments, the data storage device also includes a query unit, including: the query unit is used to obtain attribute information query instructions, the attribute information query instructions are used to query at least one of the node attribute information of at least one node of the graph data and the edge attribute information of at least one edge; according to the attribute information query instructions and the index identifier stored in the index storage space, the directional information corresponding to the attribute information query instruction is obtained; according to the obtained directional information, the attribute information pointed to by the directional information corresponding to the attribute information query instruction is obtained from the attribute storage space.

[0200] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0201] As can be seen from the above, the data storage device of this embodiment includes an acquisition unit, an attribute storage unit, an index determination unit and an index storage unit. Among them, the acquisition unit is used to acquire graph data and graph data storage space, the graph data includes nodes and edges connected between nodes, and the graph data storage space includes index storage space and attribute storage space; the attribute storage unit is used to store attribute information of the graph data in the attribute storage space, and the attribute information includes node attribute information and edge attribute information; the index determination unit is used to determine the index identifier of the node for any node according to the directional information corresponding to the node, and the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, and the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; the index storage unit is used to store the index identifier of the node in the index storage space according to the connection relationship of the nodes in the graph data, so as to store the graph data in the graph data storage space.

[0202] Therefore, the embodiment of the present application stores the index identifier and attribute information of the graph data separately in the index storage space and the attribute storage space to achieve separate management of the graph index and the graph attribute, so as to improve the storage flexibility and query efficiency of the graph data. Among them, the index storage space stores the index identifier of the node corresponding to the attribute information according to the connection relationship of the nodes in the graph data. So that when querying the graph data, it is possible to directly traverse the connection relationship of the nodes in the index storage space without reading the graph attribute information to perform queries and traversals on the graph. After determining the relevant data to be queried, the corresponding attribute information is obtained from the attribute storage space according to the directional information corresponding to the index identifier of the queried node, so as to reduce the call of data resources during the query process, avoid resource waste, and improve the query efficiency of the graph data.

[0203] The embodiment of the present application also provides an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc. The server can be a single server or a server cluster composed of multiple servers, etc.

[0204] In some embodiments, the data storage device may also be integrated into multiple electronic devices. For example, the data storage device may be integrated into multiple servers, and the data storage method of the present application may be implemented by multiple servers.

[0205] In this embodiment, the electronic device of this embodiment is a server as an example for detailed description, for example, Figure 4 As shown, it shows a schematic diagram of the structure of the server involved in the embodiment of the present application, specifically:

[0206] The server may include one or more processing core processors 410, one or more computer-readable storage media memories 420, a power supply 430, an input module 440, and a communication module 450. Those skilled in the art will appreciate that Figure 4 The server structure shown in the figure does not constitute a limitation on the server, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0207] The processor 410 is the control center of the server, and uses various interfaces and lines to connect various parts of the entire server. It executes various functions of the server and processes data by running or executing software programs and / or modules stored in the memory 420, and calling data stored in the memory 420. In some embodiments, the processor 410 may include one or more processing cores; in some embodiments, the processor 410 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 410.

[0208] The memory 420 can be used to store software programs and modules. The processor 410 executes various functional applications and data processing by running the software programs and modules stored in the memory 420. The memory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 420 may also include a memory controller to provide the processor 410 with access to the memory 420.

[0209] The server also includes a power supply 430 for supplying power to various components. In some embodiments, the power supply 430 can be logically connected to the processor 410 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 430 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0210] The server may further include an input module 440, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0211] The server may further include a communication module 450. In some embodiments, the communication module 450 may include a wireless module. The server may perform short-range wireless transmission through the wireless module of the communication module 450, thereby providing wireless broadband Internet access to the user. For example, the communication module 450 may be used to help the user send and receive emails, browse web pages, and access streaming media.

[0212] Although not shown, the server may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 410 in the server will load the executable files corresponding to the processes of one or more application programs into the memory 420 according to the following instructions, and the processor 410 will run the application programs stored in the memory 420, thereby realizing various functions, as follows:

[0213] Acquire graph data and graph data storage space, the graph data includes nodes and edges connecting the nodes, the graph data storage space includes index storage space and attribute storage space; store attribute information of the graph data in the attribute storage space, the attribute information includes node attribute information and edge attribute information; for any node, determine the index identifier of the node according to the directional information corresponding to the node, the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; according to the connection relationship of the nodes in the graph data, store the index identifier of the node in the index storage space, so as to store the graph data in the graph data storage space.

[0214] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0215] As can be seen from the above, the embodiment of the present application stores the index identifier and attribute information of the graph data separately in the index storage space and the attribute storage space to achieve separate management of the graph index and the graph attributes, so as to improve the storage flexibility and query efficiency of the graph data. Among them, the index storage space stores the index identifier of the node corresponding to the attribute information according to the connection relationship of the nodes in the graph data. So that when querying the graph data, it is possible to directly traverse the connection relationship of the nodes in the index storage space without reading the graph attribute information to perform queries and traversals on the graph. After determining the relevant data to be queried, the corresponding attribute information is obtained from the attribute storage space according to the directional information corresponding to the index identifier of the queried node, so as to reduce the call of data resources during the query process, avoid waste of resources, and improve the query efficiency of the graph data.

[0216] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0217] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any data storage method provided in the embodiment of the present application. For example, the instructions can execute the following steps:

[0218] Acquire graph data and graph data storage space, the graph data includes nodes and edges connecting the nodes, the graph data storage space includes index storage space and attribute storage space; store attribute information of the graph data in the attribute storage space, the attribute information includes node attribute information and edge attribute information; for any node, determine the index identifier of the node according to the directional information corresponding to the node, the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node; according to the connection relationship of the nodes in the graph data, store the index identifier of the node in the index storage space, so as to store the graph data in the graph data storage space.

[0219] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0220] According to one aspect of the present application, a computer program product or computer program is provided, including a computer program or instruction, which, when executed by a processor, implements the steps in the method provided in various optional implementations provided in the above embodiments. The computer program / instruction is stored in a computer-readable storage medium. A processor of an electronic device reads the computer program / instruction from the computer-readable storage medium, and the processor executes the computer program / instruction, so that the electronic device performs the method provided in various optional implementations provided in the above embodiments.

[0221] Since the instructions stored in the storage medium can execute the steps in any data storage method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data storage method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0222] The above is a detailed introduction to a data storage method, device, electronic device, storage medium and program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data storage method, characterized in that: include: Acquire graph data and graph data storage space, wherein the graph data includes nodes and edges connected between the nodes, and the graph data storage space includes index storage space and attribute storage space; Storing attribute information of the graph data in an attribute storage space, the attribute information including node attribute information and edge attribute information; For any of the nodes, determine the index identifier of the node according to the directional information corresponding to the node, the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node, the directional information corresponding to the node includes node directional information, out-edge directional information and in-edge directional information, the node directional information is the directional information pointing to the node attribute information of the node, the out-edge directional information is the directional information pointing to the edge attribute information of the adjacent edge of the node which is the out-edge, and the in-edge directional information is the directional information pointing to the edge attribute information of the adjacent edge of the node which is the in-edge; According to the connection relationship of the nodes in the graph data, the index identifiers of the nodes are stored in the index storage space, so that the graph data is stored in the graph data space.

2. The data storage method according to claim 1, characterized in that: The storing the attribute information of the graph data in the attribute storage space includes: Determine, according to the connection relationship of the node to be stored in the graph data, an adjacent edge to be stored connected to the node to be stored, wherein the node to be stored is any node in the graph data; The node attribute information of the node to be stored and the edge attribute information of the adjacent edge to be stored are stored in adjacent positions in the attribute storage space.

3. The data storage method according to claim 2, characterized in that: The storing the attribute information of the graph data in the attribute storage space further includes: The nodes to be stored are determined from the graph data according to the serial numbering sequence of the nodes in the graph data.

4. The data storage method according to claim 1, characterized in that: Before determining the index identifier of the node according to the directional information corresponding to the node for any of the nodes, the method further includes: The storage position of the node attribute information in the attribute storage space and the storage position of the edge attribute information in the attribute storage space are respectively used as the directional information of the node corresponding to the node attribute information and the directional information of the edge corresponding to the edge attribute information.

5. The data storage method according to claim 1, characterized in that: The step of determining, for any of the nodes, an index identifier of the node according to the directional information corresponding to the node, includes: For any of the nodes, obtain the index number of the node; Using the index number of the node as a key and the directional information corresponding to the node as a value, constructing a key-value pair corresponding to the node; The key-value pair corresponding to the node is used as the index identifier of the node.

6. The data storage method according to claim 1, characterized in that: The method further comprises: According to the designated query information, a designated node index is established for the index identifier of the node corresponding to the designated query information, and the designated node index is used to determine the index identifier of the node corresponding to the designated query information.

7. The data storage method according to claim 1, characterized in that: According to the connection relationship of the nodes in the graph data, storing the index identifiers of the nodes in the index storage space to store the graph data in the graph data storage space includes: According to the connection relationship of the nodes in the graph data, an index array is created, wherein the index array is used to store the index identifiers of the nodes according to the connection relationship of the nodes, and the elements in the index array correspond to the nodes; An adjacent node table of the node corresponding to the element in the index array is created, wherein the adjacent node table is used to store index information of adjacent nodes of the node corresponding to the element.

8. The data storage method according to claim 1, characterized in that: The method further comprises: Obtaining a deletion instruction for any of the nodes; Deleting the index identifier of any of the nodes from the index storage space according to the deletion instruction; Returning the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space; According to the directional information returned by the index storage space, the node attribute information and the adjacent edge attribute information pointed to by the directional information returned by the index storage space are deleted from the attribute storage space.

9. The data storage method according to claim 1, characterized in that: The method further comprises: Obtaining a modification instruction for the attribute information to be modified, wherein the attribute information to be modified is the attribute information of any node or any edge in the graph data; According to the modification instruction and the index identifier stored in the index storage space, acquiring the directional information corresponding to the attribute information to be modified; Returning the acquired directionality information to the attribute storage space; According to the directionality information returned by the index storage space, querying the attribute information to be modified from the attribute storage space; The queried attribute information to be modified is updated according to the modification instruction to obtain updated attribute information; Determining updated directivity information according to the updated attribute information, wherein the updated directivity information is used to point to the updated attribute information; The index identifier of the node corresponding to the attribute information to be modified stored in the index storage space is updated according to the updated directionality information.

10. The data storage method according to claim 9, characterized in that: The updating of the to-be-modified attribute information obtained by querying according to the modification instruction to obtain updated attribute information includes: Marking the to-be-modified attribute information in the attribute storage space as a deleted state; Generate updated attribute information according to the modification instruction and the attribute information to be modified; The step of determining updated directivity information according to the updated attribute information includes: The updated attribute information is stored at the end of the attribute storage space to determine the updated directivity information.

11. The data storage method according to any one of claims 1 to 10, characterized in that: The method further comprises: Obtain an attribute information query instruction, where the attribute information query instruction is used to query at least one of the node attribute information of at least one of the nodes of the graph data and the edge attribute information of at least one of the edges; According to the attribute information query instruction and the index identifier stored in the index storage space, acquiring the directionality information corresponding to the attribute information query instruction; According to the acquired directional information, the attribute information pointed to by the directional information corresponding to the attribute information query instruction is acquired from the attribute storage space.

12. A data storage device, characterized in that: include: An acquisition unit, used to acquire graph data and graph data storage space, wherein the graph data includes nodes and edges connected between the nodes, and the graph data storage space includes index storage space and attribute storage space; An attribute storage unit, used to store attribute information of the graph data in an attribute storage space, wherein the attribute information includes node attribute information and edge attribute information; An index determination unit is used to determine, for any of the nodes, an index identifier of the node according to the directional information corresponding to the node, the directional information corresponding to the node is used to point to the node attribute information and adjacent edge attribute information of the node stored in the attribute storage space, the adjacent edge attribute information is the edge attribute information of the adjacent edge connected to the node, the directional information corresponding to the node includes node directional information, out-edge directional information and in-edge directional information, the node directional information is the directional information pointing to the node attribute information of the node, the out-edge directional information is the directional information pointing to the edge attribute information of the adjacent edge of the node which is the out-edge, and the in-edge directional information is the directional information pointing to the edge attribute information of the adjacent edge of the node which is the in-edge; An index storage unit is used to store the index identifier of the node in the index storage space according to the connection relationship of the nodes in the graph data, so as to store the graph data in the graph data space.

13. The data storage device according to claim 12, wherein: The attribute storage unit includes a first attribute storage subunit and a second attribute storage subunit, including: The first attribute storage subunit is used to determine, according to the connection relationship of the node to be stored in the graph data, the adjacent edge to be stored connected to the node to be stored, wherein the node to be stored is any node in the graph data; The second attribute storage subunit is used to store the node attribute information of the node to be stored and the edge attribute information of the adjacent edge to be stored in adjacent positions in the attribute storage space.

14. The data storage device according to claim 13, wherein: The attribute storage unit further includes a third attribute storage subunit, including: The third attribute storage subunit is used to determine the to-be-stored nodes from the graph data according to the numbering sequence of the nodes in the graph data.

15. The data storage device according to claim 12, wherein: The data storage device further includes a directivity unit, including: The directionality unit is used to use the storage position of the node attribute information in the attribute storage space and the storage position of the edge attribute information in the attribute storage space as the directionality information of the node corresponding to the node attribute information and the directionality information of the edge corresponding to the edge attribute information, respectively.

16. The data storage device according to claim 12, wherein: The index determination unit includes a first index determination subunit, a second index determination subunit and a third index determination subunit, including: The first index determination subunit is used to obtain the index number of any node; The second index determination subunit is used to use the index number of the node as the key and the directional information corresponding to the node as the value to construct a key-value pair corresponding to the node; the third index determination subunit is used to use the key-value pair corresponding to the node as the index identifier of the node.

17. The data storage device according to claim 12, wherein: The data storage device further includes a designated index unit, including: The designated index unit is used to establish a designated node index for the index identifier of the node corresponding to the designated query information according to the designated query information, and the designated node index is used to determine the index identifier of the node corresponding to the designated query information.

18. The data storage device according to claim 12, wherein: The index storage unit includes a first index storage subunit and a second index storage subunit, including: The first index storage subunit is used to create an index array according to the connection relationship of the nodes in the graph data, and the index array is used to store the index identifiers of the nodes according to the connection relationship of the nodes, and the elements in the index array correspond to the nodes; The second index storage subunit is used to create an adjacent node table of the node corresponding to the element in the index array, and the adjacent node table is used to store index information of the adjacent nodes of the node corresponding to the element.

19. The data storage device according to claim 12, wherein: The data storage device further includes a deletion unit, including: The deletion unit is used to obtain a deletion instruction for any of the nodes; according to the deletion instruction, delete the index identifier of any of the nodes from the index storage space; return the directional information corresponding to the index identifier deleted from the index storage space to the attribute storage space; and according to the directional information returned by the index storage space, delete from the attribute storage space the node attribute information and the adjacent edge attribute information pointed to by the directional information returned by the index storage space.

20. The data storage device according to claim 12, wherein: The data storage device further includes a modification unit, including: The modification unit is used to obtain a modification instruction for the attribute information to be modified, where the attribute information to be modified is the attribute information of any node or any edge in the graph data; according to the modification instruction and the index identifier stored in the index storage space, the directional information corresponding to the attribute information to be modified is obtained; the obtained directional information is returned to the attribute storage space; according to the directional information returned by the index storage space, the attribute information to be modified is queried from the attribute storage space; according to the modification instruction, the queried attribute information to be modified is updated to obtain the updated attribute information; according to the updated attribute information, the updated directional information is determined, and the updated directional information is used to point to the updated attribute information; according to the updated directional information, the index identifier of the node corresponding to the attribute information to be modified stored in the index storage space is updated.

21. The data storage device according to claim 20, characterized in that The updating of the to-be-modified attribute information obtained by querying according to the modification instruction to obtain updated attribute information includes: Marking the to-be-modified attribute information in the attribute storage space as a deleted state; Generate updated attribute information according to the modification instruction and the attribute information to be modified; The step of determining updated directivity information according to the updated attribute information includes: The updated attribute information is stored at the end of the attribute storage space to determine the updated directivity information.

22. The data storage device according to claim 12, wherein: The data storage device further includes a query unit, including: The query unit is used to obtain an attribute information query instruction, and the attribute information query instruction is used to query at least one of the node attribute information of at least one node of the graph data and the edge attribute information of at least one edge; according to the attribute information query instruction and the index identifier stored in the index storage space, the directional information corresponding to the attribute information query instruction is obtained; according to the obtained directional information, the attribute information pointed to by the directional information corresponding to the attribute information query instruction is obtained from the attribute storage space.

23. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the data storage method according to any one of claims 1 to 11.

24. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the data storage method according to any one of claims 1 to 11.

25. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the data storage method according to any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Indexing method and device based on key value pair KV system, electronic equipment and medium

    CN111241108A

  • Retrieval method and device for graph database

    CN113901279A