Hierarchical relationship data compression method, decompression method and system

By introducing hierarchical symbols and encoding omission rules into hierarchical relational data, the redundancy problem of hierarchical relational data is solved, resulting in a significant reduction in data volume and an improvement in transmission efficiency, thus meeting the needs of efficient storage and fast transmission.

CN121727554APending Publication Date: 2026-03-24ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-09
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In the storage and transmission of hierarchical relationship data, existing technologies suffer from data redundancy, resulting in low compression efficiency and impacting network transmission speed and application performance.

Method used

By introducing hierarchical symbols to represent the relationships between hierarchical data, and combining this with encoding omission rules, the original encoded data is adjusted to generate a compressed data set, eliminating redundant information.

Benefits of technology

It significantly reduces data volume, improves the compression efficiency and parsing performance of hierarchical data, meets the needs of efficient storage and fast transmission, and enhances application performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121727554A_ABST
    Figure CN121727554A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a compression method, a decompression method and a system for hierarchical relationship data. According to the technical scheme provided by the embodiment of the invention, an original hierarchical relationship data set is obtained, and the original hierarchical relationship data set comprises a plurality of pieces of original coded data sorted according to the hierarchical relationship; determining hierarchical association information of each piece of original coded data in the original hierarchical relationship data set; adding a hierarchical symbol in the associated original coded data based on the hierarchical association information; and adjusting the original coded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set. By adopting the technical means, the compression efficiency and the analysis performance of the hierarchical relationship data can be improved, the efficient storage and rapid transmission requirements of the hierarchical relationship data are met, and then the application performance and the use experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, decompression method and system for hierarchical relational data. Background Technology

[0002] Currently, in scenarios involving the storage and transmission of hierarchical relational data (such as regional divisions, organizational structures, and classification directories), the data is typically compressed to reduce its size and thus lower storage and transmission costs. When compressing hierarchical relational data, a layered encoding scheme is usually employed.

[0003] However, when storing and transmitting hierarchical relational data, all child node data under the same parent node need to repeatedly carry the complete parent prefix, resulting in a large amount of data redundancy in hierarchical relational data. This affects the compression efficiency of hierarchical relational data, and consequently, the hierarchical relational data is slow and has a response delay when transmitted over the network (such as in scenarios like address database synchronization and map service loading), thus affecting application performance. Summary of the Invention

[0004] This application provides a method, a decompression method, and a system for compressing hierarchical relational data, which can reduce data redundancy in hierarchical data, improve the compression efficiency of hierarchical data, and thus improve the storage and transmission efficiency of hierarchical encoded data, thereby solving the data redundancy problem of hierarchical encoded data.

[0005] In a first aspect, embodiments of this application provide a method for compressing hierarchical relationship data, comprising: Obtain the original hierarchical relationship data set, which includes multiple original coded data items sorted according to the hierarchical relationship; Determine the hierarchical association information of the original coded data in the original hierarchical relational data set; Hierarchical symbols are added to the associated original coded data based on hierarchical association information; The original encoded data is adjusted based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

[0006] Furthermore, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current raw encoded data has entered the next deeper level relative to the previous raw encoded data, while the roll-up symbol indicates that the current raw encoded data has returned to the previous shallower level relative to the previous raw encoded data. Based on hierarchical association information, hierarchical symbols are added to the associated original encoded data, including: If the current raw encoded data is determined to be at a deeper level than the previous raw encoded data based on the hierarchical association information, a drill-down symbol is added to the prefix position of the current raw encoded data. If, based on the hierarchical association information, it is determined that the current original encoded data returns to a shallower level relative to the previous original encoded data, a roll-up symbol is added to the prefix position of the current original encoded data.

[0007] Furthermore, the original encoded data is adjusted based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set, including: The original encoded data is adjusted based on the set adjustment rules and hierarchical association information. The compressed data set of the original hierarchical relationship data set is generated based on the compressed encoded data obtained from the adjustment process.

[0008] Furthermore, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: When the difference between the specified codes of the current original encoded data and the previous original encoded data is determined to be a fixed step size based on the hierarchical association information, the specified codes of the current original encoded data are omitted based on the code omission rules.

[0009] Furthermore, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified name field of the current original encoded data is the same as that of the previous original encoded data based on the hierarchical association information, the specified name field of the current original encoded data is omitted based on the encoding omission rule.

[0010] Furthermore, the original encoded data is adjusted based on the established adjustment rules and hierarchical association information, including: If the number of bytes in the specified code of the current raw encoded data is the first specific number of bits, obtain the specified number of bits field of the specified code of the previous shallower level raw encoded data, and add the specified number of bits field to the prefix position of the specified code of the raw encoded data.

[0011] Furthermore, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified code of the current original encoded data is empty or has a zero value, the specified code of the current original encoded data is omitted based on the encoding omission rule.

[0012] Furthermore, the original encoded data is adjusted based on the established adjustment rules and hierarchical association information, including: If consecutive target fields are omitted in the current raw encoded data, the separators between the target fields are omitted. The target fields include the specified code and specified name fields of the current raw encoded data.

[0013] In a second aspect, embodiments of this application provide a method for decoding hierarchical compressed data, including: Obtain the compressed data set, which includes multiple encoded compressed data entries sorted according to hierarchical relationships; Initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data. Based on the hierarchical state information, the field restoration process is performed on the currently traversed encoded compressed data to generate the original hierarchical relationship data set of the corresponding compressed data set; Update the hierarchical state information based on the hierarchical symbols in the currently traversed encoded compressed data.

[0014] Furthermore, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current encoded compressed data has entered the next deeper level relative to the previous encoded compressed data, while the roll-up symbol indicates that the current encoded compressed data has returned to the previous shallower level relative to the current encoded compressed data. Update the hierarchical state information based on the hierarchical symbols in the currently traversed encoded and compressed data, including: If the currently traversed encoded compressed data contains drill-down symbols, update the original encoded data generated from the current encoded compressed data to the hierarchical status information; If the currently traversed encoded compressed data contains roll-up symbols, the current level state information is rolled back to the previous level state information.

[0015] Furthermore, based on the hierarchical state information, the currently traversed encoded compressed data undergoes field restoration processing to generate the original hierarchical relationship data set of the corresponding compressed data set, including: Based on the hierarchical status information and the set decoding and restoration rules, the field restoration processing is performed on the currently traversed encoded and compressed data to generate the corresponding original encoded data. The encoded and compressed data is obtained by adjusting the original encoded data based on the set adjustment rules and hierarchical association information during encoding. The adjustment rules correspond to the decoding and restoration rules. Generate the original hierarchical relationship data set corresponding to the compressed data set based on the original encoded data.

[0016] Furthermore, based on the hierarchical state information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the specified code of the current encoded compressed data is found to be omitted, the specified code of the current encoded compressed data is calculated and generated based on the hierarchical status information and the sorting of the current encoded compressed data in the current level.

[0017] Furthermore, based on the hierarchical state information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the specified name field of the current encoded compressed data is found to be omitted, the specified name field of the previous original encoded data is determined based on the hierarchical status information, and the specified name field of the current encoded compressed data is restored based on the specified name field of the previous original encoded data.

[0018] Furthermore, based on the hierarchical state information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the second specific number of bits, the specified number of bits field of the specified code in the previous shallower level original encoded data is determined based on the hierarchical status information, and the specified number of bits field is deleted from the prefix position of the specified code in the current encoded compressed data.

[0019] Furthermore, based on the hierarchical state information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the third specific number of bits, the specified code of the previous shallower level original encoded data is determined based on the hierarchical status information, and the field restoration process of the specified code is performed based on the specified code of the current encoded compressed data and the specified code of the previous shallower level original encoded data.

[0020] Furthermore, based on the hierarchical state information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If it is detected that the delimiter of consecutive target fields is omitted in the current encoded compressed data, The query specifies the field order rules and the number of fields in the defined decoding and restoration rules. Based on the hierarchical status information, field order rules, and the number of fields, the query performs field restoration processing on the currently traversed encoded and compressed data.

