Path update methods, devices, media, and program products based on node movement
By constructing a node path table and concurrently executing path update tasks, the problem of database transaction extension caused by large-scale node movement in smart community device topology management is solved, thereby improving system responsiveness and data consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN LEELEN TECH CO LTD
- Filing Date
- 2026-01-26
- Publication Date
- 2026-06-02
AI Technical Summary
In smart community device topology management, large-scale node movement operations caused by device location adjustments or changes in property management can prolong database transaction execution time and affect the system's concurrent processing capabilities.
A path update method based on a node path table is adopted. By constructing a node path table, the subtree range can be quickly identified, and path update tasks can be executed concurrently to avoid recursive traversal and writing one by one. A thread pool or message queue is used to implement the task queue, record the task status, and retry failed tasks.
Significantly shortens transaction execution time, reduces database lock contention, improves system responsiveness and resource utilization in high-concurrency scenarios, and ensures data consistency.
Smart Images

Figure CN122137782A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data management technology, specifically to a path update method, device, medium, and program product based on node movement. Background Technology
[0002] In smart community device topology management, a tree structure is typically used to hierarchically manage a large number of devices. However, in real-world business scenarios, operations such as device location adjustments, regional reorganization, or changes in property management can frequently trigger device node movements. When a device node is migrated to a new parent node, not only does the node path of that device node itself need to be updated, but the node paths of all its descendant devices (such as access control systems and sensors under rooms) also need to be updated synchronously. In large-scale smart communities, a single movement may involve hundreds or even thousands of device nodes. If traditional recursive traversal or update-by-update methods are used, it may lead to long database transactions and lock contention, affecting the system's concurrent processing capabilities. Summary of the Invention
[0003] This disclosure provides a path update method, electronic device, medium, and program product based on node movement.
[0004] According to one aspect of this disclosure, a path update method based on node movement is provided for updating the topology relationships of smart community devices, comprising: constructing tree structure data representing the topology relationships between smart community devices, wherein nodes in the tree structure data represent smart community devices, and the node paths of each node in the tree structure data represent the topology relationships between smart community devices; constructing a node path table corresponding to the tree structure data based on the node paths of each node in the tree structure data, wherein the node path table records the node identifier and node path of each node in the tree structure data; and, in response to a node movement request, extracting the node identifier of the node to be moved and the node identifier of the target parent node contained in the node movement request, wherein the target parent node... The node is the parent node of the node to be moved after the node is moved; based on the node identifier of the node to be moved, the corresponding node path is searched from the node path table as the prefix to be replaced; based on the prefix to be replaced, the node path containing the prefix to be replaced is searched from the node path table to obtain at least one path to be updated; based on the node identifier of the target parent node, the corresponding node path is searched from the node path table to obtain the target parent node path; based on the target parent node path and the node identifier of the node to be moved, the node path after the node to be moved is formed as the target prefix; and the target prefix is used to replace the prefix to be replaced contained in the path to be updated to obtain the path update result of the path to be updated.
[0005] According to one technical solution, recursive traversal and record-by-record writing can be avoided, significantly shortening transaction execution time, thereby reducing database lock contention and improving system responsiveness in high-concurrency scenarios.
[0006] According to at least one embodiment of this disclosure, using the target prefix to replace the prefix to be replaced contained in each path to be updated includes: dividing the plurality of paths to be updated into a plurality of path sets, constructing a path update task for each path set, and executing each path update task concurrently, wherein the path update task performs the operation of replacing the prefix to be replaced contained in each path to be updated.
[0007] According to the technical solution of this embodiment, by breaking down large-scale update tasks into multiple small batches for concurrent execution, the database lock waiting time can be significantly reduced and the concurrent processing capability can be improved.
[0008] According to at least one embodiment of this disclosure, concurrent execution of each path update task includes: adding each path update task to a task queue, wherein the task queue is implemented using a thread pool or a message queue; and concurrently executing each path update task through the task queue.
[0009] According to the technical solution of this embodiment, task scheduling efficiency and resource utilization can be effectively improved, and path update delay can be further reduced.
[0010] According to at least one embodiment of this disclosure, concurrent execution of each path update task further includes: recording the execution status of each path update task; and re-executing the corresponding path update task if the execution status is a failure.
[0011] According to the technical solution of this embodiment, by recording the execution status of each path update task and automatically retrying when it fails, the fault tolerance and data consistency of the path update process can be effectively improved, ensuring the reliable completion of large-scale node migration operations.
[0012] According to at least one embodiment of this disclosure, after replacing the prefix to be replaced contained in the path to be updated, the method further includes: generating a request completion notification and returning it.
[0013] According to the technical solution of this embodiment, the operation results can be fed back in a timely manner, and a clear triggering time can be provided for subsequent operations such as cache synchronization.
[0014] According to at least one embodiment of this disclosure, after generating the request completion notification, the method further includes: deleting a cache entry containing the path to be updated stored in the cache, the cache being used to store search results for finding node paths containing the prefix to be replaced from the node path table, each cache entry in the cache corresponding to a search result, the cache entry using the prefix to be replaced as the cache key, and each node path containing the prefix to be replaced as the cache value of the cache entry.
[0015] According to the technical solution of this embodiment, by actively deleting the cache item with the prefix to be replaced as the cache key after the request is completed, the subtree query results that have become invalid due to path changes can be accurately cleared, thus avoiding subsequent business logic from reading expired or incorrect device topology data.
[0016] According to at least one embodiment of this disclosure, the cache uses Redis, and the cache key of each cache item is recorded using a Set data structure.
[0017] According to the technical solution of this embodiment, the cache index can be managed efficiently, and it is convenient to delete cache items related to path updates in batches or precisely.
[0018] According to another aspect of this disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, causing the processor to perform a node-movement-based path update method according to any embodiment of this disclosure.
[0019] According to another aspect of this disclosure, a readable storage medium is provided, wherein executable instructions are stored therein, which, when executed by a processor, are used to implement a node-movement-based path update method according to any embodiment of this disclosure.
[0020] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a node-movement-based path update method according to any embodiment of this disclosure.
[0021] This disclosure avoids recursive traversal and record-by-record writing, significantly shortening transaction execution time, thereby reducing database lock contention and improving system responsiveness in high-concurrency scenarios. Attached Figure Description
[0022] The accompanying drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0023] Figure 1This is a flowchart illustrating a path update method based on node movement according to one embodiment of the present disclosure.
[0024] Figure 2 This is a flowchart illustrating a method for concurrent execution of path update tasks according to one embodiment of the present disclosure.
[0025] Figure 3 This is a flowchart illustrating a method for concurrent execution of path update tasks according to another embodiment of this disclosure.
[0026] Figure 4 This is a schematic block diagram of a path update device according to one embodiment of the present disclosure.
[0027] Figure 5 This is a schematic structural block diagram of an electronic device employing a processor-based hardware implementation according to one embodiment of the present disclosure. Detailed Implementation
[0028] The present disclosure will now be described in further detail with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are for illustrative purposes only and are not intended to limit the scope of the disclosure. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the accompanying drawings.
[0029] It should be noted that, where there is no conflict, the embodiments and features described in this disclosure can be combined with each other. The technical solutions of this disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0030] Current smart community management platforms typically need to maintain large-scale device topology trees (tree-structured data representing the topological relationships between smart community devices). Frequent device location adjustments trigger node movement. Traditional recursive update methods have significant drawbacks in handling such operations: Firstly, subtree range identification relies on recursive traversal or full table scans, which is inefficient and puts a heavy burden on the database. Secondly, because traditional solutions require recursively traversing the subtree and updating the path of each node one by one when a node moves, a single operation involves a large number of database reads and writes, significantly extending transaction execution time. Such long transactions can lead to severe lock contention in high-concurrency scenarios, resulting in slow system response or even request timeouts.
[0031] To address this, this disclosure proposes the following technical solution. First, the node paths of each node in the tree structure data are recorded using a node path table. Then, when a node is moved, the subtree range is quickly identified based on the path of the node to be moved as a prefix. Next, a new path prefix is generated by combining the target parent node path and the identifier of the node to be moved. Finally, a batch replacement operation is used to update the path of the entire subtree in one go. This disclosure avoids recursive traversal and line-by-line writing, significantly shortening transaction execution time, thereby reducing database lock contention and improving system responsiveness in high-concurrency scenarios.
[0032] To facilitate description and make the technical solutions of this disclosure easier to understand, the terminology of this disclosure will be explained before describing the technical solutions of this disclosure.
[0033] Topological relationships refer to the hierarchical relationships formed by devices based on their physical deployment location or logical management structure, specifically manifested as parent-child relationships, ancestor-descendant relationships, etc. in a tree structure.
[0034] A thread pool is a multi-threaded processing mechanism used to manage and reuse a set of pre-created threads to efficiently execute a large number of short-lived asynchronous tasks.
[0035] Message queues are a middleware mechanism for implementing reliable asynchronous communication in distributed systems or asynchronous processing architectures.
[0036] This disclosure applies to smart community device topology management scenarios, and is particularly applicable to smart community device topology relationship updating scenarios.
[0037] Figure 1 A schematic diagram illustrating the overall flow of a node-movement-based path update method according to one embodiment of this disclosure is shown. Figure 1 The method shown includes steps S110 to S180. This method can be executed by electronic devices such as mobile phones and tablets.
[0038] In step S110, a tree structure data is constructed to represent the topological relationships between smart community devices. Nodes in the tree structure data represent smart community devices. The node paths of each node in the tree structure data represent the topological relationships between the smart community devices.
[0039] In a smart community device management system, to manage the hierarchical relationships among a large number of smart community devices (such as buildings, units, rooms, access control systems, cameras, etc.), a tree-structured data model can be used to model the topological relationships between smart community devices, resulting in a tree-structured data representing these relationships. In the constructed tree-structured data, each node corresponds to a smart community device, and the parent-child relationship between nodes reflects the subordinate relationship of smart community devices in their physical deployment location or logical management structure (e.g., "the room belongs to a certain unit," "the access control system is installed in a certain room," etc.).
[0040] As one possible implementation, the node path data structure can be a string format separated by forward slashes (" / ") to support prefix matching queries. For example, a node path of " / 1 / 3 / 5 / " indicates that the node identifier of the smart community device is 5, the node identifier of its parent node is 3, and the node identifier of its grandparent node (i.e., the parent node's parent node) is 1. The node path completely records the hierarchical relationship from the root node to the current node.
[0041] In step S120, a node path table corresponding to the tree structure data is constructed based on the node paths of each node in the tree structure data. The node path table records the node identifier and node path of each node in the tree structure data.
[0042] Compared to the closure table model, which requires storing one record for each ancestor-descendant relationship, resulting in a storage space complexity of O(N²), the node path table used in this implementation only adds a node path field to the original node table, with a storage space complexity of O(N). This complexity increases linearly with the number of nodes, effectively avoiding the resource pressure caused by storage expansion in large-scale tree structures.
[0043] As one possible implementation, the node path table uses a two-dimensional table. The rows in the node path table correspond to each node, and the columns include a node identifier field and a node path field. The node identifier field records the node identifier of each node (such as the smart community device ID). The node path field records the node path of each node. The node path table allows for quick retrieval of the node path for each node.
[0044] As one possible implementation, the node path table can be stored in a database for subsequent node path lookups. For example, the database can be a relational database such as MySQL or PostgreSQL.
[0045] In step S130, in response to the node move request, the node identifier of the node to be moved and the node identifier of the target parent node contained in the node move request are extracted. The target parent node is the parent node of the node to be moved after it has been moved.
[0046] Node move requests can be generated when a user needs to change the topology of smart community devices, such as moving a room in a unit and its associated smart community devices (e.g., access control, cameras) to another building or unit. In this case, the "room in a unit" can be designated as the node to be moved, and the "other building or unit" as the target parent node.
[0047] It should be noted that when there is only one smart community device requiring topology changes, the node corresponding to that smart community device can be directly designated as the node to be moved. When there are multiple smart community devices requiring topology changes, and these devices correspond to a subtree in the tree structure data, only the root node of that subtree needs to be designated as the node to be moved. The node paths of all descendant nodes (nodes other than the root node) in the subtree can then be automatically updated.
[0048] In step S140, the corresponding node path is searched from the node path table based on the node identifier of the node to be moved, and used as the prefix to be replaced.
[0049] The prefix to be replaced is the complete path of the node to be moved. For example, the node identifier of the node to be moved is 5, and the node path found in the node path table is " / 1 / 3 / 5 / ". This node path " / 1 / 3 / 5 / " is used as the prefix to be replaced.
[0050] In step S150, based on the prefix to be replaced, the node path containing the prefix to be replaced is searched from the node path table to obtain at least one path to be updated.
[0051] The node path containing the prefix to be replaced, obtained from the node path table, is usually the node path of each descendant node in the subtree rooted at the node whose node path is the prefix to be replaced.
[0052] Based on the example above, the prefix to be replaced is " / 1 / 3 / 5 / ". Searching the node path field of the node path table for node paths containing the prefix " / 1 / 3 / 5 / " will yield at least one such path. This at least one path will be used as the path to be updated. It should be noted that the node paths obtained from the node path table must at least include the path of the node to be moved itself (i.e., " / 1 / 3 / 5 / "). Therefore, the resulting path to be updated must include at least one such path. In one example, the resulting path to be updated could include: " / 1 / 3 / 5 / " (itself), " / 1 / 3 / 5 / 7 / " (child node), " / 1 / 3 / 5 / 7 / 9 / " (grandchild node), etc.
[0053] As one possible implementation, the process of finding node paths containing the prefix to be replaced from the node path table can be achieved using path prefix matching queries (e.g., executing WHERE path LIKE ' / 1 / 3 / 5 / %' in SQL) to quickly locate all descendant node paths prefixed with " / 1 / 3 / 5 / ". This implementation's string prefix-based query method effectively utilizes database indexes, significantly improving query efficiency and outperforming traditional adjacency list models that rely on recursive traversal for subtree identification.
[0054] In step S160, the corresponding node path is found in the node path table based on the node identifier of the target parent node to obtain the target parent node path.
[0055] For example, the node identifier of the target parent node is 4. The node path corresponding to node identifier 4, found from the node path table, is " / 2 / 4 / ". Therefore, the node path " / 2 / 4 / " is taken as the target parent node path.
[0056] In step S170, the node path after the node to be moved is formed based on the target parent node path and the node identifier of the node to be moved, and is used as the target prefix.
[0057] Based on the example above, the target parent node path is " / 2 / 4 / ", and the node identifier of the node to be moved is 5. The node path after the node to be moved needs to meet the data format of the node path. Therefore, the node identifier "5" and a forward slash (" / ") of the node to be moved are added sequentially after the target parent node path " / 2 / 4 / ", resulting in the target prefix " / 2 / 4 / 5 / ".
[0058] In step S180, the target prefix is used to replace the prefix to be replaced in the path to be updated, and the path update result of the path to be updated is obtained.
[0059] Based on the example above, the prefix to be replaced is " / 1 / 3 / 5 / ", the paths to be updated include " / 1 / 3 / 5 / ", " / 1 / 3 / 5 / 7 / ", and " / 1 / 3 / 5 / 7 / 9 / ", and the target prefix is " / 2 / 4 / 5 / ". Replacing " / 1 / 3 / 5 / " in " / 1 / 3 / 5 / ", " / 1 / 3 / 5 / 7 / ", and " / 1 / 3 / 5 / 7 / 9 / " with " / 2 / 4 / 5 / " results in the following path updates: " / 2 / 4 / 5 / ", " / 2 / 4 / 5 / 7 / ", and " / 2 / 4 / 5 / 7 / 9 / ".
[0060] The embodiments described above in this disclosure store the node paths of each node in the tree structure data using a node path table, which provides a fast indexing basis for identifying the node paths of each node within the subsequent subtree range. By querying the path to be updated based on the prefix matching method of the prefix to be replaced, the node paths of the node to be moved and all its descendant nodes can be located efficiently, avoiding the high time complexity caused by traditional recursive traversal.
[0061] As one possible implementation, a target prefix is used to replace the prefixes to be replaced in each path to be updated. This includes: dividing multiple paths to be updated into multiple path sets, constructing a path update task for each path set, and executing each path update task concurrently. The path update task performs the operation of replacing the prefixes to be replaced in each path to be updated. This implementation significantly reduces database lock waiting time and improves concurrent processing capabilities by breaking down large-scale update tasks into multiple small batches for concurrent execution. Simultaneously, the asynchronous execution method allows node movement operations to quickly respond to users without blocking the main business process.
[0062] As one possible implementation, the task information for the path update task may include the target prefix, the prefix to be replaced, and the path to be updated.
[0063] As one possible implementation, when dividing multiple paths to be updated into multiple path sets, the paths can be divided into multiple path sets according to a fixed batch size (e.g., 100 nodes per batch), with each path set containing the number of paths to be updated equal to the fixed batch size. The batch size can be dynamically adjusted based on database performance and business characteristics, and is not limited here.
[0064] As one possible implementation, each path update task is executed within an independent database transaction. Multiple paths in the path set are updated in batches using a database batch update statement (e.g., `UPDATE nodes SET path = REPLACE(path, ' / 1 / 3 / 5 / ', ' / 2 / 4 / 5 / ') WHERE id IN (...)`). This implementation keeps the execution time of a single transaction within a short range (e.g., less than 100 milliseconds), avoiding prolonged holding of database locks.
[0065] Figure 2 A flowchart illustrating a method for concurrent execution of path update tasks according to one embodiment of this disclosure is shown. Figure 2 The method shown includes steps S210 to S220.
[0066] In step S210, each path update task is added to the task queue, which is implemented using a thread pool or a message queue.
[0067] In step S220, update tasks for each path are executed concurrently through a task queue.
[0068] This implementation method can effectively improve task scheduling efficiency and resource utilization, and further reduce path update latency.
[0069] Figure 3 A flowchart illustrating a method for concurrent execution of path update tasks according to another embodiment of this disclosure is shown. Figure 3 The method shown includes steps S310 to S340. Steps S310-S320 respectively correspond to... Figure 2 For details of steps S210-S220 of the implementation method, please refer to [link / reference]. Figure 2 The relevant descriptions of the implementation methods will not be repeated here.
[0070] In step S330, the execution status of each path update task is recorded.
[0071] In step S340, if the execution status is failed, the corresponding path update task is re-executed.
[0072] This implementation method effectively improves the fault tolerance and data consistency of the path update process by recording the execution status of each path update task and automatically retrying when it fails, thus ensuring the reliable completion of large-scale node migration operations.
[0073] As one possible implementation, after replacing the prefix to be replaced in the path to be updated, the method further includes: generating and returning a request completion notification. By generating and returning a request completion notification after the path replacement is completed, the operation result can be fed back in a timely manner, and a clear triggering time can be provided for subsequent operations such as cache synchronization.
[0074] As one possible implementation, after generating the request completion notification, the method further includes: deleting cache entries containing the paths to be updated stored in the cache. The cache stores lookup results from the node path table for finding node paths containing the prefix to be replaced. Each cache entry corresponds to a lookup result. The cache entry uses the prefix to be replaced as the cache key and the node paths containing the prefix to be replaced as the cache value. Based on the above example, the cache key in the cache entry can include the prefix to be replaced " / 1 / 3 / 5 / ", and the cache value can be a list of paths to be updated, such as [" / 1 / 3 / 5 / ", " / 1 / 3 / 5 / 7 / ", " / 1 / 3 / 5 / 7 / 9 / "]. This implementation, by actively deleting cache entries with the prefix to be replaced as the cache key after the request is completed, can accurately clear subtree query results that have become invalid due to path changes, avoiding performance fluctuations caused by full cache refreshes in traditional solutions and eliminating data inconsistency windows.
[0075] As one possible implementation, the cache uses Redis, recording the cache keys of each cached item through a Set data structure. This implementation can efficiently manage the cache index and facilitate batch or precise deletion of cached items related to path updates.
[0076] As one possible implementation, when deleting cache entries containing paths to be updated stored in the cache, batch deletion operations can be performed using batch deletion commands (such as Redis's DEL or UNLINK commands). Compared to individual deletion operations, the batch deletion operation used in this implementation can significantly reduce the number of network round trips and improve deletion efficiency.
[0077] As one possible implementation, path updates and cache invalidation can be coordinated through an event-driven architecture. After a node path update is successful, a cache change event is published; the cache service subscribes to this event and executes the deletion operation of the corresponding cache item. If the cache item deletion fails, a failure log can be recorded and a retry mechanism can be triggered, thereby ensuring eventual consistency between the database and the cache in a distributed environment and preventing expired data from impacting business operations.
[0078] According to any of the above embodiments, this disclosure also provides a path update apparatus 400. Figure 4 This is a schematic block diagram of a path update device 400 according to one embodiment of this disclosure. Figure 4 As shown, the path update device 400 includes a tree structure data construction module 410, a node path table construction module 420, a node identifier extraction module 430, a prefix to be replaced determination module 440, a path to be updated determination module 450, a target parent node path determination module 460, a target prefix determination module 470, and a path replacement module 480.
[0079] The tree structure data construction module 410 is used to construct tree structure data to represent the topological relationship between smart community devices. The nodes in the tree structure data represent smart community devices, and the node paths of each node in the tree structure data represent the topological relationship between smart community devices.
[0080] The node path table construction module 420 is used to construct the node path table corresponding to the tree structure data based on the node path of each node in the tree structure data. The node path table records the node identifier and node path of each node in the tree structure data.
[0081] The node identifier extraction module 430 is used to respond to a node movement request by extracting the node identifier of the node to be moved and the node identifier of the target parent node contained in the node movement request. The target parent node is the parent node of the node to be moved after it has been moved.
[0082] The prefix determination module 440 is used to find the corresponding node path from the node path table based on the node identifier of the node to be moved, and use it as the prefix to be replaced.
[0083] The path to be updated determination module 450 is used to search for a node path containing the prefix to be replaced in the node path table based on the prefix to be replaced, and obtain at least one path to be updated.
[0084] The target parent node path determination module 460 is used to find the corresponding node path from the node path table based on the node identifier of the target parent node, and obtain the target parent node path.
[0085] The target prefix determination module 470 is used to compose the node path of the node to be moved after it has been moved, based on the target parent node path and the node identifier of the node to be moved, and use it as the target prefix.
[0086] The path replacement module 480 is used to replace the prefix to be replaced in the path to be updated using the target prefix, so as to obtain the path update result of the path to be updated.
[0087] The path update device 400 disclosed herein can be implemented via a computer software architecture.
[0088] According to further embodiments of this disclosure, an electronic device is also provided. Figure 5 This diagram illustrates a schematic block diagram of an electronic device employing a processor-based hardware implementation according to an embodiment of the present disclosure. The hardware structure of the electronic device of the present disclosure can be implemented using a bus architecture. The bus architecture can include any number of interconnect buses and bridges, depending on the specific application and overall design constraints of the hardware. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc. Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one connecting line is used in this figure, but this does not indicate that there is only one bus or one type of bus.
[0089] This disclosure also provides a readable storage medium storing a computer program that, when executed by a processor, is used to implement the methods described above. A "readable storage medium" can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples of a readable storage medium include: an electrical connection with one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable read-only memory (CDROM), etc.
[0090] This disclosure also provides a computer program product, the methods of which can be implemented wholly or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially as a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, all or part of the processes or functions of this disclosure are performed.
[0091] Computer programs or instructions can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any available medium capable of access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or it can include both volatile and non-volatile types of storage media.
[0092] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0094] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0095] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0096] In the description of this specification, the references to terms such as "one embodiment / mode," "some embodiments / modes," "example," "specific example," or "some examples," etc., refer to specific features, structures, or characteristics described in connection with that embodiment / mode or example, which are included in at least one embodiment / mode or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment / mode or example. Moreover, the specific features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments / modes or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments / modes or examples described in this specification, as well as the features of different embodiments / modes or examples.
[0097] Those skilled in the art should understand that the above embodiments are merely for illustrating the present disclosure and are not intended to limit the scope of the disclosure. Those skilled in the art can make other changes or modifications based on the above disclosure, and these changes or modifications still fall within the scope of the present disclosure.
Claims
1. A path update method based on node movement for updating the topology of smart community devices, characterized in that, include: Construct a tree structure data to represent the topological relationship between smart community devices, wherein the nodes in the tree structure data represent the smart community devices, and the node paths of each node in the tree structure data represent the topological relationship between the smart community devices; Based on the node paths of each node in the tree structure data, a node path table corresponding to the tree structure data is constructed. The node path table records the node identifier and node path of each node in the tree structure data. In response to a node move request, extract the node identifier of the node to be moved and the node identifier of the target parent node contained in the node move request, wherein the target parent node is the parent node of the node to be moved after it has been moved. Based on the node identifier of the node to be moved, the corresponding node path is searched from the node path table and used as the prefix to be replaced; Based on the prefix to be replaced, search the node path table for a node path containing the prefix to be replaced to obtain at least one path to be updated; Based on the node identifier of the target parent node, the corresponding node path is found in the node path table to obtain the target parent node path; Based on the target parent node path and the node identifier of the node to be moved, the node path after the node to be moved is formed, which serves as the target prefix; as well as Using the target prefix, the prefix to be replaced in the path to be updated is replaced to obtain the path update result of the path to be updated.
2. The path update method based on node movement as described in claim 1, characterized in that, Using the target prefix, the prefix to be replaced contained in each path to be updated is replaced, including: The multiple paths to be updated are divided into multiple path sets, and a path update task is constructed for each path set. The path update tasks are executed concurrently, and each path update task performs the operation of replacing the prefix to be replaced contained in each path to be updated.
3. The path update method based on node movement as described in claim 2, characterized in that, Concurrent execution of update tasks for each path, including: Add each path update task to a task queue, which is implemented using a thread pool or a message queue; and The update tasks for each path are executed concurrently through the task queue.
4. The path update method based on node movement as described in claim 3, characterized in that, Concurrent execution of update tasks for each path also includes: Record the execution status of update tasks for each path; and If the execution status is failed, the corresponding path update task will be re-executed.
5. The path update method based on node movement as described in claim 1, characterized in that, After replacing the prefix to be replaced in the path to be updated, the process further includes: generating a request completion notification and returning it.
6. The path update method based on node movement as described in claim 5, characterized in that, Following the generation of the request completion notification, the following is also included: Delete the cache entry containing the path to be updated stored in the cache. The cache is used to store the search results of finding the node path containing the prefix to be replaced from the node path table. Each cache entry in the cache corresponds to a search result. The cache entry uses the prefix to be replaced as the cache key and each node path containing the prefix to be replaced as the cache value of the cache entry.
7. The path update method based on node movement as described in claim 6, characterized in that, The cache uses Redis, and the cache key of each cache item is recorded using a Set data structure.
8. An electronic device, characterized in that, include: The memory stores execution instructions; as well as A processor that executes the execution instructions stored in the memory, causing the processor to perform the path update method based on node movement as described in any one of claims 1 to 7.
9. A readable storage medium, characterized in that, The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the path update method based on node movement as described in any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the path update method based on node movement as described in any one of claims 1 to 7.