Spaceborne router variable-length key-value data reading method and device, equipment and medium
Patent Information
- Application Number
- CN202511145686.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2045-08-15
AI Technical Summary
[0005]本发明提供一种星载路由器变长键值数据读取方法、装置、设备及介质,用以解决现有技术中受限于功耗和内存资源约束以致难以实现对变长键值数据高效、低延迟查找的缺陷,通过充分利用内存的高速性和硬盘的大容量特性,兼顾查找速度和存储容量,适合星载路由器的资源受限环境,实现性能与存储的平衡
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the variable-length key-value data reading method for a spaceborne router as described above.
Smart Images

Figure CN121193307B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, device, and medium for reading variable-length key-value data from a spaceborne router. Background Technology
[0002] With the rapid development of space information networks (such as satellite internet), spaceborne routers, as core nodes, undertake the critical task of high-speed on-orbit packet addressing and forwarding. However, compared with ground-based equipment, the operating environment of spaceborne routers is extremely demanding, placing extreme requirements on power consumption, memory resources, response latency, and reliability. With the evolution of network protocols and the diversification of service requirements, traditional fixed-length key-value pair lookup mechanisms are gradually becoming insufficient to support the complex data structures such as variable-length identifiers and policy descriptions in future networks. Therefore, how to achieve efficient lookup of large-scale, dynamic, and variable-length key-value pairs under limited resource conditions has become a significant challenge in current spaceborne router technology research.
[0003] Currently, for variable-length key-value pair lookups, one approach is based on hash tables. These techniques map variable-length keys to fixed-length hash values using hash functions to support fast lookups. Another approach is based on tree structures, such as Trie trees or B+ trees. These methods can handle variable-length keys and achieve efficient lookups through hierarchical indexing. In addition, there are hybrid approaches, such as combining hash tables with tree structures or using multi-level indexing mechanisms to balance lookup speed and memory usage. These methods are widely used in ground systems, and some techniques are optimized for memory and storage media, such as using Flash storage for auxiliary index structures.
[0004] However, while the aforementioned technologies perform well in terrestrial environments, they reveal significant shortcomings in the specific scenarios of spaceborne routers. First, hash table-based schemes often require additional memory to store the keys themselves when processing variable-length keys, and hash collisions increase lookup latency and complexity, making it difficult to meet the low latency and deterministic requirements of spaceborne systems. Second, while tree-structured schemes support variable-length keys, their lookup process typically requires multiple memory accesses, resulting in high latency and instability, making it difficult to meet the line-speed forwarding performance requirements of spaceborne routers. Furthermore, while hybrid schemes alleviate resource consumption issues to some extent, their implementation complexity is high, and performance and resource efficiency remain difficult to balance in dynamic update and large-scale data scenarios. Therefore, existing technologies cannot achieve efficient, low-latency lookups of variable-length key-value pairs under the strict resource constraints of spaceborne routers. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and medium for reading variable-length key-value data from a spaceborne router. It addresses the shortcomings of existing technologies that are limited by power consumption and memory resource constraints, making it difficult to achieve efficient and low-latency lookup of variable-length key-value data. By fully utilizing the high speed of memory and the large capacity of hard disk, it balances lookup speed and storage capacity, making it suitable for the resource-constrained environment of spaceborne routers and achieving a balance between performance and storage.
[0006] This invention provides a method for reading variable-length key-value data from a spaceborne router, comprising: acquiring variable-length key-value data; wherein the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; searching a preset index table based on the key of the variable-length key-value data to obtain corresponding index information; wherein the preset index table is created or updated in the memory of the spaceborne router based on the corresponding newly added variable-length key-value data; and reading the corresponding value information of the variable-length key-value data based on the index information and the preset key-value table; wherein the preset key-value table is created or updated in the hard disk of the spaceborne router based on the newly added variable-length key-value data using a variable-length storage format.
[0007] According to the present invention, a method for reading variable-length key-value data of a spaceborne router includes the following steps: SA, acquiring newly added variable-length key-value data, or determining newly added variable-length key-value data based on the absence of corresponding index information; SB, obtaining candidate positions corresponding to each preset hash function based on the newly added variable-length key-value data and a preset number of preset hash functions; SC, evaluating each candidate position to determine the optimal position and the index information corresponding to the optimal position; SD, storing the data block obtained based on the newly added variable-length key-value data into the preset key-value table according to the optimal position, and determining the storage position in the corresponding preset index table and storing the index information corresponding to the optimal position based on the key of the newly added variable-length key-value data using a preset hash mapping function.
[0008] According to the present invention, a method for reading variable-length key-value data of a spaceborne router is provided. Based on newly added variable-length key-value data and combined with a preset number of preset hash functions, candidate positions corresponding to each preset hash function are obtained. The method includes: obtaining initial positions corresponding to each preset hash function based on the key of the newly added variable-length key-value data and combined with a preset number of preset hash functions; for each initial position corresponding to a preset hash function, a preset key-value table is searched leftwards using a preset maximum left-shift search distance; the first position found in the leftward search, which has the same routing strategy or rule as the corresponding previous data block, or is adjacent to the position on the hard disk of the corresponding previous data block, is taken as a candidate position for the corresponding initial position; wherein, the corresponding previous data block route is used to represent the first data block to the left of the first position found in the leftward search.
[0009] According to the present invention, a method for reading variable-length key-value data from a spaceborne router includes an index information corresponding to the optimal position, comprising a preset hash function index and an offset; evaluating each candidate position to obtain the optimal position and its corresponding index information, including: determining the corresponding free and occupied positions in a preset key-value table based on each candidate position, and performing position scoring to obtain a position score for each candidate position; evaluating the distance between each candidate position and its corresponding previous data block based on each candidate position to obtain a data block distance score for each candidate position; wherein the distance is obtained based on the hash difference or key order difference between the candidate position and its corresponding previous data block; and evaluating the physical distance between each candidate position and its corresponding previous data block based on each candidate position. The physical storage distance is used to obtain a physical storage distance score for each candidate location. This physical storage distance characterizes the continuity of the candidate location with its preceding data block in physical storage. When determining the corresponding occupied location in the preset key-value table based on each candidate location, the cost of kicking out the occupied data block at that location is evaluated, resulting in a cost score for that location. Based on the location score, data block distance score, physical storage distance score, and cost score of each candidate location, an evaluation result for each candidate location is obtained. Based on the evaluation results of each candidate location, the highest score is selected as the optimal location. Based on the optimal location, the corresponding preset hash function index and the offset for left lookup are determined, resulting in the index information corresponding to the optimal location.
[0010] According to the present invention, a method for reading variable-length key-value data of a spaceborne router includes, after evaluating each candidate position and determining the optimal position and the index information corresponding to the optimal position, the method further includes: based on the optimal position, if it is determined that the length of the corresponding occupied data block exceeds a preset length threshold, the optimal position is discarded, and the remaining candidate positions are re-evaluated to determine the corresponding optimal position and the index information corresponding to the optimal position; or, based on the optimal position, if it is determined that the length of the corresponding occupied data block exceeds a preset length threshold, the optimal position is discarded, and according to the evaluation results of each candidate position, the candidate position with the next lower evaluation result than the optimal position is selected as the optimal position, and the corresponding optimal position and the index information corresponding to the optimal position are determined.
[0011] According to a method for reading variable-length key-value data in a spaceborne router provided by the present invention, when the optimal position is an occupied position, after storing the newly added variable-length key-value data into a preset key-value table based on the optimal position, the method includes: obtaining the data block that has been kicked out or covered at the optimal position, and executing steps SB-SD to re-insert the kicked out or covered data block; and when it is determined that there is a kicked out or covered data block corresponding to the optimal position for re-insertion, continuing to execute steps SB-SD for the data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion; or, obtaining the alternative insertion position corresponding to the data block that has been kicked out or covered at the optimal position, and re-inserting the kicked out or covered data block according to the alternative insertion position; wherein, the alternative insertion position is an alternative candidate position selected when the optimal position of the data block is determined first; when it is determined that there is a kicked out or covered data block at the alternative insertion position for re-insertion, continuing to re-insert the corresponding data block into the alternative insertion position of the corresponding data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion.
[0012] According to the present invention, a method for reading variable-length key-value data of a spaceborne router is provided, which reads the corresponding value information of variable-length key-value data based on index information and in conjunction with a preset key-value table. The method includes: determining the first storage location of the variable-length key-value data in the preset key-value table based on the index information; reading the corresponding data block based on the first storage location, and extracting the value information from the data block; wherein the data block is obtained by combining the key, value, and value length of the newly added variable-length key-value data and storing it in the preset key-value table. Based on the key of the variable-length key-value data, a preset index table is searched to obtain the corresponding index information, including: determining the second storage location of the variable-length key-value data in the preset index table using a preset hash mapping function based on the key of the variable-length key-value data; and reading the corresponding index information in the preset index table based on the second storage location.
[0013] This invention also provides a device for reading variable-length key-value data from a spaceborne router, comprising: a data acquisition module for acquiring variable-length key-value data; wherein the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; an index lookup module for searching a preset index table based on the key of the variable-length key-value data to obtain corresponding index information; wherein the preset index table is created or updated in the memory of the spaceborne router based on the corresponding newly added variable-length key-value data; and a data reading module for reading the corresponding value information of the variable-length key-value data based on the index information and in conjunction with the preset key-value table; wherein the preset key-value table is created or updated in the hard disk of the spaceborne router based on the newly added variable-length key-value data using a variable-length storage format.
[0014] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the variable-length key value data reading method for a spaceborne router as described above.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the variable-length key-value data reading method for a spaceborne router as described above.
[0016] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the variable-length key value data reading method for spaceborne routers as described above.
[0017] The present invention provides a method, apparatus, device, and medium for reading variable-length key-value data in a spaceborne router. By acquiring variable-length key-value data, a preset index table can be quickly searched, avoiding direct access to the complete key-value table on the hard drive. This reduces hard drive I / O overhead and the number of hard drive accesses, thereby improving system stability. Furthermore, based on the found index information, the preset key-value table is searched, avoiding a full table scan and further improving reading efficiency. Simultaneously, the preset key-value table uses a variable-length storage format, which can flexibly adapt to value information of different lengths, avoiding storage waste or data truncation. Through the separate design of the preset index table and the preset key-value table, the high speed of memory and the large capacity of hard drive are fully utilized, balancing search speed and storage capacity. This is suitable for the resource-constrained environment of spaceborne routers, achieving a balance between performance and storage. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating the variable-length key-value data reading method for spaceborne routers provided by the present invention; Figure 2 This is a schematic diagram of the structure of the spaceborne router variable-length key value data reading device provided by the present invention; Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0021] Figure 1 This is a flowchart illustrating the variable-length key-value data reading method for spaceborne routers provided by the present invention, as shown below. Figure 1 As shown, the method includes: S11, Obtain variable-length key-value data; wherein, variable-length key-value data is used to characterize key-value data corresponding to variable-length key-value storage format; S12, based on the key of the variable-length key-value data, look up the preset index table to obtain the corresponding index information; wherein, the preset index table is created or updated in the memory of the onboard router based on the corresponding newly added variable-length key-value data; S13. Based on the index information and in conjunction with the preset key-value table, read the value information corresponding to the variable-length key-value data; wherein, the preset key-value table is created or updated in the hard drive of the satellite router based on the newly added variable-length key-value data and using variable-length storage.
[0022] It should be noted that the step number "S1N" in this specification does not represent the order of the variable-length key value data reading method of the satellite router. The satellite router variable-length key value data reading method of the present invention is described in detail below.
[0023] Step S11: Obtain variable-length key-value data; wherein, variable-length key-value data is used to characterize the key-value data corresponding to the variable-length key-value storage format.
[0024] It's worth noting that variable-length key-value data includes complete, variable-length routing entries and Access Control List (ACL) rules, among other key-value pairs. A routing entry represents a record in the routing table that guides packet forwarding. It contains crucial information determining the packet's transmission path, including destination network / mask, next-hop address, outgoing interface, metric, route type, time-to-live (TTL), and administrative distance, to guide the packet's transmission path within the network. Furthermore, in spaceborne routers, the length of routing entries may vary depending on network topology, protocol type, etc. Variable-length storage is more versatile, adapting to keys and values of different lengths and avoiding the space waste or truncation issues associated with fixed-length storage.
[0025] Furthermore, obtaining variable-length key-value data includes: obtaining routing entries or ACL rules waiting to be searched, using the fields corresponding to the data to be searched as keys and the specific content corresponding to the fields as values, converting them into corresponding key-value pairs to obtain variable-length key-value data.
[0026] In one optional embodiment, before obtaining the variable-length key-value data, or after looking up a preset index table based on the key of the variable-length key-value data, the process includes: SA (Service Controller) retrieves newly added variable-length key-value data, or determines newly added variable-length key-value data based on the absence of corresponding index information. It's important to note that by retrieving and storing the corresponding newly added variable-length key-value data before retrieving the original variable-length key-value data, subsequent direct lookups and retrieval of the corresponding data are possible, reducing redundant calculations or network requests during each lookup and significantly improving data access speed. Alternatively, if the corresponding index information for the variable-length key-value data is not found, it can be stored as newly added variable-length key-value data to avoid repeated misses when searching for the same data, thus optimizing the lookup path. Furthermore, by storing data in advance or updating it in real-time to support the dynamic insertion of variable-length key-value data, the spaceborne router can flexibly adapt to changes in network topology and provides compatibility and scalability for future more complex space network protocols.
[0027] Furthermore, after acquiring the newly added variable-length key-value data, the process includes: combining the key, value, and value length of the newly added variable-length key-value data to obtain a data block.
[0028] SB, based on the newly added variable-length key-value data and combined with a preset number of preset hash functions, obtains the candidate positions corresponding to each preset hash function.
[0029] Specifically, based on the newly added variable-length key-value data and combined with a preset number of preset hash functions, candidate positions corresponding to each preset hash function are obtained, including: based on the key of the newly added variable-length key-value data and combined with a preset number of preset hash functions, the initial position corresponding to each preset hash function is obtained; for each initial position corresponding to a preset hash function, combined with a preset maximum left-shift search distance, the preset key-value table is searched to the left, and the first position found to the left, which is the same as the routing strategy or rule of the corresponding previous data block, or the position on the hard disk of the corresponding previous data block, is taken as the candidate position of the corresponding initial position; wherein, the corresponding previous data block is used to represent the first data block to the left of the first position found to the left.
[0030] Furthermore, by using the left-shift search method described above, we can ensure that the candidate positions obtained are closely packed, significantly reducing storage fragmentation. This allows the limited on-board memory space to store more and more complex routing tables and strategies, thereby improving the network capabilities and scalability of satellite nodes.
[0031] Furthermore, the candidate position corresponding to the initial position is the first free position found by searching to the left, which greatly reduces storage fragmentation, maximizes the utilization of physical storage media, and avoids kicking out or overwriting existing data blocks when inserting data at this candidate position as the optimal position, reducing performance loss caused by cache pollution or collisions and improving overall efficiency. In addition, the preset number of preset hash functions are completely different hash functions H(key), such as Message-Digest Algorithm 5 (MD5), Secure Hash Algorithm 1 (SHA1), multiply and rotate Hash (MurmurHash), etc.; or, the preset number of preset hash functions are variants H(key + i) generated by the same hash function through a preset number of different seeds or offsets, i = 0,1,…,15; or, the preset number of preset hash functions include at least some variants generated by the same hash function through a corresponding number of different seeds or offsets, such as combinations of the first two methods. The specific design can be designed according to actual design requirements, and no further limitations are made here.
[0032] SC evaluates each candidate position and determines the optimal position and the corresponding index information.
[0033] Specifically, the index information corresponding to the optimal position includes a preset hash function index and an offset; each candidate position is evaluated to obtain the optimal position and its corresponding index information, including: determining the corresponding free and occupied positions in the preset key-value table based on each candidate position, and performing position scoring to obtain a position score for each candidate position; evaluating the distance between each candidate position and its corresponding preceding data block to obtain a data block distance score for each candidate position; wherein the distance is obtained based on the hash difference or key order difference between the candidate position and its corresponding preceding data block; and evaluating the physical storage distance between each candidate position and its corresponding preceding data block to obtain a data block distance score for each candidate position. The physical storage distance score is used to select the location; where the physical storage distance is used to characterize the continuity of the candidate location with the corresponding previous data block in physical storage; when determining the corresponding occupied location in the preset key-value table based on each candidate location, the cost of kicking out the occupied data block at the occupied location is evaluated to obtain the cost score of the corresponding occupied location; based on the location score, data block distance score, physical storage distance score and cost score of each candidate location, the evaluation result of each candidate location is obtained; based on the evaluation results of each candidate location, the highest score result is selected as the optimal location; based on the optimal location, the corresponding preset hash function index and the offset for left lookup are determined to obtain the index information corresponding to the optimal location.
[0034] It should be noted that the evaluation can use the preset evaluation function GetIdealPos. The specific evaluation function can be selected according to the actual design requirements, and no further restrictions are made here. In addition, when evaluating the continuity of candidate positions with the corresponding previous data block in physical storage, it is possible to determine whether they are adjacent sectors or blocks based on the physical storage distance, thereby determining whether they are continuous. This will not be elaborated further here.
[0035] In addition, when determining the optimal position, alternative insertion positions can also be determined. For example, candidate positions whose evaluation results are second to the optimal position can be used as alternative insertion positions. The specific settings can be set according to actual design requirements, and will not be further determined here.
[0036] In one optional embodiment, after evaluating each candidate position and determining the optimal position and its corresponding index information, the process includes: based on the optimal position, if the length of the corresponding occupied data block exceeds a preset length threshold, discarding the optimal position and re-evaluating the remaining candidate positions to determine the corresponding optimal position and its corresponding index information; or, based on the optimal position, if the length of the corresponding occupied data block exceeds a preset length threshold, discarding the optimal position and selecting the candidate position with the next lower evaluation result as the optimal position according to the evaluation results of each candidate position, and determining the corresponding optimal position and its corresponding index information. It should be noted that the determination of the index information can refer to the above description and will not be repeated here.
[0037] SD stores the data block obtained based on the newly added variable-length key-value data into the preset key-value table according to the optimal position, and determines the storage location in the corresponding preset index table and stores the index information corresponding to the optimal position according to the key of the newly added variable-length key-value data using the preset hash mapping function.
[0038] It should be added that by storing a small amount of index information in the extremely limited on-chip SRAM or DRAM of the onboard processor, and with the index information volume requiring only a few bits, the memory overhead is extremely low. Furthermore, by storing most of the data on a hard disk, such as the large-capacity but slow non-volatile memory (e.g., Rad-Hard Flash) of the onboard platform, complete, variable-length routing entries, ACL rules, and other key-value pair data can be tightly stored.
[0039] In an optional embodiment, when the optimal position is an occupied position, after storing the newly added variable-length key-value data into a preset key-value table according to the optimal position, the method includes: obtaining the data block that has been kicked out or covered at the optimal position, and executing steps SB-SD to re-insert the kicked out or covered data block; and when it is determined that there is a kicked out or covered data block corresponding to the optimal position for re-insertion, continuing to execute steps SB-SD for the data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion; or, obtaining the alternative insertion position corresponding to the data block that has been kicked out or covered at the optimal position, and re-inserting the kicked out or covered data block according to the alternative insertion position; wherein, the alternative insertion position is an alternative candidate position selected when the optimal position of the data block is determined first; when it is determined that there is a kicked out or covered data block at the alternative insertion position for re-insertion, continuing to re-insert the corresponding data block into the alternative insertion position of the corresponding data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion.
[0040] It should be noted that by using alternative insertion positions, when an insertion operation removes or overwrites the original data block, the original data block will attempt to re-insert using one of these alternative positions, ensuring that the system can dynamically update the routing table. Simultaneously, to ensure the determinism and reliability of the insertion operation, a corresponding upper limit on the number of re-insertion attempts is configured, i.e., a preset maximum number, to guarantee that any single update operation can be completed within a predictable timeframe. This ensures the determinism of the update operation, avoids system deadlock due to update failures, and meets the high reliability and maintenance-free autonomous operation requirements of spacecraft.
[0041] When the number of re-insertion attempts exceeds the preset maximum, the corresponding data block is marked as an error block and temporarily removed from the insertion process to avoid consuming system resources and reduce interference with the normal insertion process. Additionally, when the number of error blocks reaches the preset maximum, subsequent processes can be configured according to actual design requirements, such as pausing all new data block insertion operations until the error blocks are processed or system resources are released, thereby preventing the system from crashing due to an excessive number of error blocks. No further limitations are imposed here.
[0042] In addition, for the very few erroneous blocks that cannot be inserted, a dedicated, small-capacity reserved area can be set up to manage the erroneous blocks, thereby ensuring the integrity of routing information.
[0043] Step S12: Based on the key of the variable-length key-value data, search the preset index table to obtain the corresponding index information; wherein, the preset index table is created or updated in the memory of the spaceborne router based on the corresponding newly added variable-length key-value data.
[0044] In this embodiment, the process of searching a preset index table based on the key of the variable-length key-value data to obtain the corresponding index information includes: determining the second storage location of the variable-length key-value data in the preset index table using a preset hash mapping function based on the key of the variable-length key-value data; and reading the corresponding index information in the preset index table based on the second storage location.
[0045] Step S13: Based on the index information and in conjunction with the preset key-value table, read the value information corresponding to the variable-length key-value data; wherein, the preset key-value table is created or updated in the hard drive of the satellite router based on the newly added variable-length key-value data and using variable-length storage.
[0046] In this embodiment, based on index information and a preset key-value table, the corresponding value information of variable-length key-value data is read. This includes: determining the first storage location of the variable-length key-value data in the preset key-value table based on the index information; reading the corresponding data block based on the first storage location, and extracting value information from the data block; wherein, the data block is first obtained by combining the key, value, and value length of the newly added variable-length key-value data and then stored in the preset key-value table. It should be noted that by storing most of the data in the hard disk and only retaining a very small index in SRAM or DRAM, the lookup operation requires only one fast access to the preset index and one slow access to the preset key-value table. The total latency is stable and predictable, meeting the stringent requirements of high-speed line-rate forwarding of routers, and greatly reducing the demand for valuable memory resources and the overall power consumption of the system, perfectly meeting the extreme limitations of satellite platforms.
[0047] In summary, this embodiment of the invention obtains variable-length key-value data for rapid lookup of a preset index table, avoiding direct access to the complete key-value table on the hard drive. This reduces hard drive I / O overhead and the number of hard drive accesses, thus improving system stability. Furthermore, based on the found index information, the preset key-value table is searched, avoiding a full table scan and further improving read efficiency. Simultaneously, the preset key-value table uses a variable-length storage format, flexibly adapting to value information of different lengths, avoiding storage waste or data truncation. The separate design of the preset index table and the preset key-value table fully utilizes the high speed of memory and the large capacity of the hard drive, balancing search speed and storage capacity. This is suitable for the resource-constrained environment of spaceborne routers, achieving a balance between performance and storage.
[0048] The following describes the spaceborne router variable-length key value data reading device provided by the present invention. The spaceborne router variable-length key value data reading device described below and the spaceborne router variable-length key value data reading method described above can be referred to in correspondence with each other.
[0049] Figure 2 A schematic diagram of a variable-length key-value data reading device for a spaceborne router is shown. The device includes: The data acquisition module 21 acquires variable-length key-value data; wherein, the variable-length key-value data is used to characterize the key-value data corresponding to the variable-length key-value storage format; The index lookup module 22 searches a preset index table based on the key of the variable-length key-value data to obtain the corresponding index information. The preset index table is created or updated in the memory of the onboard router based on the corresponding newly added variable-length key-value data and using variable-length storage. The data reading module 23 reads the corresponding value information of the variable-length key-value data according to the index information and in combination with the preset key-value table; wherein, the preset key-value table is created or updated in the hard disk of the satellite router based on the newly added variable-length key-value data.
[0050] In this implementation, the data acquisition module 21 includes: a data acquisition unit for acquiring routing entries or ACL rules to wait for data to be searched; and a format conversion unit for converting the fields corresponding to the data to be searched into keys and the specific content corresponding to the fields into values, thereby obtaining variable-length key-value data.
[0051] In an optional embodiment, the device further includes: acquiring newly added variable-length key-value data before acquiring variable-length key-value data, or after searching a preset index table based on the key of the variable-length key-value data, or determining newly added variable-length key-value data based on the absence of corresponding index information; a candidate position determination module, which obtains candidate positions corresponding to each preset hash function based on the newly added variable-length key-value data and a preset number of preset hash functions; an evaluation module, which evaluates each candidate position to determine the optimal position and the index information corresponding to the optimal position; and a storage module, which stores the data block obtained based on the newly added variable-length key-value data into a preset key-value table based on the optimal position, and determines the storage position in the corresponding preset index table based on the key of the newly added variable-length key-value data using a preset hash mapping function and stores the index information corresponding to the optimal position.
[0052] Furthermore, the device also includes a data block combination module, which, after acquiring the newly added variable-length key-value data, combines the key, value, and value length of the newly added variable-length key-value data to obtain a data block.
[0053] Specifically, the candidate position determination module includes: an initial position determination unit, which, based on the key of the newly added variable-length key-value data and combined with a preset number of preset hash functions, obtains the initial position corresponding to each preset hash function; and a left-direction search unit, which, for each initial position corresponding to a preset hash function, combines a preset maximum left-shift search distance to search the preset key-value table to the left, and selects the first position found in the left-direction search that is the same as the routing strategy or rule of the corresponding previous data block, or the position on the hard disk of the corresponding previous data block, as the candidate position of the corresponding initial position; wherein, the corresponding previous data block is used to represent the first data block to the left of the first position found in the left-direction search.
[0054] In addition, the index information corresponding to the optimal position includes a preset hash function index and an offset; the evaluation module is used to: determine the corresponding free and occupied positions in the preset key-value table based on each candidate position, and perform position scoring to obtain a position score for each candidate position; evaluate the distance between each candidate position and its corresponding previous data block based on each candidate position to obtain a data block distance score for each candidate position; wherein, the distance is obtained based on the hash difference or key order difference between the candidate position and its corresponding previous data block; evaluate the physical storage distance between each candidate position and its corresponding previous data block based on each candidate position to obtain a physical storage distance score for each candidate position; its In this process, physical storage distance is used to characterize the continuity of a candidate location with its preceding data block in physical storage. When determining the corresponding occupied location in the preset key-value table based on each candidate location, the cost of kicking out the occupied data block at the occupied location is evaluated to obtain the cost score of the corresponding occupied location. Based on the location score, data block distance score, physical storage distance score, and cost score of each candidate location, the evaluation result of each candidate location is obtained. Based on the evaluation results of each candidate location, the highest score result is selected as the optimal location. Based on the optimal location, the corresponding preset hash function index and the offset for left lookup are determined to obtain the index information corresponding to the optimal location.
[0055] In an optional embodiment, the device further includes: an update module, which, after evaluating each candidate position and determining the optimal position and its corresponding index information, discards the optimal position when the length of the corresponding occupied data block exceeds a preset length threshold, and re-evaluates the remaining candidate positions to determine the corresponding optimal position and its corresponding index information; or, when the length of the corresponding occupied data block exceeds the preset length threshold, discards the optimal position, and selects the candidate position with the next lower evaluation result as the optimal position based on the evaluation results of each candidate position, and determines the corresponding optimal position and its corresponding index information. It should be noted that the determination of the index information can be referred to the above description and will not be repeated here.
[0056] In an optional embodiment, when the optimal position is an occupied position, the device further includes: a re-insertion module, which, after storing the newly added variable-length key-value data into a preset key-value table according to the optimal position, obtains the data block that was kicked out or covered at the optimal position, and executes steps SB-SD to re-insert the kicked out or covered data block. If it is determined that there is a kicked out or covered data block corresponding to the optimal position for re-insertion, steps SB-SD are continued for the data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion; or, obtains a backup insertion position corresponding to the data block that was kicked out or covered at the optimal position, and re-inserts the kicked out or covered data block according to the backup insertion position; wherein, the backup insertion position is an alternative candidate position selected when the optimal position of the data block is determined first; if it is determined that there is a kicked out or covered data block at the backup insertion position for re-insertion, the corresponding data block is continued to be re-inserted into the backup insertion position of the corresponding data block until the number of re-insertions exceeds a preset maximum number, or until there is no corresponding kicked out or covered data block position at the corresponding optimal position for re-insertion.
[0057] The index lookup module 22 includes: a first position determination unit, which determines the second storage location of the variable-length key-value data in a preset index table based on the key of the variable-length key-value data and using a preset hash mapping function; and a first information reading unit, which reads the corresponding index information in the preset index table based on the second storage location.
[0058] The data reading module 23 includes: a second location determination unit, which determines the first storage location of variable-length key-value data in a preset key-value table based on index information; and a second information reading unit, which reads the corresponding data block based on the first storage location and extracts value information from the data block; wherein the data block is obtained by combining the key, value, and value length of the newly added variable-length key-value data and storing it in the preset key-value table.
[0059] In summary, this embodiment of the invention acquires variable-length key-value data through a data acquisition module, enabling a quick lookup of a preset index table via an index lookup module. This avoids direct access to the complete key-value table on the hard drive, reducing hard drive I / O overhead and the number of hard drive accesses, thus improving system stability. Furthermore, the data reading module uses the found index information to search the preset key-value table, avoiding a full table scan and further improving read efficiency. Simultaneously, the preset key-value table uses a variable-length storage format, flexibly adapting to value information of different lengths, avoiding storage waste or data truncation. The separate design of the preset index table and the preset key-value table fully utilizes the high speed of memory and the large capacity of the hard drive, balancing lookup speed and storage capacity. This is suitable for the resource-constrained environment of spaceborne routers, achieving a balance between performance and storage.
[0060] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340. The processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a method for reading variable-length key-value data from a satellite router. This method includes: acquiring variable-length key-value data; wherein the variable-length key-value data is used to represent key-value data corresponding to a variable-length key-value storage format; searching a preset index table based on the key of the variable-length key-value data to obtain corresponding index information; wherein the preset index table is created or updated in the memory of the satellite router based on newly added variable-length key-value data using a variable-length storage format; and reading the corresponding value information of the variable-length key-value data based on the index information and the preset key-value table; wherein the preset key-value table is created or updated in the hard disk of the satellite router based on newly added variable-length key-value data.
[0061] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0062] On the other hand, the present invention also provides a computer program product, which includes a computer program that 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 spaceborne router variable-length key-value data reading method provided by the above methods. The method includes: acquiring variable-length key-value data; wherein the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; searching a preset index table according to the key of the variable-length key-value data to obtain corresponding index information; wherein the preset index table is created or updated in the memory of the spaceborne router based on the corresponding newly added variable-length key-value data and using a variable-length storage format; and reading the value information corresponding to the variable-length key-value data according to the index information and in conjunction with the preset key-value table; wherein the preset key-value table is created or updated in the hard disk of the spaceborne router based on the newly added variable-length key-value data.
[0063] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a method for reading variable-length key-value data from a spaceborne router, as described above. This method includes: acquiring variable-length key-value data; wherein the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; searching a preset index table based on the key of the variable-length key-value data to obtain corresponding index information; wherein the preset index table is created or updated in the memory of the spaceborne router based on newly added variable-length key-value data using a variable-length storage format; and reading the corresponding value information of the variable-length key-value data based on the index information and in conjunction with the preset key-value table; wherein the preset key-value table is created or updated in the hard disk of the spaceborne router based on newly added variable-length key-value data.
[0064] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0065] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for reading variable-length key-value data from a spaceborne router, characterized in that, include: Obtain variable-length key-value data; wherein, the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; Based on the key of the variable-length key-value data, a preset index table is searched to obtain the corresponding index information; wherein, the preset index table is created or updated in the memory of the onboard router based on the corresponding newly added variable-length key-value data; Based on the index information and in conjunction with the preset key-value table, the corresponding value information of the variable-length key-value data is read; wherein, the preset key-value table is created or updated in the hard disk of the onboard router based on the newly added variable-length key-value data and using variable-length storage format; Before acquiring variable-length key-value data, or after searching a preset index table based on the key of the variable-length key-value data, the process includes: SA retrieves newly added variable-length key-value data, or determines newly added variable-length key-value data based on the absence of corresponding index information; SB, based on the newly added variable-length key-value data and combined with a preset number of preset hash functions, obtains the candidate positions corresponding to each preset hash function; SC evaluates each of the candidate positions to determine the optimal position and the index information corresponding to the optimal position; SD, based on the optimal position, stores the data block obtained based on the newly added variable-length key-value data into a preset key-value table, and based on the key of the newly added variable-length key-value data, uses a preset hash mapping function to determine the storage location in the corresponding preset index table and stores the index information corresponding to the optimal position; Based on the newly added variable-length key-value data and combined with a preset number of preset hash functions, candidate positions corresponding to each preset hash function are obtained, including: Based on the key of the newly added variable-length key value data, and combined with a preset number of preset hash functions, the initial position corresponding to each preset hash function is obtained; For each of the preset hash functions, the preset key-value table is searched to the left in combination with the preset maximum left shift search distance. The first position found to the left that is the same as the routing strategy or rule of the corresponding previous data block, or the position on the hard disk of the corresponding previous data block, is taken as the candidate position of the corresponding initial position. The corresponding previous data block is used to represent the first data block to the left of the first position found to the left. The index information corresponding to the optimal position includes a preset hash function index and an offset; each candidate position is evaluated to obtain the optimal position and the index information corresponding to the optimal position, including: Based on each candidate position, the corresponding free and occupied positions in the preset key value table are determined, and position scores are performed to obtain the position score for each candidate position. Based on each candidate position, the distance between each candidate position and the corresponding preceding data block is evaluated to obtain a data block distance score for each candidate position; wherein, the distance is obtained based on the hash difference or key order difference between the candidate position and the corresponding preceding data block; Based on each candidate position, the physical storage distance between each candidate position and the corresponding preceding data block is evaluated to obtain a physical storage distance score for each candidate position; wherein, the physical storage distance is used to characterize the physical storage continuity between the candidate position and the corresponding preceding data block; When determining the corresponding occupied position in the preset key-value table based on each candidate position, the cost of kicking out the occupied data block of the occupied position is evaluated to obtain the cost score of the corresponding occupied position. The evaluation results for each candidate location are obtained based on the location score, data block distance score, physical storage distance score, and cost score. Based on the evaluation results of each candidate position, the position with the highest score is selected as the optimal position. Based on the optimal position, determine the corresponding preset hash function index and the offset for left lookup, and obtain the index information corresponding to the optimal position.
2. The method for reading variable-length key-value data from a spaceborne router according to claim 1, characterized in that, After evaluating each of the candidate positions and determining the optimal position and the index information corresponding to the optimal position, the process includes: Based on the optimal position, if the length of the corresponding occupied data block exceeds a preset length threshold, the optimal position is discarded, and the remaining candidate positions are re-evaluated to determine the corresponding optimal position and its corresponding index information; or... Based on the optimal position, when the length of the corresponding occupied data block exceeds a preset length threshold, the optimal position is discarded. Then, according to the evaluation results of each candidate position, the candidate position with the next lower evaluation result than the optimal position is selected as the optimal position, and the corresponding optimal position and the index information corresponding to the optimal position are determined.
3. The method for reading variable-length key-value data from a spaceborne router according to claim 1, characterized in that, When the optimal position is an occupied position, after storing the newly added variable-length key-value data into a preset key-value table according to the optimal position, the process includes: Obtain the data block that was kicked out or covered at the optimal position, and execute steps SB-SD to re-insert the kicked-out or covered data block. If it is determined that there is a kicked-out or covered data block corresponding to the optimal re-insertion position, continue executing steps SB-SD for that data block until the number of re-insertions exceeds a preset maximum, or until there is no corresponding kicked-out or covered data block position at the optimal re-insertion position; or... Obtain alternative insertion positions corresponding to the data blocks that are kicked out or covered at the optimal position, and re-insert the kicked out or covered data blocks according to the alternative insertion positions; wherein, the alternative insertion positions are the candidate positions selected when the optimal position of the data block is determined first; When it is determined that there is a kicked-out or covered data block at the alternative insertion position for re-insertion, the corresponding data block is re-inserted into the alternative insertion position for the corresponding data block until the number of re-insertions exceeds the preset maximum number, or until there is no corresponding kicked-out or covered data block at the optimal re-insertion position.
4. The method for reading variable-length key-value data from a spaceborne router according to claim 1, characterized in that, Based on the index information and in conjunction with a preset key-value table, the corresponding value information of the variable-length key-value data is read, including: Based on the index information, determine the first storage location of the variable-length key value data in the preset key value table; According to the first storage location, the corresponding data block is read, and value information is extracted from the data block; wherein, the data block is first obtained by combining the key, value and value length of the newly added variable-length key-value data and stored in the preset key-value table; Based on the key of the variable-length key value data, a preset index table is searched to obtain the corresponding index information, including: Based on the key of the variable-length key-value data, a preset hash mapping function is used to determine the second storage location of the variable-length key-value data in the preset index table; Based on the second storage location, read the corresponding index information from the preset index table.
5. A device for reading variable-length key-value data from a spaceborne router, characterized in that, include: The data acquisition module acquires variable-length key-value data; wherein, the variable-length key-value data is used to characterize key-value data corresponding to a variable-length key-value storage format; The index lookup module searches a preset index table based on the key of the variable-length key-value data to obtain the corresponding index information; wherein, the preset index table is created or updated in the memory of the onboard router based on the corresponding newly added variable-length key-value data; The data reading module reads the corresponding value information of the variable-length key-value data according to the index information and in conjunction with the preset key-value table; wherein, the preset key-value table is created or updated in the hard disk of the spaceborne router based on the newly added variable-length key-value data and using variable-length storage format; The device is also used for: Before acquiring variable-length key-value data, or after searching a preset index table based on the key of the variable-length key-value data, acquire the newly added variable-length key-value data; or, based on the fact that no corresponding index information is found, determine that the newly added variable-length key-value data is to be acquired. The device further includes: The candidate position determination module obtains the candidate position corresponding to each preset hash function based on the newly added variable-length key value data and in combination with a preset number of preset hash functions. The evaluation module evaluates each of the candidate positions and determines the optimal position and the index information corresponding to the optimal position. The storage module stores the data block obtained based on the newly added variable-length key-value data into a preset key-value table according to the optimal position, and determines the storage location in the corresponding preset index table and stores the index information corresponding to the optimal position according to the key of the newly added variable-length key-value data using a preset hash mapping function. The candidate location determination module includes: The initial position determination unit determines the initial position corresponding to each preset hash function based on the key of the newly added variable-length key value data and in combination with a preset number of preset hash functions. The left-lookup unit, for each initial position corresponding to the preset hash function, combines the preset maximum left-shift lookup distance to search the preset key-value table in the left direction, and takes the first position found in the left-lookup that is the same as the routing strategy or rule of the corresponding previous data block, or the position on the hard disk of the corresponding previous data block, as the candidate position of the corresponding initial position; wherein, the corresponding previous data block is used to represent the first data block to the left of the first position found in the left-lookup. The index information corresponding to the optimal position includes a preset hash function index and an offset; the evaluation module is used for: Based on each candidate position, the corresponding free and occupied positions in the preset key value table are determined, and position scores are performed to obtain the position score for each candidate position. Based on each candidate position, the distance between each candidate position and the corresponding preceding data block is evaluated to obtain a data block distance score for each candidate position; wherein, the distance is obtained based on the hash difference or key order difference between the candidate position and the corresponding preceding data block; Based on each candidate position, the physical storage distance between each candidate position and the corresponding preceding data block is evaluated to obtain a physical storage distance score for each candidate position; wherein, the physical storage distance is used to characterize the physical storage continuity between the candidate position and the corresponding preceding data block; When determining the corresponding occupied position in the preset key-value table based on each candidate position, the cost of kicking out the occupied data block of the occupied position is evaluated to obtain the cost score of the corresponding occupied position. The evaluation results for each candidate location are obtained based on the location score, data block distance score, physical storage distance score, and cost score. Based on the evaluation results of each candidate position, the position with the highest score is selected as the optimal position. Based on the optimal position, determine the corresponding preset hash function index and the offset for left lookup, and obtain the index information corresponding to the optimal position.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the variable-length key value data reading method for a spaceborne router as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the variable-length key value data reading method for a spaceborne router as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Persistent memory key value storage system
CN111309270A
Confidential statistical data sharing method and system based on set operation
CN111984984A
Bandwidth control method and device, equipment and storage medium
CN120321198A