[0021] In a third aspect, embodiments of this application provide a compression system for hierarchical relational data, comprising: The first acquisition module is used to acquire the original hierarchical relationship data set, which includes multiple original coded data arranged according to the hierarchical relationship. The hierarchy determination module is used to determine the hierarchical association information of the original coded data in the original hierarchy relation data set; The symbol addition module is used to add hierarchical symbols to the associated raw encoded data based on hierarchical association information; The processing module is used to adjust the original encoded data based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

[0022] In a fourth aspect, embodiments of this application provide a decoding system for hierarchical compressed data, comprising: The second acquisition module is used to acquire a compressed data set, which includes multiple encoded compressed data items sorted according to hierarchical relationships. The traversal module is used to initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data. The data restoration module is used to restore the fields of the currently traversed encoded compressed data based on the hierarchical status information, and generate the original hierarchical relationship data set of the corresponding compressed data set. The layer update module is used to update the layer status information based on the layer symbols in the currently traversed encoded compressed data.

[0023] In a fifth aspect, embodiments of this application provide an electronic device, including: Memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the hierarchical data compression method as described in the first aspect, or the hierarchical data decoding method as described in the second aspect.

[0024] In a sixth aspect, embodiments of this application provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a method for compressing hierarchical relationship data as described in the first aspect, or a method for decoding hierarchical relationship compressed data as described in the second aspect.

[0025] This application embodiment obtains an original hierarchical relationship data set, which includes multiple original coded data items sorted according to hierarchical relationships; determines the hierarchical association information of each original coded data item in the original hierarchical relationship data set; adds hierarchical symbols to the associated original coded data based on the hierarchical association information; and adjusts the original coded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set. By employing the above technical means, and introducing hierarchical symbols to represent the hierarchical relationship relationships of the hierarchical relationship data, structural redundancy and duplicate information can be effectively eliminated during the compression process, resulting in a significant reduction in data volume. This improves the compression efficiency and parsing performance of the hierarchical relationship data, meets the requirements for efficient storage and rapid transmission of hierarchical relationship data, and ultimately enhances application performance and user experience. Attached Figure Description

[0026] Figure 1 This is a flowchart of a method for compressing hierarchical relationship data provided in Embodiment 1 of this application; Figure 2 This is a flowchart illustrating the addition of hierarchical symbols in Embodiment 1 of this application; Figure 3 This is a flowchart illustrating the generation process of the compressed data set in Embodiment 1 of this application; Figure 4 This is a flowchart of a method for decoding hierarchical compressed data provided in Embodiment 1 of this application; Figure 5 This is a flowchart illustrating the update process of hierarchical status information in Embodiment 1 of this application; Figure 6 This is a flowchart illustrating the generation process of the original hierarchical relationship data set in Embodiment 1 of this application; Figure 7 This is a schematic diagram of the structure of a hierarchical data compression system provided in Embodiment 2 of this application; Figure 8 This is a schematic diagram of the structure of a decoding system for hierarchical compressed data provided in Embodiment 2 of this application; Figure 9 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0028] The hierarchical relationship data compression method provided in this application aims to effectively eliminate structural redundancy and duplicate information during the compression process by introducing hierarchical symbols to represent the hierarchical relationship of hierarchical relationship data and combining encoding omission rules, thereby achieving a significant reduction in data volume and improving the compression efficiency and parsing performance of hierarchical relationship data.

[0029] In the storage and transmission of hierarchical data (such as regional divisions, organizational structures, and classification directories), compression is typically performed to reduce data volume and thus lower storage and transmission costs. When compressing hierarchical data, a layered encoding scheme is usually employed. For example, regional division data commonly uses a fixed-length numerical code of "2 digits for provincial level + 2 digits for municipal level + 2 digits for county level" to ensure logical clarity while compressing the data. Alternatively, compression algorithms such as LZ77 and Huffman coding can be used to compress common hierarchical data. However, when storing and transmitting hierarchical data, all child nodes under the same parent node need to repeatedly carry the complete parent prefix. For example, for regional division data, the original encoded data of multiple cities under the same province all need to repeatedly store the provincial prefix. This compression method does not consider the correlation between hierarchical relationship data, resulting in a large amount of data redundancy in the hierarchical relationship data. This affects the compression efficiency of the hierarchical relationship data, and consequently, leads to slow speed and response delays during network transmission (such as address database synchronization and map service loading), impacting application performance. Therefore, this application provides a method for compressing hierarchical relationship data to solve the data redundancy problem of hierarchical encoded data.

[0030] Example 1: Figure 1A flowchart of a hierarchical relationship data compression method according to Embodiment 1 of this application is provided. The hierarchical relationship data compression method provided in this embodiment can be executed by a hierarchical relationship data compression device. This compression device can be implemented by software and / or hardware, and can consist of two or more physical entities, or a single physical entity. Generally, the hierarchical relationship data compression device can be an encoding device such as a data sending end or an encoding server.

[0031] The following description uses an encoding device as the main component in a method for compressing hierarchical relational data. (Refer to...) Figure 1 The specific methods for compressing this hierarchical data include: S110. Obtain the original hierarchical relationship data set.

[0032] This application, when compressing hierarchical relationship data, obtains multiple original coded data entries ordered according to hierarchical relationships from a corresponding storage system (such as a database, data file, or API interface) to be compressed. This collection of original coded data with hierarchical relationships is defined as the original hierarchical relationship data set, which includes multiple original coded data entries ordered according to hierarchical relationships. The original hierarchical relationship data set can be a collection of coded data such as regional division codes, organizational structure codes, and classification codes. Its original coded data can contain field information with hierarchical association characteristics, along with related attribute fields such as name, postal code, and code.

[0033] Taking address book data or regional classification coding data as an example, the original coding data is represented as [code, postcode, name]. Here, code represents the regional code, postcode represents the postal code, and name represents the regional name. The original coding data can use a triple or double tuple structure, such as [code, postcode, name], [code, name], [postcode, name], and the order of fields within different tuples can also be configured adaptively. It is understandable that different regional classification coding data contain hierarchical relationships such as province → city → district. Therefore, when compressing this part of the regional classification coding data, redundant information can be omitted based on the hierarchical relationship between the data to achieve further compression of the coding data. Similarly, for electronic product classification coding data, it may contain hierarchical relationships such as electronic product → mobile phone → brand A. Redundant information can also be omitted based on the hierarchical relationship between the data.

[0034] The following describes the compression method for hierarchical relationship data in this application, using regional division coding data as an example. It should be noted that during the initial coding operation, the original coded data in this application is sorted according to the hierarchical relationship between the data, thereby constructing an original hierarchical relationship data set. For example, in the original hierarchical relationship data set corresponding to regional division coding data, the coded data strictly follows the order of "Province A → City A1 under Province A → District A1a under City A1 → District A1b under City A1 → City A2 under Province A → Province B →...". For original hierarchical relationship data sets where the original coded data is not sorted according to the hierarchical relationship, the hierarchical information of each piece of original coded data can be identified, and a tree model can be constructed based on the identified hierarchical information, thereby determining the hierarchical relationship order of the original coded data through the tree model.

[0035] S120. Determine the hierarchical association information of the original coded data in the original hierarchical relational data set.

