Transaction type and analysis type mixed query load-oriented graph storage method
By combining row and column storage structures in the LSM-Tree structure, the storage and query methods of graph data are optimized, and the efficiency of transaction-type and analytical hybrid query load in the existing technology is solved, reducing latency and resource occupation. Simplified deployment and maintenance.
Patent Information
- Application Number
- CN202411024156.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-29
AI Technical Summary
When handling transaction-based and analytical mixed query loads, the prior art leads to large query delays and occupies more computing resources, making it difficult to meet business efficiency requirements, and has high deployment and maintenance complexity.
Adopting the LSM-Tree hierarchical structure, the transaction-oriented row storage structure and the analysis-oriented column storage structure are connected, and the memory-oriented row storage structure is preferred to respond to transaction-oriented query requests, and the newer graph data is added. It is stored in memory in columnar structure, adapts to the needs of transactional requests, and migrates data to external memory when the upper limit of the capacity is reached, and converts it into a columnar storage structure for analytical queries.
It significantly reduces the system deployment and maintenance costs, reduces the computing overhead of data retrieval, transmission and synchronization, and effectively reduces the response delay and computing resource usage when processing transaction/analyzing hybrid query loads.
Smart Images

Figure CN118964353A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of graph data storage, and in particular to a graph storage method for transactional and analytical hybrid query loads. Background Art
[0002] In modern data-driven applications, the importance of graph data is becoming increasingly prominent, and graph computing has become the basis of many data analysis scenarios (such as e-commerce recommendations, social media network analysis, fraud detection, and graph-based deep learning). According to the characteristics of the query, graph queries are divided into transactional queries (GTP) and analytical queries (GAP). GTP queries usually only access a single vertex, edge, or their neighborhood (i.e., vertices or edges adjacent to them), and require atomic guarantees when concurrently inserting, deleting, or updating the properties of multiple vertices and edges. GAP queries usually involve exploring most or the entire graph in a static graph snapshot (such as PageRank web page ranking and DFS depth-first search), which usually involves complex multi-hop graph traversal and pattern matching.
[0003] At present, different storage methods are usually used when processing GTP query and GAP query requests separately. The graph storage method for GTP query usually adopts flexible and loose row storage data structures such as adjacency list or edge table, while the graph storage method for GAP query usually uses compact and efficient column storage data structures such as compressed array of adjacency matrix (CSR).
[0004] As the business develops, in actual use, it is often necessary to initiate GTP requests and GAP requests at the same time (i.e., transaction / analysis mixed query load). In order to handle this situation, enterprises usually need to deploy two graph storage systems with different storage methods at the same time. The two systems not only need to store the same graph data separately, but also need to design independent read and write links, data high availability guarantees, and operation and maintenance links, which further increases the deployment and use costs and increases the complexity of operation and maintenance; in addition, in order to ensure the consistency and timeliness of data for GAP and GTP storage systems, additional data verification and synchronization links need to be added, which further increases the cost and operation and maintenance complexity. Therefore, when processing transactional and analytical mixed query loads, this storage method will cause large query delays and occupy more computing resources, making it difficult to meet the efficiency requirements of existing businesses for processing transactional / analysis mixed query loads.
[0005] Therefore, there is an urgent need for a new graph storage method for transactional and analytical hybrid query loads. Summary of the invention
[0006] The present invention provides a graph storage method for transactional and analytical hybrid query loads, which can solve the problem that the existing graph storage method for hybrid query loads causes large query delays and occupies more computing resources. The technical solution is as follows:
[0007] On the one hand, a graph storage method for transactional and analytical hybrid query loads is provided, the method comprising:
[0008] Before reaching the upper limit of the capacity allocated in the LSM tree memory, the graph data is stored in a row storage structure for transactional queries;
[0009] When the written graph data reaches the upper capacity limit, the LSM tree memory allocates new empty memory to store the new graph data in a row storage structure, and migrates the graph data in the old memory that has reached the upper capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory to store the new graph data in a row storage structure is the upper capacity limit;
[0010] Convert the old graph data in memory into a columnar storage structure for analytical queries and store it in the LSM tree external memory;
[0011] In response to receiving a hybrid query concurrent request, the transactional query request preferentially retrieves the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request preferentially retrieves the second target graph data from the column storage structure of the LSM tree external memory.
[0012] On the other hand, a graph storage device for transactional and analytical hybrid query loads is provided, the device comprising:
[0013] The row storage module is used to store graph data in a row storage structure for transactional queries before reaching the upper limit of the capacity allocated in the LSM tree memory;
[0014] A migration module, configured to allocate new empty memory to the LSM tree memory to store the new graph data in a row storage structure when the graph data written reaches the upper capacity limit, and migrate the graph data in the old memory that has reached the upper capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory to store the new graph data in a row storage structure is the upper capacity limit;
[0015] The column storage module is used to convert the graph data in the old memory into a column storage structure for analytical queries and store it in the LSM tree external memory;
[0016] The query module is used to respond to the reception of a mixed query concurrent request, where the transactional query request gives priority to retrieving the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request gives priority to retrieving the second target graph data from the column storage structure of the LSM tree external memory.
[0017] On the other hand, a computer device is provided, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of the above-mentioned method.
[0018] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned method are implemented.
[0019] On the other hand, a computer program product is provided, comprising a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0020] The technical solution provided by the present invention can at least bring the following beneficial effects:
[0021] Abandoning the traditional architecture of using two storage systems to handle transactional requests and analytical requests respectively, the present invention connects the transactional row storage structure and the analytical column storage structure based on the hierarchical structure of LSM-Tree, and uses a single system to efficiently handle transactional / analytical mixed query requests. In addition, graph data with newer dates are stored in a columnar structure in the memory, and the memory row storage structure gives priority to responding to transactional query requests, which can adapt to the characteristics of transactional requests that need to obtain the latest target graph data. Therefore, the storage method proposed in the present invention can significantly reduce the deployment and maintenance costs of the system, and can save the computing overhead of data retrieval, transmission and synchronization of the two traditional systems, thereby effectively reducing the response delay and the occupation of computing resources when processing transactional / analytical mixed query loads. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 This is a flow chart of a graph storage method for transactional and analytical hybrid query loads provided by an embodiment of the present invention;
[0024] Figure 2 This is a structural diagram of a graph storage device for transactional and analytical hybrid query loads provided by an embodiment of the present invention;
[0025] Figure 3It is a hardware architecture diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0027] The specific implementation of the above concept is described below.
[0028] Please refer to Figure 1 , an embodiment of the present invention provides a graph storage method for transactional and analytical hybrid query loads, the method comprising:
[0029] Step 100, before reaching the upper limit of the capacity allocated in the LSM tree memory, store the graph data in a row storage structure for transactional queries;
[0030] Step 102: When the written graph data reaches the capacity limit, the LSM tree memory allocates new empty memory to store the new graph data in a row storage structure, and migrates the graph data in the old memory that has reached the capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory to store the new graph data in the row storage structure is the capacity limit;
[0031] Step 104: convert the graph data in the old memory into a columnar storage structure for analytical queries and store it in the LSM tree external memory;
[0032] Step 106, in response to receiving a hybrid query concurrent request, the transactional query request preferentially retrieves the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request preferentially retrieves the second target graph data from the column storage structure of the LSM tree external memory.
[0033] In the embodiment of the present invention, the traditional architecture of using two storage systems to process transactional requests and analytical requests respectively is abandoned. The present invention connects the transactional row storage structure and the analytical column storage structure based on the hierarchical structure of LSM-Tree, and uses a set of systems to efficiently process transactional / analytical mixed query requests. In addition, graph data with newer dates are stored in the memory in a columnar structure, and the memory row storage structure gives priority to responding to transactional query requests, which can adapt to the characteristics of transactional requests that need to obtain the latest target graph data. Therefore, the storage method proposed in the present invention can significantly reduce the deployment and maintenance costs of the system, and can save the computing overhead of data retrieval, transmission and synchronization of the traditional two systems, thereby effectively reducing the response delay and the occupation of computing resources when processing transactional / analytical mixed query loads.
[0034] Described below Figure 1 How the various steps are performed.
[0035] For steps 100 and 102:
[0036] In some implementations, the row storage structure is an adjacency list structure;
[0037] LSM tree memory stores graph data in a row-based storage structure in the following way:
[0038] When storing the first graph data, the inserted edge is located in the corresponding adjacency table memory block based on the LSM tree memory sorting structure;
[0039] For each graph data stored next, execute:
[0040] New edge storage space is allocated for the adjacency list in memory, and the pointer of the preceding edge related to the current graph data is linked to the newly inserted edge used to represent the current graph data to complete the insertion of the current graph data.
[0041] In some implementations, the column storage structure is a compressed array structure of an adjacency matrix.
[0042] In this embodiment, the LSM tree is divided into memory and external memory. The graph data is first stored in the memory in an adjacency list structure. When the space allocated to the adjacency list in the memory reaches the set capacity limit, the merging and conversion of the graph data from the memory to the external memory will be triggered. This is because the adjacency list structure supports the insertion and modification of edges, while the insertion and modification of graph data under the compressed array structure requires the reconstruction of the entire compressed array. Therefore, the memory for storing graph data can only use a row storage structure, not a column storage structure.
[0043] Regarding step 104:
[0044] In some implementations, step 104 may include:
[0045] Divide the external memory of the LSM tree into several levels;
[0046] The graph data migrated from the old memory is stored starting from the top zero layer of the LSM tree external memory, and is compressed layer by layer from the upper layer column storage array to the lower layer into a global compressed array.
[0047] In this embodiment, each time the capacity limit is reached, a new empty memory is allocated to migrate the graph data in the old memory to the external memory of the LSM tree, starting from the top zero layer of the LSM tree external memory, and gradually compressing the upper loose column storage array to the lower layer into a compact global CSR array.
[0048] Regarding step 106:
[0049] In some implementations, the transactional query request in step 106 preferentially retrieves the first target graph data from the row storage structure of the LSM tree memory, including:
[0050] The transactional query request first retrieves the first target graph data that meets the query condition from the row storage structure of the LSM tree memory;
[0051] If not found, the LSM tree external memory is searched layer by layer from the upper layer to the lower layer until the first target graph data is obtained.
[0052] For example, transactional queries in banking systems: A customer's current balance, etc. Transactional queries usually only access a single vertex, edge, or their neighborhood (i.e., vertices or edges adjacent to them), and require atomicity guarantees when concurrently inserting, deleting, or updating the properties of multiple vertices and edges. It is usually necessary to obtain the latest target graph data. Therefore, transactional query requests prioritize retrieving the first target graph data from the row storage structure of the LSM tree memory, and the row storage structure is more suitable for transactional queries, which can be retrieved as soon as possible. If not retrieved, it will be transferred to the LSM tree external memory and retrieved layer by layer from the upper layer to the lower layer until the first target graph data is obtained, so as to ensure the response efficiency of transactional query requests.
[0053] In some implementations, the analytical query request in step 106 preferentially retrieves the second target graph data from the column storage structure of the LSM tree external memory, including:
[0054] Analytical query requests first traverse the graph data layer by layer from the bottom layer to the top layer in the LSM tree external memory, and retrieve the second target graph data that meets the query conditions;
[0055] If not retrieved, continue traversing in the LSM tree memory until the second target graph data is obtained.
[0056] For example, analytical queries in banking systems: A customer's income and expenditure details during a set date period, etc., usually require traversing most or all of the graph data.
[0057] Since the columnar storage structure of the LSM tree external memory is more suitable for analytical query requests, analytical query requests are preferentially traversed in the LSM tree external memory. Moreover, if a transactional query request is not retrieved in the memory, it is searched layer by layer from the upper layer to the lower layer in the LSM tree external memory. In order to avoid the mutual blocking influence of transactional queries and analytical queries and reduce the probability of queuing, the analytical query request of this embodiment preferentially traverses the graph data layer by layer from the lower layer to the upper layer in the LSM tree external memory, so as to more quickly retrieve the second target graph data that meets the analytical query conditions.
[0058] In summary, the embodiment of the present invention utilizes the LSM-Tree (Log-Structed-Merge-Tree) structure to organically connect the GTP-oriented graph storage data structure and the GAP-oriented graph storage data structure in a set of system services. By converting the row storage structure of the memory to the column storage structure of the external memory, and designing a set of innovative graph data read and write links to efficiently process concurrent requests for graph transaction queries and graph analysis queries, the deployment and maintenance costs of the system can be significantly reduced, the computing overhead of data retrieval, transmission and synchronization of the two traditional systems can be avoided, and the response delay and computing resource occupancy when processing transaction / analysis mixed query loads can be effectively reduced.
[0059] Please refer to Figure 2 The embodiment of the present invention provides a graph storage device for transactional and analytical hybrid query loads, the device comprising:
[0060] A row storage module 201 is used to store graph data in a row storage structure oriented to transactional queries before reaching the upper limit of the capacity allocated in the LSM tree memory;
[0061] Migration module 202, used for allocating new empty memory in the LSM tree memory to store the new graph data in a row storage structure when the written graph data reaches the upper capacity limit, and migrating the graph data in the old memory that has reached the upper capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory storing the new graph data in the row storage structure is the upper capacity limit;
[0062] The column storage module 203 is used to convert the graph data in the old memory into a column storage structure for analytical queries and store it in the LSM tree external memory;
[0063] The query module 204 is used to respond to the reception of a hybrid query concurrent request, where the transactional query request gives priority to retrieving the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request gives priority to retrieving the second target graph data from the column storage structure of the LSM tree external memory.
[0064] In one embodiment of the present invention, the row storage structure in the row storage module 201 and the migration module 202 is an adjacency list structure;
[0065] LSM tree memory stores graph data in a row-based storage structure in the following way:
[0066] When storing the first graph data, the inserted edge is located in the corresponding adjacency table memory block based on the LSM tree memory sorting structure;
[0067] For each graph data stored next, execute:
[0068] New edge storage space is allocated for the adjacency list in memory, and the pointer of the preceding edge related to the current graph data is linked to the newly inserted edge used to represent the current graph data to complete the insertion of the current graph data.
[0069] In one embodiment of the present invention, the column storage structure in the migration module 202 is a compressed array structure of an adjacency matrix.
[0070] In one embodiment of the present invention, the column storage module 203 is used to execute:
[0071] Divide the external memory of the LSM tree into several levels;
[0072] The graph data migrated from the old memory is stored starting from the top zero layer of the LSM tree external memory, and is compressed layer by layer from the upper layer column storage array to the lower layer into a global compressed array.
[0073] In one embodiment of the present invention, when executing a transactional query request to preferentially retrieve the first target graph data from the row storage structure of the LSM tree memory, the query module 204 is configured to:
[0074] The transactional query request first retrieves the first target graph data that meets the query condition from the row storage structure of the LSM tree memory;
[0075] If not found, the LSM tree external memory is searched layer by layer from the upper layer to the lower layer until the first target graph data is obtained.
[0076] In one embodiment of the present invention, when executing an analytical query request to preferentially retrieve the second target graph data from the column storage structure of the LSM tree external memory, the query module 204 is used to:
[0077] Analytical query requests first traverse the graph data layer by layer from the bottom layer to the top layer in the LSM tree external memory, and retrieve the second target graph data that meets the query conditions;
[0078] If not retrieved, continue traversing in the LSM tree memory until the second target graph data is obtained.
[0079] It should be noted that the graph storage device for transactional and analytical hybrid query loads provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the above device embodiment and the method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0080] The embodiment of the present application also provides a computer device, please refer to Figure 3 The computer device includes a processor and a memory, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the graph storage method for transactional and analytical hybrid query loads provided by the above-mentioned method embodiments.
[0081] An embodiment of the present application also provides a computer-readable storage medium, on which is stored at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the graph storage method for transactional and analytical hybrid query loads provided by the above-mentioned method embodiments.
[0082] An embodiment of the present application also provides a computer program product, which includes a computer program. A processor of a computer device reads the computer program from a computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the graph storage method for transactional and analytical hybrid query loads as described in any of the above embodiments.
[0083] For the convenience of description, the above system or device is described by dividing it into various modules or units according to its functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0084] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0085] Finally, it should be noted that, in this article, relational terms such as first, second, third and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0086] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A graph storage method for transactional and analytical hybrid query loads, characterized in that: The method comprises: Before reaching the upper limit of the capacity allocated in the LSM tree memory, the graph data is stored in a row storage structure for transactional queries; When the written graph data reaches the upper capacity limit, the LSM tree memory allocates new empty memory to store the new graph data in a row storage structure, and migrates the graph data in the old memory that has reached the upper capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory to store the new graph data in a row storage structure is the upper capacity limit; Convert the old graph data in memory into a columnar storage structure for analytical queries and store it in the LSM tree external memory; In response to receiving a hybrid query concurrent request, the transactional query request preferentially retrieves the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request preferentially retrieves the second target graph data from the column storage structure of the LSM tree external memory.
2. The method according to claim 1, characterized in that The row storage structure is an adjacency list structure; LSM tree memory stores graph data in a row-based storage structure in the following way: When storing the first graph data, the inserted edge is located in the corresponding adjacency table memory block based on the LSM tree memory sorting structure; For each graph data stored next, execute: New edge storage space is allocated for the adjacency list in memory, and the pointer of the preceding edge related to the current graph data is linked to the newly inserted edge used to represent the current graph data to complete the insertion of the current graph data.
3. The method according to claim 1, characterized in that The column storage structure is a compressed array structure of the adjacency matrix.
4. The method according to claim 3, characterized in that The step of converting the graph data in the old memory into a columnar storage structure for analytical queries and storing it in the LSM tree external memory includes: Divide the external memory of the LSM tree into several levels; The graph data migrated from the old memory is stored starting from the top zero layer of the LSM tree external memory, and is compressed layer by layer from the upper layer column storage array to the lower layer into a global compressed array.
5. The method according to claim 4, characterized in that The transactional query request preferentially retrieves the first target graph data from the row storage structure of the LSM tree memory, including: The transactional query request first retrieves the first target graph data satisfying the query condition from the row storage structure of the LSM tree memory; If not found, the LSM tree external memory is searched layer by layer from the upper layer to the lower layer until the first target graph data is obtained.
6. The method according to claim 5, characterized in that The analytical query request preferentially retrieves the second target graph data from the column storage structure of the LSM tree external memory, including: The analytical query request preferentially traverses the graph data layer by layer from the lower layer to the upper layer in the LSM tree external memory, and retrieves the second target graph data that meets the query condition; If not retrieved, continue traversing in the LSM tree memory until the second target graph data is obtained.
7. A graph storage device for transactional and analytical hybrid query loads, characterized in that: The device comprises: The row storage module is used to store graph data in a row storage structure for transactional queries before reaching the upper limit of the capacity allocated in the LSM tree memory; A migration module, configured to allocate new empty memory to the LSM tree memory to store the new graph data in a row storage structure when the graph data written reaches the upper capacity limit, and migrate the graph data in the old memory that has reached the upper capacity limit to the external memory of the LSM tree; wherein the upper limit of the new empty memory to store the new graph data in a row storage structure is the upper capacity limit; The column storage module is used to convert the graph data in the old memory into a column storage structure for analytical queries and store it in the LSM tree external memory; The query module is used to respond to the reception of a mixed query concurrent request, where the transactional query request gives priority to retrieving the first target graph data from the row storage structure of the LSM tree memory, and the analytical query request gives priority to retrieving the second target graph data from the column storage structure of the LSM tree external memory.
8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of any one of the methods described in claims 1-6.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The method comprises a computer program, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Business data query method and device and database system
CN104537030A
Hybrid index structure with storage perception
CN104899297A
Data storage and query method, device and equipment and computer storage medium
CN111291037A
Graph data storage architecture based on persistent memory
CN113961755A
Graph data storage method, reading method and system
CN116226425A
Cited By
Log structure merge tree compression state scanning method based on order-preserving dictionary
CN121008756A
