Entity topological graph storage method and device, equipment and storage medium
By obtaining and serializing the node data of the entity topology graph in parallel and saving files according to the node order, the problem of long storage time of large-scale CAD models is solved, improving efficiency and user experience.
Patent Information
- Application Number
- CN202411647290.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-04-04
AI Technical Summary
When the prior art deals with large-scale CAD models, the running time of entity preservation is long, which affects the efficiency of the three-dimensional geometric modeling engine, and users cannot perform modeling operations when the entity preservation is performed.
By obtaining the node order of the entity topology graph, obtaining the serialized data of each node in parallel, using the thread pool for parallel serialization, and saving the serialized data according to the node order to improve the file storage speed.
Improves the serialization efficiency and file saving speed of entity topology graphs, reduces the running time required for entity saving, and allows users to perform modeling operations during saving.
Smart Images

Figure CN119759856A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for storing a physical topology map. Background Art
[0002] B-Rep (Boundary Representation) is a commonly used representation method in computer-aided design (CAD) and computer graphics to describe the geometry of entities. In B-Rep, the geometry of an entity is described by its boundary and topological information. This representation method contains the geometric information and topological structure of the entity, making it more convenient and accurate to model, analyze and operate the entity.
[0003] In the prior art, a conventional solution for saving a B-Rep entity as a file is to convert the topology map of the B-Rep entity into a specific file format that can support the storage and exchange of B-Rep data.
[0004] However, with the development of manufacturing, especially high-end manufacturing such as aircraft and shipbuilding, the scale of models processed by CAD software is getting larger and larger, which puts higher requirements on the efficiency of 3D geometric modeling engines in processing large-scale data. And due to the particularity of the entity preservation algorithm in geometric modeling, users cannot perform modeling operations while saving entities, so users are very sensitive to the running time of the entity preservation algorithm.
[0005] Therefore, there is an urgent need in the art for an entity preservation method with high operating efficiency and short running time required for saving into files. Summary of the invention
[0006] The present invention provides a method, device, equipment and storage medium for storing an entity topology map, which improves the efficiency of serializing the entity topology map and speeds up the file storage speed of the entity topology map.
[0007] The present invention provides a method for saving an entity topology map, comprising the following steps: obtaining the node sequence corresponding to the entity topology map, obtaining serialized data of each node in the entity topology map in parallel, the node sequence is used to indicate the order in which each node is accessed, and the serialized data of each node is obtained by formatting the information of each node in the topology map; saving the serialized data of each node according to the node sequence to obtain a saved file corresponding to the entity topology map.
[0008] According to a method for saving an entity topology map provided by the present invention, the node order corresponding to the entity topology map is obtained, including: writing the starting node of the entity topology map into a node queue; when the node queue is not empty, executing the following loop: taking out a target node from the head of the node queue, visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue, marking the target node as visited, and repeating the loop until the node queue is empty; using a sequential data structure to save the order in which each node is added to obtain the node order, and the order in which each node is added is used to indicate the order in which each node is added to the node queue.
[0009] According to a method for saving an entity topology map provided by the present invention, before visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue, the method also includes: determining whether the target node is the same as any node saved in the tuple; visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue includes: when the target node is not the same as any node saved in the tuple, visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue.
[0010] According to a method for saving an entity topology map provided by the present invention, obtaining serialized data of each node in the entity topology map includes: calling a thread in a thread pool according to a target calling strategy to determine a target thread, wherein the target calling strategy includes at least one of a contention strategy, a thread binding strategy and a time statistics prediction strategy; using the target thread to serialize each node in the entity topology map to obtain serialized data of each node.
[0011] According to a method for saving an entity topology map provided by the present invention, the serialized data of each node is saved according to the node sequence to obtain a saved file corresponding to the entity topology map, including: writing the basic information of the entity topology map into the file header of a model file; writing the serialized data of each node into the model file according to the node sequence; after writing into the file tail of the model file, closing the model file to obtain a saved file corresponding to the entity topology map.
[0012] According to a method for saving an entity topology map provided by the present invention, the method also includes: storing the serialized data of each node in a hierarchical cache area based on the number of references corresponding to each node, wherein the more references corresponding to the node, the faster the access speed of the cache partition stored therein, and the cache partition is the storage area in the hierarchical cache area.
[0013] According to a method for preserving a physical topology map provided by the present invention, the method also includes: in the hierarchical cache area, determining whether to delete the serialized data of each node based on the size relationship between the time difference corresponding to the serialized data of each node and a preset time difference threshold, the time difference corresponding to each node is calculated based on the most recent access time corresponding to the serialized data of each node and the current time; or, when the total number of accesses corresponding to the serialized data of all nodes reaches a preset first number threshold, determining whether to delete the serialized data of each node based on the size relationship between the number of accesses corresponding to the serialized data of each node and a preset second number threshold.
[0014] The present invention also provides a device for saving an entity topology map, comprising the following modules: a serialization module, used to obtain the serialized data of each node in the entity topology map in parallel while obtaining the node sequence corresponding to the entity topology map, the node sequence is used to indicate the order in which each node is accessed, and the serialized data of each node is obtained by formatting the information of each node in the topology map; a storage module, used to save the serialized data of each node according to the node sequence to obtain a saved file corresponding to the entity topology map.
[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the above-mentioned entity topology map saving methods is implemented.
[0016] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for saving an entity topology map as described above is implemented.
[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned entity topology map storage methods.
[0018] The entity topology map storage method, device, equipment and storage medium provided by the present invention perform node traversal and serialization simultaneously, thereby improving the efficiency of serialization of the entity topology map, accelerating the file storage speed of the entity topology map, and also using the node traversal order for file storage, thereby ensuring the logical order of serialized data writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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.
[0020] Figure 1 It is a flow chart of a method for saving a physical topology map provided by the present invention.
[0021] Figure 2 It is a schematic diagram of the overall process of a method for saving an entity topology map provided by the present invention.
[0022] Figure 3 It is a workflow diagram of a parallel optimized B-Rep entity preservation method provided by the present invention.
[0023] Figure 4 It is a structural schematic diagram of the entity topology map storage device provided by the present invention.
[0024] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0027] Figure 1 This is one of the flow diagrams of the method for saving a physical topology map provided by the present invention. The physical topology map saving method can be applied to electronic devices, which can be various types of devices with information processing capabilities during implementation. For example, the electronic device can include a personal computer, a laptop, a PDA or a server, etc.; the electronic device can also be a mobile terminal, for example, the mobile terminal can include a mobile phone, a car computer, a tablet computer or a projector, etc. Figure 1 As shown, the method may include the following steps 110 to 120: Step 110: While obtaining the node sequence corresponding to the entity topology map, serialized data of each node in the entity topology map is obtained in parallel. The node sequence is used to indicate the order in which each node is accessed. The serialized data of each node is obtained by formatting the information of each node in the topology map.
[0028] A main thread is used to traverse an entity topology graph such as a B-Rep topology graph, and the order in which the main thread visits the nodes in the topology graph is saved in real time to obtain the node order corresponding to the entity graph.
[0029] In addition to the main thread, there is also a serialization thread in this application, and the serialization thread and the main thread are in parallel. Specifically, during the traversal of the main thread, the serialization thread will also serialize the information of each node in the entity topology map to obtain serialized data of each node.
[0030] The nodes in the above topological graph, also known as topological nodes, are used to store specific information of entities, mainly node intrinsic information and geometric data information. The topological structure of a topological graph such as a B-Rep topological graph includes: faces, edges, points, and their connected components. The geometric information of a topological graph includes: surfaces, curves, and points under geometric definitions. In a topological graph, a face is defined as a bounded part of a surface, an edge is defined as a bounded part of a curve, and a point is located on the same three-dimensional space coordinate as a geometric point. In addition to the above main parts, a topological graph also includes other topological elements such as shells and loops, which are defined as a set of connected faces and boundary loops of faces, respectively. A three-dimensional geometric modeling engine generally uses graph data structures to represent B-Rep entities. These abstract graph data structures represent the topological information of B-Rep entities, so they are called topological graphs. The edges in a topological graph represent the topological relationship between different topological nodes.
[0031] In one embodiment of the present application, the node order corresponding to the entity topology map is obtained, including: writing the starting node of the entity topology map into a node queue; when the node queue is not empty, executing the following loop: taking out the target node from the head of the node queue, visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue, marking the target node as visited, and repeating the loop until the node queue is empty; using a sequential data structure to save the order in which each node is added to obtain the node order, and the order in which each node is added is used to indicate the order in which each node is added to the node queue.
[0032] Determine the starting node in the topology graph. The starting node is all the nodes in the topology graph when traversing, and add the starting node to the node queue.
[0033] It is determined whether the node queue is empty, and when the node queue is not empty, multiple loops are executed.
[0034] In each cycle, a node is taken from the head of the node queue and used as the target node. The target node is visited, and all the neighboring nodes corresponding to the target node that have not been visited are added to the tail of the node queue, marking the target node as visited.
[0035] The loop is repeated multiple times until the node queue is empty.
[0036] A sequential data structure is used to save the order in which each node is added. For example, the main thread uses a sequential data structure list to save the order in which the nodes are written to obtain the node order.
[0037] In the above embodiment, all possible paths are explored layer by layer and all nodes are traversed, thereby ensuring the logical correctness of the traversal process.
[0038] In one embodiment of the present application, before visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue, the method also includes: determining whether the target node is the same as any node saved in the tuple; visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue includes: when the target node is not the same as any node saved in the tuple, visiting the target node and adding all unvisited neighbor nodes corresponding to the target node to the tail of the node queue.
[0039] The main thread determines whether the topological node has been visited by maintaining a tuple. When a node is visited, it is added to the tuple. Therefore, after the main thread determines the target node, the main thread will also determine whether the target node is the same as any node saved in the tuple.
[0040] If it is found that the node is the same as the node in the tuple, it means that the node is already in the tuple, and the main thread traverses to the node for the second time during the traversal, and the related processing can be skipped.
[0041] If the target node is different from any node saved in the tuple, it means that the main thread is traversing to the node for the first time, then the target node in the topology graph is visited, and all the neighbor nodes corresponding to the target node that have not been visited are added to the tail of the node queue.
[0042] In the above embodiment, the nodes that have been visited are recorded by tuples to ensure that each node is visited only once, thereby further ensuring the logical correctness of the node traversal.
[0043] In one embodiment of the present application, obtaining serialized data of each node in the entity topology graph includes: calling a thread in a thread pool according to a target calling strategy to determine a target thread, wherein the target calling strategy includes at least one of a contention strategy, a thread binding strategy, and a time statistics prediction strategy; using the target thread to serialize each node in the entity topology graph to obtain serialized data of each node.
[0044] The main thread evenly loads the serialization work of the topological nodes in the thread pool. The thread pool is preset and includes multiple serialization threads. The threads in the thread pool can be threads with the same code logic or threads with specific optimizations for certain node types. When a thread in the thread pool receives a topological node, it serializes the topological and geometric information inside the topological node according to the code logic to obtain serialized data and saves it in memory. The serialized data can be a character string or a binary byte string. Finally, the thread passes the serialized data to the serialized data manager. The serialized data manager stores the serialized data in the form of a hash table, with the topological node id as the primary key of the hash table.
[0045] The main thread will call the threads in the thread pool according to the preset target calling strategy, and use the called threads to serialize the nodes. This application presets a variety of thread pool load schemes, including: contention strategy, thread binding strategy, and time statistics prediction strategy. Among them, the contention strategy does not provide any additional scheduling, which is suitable for situations where the topological characteristics of the B-Rep entity are uncertain, and is the most universal load strategy. The thread binding strategy binds specific threads to only process a certain type of topological node. This strategy is suitable for individual optimization of specific threads in the thread pool. The time statistics prediction strategy dynamically adjusts the thread pool, including the number of threads and thread types, based on the thread pool's past serialization time records of topological nodes.
[0046] In the above embodiment, the target calling strategy is used to call the threads in the thread pool to ensure that the nodes can be serialized by the optimal thread, which further improves the efficiency of serialization and ensures the balanced load of the threads, reduces the waiting time, and speeds up the serialization.
[0047] Step 120: Save the serialized data of each node according to the node sequence to obtain a saved file corresponding to the entity topology map.
[0048] Use the entity traversal order of the node queue as the topological node order in the file writing phase. Write the serialized data into the file to obtain the saved file corresponding to the entity topology graph.
[0049] The above-mentioned entity topology map saving method traverses and serializes nodes simultaneously, thereby improving the efficiency of serializing the entity topology map, accelerating the file saving speed of the entity topology map, and also using the node traversal order for file saving to ensure the logical order of serialized data writing.
[0050] In one embodiment of the present application, the serialized data of each node is saved according to the node sequence to obtain a saved file corresponding to the entity topology map, including: writing basic information of the entity topology map into the file header of a model file; writing the serialized data of each node into the model file according to the node sequence; after writing into the file tail of the model file, closing the model file to obtain a saved file corresponding to the entity topology map.
[0051] The main thread will perform the serialization work of the entity topology map and the thread pool on the topology nodes at the same time, and the file writing work will be carried out after the two are completed.
[0052] Furthermore, the main thread arranges and modifies the node sequence obtained by its traversal (if modification is required or the user specifies the modification, such as specifying to save or not save a certain type of node data), and then passes the node sequence to the serialized data manager.
[0053] The serialized data manager opens the file and first writes the model file header to record basic information such as the software version number, file version number, and file writing time. Then, the corresponding serialized data is written to the file in sequence according to the obtained node sequence as the writing sequence. Finally, the file tail is written to indicate the end of the file and the file is closed after completion. When the data manager writes the file, you can also choose to write the writing sequence and other information at the same time.
[0054] In one embodiment of the present application, the method further includes: storing the serialized data of each node in a hierarchical cache area based on the number of references corresponding to each node, wherein the more references corresponding to the node, the faster the access speed of the cache partition stored therein, and the cache partition is the storage area in the hierarchical cache area.
[0055] After a single file is saved, in order to avoid multiple saves of the same B-Rep entity, or if the user only makes a small change to the model, the model is backed up midway. The data in the serialized data manager will be stored in memory for a long time.
[0056] At the same time, the manager sets up a hierarchical cache area to record the references of different topological nodes. For example, there are multiple storage areas in the hierarchical cache area: A, B, and C. The cache priority of area A is greater than the cache priority of area B, and the cache priority of area B is greater than the cache priority of area C. The cache priority can be set according to demand, for example, the cache priority is set according to the access speed. The faster the access speed of a storage area, the higher the priority set for the storage area.
[0057] The more times a node is referenced, the higher the priority of the storage area where it is located should be. For example, if the number of references of a node is 1, it can be stored in cache area C, but as the number of references increases, it will be stored in cache area B.
[0058] Multi-level caches can handle a variety of situations, including high-frequency references to topological nodes in a short period of time.
[0059] In the above embodiment, the serialized data of the node is cached, so that the same topology map can be saved multiple times quickly, and the saving speed of the topology map can also be accelerated when the user makes partial modifications.
[0060] In one embodiment of the present application, the method further includes: in the hierarchical cache area, determining whether to delete the serialized data of each node based on the relationship between the time difference corresponding to the serialized data of each node and a preset time difference threshold, the time difference corresponding to each node being calculated based on the most recent access time corresponding to the serialized data of each node and the current time; or, when the total number of accesses corresponding to the serialized data of all nodes reaches a preset first number threshold, determining whether to delete the serialized data of each node based on the relationship between the number of accesses corresponding to the serialized data of each node and a preset second number threshold.
[0061] The serialized data manager will not permanently save all serialized data. It can adopt two data forgetting strategies, namely time-based strategy and count-based strategy.
[0062] Under the time strategy, the manager forgets the data after the fixed time of the last access to the data, and re-records the time each time the data is accessed. For example, the time difference corresponding to the serialized data of each node is calculated. A time difference is calculated based on the last access time and the current time corresponding to the serialized data of a node. The time difference of each serialized data is compared with the preset time difference threshold, and whether to delete the data is determined based on the comparison result. For example, if the time difference of a serialized data is greater than the preset time difference threshold, the data is deleted, otherwise the data is retained.
[0063] Under the counting strategy, the manager records the overall access frequency. If some nodes are not accessed for more than a fixed number of times, the data will be forgotten. For example, the total number of accesses corresponding to the serialized data of all nodes is calculated. When the total number of accesses reaches the preset first number threshold, the number of accesses corresponding to the serialized data of each node is obtained, and the number of accesses of each serialized data is compared with the preset second number threshold to determine whether to delete the serialized data of each node.
[0064] In the above embodiment, the serialized data in the cache space is cleaned up according to the preset strategy to reduce the occupation of the cache space by data that has not been used for a long time, and cache space can be generated for new serialized data, thereby reducing the storage resource occupation and improving the storage efficiency of the new entity topology map.
[0065] The following describes an exemplary application of an embodiment of the present invention in a practical application scenario. Figure 2 The overall flow diagram of a method for saving a physical topology diagram provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method comprises the following steps S1 to S7: S1: The main thread uses BFS to traverse the B-Rep entity topology graph. The main thread determines whether the topological node has been visited by maintaining a tuple. When a node is visited, it is added to the tuple. If the main thread traverses the node for the second time during the traversal, it will be found that it is already in the tuple, and the relevant processing can be skipped. The main thread ensures the logical correctness of BFS through the node queue, and uses the entity traversal order of the node queue as the topological node order in the file writing phase. The main thread uses the sequential data structure list to save the write order of the nodes.
[0066] S2. The main thread evenly loads the serialization work of the topological nodes in the thread pool. There are multiple preset thread pool load schemes, including the contention strategy, thread binding strategy, and time statistics prediction strategy. The contention strategy does not provide any additional scheduling and is suitable for situations where the topological characteristics of the B-Rep entity are uncertain. It is the most universal load strategy. The thread binding strategy binds a specific thread to only process a certain type of topological node. This strategy is suitable for individual optimization of specific threads in the thread pool. The time statistics prediction strategy dynamically adjusts the thread pool, including the number of threads and thread types, based on the thread pool's past serialization time records of topological nodes.
[0067] S3. The threads in the thread pool can be threads with the same code logic or threads optimized for certain node types. When a thread in the thread pool receives a topology node, it serializes the topology and geometry information inside the topology node according to the code logic to obtain serialized data and saves it in memory. The serialized data can be a character string or a binary byte string. Finally, the thread passes the serialized data to the serialized data manager. The serialized data manager stores the serialized data in the form of a hash table, with the topology node id as the primary key of the hash table.
[0068] S4, the main thread traverses the B-Rep entity topology map and the thread pool serializes the topology nodes at the same time, and waits for both to complete before writing the file. Figure 3 As shown, Figure 3 A workflow diagram of a parallel optimized B-Rep entity preservation method provided by the present invention. Figure 3 In the process, the main thread traverses the B-Rep entity topology graph and the thread pool serializes the topology nodes at the same time. During the main thread traversal, it determines whether the traversed node is serialized. If it is not serialized, it is handed over to the thread pool for serialization. If it is already serialized, the node is skipped. After the main thread traverses the B-Rep entity topology graph and the thread pool serializes the topology nodes, the file is written.
[0069] S5. The main thread arranges and modifies the node sequence obtained by its traversal (if modification is required or the user specifies the modification, such as specifying to save or not save a certain type of node data). After completion, the node sequence is passed to the serialized data manager.
[0070] S6. The serialized data manager opens the file and first writes the model file header to record basic information such as the software version number, file version number, and file writing time. Then, the corresponding serialized data is written to the file in sequence according to the obtained node sequence as the writing sequence. Finally, the file tail is written to indicate the end of the file and the file is closed after completion. When the data manager writes the file, you can also choose to write the writing sequence and other information at the same time.
[0071] S7. After a single file is saved, in order to avoid multiple saves of the same B-Rep entity, or if the user only makes a small change to the model, the model is backed up in the middle. The data in the serialized data manager will be stored in the memory for a long time. At the same time, the manager sets up a hierarchical cache area to record the references of different topological nodes. The multi-level cache area can handle various situations, including high-frequency references to topological nodes in a short period of time. Of course, the serialized data manager will not permanently save all serialized data. It has two data forgetting strategies, namely time-based strategy and count-based strategy. Under the time strategy, the manager forgets the data after the fixed time of the last access to the data, and re-records the time each time the data is accessed. Under the counting strategy, the manager records the overall access frequency. If some nodes are not accessed for more than a fixed number of times, the data will be forgotten.
[0072] Based on the above embodiments, the embodiments of the present invention provide a device for storing a physical topology map. Each module included in the device and each unit included in each module can be implemented by a processor; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc. The XX device provided by the present invention is described below, and the physical topology map storage device described below and the physical topology map storage method described above can be referred to each other.
[0073] Figure 4 A schematic diagram of the structure of a device for storing a physical topology map provided by an embodiment of the present invention. Figure 4 As shown, the apparatus 400 includes a serialization module 410 and a storage module 420, wherein: A serialization module 410 is used to obtain serialized data of each node in the entity topology graph in parallel when obtaining the node sequence corresponding to the entity topology graph, wherein the node sequence is used to indicate the order in which each node is accessed, and the serialized data of each node is obtained by formatting the information of each node in the topology graph; The storage module 420 stores the serialized data of each node according to the node sequence to obtain a storage file corresponding to the entity topology map.
[0074] In some embodiments, the serialization module 410 is specifically used to write the starting node of the entity topology map into a node queue; when the node queue is not empty, execute the following loop: take out the target node from the head of the node queue, visit the target node and add all the unvisited neighbor nodes corresponding to the target node to the tail of the node queue, mark the target node as visited, and repeat the loop until the node queue is empty; use a sequential data structure to save the order in which each node is added to obtain the node order, and the order in which each node is added is used to indicate the order in which each node is added to the node queue.
[0075] In some embodiments, the serialization module 410 is also used to determine whether the target node is the same as any node stored in the tuple; and, when the target node is not the same as any node stored in the tuple, access the target node and add all unvisited neighbor nodes corresponding to the target node to the tail of the node queue.
[0076] In some embodiments, the serialization module 410 is also used to call the threads in the thread pool according to the target calling strategy to determine the target thread, wherein the target calling strategy includes at least one of a contention strategy, a thread binding strategy and a time statistics prediction strategy; and use the target thread to serialize each node in the entity topology diagram to obtain serialized data of each node.
[0077] The storage module 420 is specifically used to write the basic information of the entity topology map into the file header of the model file; write the serialized data of each node into the model file according to the node order; after writing the file tail of the model file, close the model file to obtain the saved file corresponding to the entity topology map.
[0078] The storage module 420 is also used to store the serialized data of each node in a hierarchical cache area according to the number of references corresponding to each node, wherein the more references corresponding to the node, the faster the access speed of the cache partition stored therein, and the cache partition is the storage area in the hierarchical cache area.
[0079] The storage module 420 is also used to determine whether to delete the serialized data of each node in the hierarchical cache area based on the relationship between the time difference corresponding to the serialized data of each node and a preset time difference threshold, where the time difference corresponding to each node is calculated based on the most recent access time corresponding to the serialized data of each node and the current time; or, when the total number of accesses corresponding to the serialized data of all nodes reaches a preset first number threshold, determine whether to delete the serialized data of each node based on the relationship between the number of accesses corresponding to the serialized data of each node and a preset second number threshold.
[0080] Figure 5 A schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the entity topology map saving method provided by the above methods.
[0081] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0082] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the entity topology map saving method provided by the above methods.
[0083] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0084] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the entity topology map saving method provided by the above methods.
[0085] The above-mentioned computer-readable storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0086] Computer-readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0087] The program code embodied on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0088] Computer program code for performing the operations of the present specification may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0089] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0090] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for storing a physical topology map, characterized in that: The method comprises: In the case of obtaining the node sequence corresponding to the entity topology graph, serialized data of each node in the entity topology graph is obtained in parallel, the node sequence is used to indicate the order in which each node is accessed, and the serialized data of each node is obtained by formatting the information of each node in the topology graph; The serialized data of each node is saved according to the node sequence to obtain a saved file corresponding to the entity topology diagram.
2. The method according to claim 1, characterized in that The obtaining of the node sequence corresponding to the entity topology graph includes: Writing the starting node of the entity topology graph into a node queue; When the node queue is not empty, the following loop is executed: taking the target node from the head of the node queue, visiting the target node and adding all the neighboring nodes corresponding to the target node that have not been visited to the tail of the node queue, marking the target node as visited, and repeating the loop until the node queue is empty; A sequential data structure is used to save the order in which each node joins, so as to obtain the node order. The order in which each node joins is used to indicate the order in which each node joins the node queue.
3. The method according to claim 2, characterized in that Before visiting the target node and adding all the unvisited neighbor nodes corresponding to the target node to the tail of the node queue, the method further includes: Determine whether the target node is the same as any node stored in the tuple; The step of visiting the target node and adding all the neighboring nodes corresponding to the target node that have not been visited to the tail of the node queue includes: In the case that the target node is not the same as any node stored in the tuple, the target node is visited and all the neighboring nodes corresponding to the target node that have not been visited are added to the tail of the node queue.
4. The method according to claim 1, characterized in that: The obtaining of serialized data of each node in the entity topology graph includes: Calling a thread in a thread pool according to a target calling strategy to determine a target thread, wherein the target calling strategy includes at least one of a contention strategy, a thread binding strategy, and a time statistics prediction strategy; The target thread is used to serialize each node in the entity topology graph to obtain serialized data of each node.
5. The method according to claim 1, characterized in that The step of saving the serialized data of each node according to the node sequence to obtain a saved file corresponding to the entity topology graph includes: Writing the basic information of the entity topology map into the file header of the model file; Writing the serialized data of each node into the model file according to the node order; After writing the file tail of the model file, the model file is closed to obtain a saved file corresponding to the entity topology diagram.
6. The method according to claim 1, characterized in that The method further comprises: According to the number of references corresponding to each node, the serialized data of each node is stored in a hierarchical cache area, wherein the more references corresponding to the node, the faster the access speed of the cache partition stored therein is, and the cache partition is the storage area in the hierarchical cache area.
7. The method according to claim 6, characterized in that The method further comprises: In the hierarchical cache area, determining whether to delete the serialized data of each node is based on the size relationship between the time difference corresponding to the serialized data of each node and a preset time difference threshold, wherein the time difference corresponding to each node is calculated based on the most recent access time corresponding to the serialized data of each node and the current time; or, When the total number of accesses corresponding to the serialized data of all nodes reaches a preset first number threshold, it is determined whether to delete the serialized data of each node based on the relationship between the number of accesses corresponding to the serialized data of each node and the preset second number threshold.
8. A device for storing a physical topology map, characterized in that: The device comprises: A serialization module, used to obtain serialized data of each node in the entity topology graph in parallel when obtaining the node sequence corresponding to the entity topology graph, wherein the node sequence is used to indicate the order in which each node is accessed, and the serialized data of each node is obtained by formatting the information of each node in the topology graph; The storage module is used to save the serialized data of each node according to the node sequence to obtain the saved file corresponding to the entity topology map.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the entity topology map saving method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for saving an entity topology map according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for saving an entity topology map according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
A method and apparatus for storing graph data
CN109492131A
Data serialization method and device, data deserialization method and device, equipment and storage medium
CN116340993A
Picture processing method and related device
CN118113961A
Graph data importing method, electronic equipment and graph data importing system
CN118568142A