[0036] Based on the aforementioned set of original hierarchical relationship data, this application determines the hierarchical relationship between adjacent original coded data by scanning each original coded data entry, defining this relationship information as hierarchical association information. When traversing to the current original coded data, its key fields (such as the area code) are compared with the previous original coded data entry in multiple dimensions, analyzing the continuity of the code values ​​(determining whether they are continuously increasing sibling nodes), changes in code length (determining whether it enters a deeper or shallower level), the matching degree of the code prefix (identifying common parent nodes), and the similarity of fields such as name, postal code, and area code. For example, in the area division data, if the previous original coded data record is named Beijing and the current original coded data is named Dongcheng District, then they are determined to be in a hierarchical relationship. If the previous original coded data record is named Beijing and the current original coded data is named Tianjin, then they are in a parallel hierarchical relationship. Similarly, based on the comparison of fields such as area code or postal code, the hierarchical association information of each original coded data entry can also be determined. This application does not impose fixed restrictions on the determination of specific hierarchical association information. I won't go into details here.

[0037] S130. Add hierarchical symbols to the associated original encoded data based on hierarchical association information.

[0038] Furthermore, based on the hierarchical association information determined above, this application uses this hierarchical association information to add corresponding hierarchical symbols to the original encoded data, so as to use the hierarchical symbols to represent the changes in hierarchical relationships between the original encoded data.

[0039] Once the hierarchical relationship between the current and previous original encoded data is determined through hierarchical association information, corresponding characters (i.e., prefix, suffix, or specified positions) can be added to specific locations in the current original encoded data according to a set of predefined symbol mapping rules. These hierarchical symbols can be numbers, letters, bytecode, etc. For example, numbers can be used to directly sort the levels as 1, 2, 3, 4. For original encoded data with parallel levels, an additional number or letter can be added to represent the level, thus indicating the hierarchical changes between adjacent original encoded data through hierarchical symbols.

[0040] Optionally, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current raw encoded data enters the next deeper level relative to the previous raw encoded data, and the roll-up symbol indicates that the current raw encoded data returns to the previous shallower level relative to the previous raw encoded data. Correspondingly, refer to Figure 2 Based on hierarchical association information, hierarchical symbols are added to the associated original encoded data, including: S1301. If it is determined that the current original encoded data is at a deeper level than the previous original encoded data based on the hierarchical association information, add a drill-down symbol to the prefix position of the current original encoded data. S1302. If, based on the hierarchical association information, it is determined that the current original encoded data returns to a shallower level relative to the previous original encoded data, a roll-up symbol is added to the prefix position of the current original encoded data.

[0041] This application uses the roll-up symbol "<" and the drill-down symbol ">" as hierarchical symbols to represent the hierarchical encoding of the current raw encoded data relative to the previous raw encoded data, respectively. (See reference...) Figure 3 Based on this hierarchical symbol, when adding hierarchical symbols, if it is found that the current original encoded data is at a deeper level than the previous original encoded data, a drill-down symbol ">" is added to the prefix position of the current original encoded data; if it is found that the current original encoded data is at a shallower level than the previous original encoded data, a roll-up symbol "<" is added to the prefix position of the current original encoded data; if it is found that the current original encoded data is at the same level as the previous original encoded data, there is no need to add a hierarchical symbol to the prefix position of the current original encoded data.

[0042] For example, for the regional classification code data "330000 Zhejiang Province 310000; 330100 Hangzhou City 310000", since "330100 Hangzhou City 310000" is at a deeper level relative to the previous original code data "330000 Zhejiang Province 310000" (i.e., Zhejiang Province → Hangzhou City), a drill-down symbol ">" needs to be added to the prefix of "330100 Hangzhou City 310000". If the next original code data of "330100 Hangzhou City 310000" is the regional classification code data of another city under Zhejiang Province, then no level symbol needs to be added to that city-level regional classification data. If the next original code data of "330100 Hangzhou City 310000" is the regional classification code data of a provincial-level region, then a roll-up symbol "<" needs to be added to the prefix of that provincial-level regional classification data.

[0043] S140. Adjust the original encoded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

[0044] For each original encoded data with added hierarchical symbols, this application adjusts the original encoded data based on the hierarchical association information to compress some redundant fields and reduce the size of the original encoded data. It is understood that for some fields that can be restored based on the hierarchical association information, the current original encoded data can be adjusted according to the corresponding rules.

[0045] Specifically, the original encoded data is adjusted based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set, including: The original encoded data is adjusted based on the set adjustment rules and hierarchical association information. The compressed data set of the original hierarchical relationship data set is generated based on the compressed encoded data obtained from the adjustment process.

[0046] For example, if some fields in the current municipal area code are inherited from the provincial area code, these fields can be omitted according to the corresponding adjustment rules. Similarly, if the name of the current original coded data is the same as the name of the previous original coded data, the name of the current original coded data can be omitted according to the corresponding adjustment rules. Based on actual data compression requirements, these adjustment rules can be adaptively set to process redundant fields in the original coded data that contain hierarchical relationship information, thereby generating a compressed dataset of the original hierarchical relationship data set based on the adjusted and compressed coded data.

[0047] When decoding the compressed dataset, it is only necessary to identify the hierarchical relationship information of the compressed data by corresponding hierarchical symbols. Combined with the encoding restoration rules corresponding to the adjustment rules, the compressed data can be accurately decoded and restored. It is understandable that since the adjustment rules process redundant fields with hierarchical relationship information in the original encoded data, this application, by adding hierarchical symbols, facilitates the determination of hierarchical relationship information between compressed data based on these symbols during subsequent decoding. This allows for the restoration of omitted fields in the current compressed data based on the field information provided by the previously decoded data. Consequently, hierarchical relationship data can effectively eliminate structural redundancy and duplicate information during compression, achieving a significant reduction in data volume and thus improving the compression efficiency and parsing performance of hierarchical relationship data.

[0048] Specifically, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: When the difference between the specified codes of the current original encoded data and the previous original encoded data is determined to be a fixed step size based on the hierarchical association information, the specified codes of the current original encoded data are omitted based on the code omission rules.

[0049] Based on this encoding omission rule, the encoding device extracts the specified code from the current raw encoded data and compares it with the specified code from the previous raw encoded data. For area-specific encoded data, the specified code can be the area code, postal code, etc. The specified code can be configured adaptively according to different types of encoded data.

[0050] Furthermore, when the difference between the current specified code and the previous specified code is detected to be a predictable fixed step size (e.g., incrementing by 1, from 110105 to 110106), the encoding omission rule is triggered, and the current specified code is omitted. It can be understood that when the difference between specified codes is a fixed step size, the specified code of the current encoded data can be derived based on the specified code of the previous original encoded data, thus allowing the deletion of this redundant data. Subsequently, by determining the specified code of the previous original encoded data based on hierarchical association information, the redundant data omitted from the current original encoded data can be restored.

[0051] For example, when omitting fields in the original encoded data for region-specific coded data, if the region code (code) of the current original encoded data is incremented by 1 compared to the region code of the previous original encoded data, then the region code (code) field of the current original encoded data can be set to empty. For example: Original encoded data:

[0052] By comparing the region codes, it was found that the second line of code increments by 1 relative to the first line. Therefore, the second line of code can be omitted. The result after omission is:

[0053] By identifying and utilizing regular fixed-step increment patterns in the encoded sequence, some predictable numerical data can be transformed into implicit information that does not require storage, thereby significantly improving compression efficiency while ensuring data integrity.

[0054] Optionally, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified name field of the current original encoded data is the same as that of the previous original encoded data based on the hierarchical association information, the specified name field of the current original encoded data is omitted based on the encoding omission rule.

[0055] Based on this encoding omission rule, the encoding device extracts the specified name field from the current raw encoded data and compares it with the specified name field from the previous raw encoded data. This is done by matching the specified name field in the current raw encoded data (e.g., the district name "Beijing") character by character with the specified name field in the cached previous raw encoded data. When two strings are found to be completely identical (e.g., two consecutive records both have the name "Beijing"), the current name field is determined to be a deducible duplicate, triggering the encoding omission rule to omit the specified name field from the current raw encoded data.

[0056] For example, when omitting fields in the original encoded data for region segmentation, if the specified name field "name" of the current original encoded data is the same as the specified name field "name" of the previous original encoded data, then the specified name field "name" of the current original encoded data can be set to empty. For example: Raw data:

