Data coding method, system and terminal
By setting the binary encoding format of the parent node and child node in the data encoding and dynamically adjusting the encoding length, the problems of excessive encoding length and difficulty in identifying data relationships in the prior art are solved, and efficient and flexible data encoding and rapid search efficiency are achieved.
Patent Information
- Application Number
- CN202311740105.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2025-06-17
AI Technical Summary
The prior art cannot ensure the encoding rate while identifying data relationships. Especially in distributed systems with complex functions, there are many types of things managed, resulting in too long encoding length, large space and low encoding rate.
By obtaining the data to be encoded and setting the data storage structure according to the preset encoding template file, setting the binary encoding of the parent node, and setting the binary encoding format of the child node as a combination of the prefix and the binary encoding of this level, dynamically adjusting the node encoding length to avoid the encoding length being too long.
It realizes fast encoding, improves coding efficiency, determines the data relationship of nodes at each level, reduces storage space usage, makes encoding more flexible and easy to expand, and improves data search efficiency.
Smart Images

Figure CN120163129A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data structure representation, and in particular to a data encoding method, system and terminal. Background Art
[0002] With the popularization of Internet technology, more and more things are connected to the Internet for more accurate and clear management; for things connected to the Internet, whether as large as a country or region, or as small as bread or cola, a code is needed for display and identification; code generation can usually be done with the help of third-party plug-ins, or the database's own functions can be used. The above encoding methods can meet the encoding of conventional data. For example, the database's auto_increment is used to generate codes. This method uses the original function of the database, is relatively simple, and can ensure uniqueness and incrementality. However, the encoding style cannot be changed and can only be an incremental number. Although the code can be generated in batches, it is impossible to find the parent node and child node through the code. The prior art also uses the method of adding letters and numbers to encode, which can identify the relationship between two data. However, when there are many levels, the data encoding length is too long, the space occupied will be large, and the encoding rate will be relatively low. For systems with complex functions, especially distributed systems, there are many types of things to manage, so it is urgent to solve the problem that the prior art cannot ensure the encoding rate while identifying data relationships. Summary of the invention
[0003] The purpose of the present invention is to overcome the problems of the prior art and provide a data encoding method, system and terminal.
[0004] The object of the present invention is achieved through the following technical solution: a data encoding method, the method comprising the following steps:
[0005] Acquire the data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file, wherein the preset encoding template file includes a node name, a parent node name, and a node level;
[0006] Set the binary code of the parent node of the data to be encoded; set the binary code format of all child nodes of the data to be encoded to a combination of a prefix and the binary code of this level, wherein the prefix is the binary code of the parent node of the current child node; and encode all child nodes according to the binary code format.
[0007] In one embodiment, before the step of setting the binary code of the parent node of the data to be encoded, the method further includes:
[0008] Setting a matching table, wherein the matching table stores the number of binary digits occupied by each node level, and the number of binary digits occupied by each node level is the same or different;
[0009] Set the binary encoding of the parent node of the data to be encoded according to the number of bits occupied by each node level in the matching table, and encode all child nodes according to the number of bits occupied by each node level in the matching table in combination with the binary encoding format.
[0010] In one embodiment, after the step of encoding all child nodes, the method further includes:
[0011] Receive a data query request;
[0012] Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of bits occupied by the node to be queried, shift the binary encoding of the node to be queried to the right by the number of bits occupied by the node to be queried, and then find the parent node of the node to be queried; and / or,
[0013] Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of bits occupied by the node to be queried, shift the binary encoding of the node to be queried to the left by the number of bits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and then find the child nodes of the node to be queried.
[0014] In one embodiment, the method further includes:
[0015] Assemble the encoding result of the data to be encoded into a tree structure, and obtain the structure parameters of the data nodes of the tree structure, including node encoding and node name.
[0016] It should be further noted that the technical features corresponding to the above method embodiments can be combined or replaced with each other to form a new technical solution.
[0017] The present invention further includes a data encoding system, which has the same inventive concept as the encoding method formed by combining any one of the above embodiments or multiple embodiments. The system includes:
[0018] A data entry module, configured to obtain data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file, where the preset encoding template file includes a node name, a parent node name, and a node level;
[0019] A data encoding module, configured to set the binary encoding of the parent node of the data to be encoded, and set the binary encoding format of all child nodes of the data to be encoded as a combination of a prefix and the binary encoding of this level, where the prefix is the binary encoding of the parent node of the current child node, and then encode all child nodes according to the binary encoding format.
[0020] In one embodiment, the system further includes a data assembly module, which is used to assemble the encoding result into a tree structure and return the structure parameters of the data nodes of the tree structure, including node encoding and node name.
[0021] In one embodiment, a matching table is set in the data encoding module. The matching table stores the number of binary digits occupied by each node level of the data stream, and the number of binary digits occupied by each level can be the same or different. Specifically, the data encoding module is used to set the binary encoding of the parent node of the data to be encoded according to the number of binary digits occupied by each node level in the matching table, and encode all child nodes according to the number of binary digits occupied by each node level in the matching table in combination with the binary encoding format.
[0022] In one embodiment, the system further includes a data search module, which is used to receive a data query request, then determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the right by the number of binary digits occupied by the node to be queried, and then find the parent node of the node to be queried; and / or, determine the node level of the node to be queried in the data query request according to the matching table, then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the left by the number of binary digits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and then find the child nodes of the node to be queried.
[0023] It should be further noted that the technical features corresponding to the above system embodiments can be combined or replaced with each other to form a new technical solution.
[0024] The present invention also includes a storage medium, on which computer instructions are stored. When the computer instructions run, they execute the steps of the data encoding method formed by any one of the above embodiments or a combination of multiple embodiments.
[0025] The present invention also includes a terminal, which includes a memory and a processor. Computer instructions that can run on the processor are stored on the memory. When the processor runs the computer instructions, it executes the steps of the data encoding method formed by any one of the above embodiments or a combination of multiple embodiments.
[0026] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0027] 1. In one embodiment, each node of the present invention uses binary encoding, which is convenient for fast encoding and improves the encoding efficiency. At the same time, the encoding format uses the parent node of each node as a prefix, which can determine the data relationships of each level of nodes, such as parent-child relationships, sibling relationships, etc., and the data structure is clear.
[0028] 2. In one embodiment, data encoding is performed based on the number of binary digits occupied by each node level defined in the matching table, which can make the number of binary digits occupied by different node levels different, thereby dynamically adjusting the node encoding length. When there are many nodes, it can effectively avoid too long encoding length, reduce the storage space occupation, make the encoding more flexible and easy to expand, and improve the subsequent data search efficiency to a certain extent.
[0029] 3. In one embodiment, the number of binary digits occupied by the node level can be obtained by querying the matching table, and then the parent node and child nodes of the current node can be quickly found by binary left and right offsets, greatly improving the data search efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The following further describes in detail the specific embodiments of the present invention with reference to the drawings. The drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The same reference numerals are used to represent the same or similar parts in these drawings. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application.
[0031] Figure 1 It is a flowchart of the encoding method provided by the embodiment of the present invention;
[0032] Figure 2 It is a schematic diagram of the text file data entry module provided by the embodiment of the present invention;
[0033] Figure 3 It is a schematic diagram of binary encoding of the tree structure provided by the embodiment of the present invention;
[0034] Figure 4 It is a flowchart of the encoding method provided by another embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0035] The technical solutions of the present invention will be clearly and completely described below with reference to the drawings. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0036] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0037] In one embodiment, as Figure 1 shown, a data encoding method specifically includes the following steps:
[0038] S10: Obtain the data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file. The preset encoding template file includes node name, parent node name, and node level;
[0039] S20: Set the binary encoding of the parent node of the data to be encoded; set the binary encoding formats of all child nodes of the data to be encoded as the combination of a prefix and the binary encoding of this level, where the prefix is the binary encoding of the parent node of the current child node; encode all child nodes according to the binary encoding format.
[0040] In step S10, set the data to be encoded according to the tree-shaped data storage structure set by the preset encoding template file. Then, sort out the data to be encoded in the tree-shaped data storage structure of node name, parent node name, and node level, and store it in the form of a file stream. The file types include Word, Excel, Text, XML, etc. Taking 4-level node data as an example, the preset encoding template table of Excel type is shown in Table 1:
[0041] Table 1 Preset Encoding Template Table
[0042] Node Name Parent Node Name Node Hierarchy Headquarters 1 Province 1 Headquarters 2 Province 2 Headquarters 2 City 1 Province 1 3 City 2 Province 1 3 Sub - district 1 City 2 4
[0043] As shown in Table 1, the first row of the table is the attribute name (data storage structure), and the second row and onwards are the attribute values of the nodes. One row of data is all the attribute values of a node. The parent node name of the node with node level 1 can be empty, and the node name, parent node name, and node level attribute values of the remaining nodes cannot be empty. The node names of each level need to be unique. Optionally, taking 4-level node data as an example, the data entry modules for Word, Text, and XML text files are as Figure 2 shown. The first row of the template text is the attribute name, and the names are separated by English commas; the second row and onwards are the attribute values of the nodes, and the values are separated by English commas (even when the value is empty, an English comma needs to be added for separation); one row of data is all the attribute values of a node. The parent node name of the node with node level 1 can be empty, and the node name, parent node name, and node level attribute values of the remaining nodes cannot be empty. The node names of each level need to be unique.
[0044] In step S20, set the binary encoding of the parent node. Generally, use the minimum encoding of the number of binary digits occupied by this node as its binary encoding. For example, when the number of binary digits occupied by the parent node is 2, generally use 00 as the binary encoding of the parent node; when the number of binary digits occupied by the parent node is 3, generally use 000 as the binary encoding of the parent node. Of course, this binary encoding can also be user-defined.
[0045] In step S20, the encoding of a child node is the binary encoding of its parent node plus the binary encoding of this node. For example, if the encoding of the current child node's parent node is 00 and the number of bits occupied by the binary encoding of the current child node is 2, then the binary encoding of the current child node can be 00, 01, etc. At this time, the encoding of the current child node is 0000 or 0001, etc. Further, when a certain level includes multiple nodes, the encoding step of each node can be fixed or unfixed. In the embodiment of the present invention, the encoding step is preferably 1. Optionally, when there are many nodes, multi-threaded encoding is performed. Specifically, if from the first node level to this node level, the number of nodes is greater than 1 for the first time, then start the corresponding number of threads according to the number of nodes at this level. Each thread is responsible for encoding all child nodes under one node at this level, so as to further improve the encoding efficiency, reduce the encoding time, and reduce the user waiting time.
[0046] In the embodiment of the present invention, each node uses binary encoding, which is convenient for fast encoding and improves the encoding efficiency. At the same time, the encoding format uses the parent node of each node as a prefix, which can determine the data relationship of each level of nodes. For example, if the prefix of the encoding of a node is the binary encoding of a certain node, then the two nodes are in a parent-child relationship; if the encoding prefixes of two nodes are the same, the two nodes are sibling relationships, and the data structure is clear and easy to obtain the hierarchical relationship of each node.
[0047] In the embodiment of the present invention, after the step of setting the number of binary bits occupied by each node level, the method of the present invention further includes:
[0048] Set up a matching table, which stores the number of binary bits occupied by each node level to centrally sort out the binary bit occupancy information of each node level. Through the number of binary bits occupied by each node level in the matching table, the binary encoding of the parent node of the data to be encoded can be set. By combining the number of binary bits occupied by each node level in the matching table with the binary encoding format, the encoding of all child nodes can be realized, thereby completing the encoding of the data to be encoded. The number of binary bits occupied by each node level in the matching table can be the same or different. When there are many nodes, the number of binary bits of the node level with the number of nodes less than the threshold (generally set manually, which can be 5, 6, etc.) can be defined as binary bit a, and the number of binary bits of the node level with the number of nodes greater than the threshold can be defined as binary bit b. Binary bit a is less than binary bit b, so as to dynamically adjust the node encoding length, effectively avoid the excessive length of the entire data encoding, reduce the storage space occupancy, make the encoding more flexible and easy to expand, and at the same time improve the subsequent data search efficiency to a certain extent.
[0049] Preferably, the matching table stores the number of binary digits occupied by each node level and the coding range of each node level. The coding range can be stored in ways such as binary coding, decimal coding, or hexadecimal coding. At this time, the matching table stores the mapping relationship among the node level, the number of binary digits occupied by the node level, and the coding range of the node level.
[0050] Combine the above-mentioned multiple embodiments of data coding to obtain a preferred embodiment of data coding. At this time, first set the template of the matching table according to the actual situation of the customer and the characteristics of the tree structure as shown in Table 2:
[0051] Table 2 Template Matching Table
[0052] Node Hierarchy (n) Occupied Binary Digits (m) Converted to int Range First Layer m(1) …… Second Layer m(2) …… Third Layer m(3) …… …… m(n) ……
[0053] As can be seen from Table 2 above, the number of binary digits occupied by each node level is set in the matching table, and the range of each layer can be deduced according to the number of binary digits occupied by each node level. On this basis, data coding includes the following sub-steps:
[0054] 1) Obtain the number of binary digits occupied by each level of nodes in the matching table; where n represents the level and m(n) represents the number of binary digits occupied by this level;
[0055] 2) The first layer (n = 1), that is, the parent node, starts coding from 1 in the embodiments of the present invention;
[0056] 3) The binary coding format of the second layer and subsequent layer nodes (layer nodes where n > 1) is: the parent node of the current node + the binary coding of this layer (preferably starting from 0);
[0057] 4) Convert the binary coding into decimal (or hexadecimal), and calculate the data range of the nodes of this level according to the matching table.
[0058] An example of this preferred data coding method is as follows:
[0059] The set matching table is shown in Table 3:
[0060] Table 3 Matching Table
[0061] Node Hierarchy (n) Occupied Binary Digits (m) Converted to int Range First Layer 2 1-3 Second Layer 3 8-31 Third Layer 4 128-511 Fourth Layer 3 1024-4096
[0062] Furthermore, the binary coding of the tree structure is as Figure 3 shown, where the nodes of the first layer occupy 2 bits and start from 1, that is, 01; the nodes of the second layer occupy 3 bits and start from 0, that is, 01 + 000, and the binary coding is 01000; the nodes of the third layer occupy 4 bits and start from 0, that is, 01000 + 0000, and the binary coding is 010000000.
[0063] Further, the data range of this layer is calculated according to the matching table as shown in Table 4:
[0064] Table 4 Simulated Encoding Data Table
[0065] Node Hierarchy Occupied Digits (Binary) Minimum Value of this Layer Maximum Value of this Layer Converted to int Range First Layer 2 01 11 1-3 Second Layer 3 01000 11111 8-31 Third Layer 4 010000000 111111111 128-511 Fourth Layer 3 010000000000 111111111111 1024-4096
[0066] Further, the encoded data is shown in Table 5:
[0067] Table 5 Data Table after Simulated Encoding
[0068] Node Name Parent Node Name Node Hierarchy Binary Encoding Converted to int Province 1 01 1 City 1 Province 2 01000 8 City 2 Province 2 01001 9 Street 1 City 2 3 010010000 144
[0069] In the embodiment of the present invention, the number of binary digits occupied by this node level can be obtained by querying the matching table, and then the parent node and its child node range of the current node can be quickly found by binary left and right offsets, greatly improving the data search efficiency.
[0070] In one embodiment, after the step of encoding all child nodes according to the binary encoding format, the data encoding method of the embodiment of the present invention further includes:
[0071] S30: Assemble the encoded data into a tree structure. The specific assembly process is as follows:
[0072] Obtain the node encoding of level 1 as the parent node encoding; obtain the node encoding of level 2 as the child node encoding of the parent node, and all nodes of level 2 are sibling nodes. By analogy, all the remaining nodes are encoded according to the parent node encoding to form a tree structure. After the assembly is completed, the structure parameters of the data nodes of the tree structure are obtained, including the node encoding and the node name. The interpretation of the structure parameters is shown in Table 6:
[0073] Table 6 Structure Parameter Table of Data Nodes in the Encoded Tree Structure
[0074] Parameter Name Interpretation Node Encoding Binary Encoding after Encoding of Data Node Node Name Node Name of Input Data
[0075] In one embodiment, after the step of assembling the encoded data into a tree structure, the method of the present invention further includes:
[0076] S401: Receive a data query request;
[0077] S402: Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary digits occupied by the node to be queried. Shift the binary encoding of the node to be queried to the right by the number of binary digits occupied by the node to be queried, and then find the parent node of the node to be queried; as Figure 3Taking the tree structure shown as an example, shift the code 010000000 of the node at the third level by the number of bits 4 occupied by this node, and the code of its parent node is obtained as 01000, so as to quickly find the parent node of the current node.
[0078] S403: Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of bits occupied by the node to be queried. Shift the binary code of the node to be queried to the left by the number of bits occupied by the node to be queried to determine the range of the child nodes of the node to be queried, and then find the child nodes of the node to be queried. Still taking Figure 3 the example shown as an example, shift the code 01000 of the node at the second level to the left by the number of bits 4 occupied by this node, and the range of the codes of its child nodes is obtained as 010000000 - 010001111, so as to quickly find that the child nodes of the current node include 010000000, 010000000, 010000001, 010000010.
[0079] Optionally, only one of steps S402 and S403 may be executed, which is specifically determined according to the content of the data query request. If the data query request only requests to query the parent node of the node to be queried, step S402 is executed at this time; if the data query request only requests to query the child nodes of the node to be queried, step S403 is executed at this time. Of course, if the data query request requests to query the parent node and the child nodes of the node to be queried, steps S402 and S403 can be executed in a swapped order or simultaneously.
[0080] Optionally, this data search embodiment may also be implemented after the step of encoding all child nodes according to the binary encoding format.
[0081] Combining the above embodiments, the preferred encoding method of the present invention is obtained. As Figure 4 shown, at this time the method includes a data entry step -> a data encoding step -> a data assembly step -> a data search step, and the specific implementation steps are as follows:
[0082] S100: Obtain the data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file. The preset encoding template file includes a node name, a parent node name, and a node level;
[0083] S200: Set a matching table, and store the number of bits occupied by each node level in the matching table;
[0084] Obtain the number of bits occupied by each level of nodes in the matching table;
[0085] Set the binary code of the parent node according to the number of bits occupied by the parent node;
[0086] Set the binary encoding format of all child nodes as a combination of the prefix and the binary encoding of this level. The prefix is the binary encoding of the parent node of the current child node. When encoding the nodes at this level, first determine the encoding bits according to the number of binary bits occupied by the node, then use the smallest encoding value corresponding to the encoding bits as the starting encoding, and continue encoding with a certain step to encode the data to be encoded in this way;
[0087] S300: Assemble the encoding result into a tree structure and return the structure parameters of the data node of the tree structure, including the node encoding and the node name;
[0088] S400: Receive a data query request;
[0089] Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary bits occupied by the node to be queried. Shift the binary encoding of the node to be queried to the right by the number of binary bits occupied by the node to be queried, and then find the parent node of the node to be queried; at the same time, determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary bits occupied by the node to be queried. Shift the binary encoding of the node to be queried to the left by the number of binary bits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and then find the child nodes of the node to be queried.
[0090] The present invention also includes a data encoding system, which has the same inventive concept as any one embodiment or a combination of multiple embodiments of the above encoding method. The system includes a data entry module and a data encoding module. Among them, the data entry module includes a preset encoding template file. The file types of the preset encoding template file include: Word, Excel, Text, XML, etc., which are used to obtain the data to be encoded and set the data storage structure of the data to be encoded. The preset encoding template file includes the node name, the parent node name, and the node level, and then stores the data to be encoded in a tree data storage structure of the node name, the parent node name, and the node level. Specifically, data entry is performed through a preset encoding template table of the Excel type, which has been disclosed above and will not be elaborated here.
[0091] The data encoding module is used to set the binary encoding of the parent node of the data to be encoded, and set the binary encoding format of all child nodes of the data to be encoded as a combination of the prefix and the binary encoding of this level. The prefix is the binary encoding of the parent node of the current child node, and then encode all child nodes according to the binary encoding format.
[0092] In one embodiment, a matching table is provided in the data encoding module. The matching table stores the number of binary digits occupied by each node level of the data stream, and the number of binary digits occupied by each level may be the same or different. Specifically, the data encoding module sets the binary encoding of the parent node of the data to be encoded according to the number of binary digits occupied by each node level in the matching table, and encodes all child nodes according to the number of binary digits occupied by each node level in the matching table in combination with the binary encoding format.
[0093] In one embodiment, the system further includes a data assembly module, which is used to assemble the encoding result into a tree structure and return the structure parameters of the data nodes of the tree structure, including node encoding and node name.
[0094] In one embodiment, the system further includes a data search module, which is used to receive a data query request, then determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the right by the number of binary digits occupied by the node to be queried, and then find the parent node of the node to be queried; and / or, determine the node level of the node to be queried in the data query request according to the matching table, then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the left by the number of binary digits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and then find the child nodes of the node to be queried.
[0095] Preferably, the system includes a data entry module, a data encoding module, a data assembly module and a data search module to form a complete data encoding and data query system.
[0096] The present invention further includes a storage medium, which has the same inventive concept as a data encoding method formed by combining any one of the above embodiments or multiple embodiments. Computer instructions are stored thereon, and when the computer instructions run, they execute the steps of a data encoding method formed by combining any one of the above embodiments or multiple embodiments.
[0097] Based on such an understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0098] This application also includes a terminal, which has the same inventive concept as any one or a combination of multiple embodiments corresponding to the above data encoding method. The terminal includes a memory and a processor. A computer instruction that can run on the processor is stored on the memory. When the processor runs the computer instruction, it executes the steps of the above data encoding method. The processor can be a single-core or multi-core central processing unit or a specific integrated circuit, or an integrated circuit configured to implement one or more of the present invention.
[0099] In one embodiment, the terminal, i.e., the electronic device, is presented in the form of a general computing device. The components of the electronic device may include, but are not limited to: the above at least one processing unit (processor), the above at least one storage unit, and a bus connecting different system components (including the storage unit and the processing unit).
[0100] Among them, the storage unit stores program code, and the program code can be executed by the processing unit, so that the processing unit executes the steps of the "exemplary method" part in the present specification according to various exemplary embodiments of the present invention. For example, the processing unit can execute the above data encoding method.
[0101] The storage unit may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 3201 and / or a cache storage unit, and may further include a read-only storage unit (ROM).
[0102] The storage unit may also include a program / utility tool having a set (at least one) of program modules. Such program modules include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. The implementation of a network environment may be included in each or some combination of these embodiments.
[0103] The bus may represent one or more of several types of bus structures, including a storage unit bus or a storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any bus structure in a variety of bus structures.
[0104] The electronic device can also communicate with one or more external devices (such as a keyboard, a pointing device, a Bluetooth device, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device, and / or communicate with any device that enables the electronic device to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface. Moreover, the electronic device can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter. The network adapter communicates with other modules of the electronic device through a bus. It should be understood that other hardware and / or software modules can be used in combination with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0105] Through the above description, those skilled in the art can easily understand that the embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions of the exemplary embodiments according to the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the methods of the exemplary embodiments of the present application.
[0106] The above specific embodiments are detailed descriptions of the present invention. It cannot be determined that the specific embodiments of the present invention are only limited to these descriptions. For those of ordinary skill in the technical field to which the present invention pertains, without departing from the concept of the present invention, several simple deductions and substitutions can still be made, which should all be regarded as belonging to the protection scope of the present invention.
Claims
1. A data encoding method, characterized in that: It includes the following steps: Obtain the data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file, where the preset encoding template file includes a node name, a parent node name, and a node level; Set the binary encoding of the parent node of the data to be encoded; Set the binary encoding format of all child nodes of the data to be encoded as a combination of a prefix and the binary encoding of this level, where the prefix is the binary encoding of the parent node of the current child node; Encode all the child nodes according to the binary encoding format.
2. The data encoding method according to claim 1, characterized in that: Before the step of setting the binary encoding of the parent node of the data to be encoded, the method further includes: Set a matching table, where the matching table stores the number of binary digits occupied by each node level, and the number of binary digits occupied by each node level is the same or different; Set the binary encoding of the parent node of the data to be encoded according to the number of binary digits occupied by each node level in the matching table, and encode all the child nodes according to the number of binary digits occupied by each node level in the matching table in combination with the binary encoding format.
3. The data encoding method according to claim 2, characterized in that: After the step of encoding all the child nodes, the method further includes: Receive a data query request; Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the right by the number of binary digits occupied by the node to be queried, and then find the parent node of the node to be queried; and / or, Determine the node level of the node to be queried in the data query request according to the matching table, and then query the number of binary digits occupied by the node to be queried, shift the binary encoding of the node to be queried to the left by the number of binary digits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and then find the child nodes of the node to be queried.
4. The data encoding method according to claim 1 or 2, characterized in that: The method further includes: Assemble the encoding result of the data to be encoded into a tree structure, and obtain the structure parameters of the data nodes of the tree structure, including node encoding and node name.
5. A data encoding system, characterized in that: It includes: A data entry module, which is used to obtain the data to be encoded, and set the data storage structure of the data to be encoded according to a preset encoding template file, where the preset encoding template file includes a node name, a parent node name, and a node level; A data encoding module, which is used to set the binary encoding of the parent node of the data to be encoded, set the binary encoding format of all child nodes of the data to be encoded as a combination of a prefix and the binary encoding of this level, where the prefix is the binary encoding of the parent node of the current child node, and then encode all the child nodes according to the binary encoding format.
6. The data encoding system according to claim 5, characterized in that: The system further includes a data assembly module, which is used to assemble the encoding result into a tree structure and return the structure parameters of the data nodes of the tree structure, including node encoding and node name.
7. The data encoding system according to claim 5, characterized in that: A matching table is set in the data encoding module, and the matching table stores the number of binary digits occupied by each node level of the data stream, and the number of binary digits occupied by each level is the same or different; The data encoding module is specifically configured to set the binary encoding of the parent node of the data to be encoded according to the number of bits occupied by each node level in the matching table, and encode all the child nodes according to the number of bits occupied by each node level in the matching table in combination with the binary encoding format.
8. The data encoding system according to claim 7, characterized in that: The system further includes a data search module, configured to receive a data query request, determine the node level of the node to be queried in the data query request according to the matching table, further query the number of bits occupied by the node to be queried, shift the binary encoding of the node to be queried to the right by the number of bits occupied by the node to be queried, and thus search for the parent node of the node to be queried; and / or, determine the node level of the node to be queried in the data query request according to the matching table, further query the number of bits occupied by the node to be queried, shift the binary encoding of the node to be queried to the left by the number of bits occupied by the node to be queried to determine the range of child nodes of the node to be queried, and thus search for the child nodes of the node to be queried.
9. A storage medium, on which computer instructions are stored, characterized in that: When the computer instructions run, they execute the steps of the data encoding method according to any one of claims 1-4.
10. An electronic device, including a memory and a processor, and computer instructions that can run on the processor are stored on the memory, characterized in that: When the processor runs the computer instructions, it executes the steps of the data encoding method according to any one of claims 1-4.