Dynamic weight-based graph database adjacency list cache management method and system
By using a dynamic weight management method, the problem of supernode adjacency lists being overtaken by ordinary nodes in graph databases is solved, improving cache hit rate and query performance, and achieving effective protection for supernodes and popular nodes.
Patent Information
- Application Number
- CN202511622024.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-11-07
AI Technical Summary
In graph databases, the adjacency list of supernodes is crowded out by ordinary nodes, resulting in a low cache hit rate and failing to effectively solve the performance problem of multi-hop queries.
A dynamic weight-based cache management method is adopted. The super node adjacency list is protected by inherent weights, and the overall weight of cache items is dynamically adjusted by combining the popularity value and the smooth increment strategy to ensure efficient use of cache space.
It improves cache hit rate, protects the adjacency table of super nodes with high access costs, prevents it from being squeezed out by ordinary nodes, takes into account the access needs of popular ordinary nodes, and improves overall query performance.
Smart Images

Figure CN121071190B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of graph database management, in particular to a graph database adjacency list cache management method and system based on dynamic weights. BACKGROUND
[0002] In a graph database, to ensure write performance, the physical storage of edges is usually scattered, which leads to the non-continuous storage of the adjacency list of a single node on the disk. Querying the neighbors of a node is a high-frequency operation, especially in a multi-hop query scenario. The association relationship of a graph often conforms to a power-law distribution, and there are a small number of super nodes with a large number of connection edges. These super nodes have a high access probability, but their huge adjacency list makes the disk reading operation very time-consuming and becomes a performance bottleneck.
[0003] Caching the adjacency list in memory is a common acceleration method. However, general cache algorithms such as LRU or LFU perform poorly in this scenario. Multi-hop queries will scan a large number of ordinary nodes, and their adjacency lists will quickly fill the cache space. Although the adjacency list of a super node is important and large, it is easily replaced in the cache due to the relatively slow accumulation of access frequency or large space occupation, resulting in a low cache hit rate and failing to effectively solve the performance problem of super node access. SUMMARY
[0004] Embodiments of the present application provide a graph database adjacency list cache management method and system based on dynamic weights, an electronic device and a storage medium to at least solve the problem of low cache hit rate caused by the adjacency list of a super node being occupied by ordinary nodes in a graph database in related technologies.
[0005] In a first aspect, embodiments of the present application provide a graph database adjacency list cache management method based on dynamic weights, which includes:
[0006] receiving a request for querying the adjacency list of a node, and finding a cache item corresponding to the adjacency list;
[0007] In a case where the request does not hit any cache item, generating a new cache item according to the adjacency list of the node, determining an inherent weight of the cache item based on the inherent properties of the node, setting an initial hotness value for the cache item, and obtaining a comprehensive weight of the cache item based on the inherent weight and the hotness value;
[0008] In a case where the request hits a cache item, obtaining a historical hotness value of the cache item, determining a new hotness value based on a smooth increment strategy and the historical hotness value, performing weighted summation on the new hotness value and the inherent weight of the cache item, and obtaining a comprehensive weight of the cache item;
[0009] In the case of insufficient cache space, the cache item with the smallest comprehensive weight is deleted.
[0010] In some embodiments, determining the new hotness value based on the smoothing increment strategy and the historical hotness value comprises:
[0011] determining a hotness decay value according to a decay factor and the historical hotness value;
[0012] obtaining a current access additional value based on the decay factor;
[0013] obtaining the new hotness value according to the hotness decay value and the current access additional value based on an exponential smoothing model.
[0014] In some embodiments, the exponential smoothing model comprises:
[0015] H_new = H_old * α + (1 - α)
[0016] wherein H_new is the new hotness value, H_old is the historical hotness value, α is the decay factor, H_old * α is the hotness decay value, and (1 - α) is the current access additional value.
[0017] In some embodiments, the method further comprises:
[0018] periodically globally decaying the hotness values of all cache items based on a global decay factor;
[0019] updating the comprehensive weight of the corresponding cache item according to the decayed hotness value.
[0020] In some embodiments, the inherent attribute comprises the degree of the node, and the formula for calculating the inherent weight comprises:
[0021] I = C * log(1 + degree)
[0022] wherein I is the inherent weight, C is a constant, and degree is the degree of the node.
[0023] In some embodiments, the weighted sum of the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item comprises:
[0024] obtaining the hit rate of the cache item and the trend of the hit rate;
[0025] determining a balance factor based on the trend of the hit rate;
[0026] weighting and summing the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item according to the balance factor.
[0027] In some embodiments, after generating the new cache entry according to the adjacency list of the node, the method further comprises:
[0028] determining a placement position of the new cache entry in the cache according to the inherent weight;
[0029] based on the placement position, searching the new cache entry and metadata thereof into the cache, wherein the metadata comprises the inherent weight, the hotness value and the comprehensive weight.
[0030] In a second aspect, the embodiments of the present application provide a graph database adjacency list cache management system based on dynamic weight, which comprises:
[0031] a searching module, configured to receive a request of searching an adjacency list of a node, and search a cache entry corresponding to the adjacency list;
[0032] a first weight determining module, configured to, in a case that the request does not hit any cache entry, generate a new cache entry according to the adjacency list of the node, determine an inherent weight of the cache entry based on inherent attributes of the node, set a hotness value of the cache entry as an initial hotness value, and obtain a comprehensive weight of the cache entry based on the inherent weight and the hotness value;
[0033] a second weight determining module, configured to, in a case that the request hits a certain cache entry, obtain a historical hotness value of the cache entry, determine a new hotness value based on a smooth increment strategy and the historical hotness value, and obtain a comprehensive weight of the cache entry by weighted summation of the new hotness value and the inherent weight of the cache entry;
[0034] a cache replacement module, configured to, in a case that cache space is insufficient, delete a cache entry with the smallest comprehensive weight.
[0035] In a third aspect, the embodiments of the present application provide a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the graph database adjacency list cache management method based on dynamic weight as described in the first aspect when executing the computer program.
[0036] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the program is executable on a processor to implement the graph database adjacency list cache management method based on dynamic weight as described in the first aspect.
[0037] Compared with the related art, the method for managing the adjacency list cache of the graph database based on the dynamic weight provided in the embodiments of the present application protects the adjacency list of the supernode with high access cost through the inherent weight, avoids the adjacency list of the supernode from being occupied by the ordinary node, and at the same time, takes into account the popular ordinary node through the heat value, so that the cache space is efficiently utilized, the data with the highest value is always reserved, and the overall cache hit rate is improved. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and together with the description serve to explain the present application. In the drawings:
[0039] Figure 1 is a flow chart of the method for managing the adjacency list cache of the graph database based on the dynamic weight according to the embodiments of the present application;
[0040] Figure 2 is a structural block diagram of the system for managing the adjacency list cache of the graph database based on the dynamic weight according to the embodiments of the present application;
[0041] Figure 3 is a schematic diagram of the internal structure of the electronic device according to the embodiments of the present application. DETAILED DESCRIPTION
[0042] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is described and explained below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.
[0043] Obviously, the drawings in the following description are only some examples or embodiments of the present application, and for those of ordinary skill in the art, the present application can be applied to other similar scenarios without creative labor on the basis of these drawings. In addition, it can be understood that although the efforts made in this development process can be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacture or production changes made on the basis of the technical content disclosed in the present application are only routine technical means and should not be understood as insufficient disclosure of the present application.
[0044] Reference to an "example" in this application means that a particular feature, structure, or characteristic described in connection with the example can be included in at least one example of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same example, nor are they necessarily mutually exclusive of other examples. Of course, one of ordinary skill in the art would understand that a reference to an example in this application can be a reference to an embodiment of the application that is not necessarily the same as other embodiments, unless explicitly stated otherwise.
[0045] Unless otherwise defined, technical terms or scientific terms used in the present application shall have the ordinary meanings as understood by one of ordinary skill in the art to which this application pertains. The terms "a", "an", "one", "this", and similar referents in the context of describing the application are to be construed to be open-ended, meaning one or more unless otherwise specifically noted. The terms "comprising", "containing", "having", and "including" and their variations are to be construed as open-ended terms that mean "including, but not limited to", unless otherwise noted. The terms "connected" and "coupled" and variations thereof are to be construed as possibly having a physical and / or electrical connection, unless otherwise noted. The term "multiple" means two or more. The term "and / or" describes association between or among multiple items and means that the items can be taken individually or in any combination. The term "first", "second", "third", and the like, merely denote different instances of a similar object without necessarily requiring or implying any specific order or chronology. The term "substantially" means that the recited characteristic, parameter, or value need not be achieved exactly, but that deviations or variations, including tolerances, rounding off, measurement error, valuing error, and other differences, can occur. The term "substantially" can vary from approximately 10% to 90%, more preferably, from 20% to 80%, and even more preferably, from 30% to 40%.
[0046] A graph database is a database that uses a graph structure for semantic queries, using nodes, edges, and properties to represent and store data.
[0047] A node is a basic unit in the graph data model, representing an entity.
[0048] An edge is a directed or undirected link connecting two nodes, representing a relationship between the nodes.
[0049] An adjacency list is a data structure used to represent a graph, storing for each node a list of all its adjacent nodes.
[0050] Degree refers to the number of edges a node is connected to.
[0051] A super node is a node in a graph database that has a degree much higher than the average.
[0052] Multi-hop query is a type of graph query, which needs to traverse multiple nodes connected by multiple edges.
[0053] The embodiment provides a graph database adjacency list cache management method based on dynamic weights. Figure 1 The flowchart of the graph database adjacency list cache management method based on dynamic weights according to the embodiment of the application is shown in Figure 1 The flowchart includes the following steps:
[0054] Step S101, receiving a request for querying the adjacency list of a node, and searching for a cache item corresponding to the adjacency list.
[0055] In the embodiment, the cache adopts Key-Value storage, Key represents a unique identifier of a node, and Value represents an adjacency list of the node.
[0056] Each cache item corresponds to a metadata entry, and the metadata entry includes a hotness value, an inherent weight, and a comprehensive weight.
[0057] The hotness value (H) is a value for reflecting recent access hotness.
[0058] The inherent weight (I) is a static weight value calculated based on inherent attributes of the node (for example, the degree of the node).
[0059] The comprehensive weight (W) is the maximum weight value combined by the hotness value (H) and the inherent weight (I), that is, W = f (H, I).
[0060] Receiving a request for querying the adjacency list of a node, searching for a cache item of the adjacency list, if the corresponding cache item is not found, performing step S102, and if the corresponding cache item is found, performing step S103.
[0061] Step S102, in the case that the request does not hit any cache item, generating a new cache item according to the adjacency list of the node, determining the inherent weight of the cache item based on the inherent attributes of the node, setting the hotness value of the cache item as an initial hotness value, and obtaining the comprehensive weight of the cache item based on the inherent weight and the hotness value.
[0062] If the request does not hit, the adjacency list of the node is loaded from the disk and inserted into the cache, and the metadata thereof is initialized.
[0063] Calculating the inherent weight (I): determining the inherent weight of the cache item according to the inherent attributes of the node.
[0064] Optionally, the inherent weight of the node is calculated according to the degree of the node. The calculation formula is as follows:
[0065] I = C * log (1 + degree)
[0066] wherein I is the inherent weight, degree is the degree of the node, and C is a configurable constant.
[0067] The greater the degree of the node, the greater the corresponding inherent weight, ensuring that the supernode has a higher inherent weight at the beginning of its birth. The inherent weight reflects the potential access value and high disk loading cost of the supernode.
[0068] Initialize the hotness value (H): the initial value can be set to 0 or a basic value.
[0069] Calculate the initial comprehensive weight (W): when the initial hotness value is 0, the initial W = I.
[0070] By setting the initial comprehensive weight of the cache item through this method, the supernode has a higher weight even if it has not been accessed, thereby being protected in cache competition.
[0071] In some embodiments, after generating the new cache item according to the adjacency list of the node in step S102, the method further includes:
[0072] Step S1021, determining the storage location of the new cache item inside the cache according to the inherent weight.
[0073] Step S1022, based on the storage location, searching the new cache item and its metadata into the cache, wherein the metadata includes the inherent weight, the hotness value, and the comprehensive weight.
[0074] Items with high inherent weights can be placed in cache areas with lower access delays, thereby improving the access efficiency of high-frequency access supernodes.
[0075] Step S103, in the case of a request hitting a certain cache item, obtaining the historical hotness value of the cache item, determining a new hotness value based on a smoothing increment strategy and the historical hotness value, and performing a weighted sum on the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item.
[0076] In some embodiments, determining the new hotness value based on the smoothing increment strategy and the historical hotness value in step S103 includes:
[0077] Step S1031, determining a hotness decay value according to the decay factor and the historical hotness value.
[0078] Step S1032, obtaining a current access additional value based on the decay factor.
[0079] Step S1033, obtaining the new hotness value based on an exponential smoothing model according to the hotness decay value and the current access additional value.
[0080] In some embodiments, the exponential smoothing model comprises:
[0081] H_new = H_old * a + (1 - a)
[0082] where H_new is the new hotness value, H_old is the historical hotness value, a is the decay factor, H_old * a is the hotness decay value, and (1 - a) is the current visit addition value.
[0083] It should be noted that the decay factor a is set according to the actual scene, for example, a is set to 0.9 according to historical data.
[0084] The embodiment adopts a smooth incremental strategy to update the hotness value, rather than simply adding 1, so that the cache item that is frequently accessed recently can quickly improve the hotness, but the accumulation of the hotness has an upper limit, avoiding the historical access record from being dominant for a long time.
[0085] The new hotness value H_new and the inherent weight I are used to recalculate the comprehensive weight W. Optionally, the comprehensive weight W is calculated according to the following formula:
[0086] W = b * I + (1 - b) * H_new
[0087] where b is a balance factor. The balance factor b can be a fixed value selected according to the actual situation, or a dynamic value that changes with the hit rate.
[0088] The embodiment adopts the comprehensive weight to ensure that the inherent value and the recent hotness of the node jointly determine the importance.
[0089] In some embodiments, the weighting sum of the new hotness value and the inherent weight of the cache item in step S103 to obtain the comprehensive weight of the cache item comprises:
[0090] In step S1034, the hit rate of the cache item and the change trend of the hit rate are obtained.
[0091] In step S1035, the balance factor is determined based on the change trend of the hit rate.
[0092] In step S1036, the weighting sum of the new hotness value and the inherent weight of the cache item is performed according to the balance factor, to obtain the comprehensive weight of the cache item.
[0093] The fixed b cannot adapt to all workloads. When the access mode changes dramatically, it may be necessary to dynamically adjust the proportion of the inherent value and the recent hotness.
[0094] The embodiment introduces a feedback control loop to monitor the change trend of the cache hit rate.
[0095] If the hit rate continues to decline, the system automatically increases β, so that the weight is more inclined to protect the high-cost node (a scan access to the supernode may occur).
[0096] If the hit rate is stable or rising, β can be appropriately reduced, and the weight of recent hotness is higher (it may be in the stage of frequent hot queries).
[0097] The embodiment changes the algorithm from "static configuration" to "adaptive dynamic optimization", and has stronger robustness.
[0098] In some embodiments, the method further comprises:
[0099] Based on the global decay factor, periodically decay the hotness value of all cache items globally;
[0100] Update the comprehensive weight of the corresponding cache item according to the decayed hotness value.
[0101] Periodically (e.g., every second) decay the hotness value (H) of all cache items globally. For example: H = H * γ, where γ is a global decay factor, such as 0.95.
[0102] Through global decay, the algorithm can adaptively forget old access patterns and preferentially retain recently active items.
[0103] Step S104, in the case of insufficient cache space, deleting the cache item with the smallest comprehensive weight.
[0104] When the cache space is insufficient to insert a new item, the cache item with the smallest current comprehensive weight (W) is selected for elimination. Since the supernode has a high inherent weight (I), even if its hotness value (H) decays due to temporary non-access, its comprehensive weight W is difficult to decrease to the lowest level, thereby effectively avoiding the problem of being "crowded out" of the cache by ordinary nodes. The comprehensive weight takes into account both supernodes and popular ordinary nodes, and the elimination mechanism naturally tends to eliminate items that are neither supernodes nor recently popular.
[0105] Through the above steps, the inherent weight protects the supernode adjacency list with high access cost, avoiding the adjacency list of the supernode being crowded out by ordinary nodes; through the hotness value (H) and the periodic decay mechanism, the algorithm can sensitively capture and respond to changes in access patterns, protecting both supernodes and suddenly popular ordinary nodes; the design of the comprehensive weight makes the cache space be used efficiently, always retaining "the most valuable" data, and improving the overall cache hit rate. Moreover, the algorithm has small computational complexity, only a small number of numerical values need to be maintained and simple arithmetic operations are performed, with extremely low overhead.
[0106] It is noted that the steps shown in the above flow or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0107] The embodiment also provides a dynamic weight-based graph database adjacency list cache management system for implementing the above embodiment and preferred embodiment, which has been described above and will not be repeated. As used below, the terms "module", "unit", "sub-unit" and the like can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiment is preferably implemented in software, hardware or a combination of software and hardware is also possible and contemplated.
[0108] Figure 2 is a structural block diagram of a dynamic weight-based graph database adjacency list cache management system according to the embodiment of the application, as shown in Figure 2 The system comprises:
[0109] The finding module 21 is configured to receive a request for querying an adjacency list of a node, and find a cache item corresponding to the adjacency list.
[0110] The first weight determination module 22 is configured to, in a case where the request does not hit any cache item, generate a new cache item according to the adjacency list of the node, determine an inherent weight of the cache item based on inherent attributes of the node, set a hotness value of the cache item as an initial hotness value, and obtain a comprehensive weight of the cache item based on the inherent weight and the hotness value.
[0111] The second weight determination module 23 is configured to, in a case where the request hits a certain cache item, obtain a historical hotness value of the cache item, determine a new hotness value based on a smooth increment strategy and the historical hotness value, and perform weighted summation on the new hotness value and an inherent weight of the cache item to obtain a comprehensive weight of the cache item.
[0112] The cache replacement module 24 is configured to, in a case where the cache space is insufficient, delete a cache item with the smallest comprehensive weight.
[0113] In some embodiments, the second weight determination module 23 comprises:
[0114] The hotness decay module is configured to determine a hotness decay value according to a decay factor and the historical hotness value.
[0115] The access additional module is configured to obtain a current access additional value based on the decay factor.
[0116] The hotness update module is configured to obtain a new hotness value based on an exponential smoothing model, according to the hotness decay value and the current access additional value.
[0117] In some embodiments, the exponential smoothing model comprises:
[0118] H_new = H_old *α+ (1 -α)
[0119] wherein H_new is a new hotness value, H_old is a historical hotness value, α is a decay factor, H_old *α is a hotness decay value, and (1 -α) is a current visit addition value.
[0120] In some embodiments, the system further comprises a global decay module configured to periodically decay the hotness value of all cache items based on a global decay factor, and update the comprehensive weight of the corresponding cache item according to the decayed hotness value.
[0121] In some embodiments, the intrinsic attribute comprises a degree of the node, and the calculation formula of the intrinsic weight comprises:
[0122] I = C * log(1 + degree)
[0123] wherein I is the intrinsic weight, C is a constant, and degree is the degree of the node.
[0124] In some embodiments, the second weight determination module 23 comprises:
[0125] a hit rate change module configured to obtain a hit rate of the cache item and a change trend of the hit rate.
[0126] a parameter determination module configured to determine a balance factor based on the change trend of the hit rate.
[0127] a comprehensive weight calculation module configured to weight and sum the new hotness value and the intrinsic weight of the cache item according to the balance factor to obtain the comprehensive weight of the cache item.
[0128] In some embodiments, the first weight determination module 22 comprises:
[0129] a position determination module configured to determine a storage position of the new cache item inside the cache according to the intrinsic weight.
[0130] an insertion module configured to search the new cache item and its metadata into the cache based on the storage position, wherein the metadata comprises the intrinsic weight, the hotness value and the comprehensive weight.
[0131] Through the system, the inherent weight protects the super node adjacency list with high access cost, and avoids the adjacency list of the super node from being occupied by the ordinary node; through the heat value (H) and the periodic decay mechanism, the algorithm can sensitively capture and respond to the change of the access mode, protects the super node, and also takes into account the suddenly popular ordinary node; the design of the comprehensive weight makes the cache space be efficiently utilized, always retains the "most valuable" data, and improves the overall cache hit rate. The algorithm has small calculation amount, only needs to maintain a small number of values and perform simple arithmetic operations, and has extremely low cost.
[0132] It should be noted that the above various modules can be functional modules or program modules, which can be implemented by software or hardware. For the modules implemented by hardware, the above various modules can be located in the same processor; or the above various modules can also be located in different processors in any combination.
[0133] The embodiment also provides an electronic device including a memory and a processor, the memory storing a computer program, and the processor being configured to execute the computer program to perform the steps in any of the above method embodiments.
[0134] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.
[0135] Optionally, in the embodiment, the processor can be configured to execute the following steps through the computer program:
[0136] S1, receiving a request for querying a node adjacency list, and finding a cache item corresponding to the adjacency list.
[0137] S2, in a case where the request does not hit any cache item, generating a new cache item according to the adjacency list of the node, determining an inherent weight of the cache item based on the inherent attribute of the node, setting a heat value of the cache item as an initial heat value, and obtaining a comprehensive weight of the cache item based on the inherent weight and the heat value.
[0138] S3, in a case where the request hits a cache item, obtaining a historical heat value of the cache item, determining a new heat value based on a smooth increment strategy and the historical heat value, and performing weighted summation on the new heat value and the inherent weight of the cache item to obtain a comprehensive weight of the cache item.
[0139] S4, in a case where the cache space is insufficient, deleting a cache item with the minimum comprehensive weight.
[0140] It should be noted that the specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.
[0141] In one embodiment, Figure 3 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, as Figure 3 indicated, an electronic device is provided, which can be a server, the internal structure diagram of which can be as Figure 3 indicated. The electronic device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capability. The memory of the electronic device includes a non-volatile storage medium, an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the electronic device is used to store data. The network interface of the electronic device is used to communicate with the external terminal through the network connection. The computer program is executed by the processor to implement a dynamic weight-based graph database adjacency list cache management method.
[0142] Those skilled in the art can understand that Figure 3 the structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0143] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM) and the like.
[0144] Those skilled in the art should understand that each technical feature of the above-described embodiments can be combined arbitrarily, and for the sake of brevity, each technical feature of the above-described embodiments is not described in all possible combinations, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the description.
[0145] The above-described embodiments only express several implementation manners of the present application, the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.
Claims
1. A graph database adjacency list cache management method based on dynamic weights, characterized in that, The method includes: Receive a request to query the node adjacency table and find the corresponding cache entry in the adjacency table; If the request does not hit any cached item, a new cached item is generated based on the adjacency list of the node, the inherent weight of the cached item is determined based on the inherent attributes of the node, and the popularity value of the cached item is set as the initial popularity value. The comprehensive weight of the cached item is obtained based on the inherent weight and the popularity value. The inherent attributes of the node include the degree of the node, which refers to the number of edges connected to the node. When the request hits a cache item, the historical popularity value of the cache item is obtained, a new popularity value is determined based on the smooth increment strategy and the historical popularity value, and the new popularity value and the inherent weight of the cache item are weighted and summed to obtain the comprehensive weight of the cache item. If there is insufficient cache space, delete the cache item with the lowest overall weight; The process of determining a new popularity value based on a smooth incremental strategy and the historical popularity values includes: The heat decay value is determined based on the decay factor and the historical heat value. Based on the attenuation factor, the additional value for this visit is obtained; Based on the exponential smoothing model, the new popularity value is obtained according to the popularity decay value and the additional value of this visit; the exponential smoothing model includes: H_new = H_old *α + (1 -α) Where H_new is the new popularity value, H_old is the historical popularity value, α is the decay factor, H_old * α is the popularity decay value, and (1 - α) is the additional value for this visit.
2. The method according to claim 1, characterized in that, The method further includes: Based on a global decay factor, the popularity value of all cached items is periodically decayed globally. The overall weight of the corresponding cache item is updated based on the decayed popularity value.
3. The method according to claim 1, characterized in that, The inherent attributes include the degree of the node; the formula for calculating the inherent weight includes: I = C * log(1 + degree) Where I is the inherent weight, C is a constant, and degree is the degree of the node.
4. The method according to claim 1, characterized in that, The weighted summation of the new popularity value and the inherent weight of the cached item to obtain the comprehensive weight of the cached item includes: Obtain the hit rate of the cached item and the trend of the hit rate; Based on the trend of the hit rate, determine the balance factor; Based on the balance factor, the new popularity value and the inherent weight of the cache item are weighted and summed to obtain the comprehensive weight of the cache item.
5. The method according to claim 1, characterized in that, After generating a new cache entry based on the node's adjacency list, the method further includes: The storage location of the new cache item within the cache is determined based on the inherent weight; Based on the storage location, the new cache item and its metadata are retrieved and cached, wherein the metadata includes inherent weight, popularity value and comprehensive weight.
6. A graph database adjacency list caching management system based on dynamic weights, characterized in that, The system includes: The lookup module is used to receive requests to query the adjacency table of nodes and to look up the cached entries corresponding to the adjacency table; The first weight determination module is used to generate a new cache item based on the adjacency list of the node when the request does not hit any cache item, determine the inherent weight of the cache item based on the inherent attributes of the node, set the popularity value of the cache item as the initial popularity value, and obtain the comprehensive weight of the cache item based on the inherent weight and the popularity value. The inherent attributes of the node include the degree of the node, which refers to the number of edges connected to the node. The second weight determination module is used to obtain the historical popularity value of the cache item when the request hits a certain cache item, determine a new popularity value based on the smooth increment strategy and the historical popularity value, and perform a weighted summation of the new popularity value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item. The process of determining a new popularity value based on a smooth incremental strategy and the historical popularity values includes: The heat decay value is determined based on the decay factor and the historical heat value. Based on the attenuation factor, the additional value for this visit is obtained; Based on the exponential smoothing model, the new popularity value is obtained according to the popularity decay value and the additional value of this visit; the exponential smoothing model includes: H_new = H_old *α + (1 -α) Where H_new is the new popularity value, H_old is the historical popularity value, α is the decay factor, H_old * α is the popularity decay value, and (1 - α) is the additional value for this visit; The cache replacement module is used to delete the cache item with the lowest overall weight when there is insufficient cache space.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the graph database adjacency list cache management method based on dynamic weights as described in any one of claims 1 to 5.
8. A storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the dynamic weight-based graph database adjacency list cache management method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Real-time indexing method and system for efficient combined query of power big data
CN112765178A
Data processing
WO2025176121A1