[0057] By comparing the specified name field "name", it is found that the specified name field "name" in the second row is the same as that in the first row. Therefore, the specified name field "name" in the second row can be omitted. The result after omission is:

[0058] By eliminating repeated name fields in consecutive data records, redundant storage of text data is effectively reduced, and the compression efficiency of hierarchical relationship data is significantly improved.

[0059] Optionally, the original encoded data is adjusted based on the set adjustment rules and hierarchical association information, including: If the number of bytes in the specified code of the current raw encoded data is the first specific number of bits, obtain the specified number of bits field of the specified code of the previous shallower level raw encoded data, and add the specified number of bits field to the prefix position of the specified code of the raw encoded data.

[0060] Based on this adjustment rule, the encoding device extracts the specified code of the current raw encoded data, analyzes the byte length of its specified code field, and if it identifies that the length falls within a preset first specific bit range (e.g., 3 to 4 bits), it triggers the set processing flow. The encoding device queries the complete specified code field of the shallower level above the current level (i.e., the direct parent), and extracts a specific specified bit field from the specified code field of the shallower level above (e.g., if the specified code field of the shallower level above is 6 bits "110000", then extracts its first 2 bits "11" as the provincial identifier of the specified code field of the current level). Then, it performs a field concatenation operation, adding the extracted specified bit field of the shallower level above as a prefix to the head of the specified code of the current raw encoded data, thereby forming a new composite code (e.g., concatenating the parent's "11" with the current level's "101" to form "11101"). By explicitly representing the hierarchical relationship of specified code fields through encoding concatenation, shorter sub-codes can carry the encoding information of the shallower level above them, providing an optimized data structure for subsequent data compression processes and thus further improving overall compression efficiency.

[0061] For example, for region-specific encoded data, if the specified code or postcode of the current original encoded data is three or four digits, then the first two digits of the specified code field at the shallowest level above are added as a prefix to the current specified code. For example: Raw data:

[0062] At this point, the designated code or postcode for Zhuhai City is three or four digits. Adding the first two digits of the designated code or postcode for Guangdong Province yields a new designated code or postcode for Zhuhai City. The processing result is:

[0063] It should be noted that, generally, the specified code or postcode uses a fixed-length standard number of bits, thus preserving the original encoding bit length. Alternatively, for partially redundant bits, such as specified codes "330000" and "310000", it is only necessary to predetermine the complete number of bits in the code. The 0-bit suffix portion can then be removed, resulting in the omitted specified codes "33" and "31". Subsequently, based on the complete number of bits in the code and the corresponding omission rules, the omitted specified codes can be padded with suffixes to restore the compressed data.

[0064] Optionally, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified code of the current original encoded data is empty or has a zero value, the specified code of the current original encoded data is omitted based on the encoding omission rule.

[0065] Based on this encoding omission rule, the encoding device extracts a specified code from the current raw encoded data and checks whether it is in a null state (e.g., the field is explicitly marked as NULL in the database) or a zero-value state (i.e., the field exists, but its numerical content is all zero, such as the number 0 or the string "0"). If the specified code of the current record satisfies either of these conditions, the field is removed before the final compressed data set is generated, based on the preset encoding omission rule. By removing null and zero-value code fields from data records, the data content is further compressed, avoiding waste of storage and transmission resources, thereby further improving the efficiency of compressed data storage and transmission.

[0066] For example, for region-specific encoded data, if the specified code postcode of the current original encoded data is 0, then the postcode field is omitted. For example: Raw data:

[0067] At this point, the specified postcode is 0, so it can be omitted. The result after omitting the postcode is as follows:

[0068] Optionally, the original encoded data is adjusted based on the set adjustment rules and hierarchical association information, including: If consecutive target fields are omitted in the current raw encoded data, the separators between the target fields are omitted. The target fields include the specified code and specified name fields of the current raw encoded data.

[0069] After completing the above field omission processing, before generating the final compressed data string, this application scans the omission-processed field sequence of each piece of encoded data to identify consecutively omitted field blocks. For example, a piece of encoded data may omit both a specified code and its immediately following name field, resulting in two or more consecutive empty value positions in the field sequence. In this case, a delimiter cleanup operation is performed to remove the delimiters between these consecutive empty fields. For example, in the original field sequence [,, Xihu District] (where both the specified code and postcode are omitted), the two consecutive delimiters ",," are directly deleted, resulting in the final encoded compressed data "Xihu District". This eliminates redundant delimiters caused by field omission, making the compressed data more concise in format and further improving compression efficiency.

[0070] For example, for region-division encoded data, suppose the data after field omission processing is as follows:

[0071] At this point, it is found that ">," and ",," contain consecutive delimiters for omitted fields. Therefore, they are further omitted, and the result after omission is as follows:

[0072] Finally, based on the above hierarchical relationship and the encoding omission rules, the original encoded data can be used to generate encoded compressed data one by one. The encoded compressed data is then sorted according to the hierarchical relationship to obtain the final compressed data set.

[0073] It should be noted that the above is only a partial example of the hierarchical relationship data compression method of this application. In practical applications, this hierarchical relationship data compression method can also be applied to the compression of coded data such as organizational structure codes and classification codes. Taking classification code data as an example, the input of the classification code data is as follows:

[0074] Assuming the original coded data includes classification codes and classification names, the hierarchical compressed data obtained using the hierarchical relationship data compression method of this application is as follows: 1. Smartphone >1,A B C Therefore, by combining hierarchical relationships with corresponding coding omission rules, categorized coding data can be further compressed, improving the storage and compression efficiency of categorized coding data. This application does not impose fixed restrictions on specific methods for compressing hierarchical relationship data, and will not elaborate on them here.

[0075] The above describes a process involving obtaining an original hierarchical relationship data set, comprising multiple original coded data entries ordered according to hierarchical relationships; determining the hierarchical association information of the original coded data within the original hierarchical relationship data set; adding hierarchical symbols to the associated original coded data based on the hierarchical association information; and adjusting the original coded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set. By employing these techniques and introducing hierarchical symbols to represent the hierarchical relationships in the hierarchical relationship data, structural redundancy and duplicate information can be effectively eliminated during the compression process, resulting in a significant reduction in data volume. This improves the compression efficiency and parsing performance of the hierarchical relationship data, meeting the requirements for efficient storage and rapid transmission of hierarchical relationship data, thereby enhancing application performance and user experience.

[0076] Figure 4 A flowchart of a method for decoding hierarchical relationship compressed data according to Embodiment 1 of this application is provided. The decoding method for hierarchical relationship compressed data provided in this embodiment can be executed by a decoding device for hierarchical relationship compressed data. This decoding device can be implemented by software and / or hardware, and can consist of two or more physical entities, or a single physical entity. Generally, the decoding device for hierarchical relationship data can be a data receiving end, a decoding server, or other decoding devices. The following description uses a decoding device as the main component in a method for decoding hierarchical compressed data. (Refer to...) Figure 4 The decoding method for this hierarchical compressed data specifically includes: S150. Obtain a compressed data set, which includes multiple encoded compressed data items sorted according to hierarchical relationships.

[0077] S160. Initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data.

[0078] S170. Based on the hierarchical status information, perform field restoration processing on the currently traversed encoded compressed data to generate the original hierarchical relationship data set of the corresponding compressed data set.

[0079] S180. Update the hierarchical status information based on the hierarchical symbols in the currently traversed encoded compressed data.

[0080] Correspondingly, after compressing the data using the aforementioned hierarchical data compression method, when decoding the compressed data set is required, the encoded compressed data is sorted according to a specific hierarchical relationship. Each data entry may contain hierarchical symbols, omitted field information, and an optimized delimiter structure. The system needs to ensure complete acquisition of the entire compressed data stream to prepare for subsequent line-by-line parsing.

[0081] During the decoding of compressed data sets, the original encoded data of the shallower layer above the initial layer provided by the initial layer status information is used as the reference benchmark for field restoration, thereby ensuring that the positional relationship of each compressed data in the original layer structure can be accurately understood.

[0082] Specifically, based on hierarchical state information, the currently traversed encoded compressed data undergoes field restoration processing to generate the original hierarchical relationship data set corresponding to the compressed data set, including: Based on the hierarchical status information and the set decoding and restoration rules, the field restoration processing is performed on the currently traversed encoded and compressed data to generate the corresponding original encoded data. When the encoded and compressed data is encoded, the original encoded data is adjusted based on the set adjustment rules and hierarchical association information to obtain the adjustment rules corresponding to the decoding and restoration rules. Generate the original hierarchical relationship data set corresponding to the compressed data set based on the original encoded data.

[0083] By detecting omissions in the fields of the current compressed data, for omitted encoded fields, the data is decoded and restored using the corresponding decoding and restoration rules by analyzing the original encoded data of the previous shallower level in the hierarchical status information and the sequence value of the current encoded field. For example, for omitted name fields, the corresponding name field is inherited from the previous row of decoded data (i.e., the decoded original encoded data); for codes with a specific number of bits, parsing is performed according to the corresponding restoration rules, thereby ensuring that each field omitted during compression can be accurately and completely restored.

[0084] Based on this, whenever a hierarchical symbol in the compressed data is parsed, the hierarchical status information is further updated to ensure that the decoding device can accurately track the changes in the position of the data in the hierarchical relationship, providing the necessary hierarchical context for the correct restoration of subsequent data.

[0085] After completing the traversal and restoration of all compressed data, the decoding device reassembles each restored original encoded data in the processing order to form a set of original hierarchical relationship data that is completely consistent with that before compression.

[0086] Optionally, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current encoded compressed data has entered the next deeper level relative to the previous encoded compressed data, and the roll-up symbol indicates that the current encoded compressed data has returned to the previous shallower level relative to the current encoded compressed data. Reference Figure 5 The hierarchical state information is updated based on the hierarchical symbols in the currently traversed encoded and compressed data, including: S1801. If the currently traversed encoded compressed data contains drill-down symbols, update the original encoded data generated from the current encoded compressed data to the hierarchical status information. S1802. If the currently traversed encoded compressed data contains the previous level symbol, the current level state information is rolled back to the previous level state information.

[0087] During the decoding process of hierarchical compressed data, the decoding device continuously monitors the hierarchical symbol at the prefix position of each data entry. The hierarchical symbol indicates the change in the hierarchical state of each encoded compressed data entry during decoding. (Refer to...) Figure 6 Specifically, when a drill-down symbol is encountered, the decoding device treats the currently restored complete data record (including its complete encoding, name, and all other fields) as a new level state information and writes it into the parent cursor stack, thus establishing it as reference data for subsequent parsing of encoded compressed data. Conversely, when a roll-up symbol is encountered, the decoding device performs the opposite operation, popping the current level state information from the top of the parent cursor stack and reverting to the level state information of the previous level. If no level symbol is encountered, the current level state information is retained. This entire process ensures that the decoding device can accurately track the positional changes of data within complex hierarchical relationships, providing correct hierarchical context information for subsequent field restoration processing and ensuring lossless restoration of compressed data.

[0088] Optionally, based on the hierarchical status information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the specified code of the current encoded compressed data is found to be omitted, the specified code of the current encoded compressed data is calculated and generated based on the hierarchical status information and the sorting of the current encoded compressed data in the current level.

[0089] When the decoding device traverses the currently encoded compressed data, it checks whether the specified code field of the current record has been omitted (i.e., the specified code field is empty). If it confirms that the specified code has been omitted, it calculates and generates the specified code for the current encoded compressed data based on the hierarchical status information and the sorting of the current encoded compressed data in the current level. It can be understood that during data compression, if the difference between the specified code and the previous line is a fixed step size, it can be omitted. For the specified code with a fixed step size in each original encoded data of parallel levels, except for the first code, all subsequent codes with increasing fixed step sizes are omitted. Based on this, the original encoded data of the shallower level above it can be determined through the hierarchical status information (e.g., the parent code "330100" represents Hangzhou City). Furthermore, by analyzing the hierarchical sorting number of the current compressed data in the compressed data of parallel levels (e.g., the current record is the 5th in the districts and counties under Hangzhou City), the decoding device can further analyze the hierarchical sorting number of the current compressed data in the parallel levels. Based on these two pieces of information, a preset restoration formula is applied for calculation, as shown in the formula "Current complete code = Parent code + Current level sequence number × Base number", where the base number is determined according to the level depth (e.g., a base number of 1 can be used for district / county level, and a base number of 100 for city level). When the parent code is "330100" and the current level sequence number is 5, the complete specified code "330105" can be accurately restored by calculating "330100 + 5 × 1". The entire restoration process strictly follows the rules agreed upon during encoding, thereby accurately reconstructing the encoding information omitted during the compression stage to eliminate redundancy, ensuring that the output data is completely consistent with the original data.

[0090] Optionally, based on the hierarchical status information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the specified name field of the current encoded compressed data is found to be omitted, the specified name field of the previous original encoded data is determined based on the hierarchical status information, and the specified name field of the current encoded compressed data is restored based on the specified name field of the previous original encoded data.

[0091] When the decoding device iterates through the currently encoded compressed data, it continuously checks whether the specified name field of the current record is omitted. If it confirms that a name field is omitted, it retrieves the specified name field value of the most recently successfully restored original encoded data by querying the current hierarchical status information. For example, if the name restored from the previous record is "Beijing," and the name field of the current record is marked as omitted, the decoding device will automatically copy the value "Beijing" and fill it into the name field of the current record, completing the field restoration. By establishing a field value inheritance method, duplicate name fields omitted during the compression process are completely restored, significantly improving the compression efficiency of text data while ensuring data integrity.

[0092] Optionally, based on the hierarchical status information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the second specific number of bits, the specified number of bits field of the specified code in the previous shallower level original encoded data is determined based on the hierarchical status information, and the specified number of bits field is deleted from the prefix position of the specified code in the current encoded compressed data.

[0093] When the decoding device traverses the currently encoded compressed data, it monitors the byte length of the specified code field in the current record. If it identifies that the length falls within the preset second specific bit range (e.g., 6 bits), it triggers the prefix stripping process. At this point, the decoding device accesses the complete encoding of the shallower level (i.e., the direct parent) stored in the hierarchical status information and determines the specified bit field that needs to be deleted from the current encoding prefix based on preset rules. For example, if the parent encoding is 6 bits "110000" and the current encoding prefix is ​​"11", then the first two bits of "11" in the current encoding need to be deleted. If the parent encoding is 6 bits "110000" and the current encoding prefix is ​​"00", it indicates that the specified code was not prefixed during compression, and the byte length of the specified code before encoding does not belong to the first specific bit range (e.g., 3-4 bits), then the current specified code field is retained. By reversing the encoding concatenation rules, the inherited prefix and the essential encoding in the composite encoding are accurately separated, thus achieving precise restoration of specially formatted encoded data.

[0094] Optionally, based on the hierarchical status information and the set decoding and restoration rules, field restoration processing is performed on the currently traversed encoded and compressed data, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the third specific number of bits, the specified code of the previous shallower level original encoded data is determined based on the hierarchical status information, and the field restoration process of the specified code is performed based on the specified code of the current encoded compressed data and the specified code of the previous shallower level original encoded data.

[0095] For the restoration of the currently specified code field, it is also possible to perform field restoration processing based on the specified code of the original coding data at the previous shallower level. Among them, when the decoder recognizes that the specified code byte length of the current coded compressed data reaches the third specific number of digits (such as a code with five or more digits), the complete coded data of the previous shallower level is obtained according to the hierarchical status information, and it is jointly analyzed with the current specified coding. Different from the above prefix deletion method, the coding device needs to identify which parts of the current specified coding are inherited from the previous level and which parts are the essential identifiers of the current level. For example, a six-digit code "330106" may contain information about the provincial level "33", the municipal level "01", and the district level "06" at the same time. The decoder needs to decompose this composite code into independent codes at each level according to the preset digit rules and hierarchical mapping relationships. Then, according to the currently decomposed essential identifier (such as the district-level coding part "06"), the restoration is performed according to the set coding restoration rules, so as to obtain the actual specified code in the original coding data. Through the analysis of the coding with specific number of digits and the reconstruction of the hierarchical relationship, the accurate restoration of complex cross-level coded data is achieved, ensuring the integrity and accuracy of multi-level nested data.

[0096] It should be noted that in practical applications, any coding omission rule can be selected according to the actual compression requirements to process the specified code, and then the corresponding coding restoration rule is used for field restoration. This application does not impose a fixed limit on the compression processing method of specific specified codes, so it will not be elaborated here.

[0097] Optionally, based on the hierarchical status information and the set decoding restoration rules, perform field restoration processing on the currently traversed coded compressed data, including: When it is detected that the delimiter of consecutive target fields in the current coded compressed data is omitted, Query the field order rule and the number of fields specified in the set decoding restoration rules, and perform field restoration processing on the currently traversed coded compressed data based on the hierarchical status information, the field order rule, and the number of fields.

[0098] During the decoding process of the hierarchical relationship compressed data, this application will also monitor the delimiter distribution pattern in the data string. When it is detected that there is a delimiter omission situation between consecutive target fields (for example, the string "Xihu District" actually represents the omission state of ",,Xihu District"). At this time, according to the field order rule and the total number of fields clearly specified in the decoding restoration rules (for example, the standard format is three fields: "area code, postal code, name"), first use the delimiter to separate the three parts of data. Furthermore, based on the hierarchical status information, the omitted parts of the area code and the postal code are restored. Thus, by analyzing the format of the omitted delimiter, the complete field sequence is accurately reconstructed, ensuring the complete restoration of the data from format to content.

[0099] For example, taking the regional division data of Xihu District, Hangzhou City, Zhejiang Province as an example, its original encoded data is 68 characters, as follows: 330000 Zhejiang Province 310000 330100 Hangzhou City 310000 330105 Gongshu District 310011 330106 Xihu District 310013 Based on the original encoded data of this application, the compressed data set can be obtained as follows: 33, 31, Zhejiang Province >1, Hangzhou >5,11, Gongshu District 13, Xihu District Where 33 is the area code for Zhejiang Province, with the suffix "0000" removed using encoding omission rules; 31 represents the postal code for Zhejiang Province, with the suffix "0000" removed using encoding omission rules; > indicates drilling down to the first sublevel (Zhejiang Province → Hangzhou City, Hangzhou City → Gongshu District); the area code for Hangzhou City, code "1", and the area code for Gongshu District, code "5", are obtained by combining the previous shallower level and omitting using encoding omission rules; the postal codes for Gongshu District, "11", and Xihu District, "13", are obtained by combining the previous shallower level and omitting using encoding omission rules; if the next line code "330106" increments by 1 compared to the previous line code "330105" (i.e., the difference is a fixed step size), then the next line code "330106" is not displayed; if the Hangzhou City postal code "310000" is the same as the previous line, it is omitted; if the postal codes "310011" and "310013" are not 0, they must be retained; if the names of the next line and the previous line are different, they must be retained. The compression method described above can produce 31 characters of encoded compressed data, allowing the original encoded data to be stored and transmitted in a smaller size.

[0100] Correspondingly, based on the above compressed data, when decoding the encoded compressed data, the region code is used. Taking the code restoration process as an example, the restoration method for four consecutive lines of code: "33", ">1", ">5", is as follows: 1. Provincial region code "33" → restored to 330000 according to the encoding restoration rules; 2. In ">1", "> indicates drilling down to the city level. The city-level area code "1" → is restored according to the encoding restoration rules: 330000 + 1*100 = 330100; 3. In ">5", "> indicates drilling down to the district level. The district-level area code "5" is restored according to the encoding restoration rules: 330100 + 5 = 330105; 4. “” indicates that it is omitted. The code 330105 is obtained by decoding the previous encoded compressed data of the same level (district / county level). The calculation is performed according to the fixed step size: 330105 + 1 = 330106.

[0101] For postal codes, the same decoding and restoration process is used to obtain the corresponding original encoded data and generate the original hierarchical relationship data set corresponding to the compressed data set.

[0102] The above describes a process involving: acquiring a compressed data set, which includes multiple encoded compressed data entries ordered according to hierarchical relationships; initializing hierarchical state information and traversing the compressed data set, where the hierarchical state information stores the original encoded data of the shallower level above the currently traversed encoded compressed data; performing field restoration processing on the currently traversed encoded compressed data based on the hierarchical state information to generate the original hierarchical relationship data set corresponding to the compressed data set; and updating the hierarchical state information based on the hierarchical symbols in the currently traversed encoded compressed data. By employing these techniques and introducing hierarchical state information for decoding and restoring compressed data, the compressed hierarchical data can dynamically reconstruct its data structure based on the hierarchical state information, achieving lossless recovery of field information and thus improving the parsing efficiency and real-time processing capabilities of hierarchical relationship data.

[0103] Example 2: Based on the above embodiments, Figure 7 This is a schematic diagram of a hierarchical data compression system provided in Embodiment 2 of this application. (Reference) Figure 7 The hierarchical relationship data compression system provided in this embodiment specifically includes: The first acquisition module 21 is used to acquire the original hierarchical relationship data set, which includes multiple original coded data sorted according to hierarchical relationship. The hierarchy determination module 22 is used to determine the hierarchy association information of the original encoded data in the original hierarchy relation data set; Symbol addition module 23 is used to add hierarchical symbols to the associated original encoded data based on hierarchical association information; Processing module 24 is used to adjust the original encoded data based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

[0104] Specifically, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current raw encoded data has entered the next deeper level relative to the previous raw encoded data, while the roll-up symbol indicates that the current raw encoded data has returned to the previous shallower level relative to the previous raw encoded data. Based on hierarchical association information, hierarchical symbols are added to the associated original encoded data, including: If the current raw encoded data is determined to be at a deeper level than the previous raw encoded data based on the hierarchical association information, a drill-down symbol is added to the prefix position of the current raw encoded data. If, based on the hierarchical association information, it is determined that the current original encoded data returns to a shallower level relative to the previous original encoded data, a roll-up symbol is added to the prefix position of the current original encoded data.

[0105] Specifically, the original encoded data is adjusted based on hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set, including: The original encoded data is adjusted based on the set adjustment rules and hierarchical association information. The compressed data set of the original hierarchical relationship data set is generated based on the compressed encoded data obtained from the adjustment process.

[0106] Specifically, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: When the difference between the specified codes of the current original encoded data and the previous original encoded data is determined to be a fixed step size based on the hierarchical association information, the specified codes of the current original encoded data are omitted based on the code omission rules.

[0107] Specifically, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified name field of the current original encoded data is the same as that of the previous original encoded data based on the hierarchical association information, the specified name field of the current original encoded data is omitted based on the encoding omission rule.

[0108] Specifically, the original encoded data is adjusted based on the established adjustment rules and hierarchical association information, including: If the number of bytes in the specified code of the current raw encoded data is the first specific number of bits, obtain the specified number of bits field of the specified code of the previous shallower level raw encoded data, and add the specified number of bits field to the prefix position of the specified code of the raw encoded data.

[0109] Specifically, the adjustment rules include encoding omission rules, which adjust the original encoded data based on the set adjustment rules and hierarchical association information, including: If the specified code of the current original encoded data is empty or has a zero value, the specified code of the current original encoded data is omitted based on the encoding omission rule.

[0110] Specifically, the original encoded data is adjusted based on the established adjustment rules and hierarchical association information, including: If consecutive target fields are omitted in the current raw encoded data, the separators between the target fields are omitted. The target fields include the specified code and specified name fields of the current raw encoded data.

[0111] The above describes a process involving obtaining an original hierarchical relationship data set, comprising multiple original coded data items ordered according to hierarchical relationships; determining the hierarchical association information of each original coded data item in the original hierarchical relationship data set; adding hierarchical symbols to the associated original coded data based on the hierarchical association information; and adjusting the original coded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set. By employing these techniques and introducing hierarchical symbols to represent the hierarchical relationships in the hierarchical relationship data, structural redundancy and duplicate information can be effectively eliminated during the compression process, resulting in a significant reduction in data volume. This improves the compression efficiency and parsing performance of the hierarchical relationship data, meeting the requirements for efficient storage and rapid transmission of hierarchical relationship data, thereby enhancing application performance and user experience.

[0112] The hierarchical relationship data compression system provided in Embodiment 2 of this application can be used to execute the hierarchical relationship data compression method provided in Embodiment 1 above, and has corresponding functions and beneficial effects.

[0113] Based on the above embodiments, Figure 8 This is a schematic diagram of a decoding system for hierarchical compressed data provided in Embodiment 2 of this application. (Reference) Figure 8 The decoding system for hierarchical compressed data provided in this embodiment specifically includes: The second acquisition module 25 is used to acquire a compressed data set, which includes multiple coded compressed data items sorted according to hierarchical relationships. The traversal module 26 is used to initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data. Data restoration module 27 is used to perform field restoration processing on the currently traversed encoded compressed data based on hierarchical status information, and generate the original hierarchical relationship data set of the corresponding compressed data set; The layer update module 28 is used to update the layer status information based on the layer symbols in the currently traversed encoded compressed data.

[0114] Specifically, the hierarchy symbols include roll-up symbols and drill-down symbols. The drill-down symbol indicates that the current encoded compressed data has entered the next deeper level relative to the previous encoded compressed data, while the roll-up symbol indicates that the current encoded compressed data has returned to the previous shallower level relative to the current encoded compressed data. Update the hierarchical state information based on the hierarchical symbols in the currently traversed encoded and compressed data, including: If the currently traversed encoded compressed data contains drill-down symbols, update the original encoded data generated from the current encoded compressed data to the hierarchical status information; If the currently traversed encoded compressed data contains roll-up symbols, the current level state information is rolled back to the previous level state information.

[0115] Specifically, based on the hierarchical state information, the currently traversed encoded compressed data undergoes field restoration processing to generate the original hierarchical relationship data set corresponding to the compressed data set, including: Based on the hierarchical status information and the set decoding and restoration rules, the field restoration processing is performed on the currently traversed encoded and compressed data to generate the corresponding original encoded data. The encoded and compressed data is obtained by adjusting the original encoded data based on the set adjustment rules and hierarchical association information during encoding. The adjustment rules correspond to the decoding and restoration rules. Generate the original hierarchical relationship data set corresponding to the compressed data set based on the original encoded data.

[0116] Specifically, based on the hierarchical state information and the set decoding and restoration rules, the currently traversed encoded and compressed data undergoes field restoration processing, including: If the specified code of the current encoded compressed data is found to be omitted, the specified code of the current encoded compressed data is calculated and generated based on the hierarchical status information and the sorting of the current encoded compressed data in the current level.

[0117] Specifically, based on the hierarchical state information and the set decoding and restoration rules, the currently traversed encoded and compressed data undergoes field restoration processing, including: If the specified name field of the current encoded compressed data is found to be omitted, the specified name field of the previous original encoded data is determined based on the hierarchical status information, and the specified name field of the current encoded compressed data is restored based on the specified name field of the previous original encoded data.

[0118] Specifically, based on the hierarchical state information and the set decoding and restoration rules, the currently traversed encoded and compressed data undergoes field restoration processing, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the second specific number of bits, the specified number of bits field of the specified code in the previous shallower level original encoded data is determined based on the hierarchical status information, and the specified number of bits field is deleted from the prefix position of the specified code in the current encoded compressed data.

[0119] Specifically, based on the hierarchical state information and the set decoding and restoration rules, the currently traversed encoded and compressed data undergoes field restoration processing, including: If the number of bytes of the specified code in the current encoded compressed data is detected to be the third specific number of bits, the specified code of the previous shallower level original encoded data is determined based on the hierarchical status information, and the field restoration process of the specified code is performed based on the specified code of the current encoded compressed data and the specified code of the previous shallower level original encoded data.

[0120] Specifically, based on the hierarchical state information and the set decoding and restoration rules, the currently traversed encoded and compressed data undergoes field restoration processing, including: If it is detected that the delimiter of consecutive target fields is omitted in the current encoded compressed data, The query specifies the field order rules and the number of fields in the defined decoding and restoration rules. Based on the hierarchical status information, field order rules, and the number of fields, the query performs field restoration processing on the currently traversed encoded and compressed data.

[0121] The above describes a process involving: acquiring a compressed data set, which includes multiple encoded compressed data entries ordered according to hierarchical relationships; initializing hierarchical state information and traversing the compressed data set, where the hierarchical state information stores the original encoded data of the shallower level above the currently traversed encoded compressed data; performing field restoration processing on the currently traversed encoded compressed data based on the hierarchical state information to generate the original hierarchical relationship data set corresponding to the compressed data set; and updating the hierarchical state information based on the hierarchical symbols in the currently traversed encoded compressed data. By employing these techniques and introducing hierarchical state information for decoding and restoring compressed data, the compressed hierarchical data can dynamically reconstruct its data structure based on the hierarchical state information, achieving lossless recovery of field information and thus improving the parsing efficiency and real-time processing capabilities of hierarchical relationship data.

[0122] Example 3: This application provides an electronic device in embodiment three, referring to... Figure 9 The electronic device includes a processor 31, a memory 32, a communication module 33, an input device 34, and an output device 35. The electronic device may have one or more processors and one or more memories. The processor, memory, communication module, input device, and output device of the electronic device can be connected via a bus or other means.

[0123] Memory, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the hierarchical relationship data compression method described in any embodiment of this application (e.g., various modules in a hierarchical relationship data compression system or a hierarchical relationship compressed data decoding system). Memory may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created according to the use of the device, etc. Furthermore, memory may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0124] The communication module is used for data transmission.

[0125] The processor executes various functional applications and data processing of the device by running software programs, instructions, and modules stored in memory, thereby realizing the hierarchical data compression method mentioned above.

[0126] Input devices can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the device. Output devices may include display devices such as displays.

[0127] The electronic device provided above can be used to execute the hierarchical relationship data compression method or the hierarchical relationship compressed data decoding method provided in Embodiment 1 above, and has the corresponding functions and beneficial effects.

[0128] Example 4: This application also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a method for compressing hierarchical relationship data or a method for decoding hierarchical relationship compressed data as described above.

[0129] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” can include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.

[0130] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the hierarchical relationship data compression method or hierarchical relationship data decoding method as described above, but can also execute related operations in the hierarchical relationship data compression method or hierarchical relationship data decoding method provided in any embodiment of this application.

[0131] The hierarchical relationship data compression system, hierarchical relationship data decoding system, storage medium, and electronic device provided in the above embodiments can execute the hierarchical relationship data compression method or hierarchical relationship data decoding method provided in any embodiment of this application. For technical details not described in detail in the above embodiments, please refer to the hierarchical relationship data compression method and hierarchical relationship data decoding method provided in any embodiment of this application.

[0132] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.

Claims

1. A method for compressing hierarchical relational data, characterized in that, include: Obtain the original hierarchical relationship data set; Determine the hierarchical association information of the original coded data in the original hierarchical relation data set; Based on the hierarchical association information, add hierarchical symbols to the associated original encoded data; The original encoded data is adjusted based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

2. The method for compressing hierarchical relationship data according to claim 1, characterized in that, The hierarchical symbols include roll-up symbols and drill-down symbols; Adding hierarchical symbols to the associated original encoded data based on the hierarchical association information includes: If, based on the hierarchical association information, it is determined that the current original encoded data is at a deeper level relative to the previous original encoded data, the drill-down symbol is added to the prefix position of the current original encoded data. If, based on the hierarchical association information, it is determined that the current original encoded data returns to a shallower level relative to the previous original encoded data, the roll-up symbol is added to the prefix position of the current original encoded data.

3. The method for compressing hierarchical relationship data according to claim 1, characterized in that, The step of adjusting the original encoded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set includes: The original encoded data is adjusted based on the set adjustment rules and the hierarchical association information, and the compressed data set of the original hierarchical relationship data set is generated based on the compressed encoded data obtained from the adjustment process.

4. The method for compressing hierarchical relationship data according to claim 3, characterized in that, The adjustment rules include encoding omission rules. The adjustment processing of the original encoded data based on the set adjustment rules and the hierarchical association information includes: If the difference between the specified code of the current original encoded data and the specified code of the previous original encoded data is determined to be a fixed step size based on the hierarchical association information, the specified code of the current original encoded data is omitted based on the code omission rule.

5. The method for compressing hierarchical relationship data according to claim 3, characterized in that, The adjustment rules include encoding omission rules. The adjustment processing of the original encoded data based on the set adjustment rules and the hierarchical association information includes: If, based on the hierarchical association information, it is determined that the specified name field of the current original encoded data is the same as that of the previous original encoded data, the specified name field of the current original encoded data is omitted based on the encoding omission rule.

6. The method for compressing hierarchical relationship data according to claim 3, characterized in that, The adjustment process for the original encoded data based on the set adjustment rules and the hierarchical association information includes: If the number of bytes of the specified code in the current original encoded data is a first specific number of bits, obtain the specified number of bits field of the specified code in the previous shallower level of the original encoded data, and add the specified number of bits field to the prefix position of the specified code in the original encoded data.

7. The method for compressing hierarchical relationship data according to claim 3, characterized in that, The adjustment rules include encoding omission rules. The adjustment processing of the original encoded data based on the set adjustment rules and the hierarchical association information includes: If the specified code of the current original encoded data is empty or has a zero value, the specified code of the current original encoded data is omitted based on the encoding omission rule.

8. The method for compressing hierarchical relationship data according to claim 3, characterized in that, The adjustment process for the original encoded data based on the set adjustment rules and the hierarchical association information includes: In the case where consecutive target fields are omitted in the current original encoded data, the separators between the target fields are omitted, and the target fields include the specified code and specified name fields of the current original encoded data.

9. A method for decoding hierarchical compressed data, characterized in that, include: Obtain a compressed data set, which includes multiple coded compressed data entries sorted according to hierarchical relationships; Initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data. Based on the hierarchical status information, the field restoration process is performed on the currently traversed encoded compressed data to generate the original hierarchical relationship data set corresponding to the compressed data set; The hierarchical state information is updated based on the hierarchical symbols in the currently traversed encoded compressed data.

10. The decoding method for hierarchical compressed data according to claim 9, characterized in that, The hierarchical symbols include roll-up symbols and drill-down symbols; Updating the hierarchical state information based on the hierarchical symbols in the currently traversed encoded compressed data includes: If the currently traversed encoded compressed data contains drill-down symbols, the original encoded data generated from the currently encoded compressed data is updated to the hierarchical status information; If the currently traversed encoded compressed data contains roll-up symbols, the current level state information is rolled back to the previous level state information.

11. The method for decoding hierarchical compressed data according to claim 9, characterized in that, The step of performing field restoration processing on the currently traversed encoded compressed data based on the hierarchical state information to generate the original hierarchical relationship data set corresponding to the compressed data set includes: Based on the hierarchical status information and the set decoding and restoration rules, the field restoration processing is performed on the currently traversed encoded compressed data to generate the corresponding original encoded data. The encoded compressed data is obtained by adjusting the original encoded data based on the set adjustment rules and hierarchical association information during encoding. The adjustment rules correspond to the decoding and restoration rules. Based on the original encoded data, generate the original hierarchical relationship data set corresponding to the compressed data set.

12. The decoding method for hierarchical compressed data according to claim 11, characterized in that, The process of restoring fields of the currently traversed encoded and compressed data based on the hierarchical status information and the set decoding and restoration rules includes: If it is detected that the specified code of the currently encoded compressed data is omitted, the specified code of the currently encoded compressed data is generated based on the hierarchical status information and the sorting of the currently encoded compressed data in the current level.

13. The method for decoding hierarchical compressed data according to claim 11, characterized in that, The process of restoring fields of the currently traversed encoded and compressed data based on the hierarchical status information and the set decoding and restoration rules includes: If it is detected that the specified name field of the current encoded compressed data is omitted, the specified name field of the previous original encoded data is determined based on the hierarchical status information, and the specified name field of the current encoded compressed data is restored based on the specified name field of the previous original encoded data.

14. The decoding method for hierarchical compressed data according to claim 11, characterized in that, The process of restoring fields of the currently traversed encoded and compressed data based on the hierarchical status information and the set decoding and restoration rules includes: If it is detected that the number of bytes of the specified code of the current encoded compressed data is a second specific number of bits, the specified number of bits field of the specified code of the original encoded data of the previous shallower level is determined based on the hierarchical status information, and the specified number of bits field is deleted from the prefix position of the specified code of the current encoded compressed data.

15. The method for decoding hierarchical compressed data according to claim 11, characterized in that, The process of restoring fields of the currently traversed encoded and compressed data based on the hierarchical status information and the set decoding and restoration rules includes: If the number of bytes of the specified code in the current encoded compressed data is detected to be a third specific number of bits, the specified code of the original encoded data at the next shallower level is determined based on the hierarchical status information, and the field restoration process of the specified code is performed based on the specified code of the current encoded compressed data and the specified code of the original encoded data at the next shallower level.

16. The method for decoding hierarchical compressed data according to claim 11, characterized in that, The process of restoring fields of the currently traversed encoded and compressed data based on the hierarchical status information and the set decoding and restoration rules includes: If it is detected that the separator of consecutive target fields in the current encoded compressed data is omitted, the field order rule and the number of fields specified in the set decoding and restoration rules are queried. Based on the hierarchical status information, the field order rule and the number of fields, the field restoration processing is performed on the currently traversed encoded compressed data.

17. A compression system for hierarchical relational data, characterized in that, include: The first acquisition module is used to acquire the original hierarchical relationship data set; The hierarchy determination module is used to determine the hierarchy association information of the original encoded data in the original hierarchy relation data set; A symbol addition module is used to add hierarchical symbols to the associated original encoded data based on the hierarchical association information; The processing module is used to adjust the original encoded data based on the hierarchical association information to generate a compressed data set corresponding to the original hierarchical relationship data set.

18. A decoding system for hierarchical compressed data, characterized in that, include: The second acquisition module is used to acquire a compressed data set, which includes multiple coded compressed data items sorted according to hierarchical relationships; The traversal module is used to initialize the hierarchical state information and traverse the compressed data set. The hierarchical state information is used to store the original encoded data of the shallower level above the currently traversed encoded compressed data. The data restoration module is used to perform field restoration processing on the currently traversed encoded compressed data based on the hierarchical status information, and generate the original hierarchical relationship data set corresponding to the compressed data set; The layer update module is used to update the layer status information based on the layer symbols in the currently traversed encoded compressed data.

19. An electronic device, characterized in that, include: Memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the hierarchical relationship data compression method as described in any one of claims 1-8, or the hierarchical relationship compressed data decoding method as described in any one of claims 9-16.