Data processing method of tree data structure and electronic device
By obtaining attribute information from a tree data structure and converting it into the target structure, the problem of excessive memory usage is solved, and effective utilization with limited memory is achieved while maintaining performance.
Patent Information
- Application Number
- CN202310988276.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2043-08-07
AI Technical Summary
In existing technologies, tree data structures cannot be effectively utilized due to excessive memory consumption, especially when dealing with massive access rules, where the high memory usage rate affects performance.
By acquiring network address rule data, an initial tree data structure is established, and then converted into a target tree data structure based on attribute information, reducing memory usage while maintaining performance.
It enables efficient use of tree data structures within a limited memory range, solving the performance problem caused by excessive memory usage.
Smart Images

Figure CN117033712B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a tree data structure data processing method and electronic equipment. BACKGROUND
[0002] Currently, the access between applications needs to be isolated in a trusted application project, including isolation of Internet Protocol (Internet Protocol, referred to as IP for short), port, domain name, etc. The rule quantity is as high as 200 million, and the massive rules make the memory consumption as high as 260 MB when using a conventional dictionary tree for matching. The code using the dictionary tree for matching runs in the data plane, and has strict requirements on memory.
[0003] For the technical problem of excessive memory consumption, which leads to the tree data structure being unable to be effectively utilized, an effective solution has not been proposed. SUMMARY
[0004] The embodiments of the present application provide a tree data structure data processing method and electronic equipment, to at least solve the technical problem that the tree data structure cannot be effectively utilized.
[0005] According to an aspect of an embodiment of the present application, a tree data structure data processing method is provided. The method can include: obtaining network address rule data to be processed by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is the network address rule data, and the network address rule data is used to indicate the generation rule of a network address to be accessed; establishing the network address rule data into an initial tree data structure based on the memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and the nodes in the initial tree data structure are used to indicate the network address rule data; obtaining attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; converting the initial tree data structure into a target tree data structure based on the attribute information, wherein the memory of the target tree data structure is smaller than that of the initial tree data structure; and outputting the target tree data structure by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the target tree data structure.
[0006] According to another aspect of the embodiments of the present application, a data processing method of a tree data structure is also provided. The method can include: obtaining network address rule data of an application, wherein the network address rule data is used to represent a generation rule of a network address to be accessed by the application; establishing the network address rule data as an initial tree data structure based on a memory of a network page corresponding to the network address, wherein the network address is used to enable the application to access the network page, and a node in the initial tree data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; converting the initial tree data structure into a target tree data structure based on the attribute information, wherein a memory of the target tree data structure is smaller than a memory of the initial tree data structure; and controlling the application to perform access based on the target tree data structure.
[0007] According to another aspect of the embodiments of the present application, a data processing method of a tree data structure is also provided. The method can include: obtaining network address rule data of an application, wherein the network address rule data is used to represent a generation rule of a network address to be accessed by the application; establishing the network address rule data as an initial tree data structure based on a memory of a network page corresponding to the network address, wherein the network address is used to enable the application to access the network page, and a node in the initial tree data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; converting the initial tree data structure into a target tree data structure based on the attribute information, wherein a memory of the target tree data structure is smaller than a memory of the initial tree data structure.
[0008] According to another aspect of the embodiments of the present application, a method for isolating inter-application access is also provided. The method can include: obtaining an access request, wherein the access request is used to represent a request of a first application to access a second application; in response to the access request, calling a target tree data structure with a memory smaller than an initial tree data structure, wherein the target tree data structure is obtained by converting the initial tree data structure based on attribute information of network address rule data corresponding to the first application, the attribute information is used to determine the network address rule data in the initial tree data structure, the initial tree data structure is established based on a memory of a network page corresponding to a network address on the second application, a node in the initial tree data structure is used to represent the network address rule data, the network address rule data is used to represent a generation rule of a network address of the second application, and the network address is used to enable the first application to access the network page of the second application; and controlling the first application to access the second application based on the target tree data structure.
[0009] According to a further aspect of the embodiments of the present application, a data processing apparatus of a tree data structure is also provided. The apparatus comprises: a first calling unit, configured to acquire network address rule data to be processed by calling a first interface, wherein the first interface comprises a first parameter, a parameter value of the first parameter is the network address rule data, and the network address rule data is used to indicate a generation rule of a network address to be accessed; a first establishing unit, configured to establish the network address rule data as an initial tree data structure based on a memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree data structure is used to indicate the network address rule data; a first acquiring unit, configured to acquire attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; a first converting unit, configured to convert the initial tree data structure into a target tree data structure based on the attribute information, wherein a memory of the target tree data structure is smaller than a memory of the initial tree data structure; and an output unit, configured to output the target tree data structure by calling a second interface, wherein the second interface comprises a second parameter, and a parameter value of the second parameter is the target tree data structure.
[0010] According to a further aspect of the embodiments of the present application, a data processing apparatus of a tree data structure is also provided. The apparatus comprises: a second acquiring unit, configured to acquire network address rule data of an application, wherein the network address rule data is used to indicate a generation rule of a network address to be accessed by the application; a second establishing unit, configured to establish the network address rule data as an initial tree data structure based on a memory of a network page corresponding to the network address, wherein the network address is used to enable the application to access the network page, and a node in the initial tree data structure is used to indicate the network address rule data; a third acquiring unit, configured to acquire attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; a second converting unit, configured to convert the initial tree data structure into a target tree data structure based on the attribute information, wherein a memory of the target tree data structure is smaller than a memory of the initial tree data structure; and a first control unit, configured to control the application to perform access based on the target tree data structure.
[0011] According to a further aspect of the embodiments of the present application, a data processing apparatus of a tree data structure is also provided. The apparatus comprises: a fourth obtaining unit, configured to obtain network address rule data to be processed, wherein the network address rule data is used to represent a generation rule of a network address to be accessed; a third establishing unit, configured to establish the network address rule data as an initial tree data structure based on a memory of a network page corresponding to the network address, wherein a node in the initial tree data structure is used to represent the network address rule data; a fifth obtaining unit, configured to obtain attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; and a second converting unit, configured to convert the initial tree data structure into a target tree data structure based on the attribute information, wherein a memory of the target tree data structure is smaller than that of the initial tree data structure.
[0012] According to a further aspect of the embodiments of the present application, an apparatus for isolating application access is also provided. The apparatus comprises: a sixth obtaining unit, configured to obtain an access request, wherein the access request is used to represent that a first application requests to access a second application; a second calling unit, configured to call a target tree data structure with a smaller memory than an initial tree data structure in response to the access request, wherein the target tree data structure is obtained by converting the initial tree data structure based on attribute information of network address rule data corresponding to the first application, the attribute information is used to determine the network address rule data in the initial tree data structure, and the initial tree data structure is obtained in the initial tree data structure, the initial tree data structure is obtained by establishing the network address rule data based on a memory of a network page corresponding to a network address on the second application, a node in the initial tree data structure is used to represent the network address rule data, the network address rule data is used to represent a generation rule of the network address of the second application, and the network address is used for the first application to access the network page of the second application; and a second control unit, configured to control the first application to access the second application based on the target tree data structure.
[0013] According to a further aspect of the embodiments of the present application, a computer readable storage medium is also provided, which comprises a stored program, wherein the program processor is used to control a computer storage medium device to execute the steps of the data processing method of the tree data structure.
[0014] According to a further aspect of the embodiments of the present application, an electronic device is also provided, which comprises a memory and a processor, the memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions, and the computer executable instructions are used to execute the steps of the data processing method of the tree data structure.
[0015] In the embodiment of the present application, the network address rule data to be processed is obtained by calling the first interface; the network address rule data is established as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address; in the initial tree-shaped data structure, the attribute information of the network address rule data is obtained; the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information; and the target tree-shaped data structure is output by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the target tree-shaped data structure. That is, in the embodiment of the present application, by obtaining the network address rule data to be processed, establishing the network address rule data as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address rule data, and converting the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information of the network address rule, the memory can be controlled within a limited range, the performance of the tree-shaped data structure is basically unchanged, the purpose of effectively utilizing the tree-shaped data structure is achieved, and the technical problem that the tree-shaped data structure cannot be effectively utilized due to the excessively high memory occupancy rate is solved.
[0016] It is easy to note that the general description above and the detailed description below are merely for exemplifying and explaining the present application, and do not constitute a limitation on the present application. BRIEF DESCRIPTION OF DRAWINGS
[0017] The drawings described herein are used to provide further understanding of the present application, constitute a part of the present application, and the illustrative embodiments of the present application and the description thereof are used to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a schematic diagram of an application scenario of a tree-shaped data structure data processing method according to an embodiment of the present application;
[0019] Figure 2 is a structural block diagram of a computing environment of a tree-shaped data structure data processing method according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a service mesh of a tree-shaped data structure data processing method according to an embodiment of the present application;
[0021] Figure 4 is a flowchart of a tree-shaped data structure data processing method according to an embodiment of the present application;
[0022] Figure 5 is a flowchart of another tree-shaped data structure data processing method according to an embodiment of the present application;
[0023] Figure 6 is a flowchart of another tree-shaped data structure data processing method according to an embodiment of the present application;
[0024] Figure 7 is a flowchart of a method for isolating inter-application access according to an embodiment of the present application;
[0025] Figure 8 is a flowchart of a data processing method of another tree data structure according to an embodiment of the present application;
[0026] Figure 9 is a schematic diagram of a memory pointer according to an embodiment of the present application;
[0027] Figure 10 is a schematic diagram of a non-leaf node and a leaf node according to an embodiment of the present application;
[0028] Figure 11 is a schematic diagram of a non-leaf node and a leaf node according to an embodiment of the present application;
[0029] Figure 12 is a schematic diagram of a compressed trie according to an embodiment of the present application;
[0030] Figure 13 is a schematic diagram of a data processing apparatus of a tree data structure according to an embodiment of the present application;
[0031] Figure 14 is a schematic diagram of a data processing apparatus of another tree data structure according to an embodiment of the present application;
[0032] Figure 15 is a schematic diagram of a data processing apparatus of another tree data structure according to an embodiment of the present application;
[0033] Figure 16 is a schematic diagram of an apparatus for isolating inter-application access according to an embodiment of the present application;
[0034] Figure 17 is a structural block diagram of a computer terminal according to an embodiment of the present application;
[0035] Figure 18 is a schematic diagram of a computer terminal of a data processing method of another tree data structure according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the person skilled in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.
[0037] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0038] First, some nouns or terms that appear in the description of the embodiments of the present application are applicable to the following explanations:
[0039] Trie, also known as word search tree, is a property structure, which is a variant of hash tree;
[0040] Segmented paging addressing divides the actual address into segment and page parts for representation, for example, actual address = segment data * page size + page offset;
[0041] Data plane, also known as user plane forwarding plane, is used to carry data traffic;
[0042] Embodiment 1
[0043] According to the embodiments of the present application, a tree data structure data processing method is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from here.
[0044] According to an aspect of the embodiments of the present application, a tree data structure data processing method is provided. As an optional implementation, the tree data structure data processing method can be applied to the application scenario as shown in Figure 1 Figure 1 This is a schematic diagram illustrating an application scenario of a data processing method using a tree-structured data structure according to an embodiment of this application, such as... Figure 1 As shown, in the application scenario, terminal device 102 can communicate with server 106 via network 104, but is not limited to this. Server 106 can perform operations on database 108, such as write or read data operations. Terminal device 102 may include, but is not limited to, a human-computer interaction screen, a processor, and a memory. The human-computer interaction screen may be used to display network address rule data to be processed on terminal device 102. The processor may be used to respond to the human-computer interaction operation, execute corresponding operations, or generate corresponding instructions and send the generated instructions to server 106. The memory is used to store relevant processing data, such as network address rule data to be processed and attribute information of the network address rule data.
[0045] As an optional approach, the following steps in the tree data structure data processing method can be executed on server 106: Step S101, obtain network address rule data to be processed, wherein the network address rule data is used to represent the generation rules of the network address to be accessed; Step S102, based on the memory of the network page corresponding to the network address, establish an initial tree data structure for the network address rule data, wherein the network address is used to access the network page, and the nodes in the initial tree data structure are used to represent the network address rule data; Step S103, obtain attribute information of the network address rule data in the initial tree data structure, wherein the attribute information is used to determine the network address rule data in the initial tree data structure; Step S104, based on the attribute information, convert the initial tree data structure into a target tree data structure, wherein the memory of the target tree data structure is smaller than the memory of the initial tree data structure.
[0046] By using the above method, network address rule data to be processed can be obtained, and the network address rule data can be used to build an initial tree data structure through the memory of the network page corresponding to the network address. Then, based on the attribute information of the network address rule, the initial tree data structure can be converted into a target tree data structure. This achieves the goal of keeping memory within a limited range while maintaining the performance of the tree data structure. This effectively utilizes the tree data structure and solves the technical problem of the tree data structure being unable to be effectively utilized due to excessive memory usage.
[0047] Figure 2 This is a structural block diagram of a computing environment for a data processing method using a tree-structured data structure according to an embodiment of this application, such as... Figure 2As shown, the computing environment 201 includes a plurality of computing nodes (e.g., servers) running on a distributed network, shown as 210-1, 210-2,..., 210-N. The computing nodes each include local processing and memory resources, and end users 202 can remotely run applications or store data in the computing environment 201. Applications can be provided as a plurality of services 220-1, 220-2, 220-3, and 220-4 in the computing environment 201, representing services “A”, “D”, “E”, and “H”, respectively.
[0048] End users 202 can provide and access services through a web browser or other software application on a client, and in some embodiments, the provisioning and / or requests of end users 202 can be provided to an ingress gateway 230. The ingress gateway 230 can include a corresponding proxy to handle provisioning and / or requests for services (one or more services provided in the computing environment 201).
[0049] Services are provided or deployed according to various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided according to virtual machine (VM)-based virtualization, container-based virtualization, and / or the like. VM-based virtualization can emulate a real computer by initializing a virtual machine to execute programs and applications without directly accessing any actual hardware resources. While a virtual machine virtualizes a machine, according to container-based virtualization, a container can be launched to virtualize an entire operating system (OS) so that multiple workloads can run on a single OS instance.
[0050] In one embodiment of container-based virtualization, several containers of a service can be assembled into a Pod (e.g., a Kubernetes Pod). For example, as shown in Figure 2 As shown, the service 220-2 can be equipped with one or more Pods 240-1, 240-2,..., 240-N (collectively, Pods). A Pod can include a proxy 245 and one or more containers 242-1, 242-2,..., 242-M (collectively, containers). The one or more containers in a Pod handle requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, and the like. Other services can also be equipped with Pods similar to the Pods.
[0051] In operation, executing a user request from an end user 202 can require invoking one or more services in the computing environment 201, and executing one or more functions of a service can require invoking one or more functions of another service. As shown in Figure 2As shown, service "A" 220-1 receives a user request from end user 202 from ingress gateway 230, service "A" 220-1 can invoke service "D" 220-2, which can request service "E" 220-3 to perform one or more functions.
[0052] The computing environment described above can be a cloud computing environment, where the allocation of resources is managed by a cloud service provider, allowing the development of functionality without the need to consider implementing, tuning or scaling servers. The computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be split into a set of functions that can automatically scale independently, rather than scaling a single hardware device to handle potential loads.
[0053] In another alternative embodiment, Figure 3 is a schematic diagram of a service mesh of a data processing method of a tree data structure according to an embodiment of the present application, as Figure 3 As shown, the service mesh 300 is mainly used to facilitate secure and reliable communication between a plurality of microservices, where a microservice refers to decomposing an application into a plurality of smaller services or instances and distributing them to run on different clusters / machines.
[0054] As shown in Figure 3 The microservices can include application service instance A and application service instance B, which form a functional application layer of the service mesh 300. In an embodiment, the application service instance A is running in the form of container / process 308 on machine / pod 314, and the application service instance B is running in the form of container / process 310 on machine / pod 316.
[0055] In an embodiment, the application service instance A can be configured to obtain network address rule data to be processed, and the application service instance B can be configured to establish the network address rule data into an initial tree data structure based on a network page memory corresponding to the network address.
[0056] As shown in Figure 3As shown, application service instance A and grid proxy (sidecar) 303 coexist in machine workload container group 314, and application service instance B and grid proxy 305 coexist in machine workload container 314. Grid proxy 303 and grid proxy 305 form the data plane layer of service mesh 300. Grid proxy 303 and grid proxy 305 run as container / process 304 and container / process 306 respectively, and can receive requests 312 for product query services. Grid proxy 303 and application service instance A can communicate bidirectionally, and grid proxy 305 and application service instance B can also communicate bidirectionally. Furthermore, grid proxy 303 and grid proxy 305 can also communicate bidirectionally with each other.
[0057] In one implementation, traffic from application service instance A is routed to the appropriate destination via mesh proxy 303, and network traffic from application service instance B is routed to the appropriate destination via mesh proxy 305. It should be noted that the network traffic mentioned here includes, but is not limited to, Hypertext Transfer Protocol (HTTP), Representational State Transfer (REST), high-performance, general-purpose open-source frameworks (Google Remote Procedure Call, gRPC), and open-source in-memory data structure storage systems (Redis).
[0058] In one implementation, the functionality of the extended data plane layer can be achieved by writing custom filters for the proxy (Envoy) in service mesh 300. The service mesh proxy configuration can enable the service mesh to correctly proxy service traffic, achieving service interoperability and service governance. Mesh proxies 303 and 305 can be configured to perform at least one of the following functions: service discovery, health checking, routing, load balancing, authentication and authorization, and observability.
[0059] like Figure 3 As shown, the service mesh 300 also includes a control plane layer. This control plane layer can consist of a set of services running in a dedicated namespace, hosted by a managed control plane component 301 within machine / workload container groups (machine / Pods) 302.Figure 3 As shown, the managed control plane component 301 communicates bidirectionally with grid agents 303 and 305. The managed control plane component 301 is configured to perform various control and management functions. For example, it receives telemetry data from grid agents 303 and 305 and can further aggregate this telemetry data. In addition to these services, the managed control plane component 301 can also provide a user-facing Application Programming Interface (API) to facilitate manipulation of network behavior and the provision of configuration data to grid agents 303 and 305.
[0060] According to an embodiment of this application, a data processing method for a tree-structured data structure is provided from the software-as-a-Service (SaaS) side. Figure 4 This is a flowchart of a data processing method for a tree-structured data structure according to an embodiment of this application, such as... Figure 4 As shown, the method may include the following steps:
[0061] Step S401: Obtain the network address rule data to be processed by calling the first interface.
[0062] In the technical solution provided in step S401 of this application, the first interface can be an interface for data interaction between the server and the computer device. The computer device can pass the network address rule data to be processed into the first interface, and the server can obtain the network address rule data to be processed by calling the first interface. The first interface includes a first parameter, the value of which is the network address rule data, which represents the generation rule of the network address to be accessed.
[0063] Step S402: Based on the memory of the network page corresponding to the network address, establish the network address rule data into an initial tree data structure.
[0064] In the technical solution provided by step S402 of this application, since the network address rule data is used to represent the generation rules of the network address to be accessed, based on this, after obtaining the network address rule data to be processed, the network address rule data can be established as an initial tree data structure based on the memory of the network page corresponding to the network address. In this structure, the network address is used to access the network page, and the nodes in the initial tree data structure are used to represent the network address rule data.
[0065] In this embodiment, the initial tree-shaped data structure can be a dictionary tree, based on which, after the network address rule data is acquired, the memory of the network page can be applied based on the network address rule data, for example, the memory of the network page can be 128MB, and then the network address rule data is established as a dictionary tree according to the network address rule data.
[0066] In step S403, attribute information of the network address rule data is acquired in the initial tree-shaped data structure.
[0067] In the technical solution provided in step S403 of the present application, after the initial tree-shaped data structure is established, the attribute information of the network address rule data can be acquired in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure.
[0068] In this embodiment, since the initial tree-shaped data structure is established based on the network address rule data, based on this, the attribute information of the network address rule data is included in the initial tree-shaped data structure, and the attribute information of the network address rule data can be acquired in the initial tree-shaped data structure.
[0069] In step S404, the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information.
[0070] In the technical solution provided in step S404 of the present application, after the attribute information of the network address rule data is acquired, the initial tree-shaped data structure can be converted into a target tree-shaped data structure based on the attribute information, wherein the memory of the target tree-shaped data structure is smaller than the memory of the initial tree-shaped data structure, so as to achieve the purpose of compressing the initial tree-shaped data structure.
[0071] In this embodiment, the tree-shaped information can be a storage pointer of the network address rule data, or a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, wherein the storage pointer is used to store the network address rule data in the initial tree-shaped data structure, and the node type can be a leaf node or a non-leaf node. When the attribute information is the storage pointer of the network address rule data, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure can be adjusted to the target memory, so as to obtain the target tree-shaped data structure. When the attribute information is the node type of the node corresponding to the network address rule data in the initial tree-shaped data structure, the initial tree-shaped data structure can be converted into the target tree-shaped data structure based on the node type, so as to achieve the purpose of reducing the memory occupation.
[0072] In step S405, the target tree-shaped data structure is output by calling the second interface.
[0073] In the technical solution provided in the foregoing step S405 of the present application, the second interface can be an interface for data interaction between the server and the computer device, and the server can transmit the target tree-shaped data structure into the second interface, where the second interface includes a second parameter, and a parameter value of the second parameter is the target tree-shaped data structure.
[0074] In this embodiment, since the second interface is an interface for data interaction between the server and the computer device, the server can transmit the target tree-shaped data structure into the second interface, and then the computer device can output the target tree-shaped data structure by calling the second interface.
[0075] Based on the solutions disclosed in the foregoing steps S401 to S405 of the embodiment, the network address rule data to be processed is established as an initial tree-shaped data structure through the memory of the network page corresponding to the network address, and in the initial tree-shaped data structure, attribute information of the network address data is acquired, and based on the attribute information, the initial tree-shaped data structure is converted into a target tree-shaped data structure, where the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure, so as to control the memory within a limited range while the performance of the tree-shaped data structure is basically unchanged, thereby achieving the purpose of effectively utilizing the tree-shaped data structure, and further solving the technical problem that the tree-shaped data structure cannot be effectively utilized due to excessively high memory occupancy.
[0076] In the foregoing operating environment, the present application further provides a data processing method of a tree-shaped data structure as shown in Figure 5 It should be noted that the data processing method of the tree-shaped data structure of this embodiment can be executed by the mobile terminal of the embodiment as shown in Figure 1 . Figure 5 is a flowchart of another data processing method of a tree-shaped data structure according to an embodiment of the present application. As shown in Figure 5 , the method can include the following steps.
[0077] Step S501: acquiring network address rule data corresponding to an application.
[0078] In the technical solution provided in the foregoing step S501 of the present application, the network address rule data is used to represent a generation rule of a network address to be accessed by the application, based on which, the network address rule data corresponding to the application can be acquired, and then a corresponding network address rule can be generated based on the network address rule data corresponding to the application, so that the application can access a network page based on the network address rule.
[0079] In this embodiment, the application to be accessed needs to be isolated in the application trusted project, where the isolation includes IP rules, port rules, domain name rules, etc., and the rule quantity is as high as 200 million or more, based on which, the network address rule data of the IP rules, the port rules, the domain name rules, etc. of the application to be accessed can be acquired.
[0080] In step S502, the network address rule data is established as an initial tree data structure based on the memory of the network page corresponding to the network address rule.
[0081] In the technical solution provided in step S502, the network address rule data is used to represent the generation rule of the network address to be accessed. Therefore, after obtaining the network address rule data corresponding to the application, the network address rule data can be established as an initial tree data structure based on the memory of the network page corresponding to the network address. The network address is used to enable the application to access the network page, and the nodes in the initial tree data structure are used to represent the network address rule data.
[0082] In this embodiment, the initial tree data structure can be a dictionary tree. Therefore, after obtaining the network address rule data corresponding to the application, the memory of the network page corresponding to the network address rule data can be obtained, for example, the memory of the network page can be 128 MB, and then the network address rule data is established as a dictionary tree.
[0083] In step S503, the attribute information of the network address rule data is obtained in the initial tree data structure.
[0084] In the technical solution provided in step S503, after the initial tree data structure is established, the attribute information of the network address rule data can be obtained in the initial tree data structure. The attribute information is used to determine the network address rule data in the initial tree data structure.
[0085] In this embodiment, since the initial tree data structure is established based on the network address rule data, the attribute information of the network address rule data can be obtained in the initial tree data structure.
[0086] In step S504, the initial tree data structure is converted into a target tree data structure based on the attribute information.
[0087] In the technical solution provided in step S504, after the attribute information of the network address rule data is obtained, the initial tree data structure can be converted into a target tree data structure based on the attribute information. The memory of the target tree data structure is smaller than that of the initial tree data structure, so as to compress the initial tree data structure.
[0088] In this embodiment, the attribute information can be a storage pointer of the network address rule data or a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, where the storage pointer is used to store the network address rule data in the initial tree-shaped data structure, and the node type can be a leaf node type or a non-leaf node type. When the attribute information is the storage pointer of the network address rule data, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure can be adjusted to the target memory to obtain the target tree-shaped data structure. When the attribute information is the node type of the node corresponding to the network address rule data in the initial tree-shaped data structure, the initial tree-shaped data structure can be converted into the target tree-shaped data structure based on the node type, so as to achieve the purpose of reducing the memory occupation.
[0089] In step S505, the control application accesses based on the target tree-shaped data structure.
[0090] In the technical solution provided in the above step S505, after the target tree-shaped data structure is obtained, the control application can access the network page based on the target tree-shaped data structure.
[0091] In this embodiment, when the control application accesses based on the target tree-shaped data structure, it can be determined whether the to-be-queried network address matches the target tree-shaped data structure. If the to-be-queried network address matches the target tree-shaped data structure, the to-be-queried network address can be converted into a network address, and the network page can be accessed according to the network address.
[0092] Based on the above steps S501 to S505, the network address rule data corresponding to the application is obtained, and the network address rule data is established as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address. The attribute information of the network address data is obtained in the initial tree-shaped data structure, the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information, the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure, the memory is controlled within a limited range, the performance of the tree-shaped data structure is basically unchanged, the technical effect of effectively utilizing the tree-shaped data structure is achieved, and the technical problem that the tree-shaped data structure cannot be effectively utilized due to the high memory occupation rate is solved.
[0093] As an optional implementation, in step S505, the control application accesses based on the target tree-shaped data structure, including: in response to the to-be-queried network address matching the target tree-shaped data structure, converting the to-be-queried network address into a network address, and accessing the network page according to the network address.
[0094] In this embodiment, the network address to be queried can be an IP rule to be inserted, and the target tree-shaped data structure can be a dictionary tree. Based on this, it can be determined whether the network address to be queried matches the target tree-shaped data structure. If the network address to be queried matches the target tree-shaped data structure, the network address to be queried can be converted into a network address, and a network page can be accessed according to the network address, where the network address can be a rule index.
[0095] In the above operating environment, the application further provides a data processing method of a tree-shaped data structure as shown in the following. Figure 6 Figure 6 is a flowchart of another data processing method of a tree-shaped data structure according to an embodiment of the application. As shown in the following, Figure 6
[0096] Step S601: Obtain network address rule data to be processed.
[0097] In the technical solution provided in the above step S601 of the application, the network address rule data to be processed can be obtained, where the network address rule data to be processed is used to represent a generation rule of a network address to be accessed, for example, an IP rule.
[0098] In this embodiment, it is necessary to isolate the access between applications in the application trusted project, where the isolation includes IP rules, port rules, domain name rules, etc., and the number of rules is as high as 200 million. Based on this, the network address rule data to be processed, such as IP rules, port rules, and domain name rules, can be obtained.
[0099] For example, the network address rule data to be processed can be obtained by sending a data instruction, for example, a data instruction can be sent to the application trusted project, where the data instruction is used to obtain the network address rule data to be processed in the application trusted project.
[0100] Step S602: Establish the network address rule data as an initial tree-shaped data structure based on the memory of a network page corresponding to the network address.
[0101] In the technical solution provided in the above step S602 of the application, since the network address rule data is used to represent a generation rule of a network address to be accessed, based on this, after obtaining the network address rule data to be processed, the network address rule data can be established as an initial tree-shaped data structure based on the memory of a network page corresponding to the network address, where the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data.
[0102] In this embodiment, the initial tree-shaped data structure can be a dictionary tree. Based on this, after the network address rule data is obtained, the memory of the network page can be applied based on the network address rule data. For example, the memory of the network page can be 128 MB. Then, the dictionary tree is established according to the network address rule data.
[0103] For example, taking the network address rule as an IP rule, assuming that the IP rule is 1.1.1.1 / 32|1-65535|2|1|123, in the IP rule, from left to right, "1.1.1.1" is used to indicate an IP address, "32" is used to indicate a mask, "1-65535" is used to indicate a port, "2" is used to indicate a priority of the rule, "1" is used to indicate that the rule executes action 1 after a rule hit (both the IP and the port hit), and "123" is used to indicate a rule id. Based on this, when the initial tree-shaped data structure is established by using the IP rule data, the address pointer corresponding to the IP rule data structure can be first converted into a 28-bit index rule_index, wherein 13 bits in the 28-bit index are segments, and 15 bits are in-page offsets. When accessed, 4 bytes are aligned, and the addressable range of the rule can be 1 GB. Then, the ports in the IP rule data structure can be sorted to facilitate subsequent matching of the ports according to the binary method. Then, the IP address 1.1.1.1 can be converted into a 4-byte host sequence (32 bits), and then the initial tree-shaped data structure is established from the highest bit. When the highest bit is 0, the left node is used for searching. When the highest bit is 1, the right node is used for searching. If no node is found, it means that the node does not exist. In this case, a memory block can be applied. The dictionary tree is constructed by sequentially circulating from the 31st bit to the 0th bit according to the above method, and the maximum circulation is 32 times. After the circulation of the dictionary tree node is completed, the last node can be marked as a leaf node, and the rule index rule_index can be stored in the leaf node.
[0104] In step S603, attribute information of the network address rule data is obtained in the initial tree-shaped data structure.
[0105] In the technical solution provided in step S603 of the present application, after the initial tree-shaped data structure is established, the attribute information of the network address rule data can be obtained in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure.
[0106] In this embodiment, since the initial tree-shaped data structure is established based on the network address rule data, based on this, the attribute information of the network address rule data is included in the initial tree-shaped data structure, and the attribute information of the network address rule data can be obtained in the initial tree-shaped data structure.
[0107] Step S604, converting the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information.
[0108] In the technical solution provided in the above step S604, after obtaining the attribute information of the network address rule data, the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information, where the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure, so as to compress the initial tree-shaped data structure.
[0109] In this embodiment, the attribute information can be a storage pointer of the network address rule data or a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, where the storage pointer is used to store the network address rule data in the initial tree-shaped data structure, and the node type can be a leaf node type or a non-leaf node type. When the attribute information is the storage pointer of the network address rule data, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure can be adjusted to a target memory to obtain the target tree-shaped data structure. When the attribute information is the node type of the node corresponding to the network address rule data in the initial tree-shaped data structure, the initial tree-shaped data structure can be converted into a target tree-shaped data structure based on the node type, so as to reduce the memory occupation.
[0110] Based on the above steps S601 to S604, the network address rule data to be processed is established as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address, the attribute information of the network address data is obtained in the initial tree-shaped data structure, and the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information, where the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure, so as to control the memory within a limited range while the performance of the tree-shaped data structure remains basically unchanged, thereby achieving the technical effect of effectively utilizing the tree-shaped data structure and solving the technical problem that the tree-shaped data structure cannot be effectively utilized due to the high memory occupation rate.
[0111] The above method of this embodiment will be further introduced below.
[0112] As an optional implementation, step S602 includes: in response to the memory of the network page being less than or equal to a memory threshold of the initial tree-shaped data structure, establishing the network address rule data as the initial tree-shaped data structure based on the memory of the network page.
[0113] In this embodiment, the memory threshold of the initial tree-shaped data structure can be the maximum memory used by the initial tree-shaped data structure, and the memory of the network page can be the size of the network page. When the memory of the network page is less than or equal to the memory threshold of the initial tree-shaped data structure, the network address rule data can be established into the initial tree-shaped data structure based on the memory of the network page, where the network address rule data can be IP rules, that is, the initial tree-shaped data structure can be established according to the IP rules.
[0114] For example, the initial tree-shaped data structure can be a dictionary tree. Assuming that the maximum memory used by the dictionary tree is 128 MB, a memory of 128 MB can be applied, and the network address rule data can be established into the initial tree-shaped data structure based on the applied memory of the network page.
[0115] As an optional implementation, when the memory of the network page is less than or equal to the memory threshold of the initial tree-shaped data structure, the network address rule data can be established into the initial tree-shaped data structure based on the memory of the network page, including: when the memory of the network page is less than or equal to the memory threshold, the network address rule data can be established into the initial tree-shaped data structure with the same memory as the memory of the network page.
[0116] In this embodiment, when the memory of the network page is less than or equal to the memory threshold, the network address rule data can be established into the initial tree-shaped data structure with the same memory as the memory of the network page.
[0117] For example, in order to ensure that the memory used by the constructed initial tree-shaped data structure is the same as the memory of the network page, the network address rule data can be established into the initial tree-shaped data structure with the same memory as the memory of the network page.
[0118] As an optional implementation, in step S604, the initial tree-shaped data structure is converted into the target tree-shaped data structure based on the attribute information, including: in response to the attribute information being a storage pointer of the network address rule data, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure is adjusted to the target memory to obtain the target tree-shaped data structure, where the storage pointer is used to store the network address rule data in the initial tree-shaped data structure.
[0119] In this embodiment, the attribute information of the network address rule data can be a storage pointer of the network address rule data, a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, or a rule chain table index corresponding to the network address rule data. Based on this, when the attribute information of the network address rule data is the storage pointer of the network address rule data, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure can be adjusted to the target memory to obtain the target tree-shaped data structure. The storage pointer can be a memory pointer, and the corresponding memory can be accessed according to the storage pointer.
[0120] For example, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure is greater than the target memory. For example, the initial memory corresponding to the storage pointer in the initial tree-shaped data structure can be an 8-byte pointer, which can be compressed to 3 bytes. For example, assuming that the maximum memory used by the initial tree-shaped data structure is 128 MB, a 128 MB page memory can be applied. The storage pointer can be 0x1234567800000000, and any 8-byte aligned memory access in the 128 MB memory can be represented as 0x1234567800000000+3-byte offset*8. The 3-byte offset refers to an index, and the 8-byte pointer can be replaced by the 3-byte offset to compress the memory, so as to adjust the initial memory corresponding to the storage pointer in the initial tree-shaped data structure to the target memory.
[0121] As an optional implementation, the method further includes: determining, in the memory of the network page, a memory pointer corresponding to the memory aligned according to the initial memory; and determining the target memory based on an offset of the memory pointer relative to the storage pointer.
[0122] In this embodiment, when the initial memory corresponding to the storage pointer in the initial tree-shaped data structure is adjusted to the target memory, a memory pointer corresponding to the memory aligned according to the initial memory can be determined in the memory of the network page, and the target memory can be determined based on an offset of the memory pointer relative to the storage pointer.
[0123] For example, assuming that the maximum memory used by the initial tree data structure is 128 MB, a network page memory of 128 MB can be applied. Assuming that the initial memory corresponding to the storage pointer in the initial tree data structure is 8 bytes, the 8-byte storage pointer can be 0x1234567800000000. Any 8-byte aligned memory pointer in the 128 MB memory can be represented as 0x1234567800000000+3 byte offset*8, where 3 bytes represent the offset of the memory pointer relative to the storage pointer. That is, the target memory can be 3 bytes, which achieves the purpose of adjusting the initial memory corresponding to the storage pointer in the initial tree data structure to the target memory.
[0124] As an optional implementation, the target memory is determined based on the offset of the memory pointer relative to the storage pointer, including: determining the memory corresponding to the offset of the memory pointer relative to the storage pointer as the target memory, where the target memory is segment page addressing, at least one first type of data bit in the segment page addressing is used to represent a segment, and at least one second type of data bit in the segment page addressing is used to represent a page.
[0125] In this embodiment, the memory corresponding to the offset of the memory pointer relative to the storage pointer can be determined as the target memory. For example, the memory pointer has an offset of 3 bytes relative to the storage pointer, and the storage space of the target memory can be determined as 3 bytes.
[0126] For example, the memory pointer of the target memory can be represented in segment page addressing mode. For example, the memory pointer of the target memory is 0x0000000012345678. The memory pointer can be divided into two parts, the first part is called segment=0x0000000012340000, and the second part is called page=0x5678, i.e., segment+page=0x0000000012345678.
[0127] As an optional implementation, in step S604, the initial tree data structure is converted into a target tree data structure based on the attribute information, including: in response to the node type of the node corresponding to the attribute information in the initial tree data structure being network address rule data, the initial tree data structure is converted into a target tree data structure based on the node type.
[0128] In this embodiment, as introduced above, the attribute information of the network address rule data can be a storage pointer of the network address rule data, a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, or a rule chain table index corresponding to the network address rule data. Based on this, when the attribute information is the node type of the node corresponding to the network address rule data in the initial tree-shaped data structure, the initial tree-shaped data structure can be converted into the target tree-shaped data structure based on the node type. The node type of the node includes a leaf node type and a non-leaf node type.
[0129] For example, when the node type of the node is the leaf node, the leaf node includes a rule ID and a rule chain table. The rule ID can be 28 bits, which can be expressed by segment page addressing, where 13 bits are segments and 15 bits are pages. The rule chain table is also a 28-bit index, which can be converted into an address pointer expressed by segment page addressing. The rule chain table pointer can store two data: a rule identity (Identity Document, referred to as ID) index and a chain table pointer index, which can be used to convert the initial tree-shaped data structure into the target tree-shaped data structure by segment page addressing.
[0130] For example, when the node type of the node is the non-leaf node, the non-leaf node includes a left node and a right node. The left node and the right node of the non-leaf node are each 4 bytes, of which 3 bytes are indexes, and the remaining 8 high bits can be used to store other data. The initial tree-shaped data structure can be converted into the target tree-shaped data structure by segment page addressing.
[0131] As an optional implementation, converting the initial tree-shaped data structure into the target tree-shaped data structure based on the node type includes separating leaf nodes of the leaf node type and non-leaf nodes of the non-leaf node type from the initial tree-shaped data structure to obtain the target tree-shaped data structure. The node type includes the leaf node type and the non-leaf node type. The leaf node is used to store network address rule data, and the non-leaf node does not store network address rule data.
[0132] In this embodiment, when the initial tree-shaped data structure is converted into the target tree-shaped data structure based on the node type, the leaf nodes of the leaf node type and the non-leaf nodes of the non-leaf node type can be separated from the initial tree-shaped data structure. After the leaf nodes and the non-leaf nodes are separated, only the leaf nodes need to carry rule nodes, which can save 3 bytes. The tree-shaped data structure after the leaf nodes and the non-leaf nodes are separated can be the target tree-shaped data structure. The leaf node is used to store network address rule data, such as a rule ID and a rule chain table. The non-leaf node includes a left node and a right node and does not carry a rule node.
[0133] For example, in the case that the leaf node is not separated from the non-leaf node, each node carries a rule node by default, and the rule node needs to occupy at least 3 bytes. After the leaf node is separated from the non-leaf node, only the leaf node needs to carry the rule node, and the leaf node does not have left and right nodes, so both the leaf node and the non-leaf node can save 3 bytes to achieve the purpose of reducing memory occupation.
[0134] As an optional implementation, the method further includes: in response to the rule adding instruction of the non-leaf node, adjusting the memory corresponding to the non-leaf node, wherein the adjusted memory corresponding to the non-leaf node includes a continuous first memory and a second memory, the first memory is used to store node data of the non-leaf node, and the second memory is used to store newly added network address rule data.
[0135] In this embodiment, the rule adding instruction is used to insert a rule in the initial tree-shaped data structure, and therefore, in response to the rule adding instruction of the non-leaf node, the memory corresponding to the non-leaf node can be adjusted to expand the memory of the non-leaf node.
[0136] For example, assuming that the original memory of the non-leaf node is 8 bytes, after the rule adding instruction of the non-leaf node, the original memory of the non-leaf node can be reclaimed, and the memory of the non-leaf node is re-applied, for example, two memories can be applied, which can be 16 bytes, wherein the two memories are the first memory and the second memory, the first memory can occupy 8 bytes, and the second memory can occupy 8 bytes, the first memory is used to store node data of the non-leaf node, and the second memory is used to store newly added network address rule data. The first memory is used to store the left node and the right node, and the second memory is used to store the rule ID and the rule linked list of the newly added network address rule data.
[0137] As an optional implementation, in step S604, the initial tree-shaped data structure is converted into the target tree-shaped data structure based on the attribute information, including: in response to the attribute information being a rule linked list index corresponding to the network address rule data, storing identification information of the rule linked list index in the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the rule linked list index is used to index the network address rule data in the initial tree-shaped data structure, and the identification information is used to indicate whether the initial tree-shaped data structure stores the rule linked list index or not.
[0138] In this embodiment, as introduced above, the attribute information of the network address rule data can be a storage pointer of the network address rule data, a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, or a rule chain table index corresponding to the network address rule data. Based on this, when the attribute information is the rule chain table index corresponding to the network address rule data, the identification information of the rule chain table index can be stored in the initial tree-shaped data structure to obtain the target tree-shaped data structure.
[0139] For example, the rule chain table index can be a rule node, and a bit can be used to store the identification information of the rule chain table index, where the identification information can be represented by 1 or 0. When the identification information is 1, it is used to indicate that the rule chain table index is stored in the initial tree-shaped data structure. When the identification information is 0, it is used to indicate that the rule chain table index is not stored in the initial tree-shaped data structure. Based on this, the target tree-shaped data structure can be obtained by storing the identification information of the rule chain table index in the initial tree-shaped data structure.
[0140] As an optional implementation, the method further includes: in response to the rule chain table index being stored in the initial tree-shaped data structure, canceling the storage of the rule chain table index in the initial tree-shaped data structure.
[0141] In this embodiment, the rule chain table index can be a rule node, and the rule chain table index corresponds to identification information. When the rule chain table index is stored in the initial tree-shaped data structure, the rule chain table index can be canceled in the initial tree-shaped data structure to save the occupation of storage space.
[0142] For example, the storage of the rule chain table index needs to occupy 3 bytes. In order to reduce the occupation of storage space, 1 bit can be used to represent the identification information of the rule chain table index, where when the identification information is 0, it is used to indicate that there is no rule chain table index. Therefore, the rule chain table index can be canceled in the initial tree-shaped data structure by changing the identification information of the rule chain table index to save the occupation of bytes.
[0143] As an optional implementation, the method further includes: in response to the memory of the target tree-shaped data structure not satisfying the predetermined memory, adjusting the memory of the target tree-shaped data structure to the predetermined memory.
[0144] In this embodiment, when the memory of the target tree-shaped data structure does not satisfy the predetermined memory, that is, the bytes of the memory of the target tree-shaped data structure are not aligned with the bytes of the predetermined memory. In this case, the memory of the target tree-shaped data structure can be adjusted to the predetermined memory to align the bytes of the memory of the target tree-shaped data structure with the bytes of the predetermined memory.
[0145] For example, assuming that the predetermined memory is 8 bytes, and the memory of the target tree-shaped data structure is 7 bytes, since 7 bytes and 8 bytes cannot be aligned, based on this, a byte can be filled in the memory of the target tree-shaped data structure, 7 bytes is adjusted to 8 bytes, thereby realizing the purpose of aligning the memory bytes of the target tree-shaped data structure with the predetermined memory bytes.
[0146] In the above steps, the segment page addressing compressed pointer is used for storage, and then the node reconstruction technology is used to compress the node again by using 1 bit to represent the regular linked list index, so that the purpose of saving memory is achieved, and the performance is unchanged.
[0147] Figure 7 is a flowchart of a method for isolating inter-application access according to an embodiment of the present application. As shown in Figure 7 the method can include the following steps:
[0148] Step S701, obtaining an access request.
[0149] In the technical solution provided in the above step S701 of the present application, the access request is used to indicate that the first application requests to access the second application, based on which the access request can be obtained, and the target tree-shaped data structure of the first application accessing the second application can be determined based on the access request.
[0150] Step S702, in response to the access request, calling a target tree-shaped data structure with a memory smaller than an initial tree-shaped data structure.
[0151] In the technical solution provided in the above step S702 of the present application, after obtaining the access request, the target tree-shaped data structure with a memory smaller than the initial tree-shaped data structure can be called based on the access request, wherein the target tree-shaped data structure is obtained by converting the initial tree-shaped data structure based on the attribute information of the network address rule data corresponding to the first application, the attribute information is used to determine the network address rule data in the initial tree-shaped data structure and is obtained in the initial tree-shaped data structure, the initial tree-shaped data structure is obtained based on the memory of the network page corresponding to the network address on the second application, the node in the initial tree-shaped data structure is used to represent the network address rule data, the network address rule data is used to represent the generation rule of the network address of the second application, and the network address is used to enable the first application to access the network page of the second application.
[0152] Step S703, controlling the first application to access the second application based on the target tree-shaped data structure.
[0153] In the technical solution provided in the above step S703 of the present application, after calling the target tree-shaped data structure based on the access request, the first application can be controlled to access the second application based on the target tree-shaped data structure.
[0154] Based on the above steps S701 to S703, by obtaining the access request of the first application accessing the second application, and further based on the access request, the target tree-shaped data structure smaller than the initial tree-shaped data structure is called, and the first application is controlled to access the second application based on the target tree-shaped data structure, thereby achieving the purpose of isolating the access between the first application and the second application.
[0155] The technical solutions of the embodiments of the present application will be further described with reference to the preferred embodiments.
[0156] Currently, the access between applications needs to be isolated in the application trust project, including the isolation of IP, port, domain name, etc. The rule quantity is as high as 200 million, and the massive rules make the memory consumption as high as 260 MB when using the conventional dictionary tree for matching. The code running in the data plane uses the dictionary tree for matching, and has strict requirements on memory. There is a technical problem that the traditional dictionary tree cannot be effectively utilized.
[0157] To solve the above technical problems, an IP matching method based on a dictionary tree is proposed, including converting the format, converting the parameter IP in the dictionary tree into a 0 padding format, and establishing a Patricia tree (Practical Algorithm to Retrieve Information Coded Alphanumeric, referred to as Patricia). However, in the case of massive rules, the memory saved is limited, which cannot meet the requirements of the memory limit in the application trust project.
[0158] However, the embodiment of the present application provides a data processing method of a tree data structure. The network address rule data to be processed is obtained, wherein the network address rule data is used to represent the generation rule of the network address to be accessed. The network address rule data is established as an initial tree data structure based on the memory of the network page corresponding to the network address, wherein the network address is used to access the network page, and the node in the initial tree data structure is used to represent the network address rule data. In the initial tree data structure, the attribute information of the network address rule data is obtained, wherein the attribute information is used to determine the network address rule data in the initial tree data structure. The initial tree data structure is converted into a target tree data structure based on the attribute information, wherein the memory of the target tree data structure is smaller than that of the initial tree data structure. That is, in the present application, the network address rule data is established as an initial tree data structure based on the memory of the network page corresponding to the network address, and the initial tree data structure is converted into a target tree data structure based on the attribute information of the network address rule. The memory can be controlled within a limited range, the performance of the tree data structure is basically unchanged, the purpose of effectively utilizing the tree data structure is achieved, and the technical problem that the tree data structure cannot be effectively utilized due to the excessively high memory occupation rate is solved.
[0159] The data processing method of the tree data structure of the embodiment of the present application is further introduced below.
[0160] Figure 8 is a flowchart of another data processing method of a tree data structure according to the embodiment of the present application. As shown in Figure 8 , the method can include the following steps:
[0161] Step S801, initializing the root node, and applying for the network page memory.
[0162] In this embodiment, the root node of the dictionary tree can be initialized, and the network page memory can be applied according to the page memory occupied by the dictionary tree.
[0163] Step S802, establishing the dictionary tree according to the IP rule.
[0164] In this embodiment, it is assumed that the IP rule is represented as 1.1.1.1 / 32|1-65535|2|1|123, in which, from left to right in the IP rule, "1.1.1.1" is used to indicate an IP address, "32" is used to indicate a mask, "1-65535" is used to indicate a port, "2" is used to indicate a priority of the rule, "1" is used to indicate that the rule hits (both the IP and the port hit) an action 1, and "123" is used to indicate a rule id. Based on this, when the initial tree data structure is established by using the IP rule data, the address pointer P corresponding to the IP rule data structure can be first converted into a 28-bit index rule_index, in which 13 bits are segments and 15 bits are in-page offsets, because the rule addressable range is 1 GB, and therefore the IP address can be accessed according to 4-byte alignment; then, the ports in the IP rule data structure can be sorted to facilitate subsequent binary matching of the ports; then, the IP address 1.1.1.1 can be converted into a 4-byte host sequence (32 bits), and then a dictionary tree is established from the highest bit, in which when the highest bit is 0, a left node is searched, and when the highest bit is 1, a right node is searched, and if no node is found, it means that the node does not exist, in which case a block can be applied, and the dictionary tree is sequentially constructed from the 31st bit to the 0th bit according to the above method, with a maximum of 32 cycles.
[0165] In step S803, a dictionary tree is created based on the network page memory, and an index of the memory is returned.
[0166] In this embodiment, a dictionary tree can be created based on the network page memory applied in step S801, and an index of the network page memory is returned.
[0167] In step S804, in response to the need to insert an IP rule in a non-leaf node of the dictionary tree, the non-leaf node is rebuilt.
[0168] In this embodiment, when the non-leaf node in the dictionary tree needs to insert an IP rule, the non-leaf node needs to be rebuilt, for example, the memory originally occupied by the non-leaf node can be reclaimed, and two memories are newly applied, one of which is used to store node data and the other is used to store the newly inserted IP rule data.
[0169] In step S805, if there are multiple IP rules, the step of establishing a dictionary tree according to the IP rule is repeatedly performed.
[0170] In this embodiment, if there are multiple IP rules in addition to the IP rule of step S801, the above steps S802 to S804 can be repeatedly performed to implement the step of establishing a dictionary tree according to the IP rules.
[0171] Step S806: Determine whether the IP rule can match the dictionary tree.
[0172] In this embodiment, after the dictionary tree is created, it can be further determined whether the IP rule can match the dictionary tree, and if so, the rule index is returned and converted into an actual address for access.
[0173] Step S807: In response to deleting the IP rule, the memory of the rule node is recycled.
[0174] In this embodiment, if a certain IP rule is to be deleted in response, the memory of the rule node can be recycled.
[0175] Based on the scheme disclosed in the above embodiment steps S801 to S807, a dictionary tree can be created based on IP rules, the dictionary tree can be compressed, and rules can be dynamically added or deleted as needed to save memory usage, thereby solving the technical problem that the dictionary tree cannot be effectively utilized.
[0176] Next, the memory pointer compression method of the dictionary tree node is introduced.
[0177] Most of the current mainstream processors are 64-bit, that is, a memory pointer is 8 bytes (64 bits), and the dictionary tree stores left and right nodes, rule pointers, etc., all of which need to store pointers, and the storage of a pointer occupies 8 bytes. According to research, the 8-byte pointer has a relatively low entropy, so the 8-byte pointer can be compressed. For example, when the pointer to be accessed is represented as: 0x0000000012345678, the pointer can be divided into two parts, the first part is called segment
[0178] = 0x0000000012340000, and the second part is called page = 0x5678, that is: segment + page = 0x0000000012345678.
[0179] Suppose the maximum memory used by the dictionary tree is 128MB, and if the network page size is set to 128MB, a 128MB network page memory can be applied, and the memory pointer is 0x1234567800000000. At this time, any 8-byte aligned memory access in the 128MB memory can be represented as 0x1234567800000000 + 3-byte offset * 8, where the 3-byte offset is the index. Through the 3-byte offset, the 8-byte pointer can be replaced to achieve compression.
[0180] Figure 9 This is a schematic diagram of a memory pointer according to an embodiment of this application. For example... Figure 9 As shown, assuming the memory pointer is 24 bits, it can be segmented and paging addressed, where bits 24 to 14 can be segments, and bits 14 to 0 can be pages.
[0181] Next, we will introduce the leaf nodes and non-leaf nodes in the trie.
[0182] Leaf nodes and non-leaf nodes use different data structures. Figure 10 This is a schematic diagram of a non-leaf node and a leaf node according to an embodiment of this application, as shown below. Figure 10 As shown, non-leaf nodes include left and right nodes, while leaf nodes include rule IDs and rule lists. The rule ID in a leaf node is 28 bits, and this 28-bit rule ID also uses segmented paging addressing, with 13 bits representing the segment and 15 bits representing the page. The rule list is also a 28-bit index, and the index-to-point pointer conversion also uses segmented paging addressing. The rule list pointer stores two pieces of data: the rule ID index and the list pointer index. It should be noted that because the 8-byte pointer has been compressed to 3 bytes or 28 bits (3 bytes + 4 bits), all memory accesses within the trie require converting the index to a physical address pointer using segmented paging addressing.
[0183] Figure 11 This is a schematic diagram of a non-leaf node and a leaf node according to an embodiment of this application, as shown below. Figure 11 As shown, both non-leaf nodes and leaf nodes are 8 bytes each. Non-leaf nodes include a left node and a right node, while leaf nodes include a rule ID and a rule list. The left and right nodes of a non-leaf node are each 4 bytes, with 3 bytes used for the index. Therefore, the remaining high 8 bits can be used to store other data. For example, bit 31 being 1 indicates the node is a leaf node, and bit 0 indicates the node is a non-leaf node; bit 30 being 1 indicates the node has a rule node, and bit 0 indicates the node does not have a rule node.
[0184] Figure 12 This is a schematic diagram of a compressed trie according to an embodiment of this application. Figure 12As shown, the root node of the compressed dictionary tree is 8 bytes, and the root node includes a left node and a right node. The left node of the root node can include a non-leaf node and a rule node, wherein the non-leaf node is 8 bytes, and the non-leaf node includes a left node and a right node (the left node can be a leaf node, the leaf node can be 8 bytes, and the leaf node includes a rule ID and a rule chain table, the right node can be a non-leaf node, the non-leaf node can be 8 bytes, and the non-leaf node includes a left node and a right node), and the rule node is also 8 bytes, and the rule node includes a rule ID and a rule chain table. The right node of the root node can be a leaf node, the leaf node is 8 bytes, and the leaf node includes a rule ID and a rule chain table.
[0185] When the dictionary tree is constructed by using the data processing method of the tree-shaped data structure provided in the embodiments of the present application, three times of compression can be performed. The first time can compress an 8-byte pointer to 3 bytes. Three bytes are 24 bits in total, wherein the high 10 bits are a segment, and the low 14 bits are a page. After the first compression, the size of the dictionary tree node is compressed from 32 bytes to 12 bytes.
[0186] The second time can separate the leaf node from the non-leaf node, saving 3 bytes, and realizing compression from 12 bytes to 9 bytes. For example, in the case where the leaf node is not separated from the non-leaf node, each node carries a rule node by default, and the rule node needs to occupy at least 3 bytes. After the leaf node is separated from the non-leaf node, only the leaf node needs to carry the rule node, and the leaf node has no left and right nodes. Therefore, both the leaf node and the non-leaf node can save 3 bytes.
[0187] The third time can use 1 bit to represent whether a rule node exists (the node needs to be reconstructed when the dictionary tree is constructed), so as to compress 9 bytes to 7 bytes. 8 bytes are used due to the need for memory alignment. For example, 3 bytes originally used to store a rule chain table index are changed to 1 bit, 1 indicating that a rule node exists (the rule node is at the address + 8 of the node, that is, two blocks are continuous), and 0 indicating that no rule node exists. Therefore, the rule node can not be stored, that is, 3 bytes are saved. However, 1 byte is also needed to occupy 1 byte because 1 bit is needed to represent whether the rule node exists. Therefore, only 2 bytes are saved. Therefore, 9 bytes are compressed to 7 bytes. However, if the processor accesses is not 4, 8, or 16-byte alignment access, the performance will decrease due to the need to read twice. Therefore, 1 byte is filled, and 7 bytes become 8 bytes. When filling, 4 bits are filled for the left and right nodes, that is, the left and right nodes occupy 4 bytes. After the above three steps, 75% of the memory is finally saved, and the performance is almost unchanged.
[0188] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0189] It should be noted that for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0190] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and necessary general hardware platform, and of course it can also be realized by hardware. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, or network device, etc.) execute the method described in each embodiment of the present application.
[0191] Embodiment 2
[0192] According to an embodiment of the present application, a data processing apparatus of a tree data structure for implementing the data processing method of the tree data structure is provided, Figure 13 is a schematic diagram of a data processing apparatus of a tree data structure according to an embodiment of the present application, as Figure 13 shown, the apparatus comprises a first calling unit 1301, a first establishing unit 1302, a first obtaining unit 1303, a first converting unit 1304 and an output unit 1305.
[0193] The first calling unit 1301 is configured to obtain network address rule data to be processed by calling a first interface, wherein the first interface comprises a first parameter, and the parameter value of the first parameter is the network address rule data, and the network address rule data is used to indicate the generation rule of the network address to be accessed.
[0194] The first establishing unit 1302 is configured to establish the network address rule data as initial tree-shaped data structure based on the memory of the network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data.
[0195] The first obtaining unit 1303 is configured to obtain attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure.
[0196] The first converting unit 1304 is configured to convert the initial tree-shaped data structure into target tree-shaped data structure based on the attribute information, wherein the memory of the target tree-shaped data structure is smaller than the memory of the initial tree-shaped data structure.
[0197] The output unit 1305 is configured to output the target tree-shaped data structure by calling the second interface, wherein the second interface comprises a second parameter, and a parameter value of the second parameter is the target tree-shaped data structure.
[0198] It should be noted that the first calling unit 1301, the first establishing unit 1302, the first obtaining unit 1303, the first converting unit 1304 and the output unit 1305 correspond to steps S401 to S405 in Embodiment 1, and the five units have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in Embodiment 1.
[0199] According to the embodiments of the present application, a data processing apparatus of a tree-shaped data structure for implementing the data processing method of the tree-shaped data structure is further provided, Figure 14 is a schematic diagram of another data processing apparatus of a tree-shaped data structure according to the embodiments of the present application, as Figure 14 shown, the apparatus comprises a second obtaining unit 1401, a second establishing unit 1402, a third obtaining unit 1403, a second converting unit 1404 and a first control unit 1405.
[0200] The second obtaining unit 1401 is configured to obtain network address rule data of an application, wherein the network address rule data is used to represent a generation rule of a network address to be accessed by the application.
[0201] The second establishing unit 1402 is configured to establish the network address rule data as initial tree-shaped data structure based on the memory of the network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data.
[0202] The third obtaining unit 1403 is configured to obtain attribute information of the network address rule data in the initial tree-shaped data structure, where the attribute information is used to determine the network address rule data in the initial tree-shaped data structure.
[0203] The second converting unit 1404 is configured to convert the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information, where the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure.
[0204] The first control unit 1405 is configured to control access based on the target tree-shaped data structure.
[0205] It should be noted that the second obtaining unit 1401, the second establishing unit 1402, the third obtaining unit 1403, the second converting unit 1404, and the first control unit 1405 correspond to steps S501 to S505 in Embodiment 1, and the five units have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in Embodiment 1.
[0206] According to the embodiments of the present application, a data processing apparatus of a tree-shaped data structure for implementing the data processing method of the tree-shaped data structure is further provided, Figure 15 is a schematic diagram of another data processing apparatus of a tree-shaped data structure according to the embodiments of the present application, as Figure 15 shown, the apparatus can include a fourth obtaining unit 1501, a third establishing unit 1502, a fifth obtaining unit 1503, and a second converting unit 1504.
[0207] The fourth obtaining unit 1501 is configured to obtain network address rule data to be processed, where the network address rule data is used to represent a generation rule of a network address to be accessed.
[0208] The third establishing unit 1502 is configured to establish the network address rule data into an initial tree-shaped data structure based on the memory of a network page corresponding to the network address, where the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data.
[0209] The fifth obtaining unit 1503 is configured to obtain attribute information of the network address rule data in the initial tree-shaped data structure, where the attribute information is used to determine the network address rule data in the initial tree-shaped data structure.
[0210] The second converting unit 1504 is configured to convert the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information, where the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure.
[0211] It should be noted that the fourth obtaining unit 1501, the third establishing unit 1502, the fifth obtaining unit 1503 and the second converting unit 1504 correspond to steps S601 to S604 in Embodiment 1, and the four units have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in Embodiment 1.
[0212] According to the embodiments of the present application, an application access isolation device for implementing the above-mentioned method of isolating application access is further provided, Figure 16 is a schematic diagram of an application access isolation device according to an embodiment of the present application, as Figure 16 shown, the device comprises a sixth obtaining unit 1601, a second calling unit 1602 and a second control unit 1603.
[0213] The sixth obtaining unit 1601 is configured to obtain an access request, wherein the access request is used to indicate that a first application requests to access a second application.
[0214] The second calling unit 1602 is configured to call a target tree-shaped data structure with smaller memory than an initial tree-shaped data structure in response to the access request, wherein the target tree-shaped data structure is obtained by converting the initial tree-shaped data structure based on attribute information of network address rule data corresponding to the first application, the attribute information is used to determine the network address rule data in the initial tree-shaped data structure and is obtained in the initial tree-shaped data structure, the initial tree-shaped data structure is established based on the memory of a network page corresponding to a network address on the second application, a node in the initial tree-shaped data structure is used to indicate the network address rule data, the network address rule data is used to indicate a generation rule of a network address of the second application, and the network address is used to enable the first application to access the network page of the second application.
[0215] The second control unit 1603 is configured to control the first application to access the second application based on the target tree-shaped data structure.
[0216] It should be noted that the sixth obtaining unit 1601, the second calling unit 1602 and the second control unit 1603 correspond to steps S701 to S703 in Embodiment 1, and the three units have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in Embodiment 1.
[0217] It should be noted that the preferred embodiments involved in the above embodiments of the present application have the same scheme, application scenario and implementation process as provided in Embodiment 1, but are not limited to the scheme provided in Embodiment 1.
[0218] Embodiment 3
[0219] The embodiment of the present application can provide a computer terminal, which can be any one of computer terminal devices in a computer terminal group. Alternatively, in the embodiment, the computer terminal can be replaced by a mobile terminal or other terminal device.
[0220] Alternatively, in the embodiment, the computer terminal can be located in at least one of a plurality of network devices in a computer network.
[0221] In the embodiment, the computer terminal can execute program codes of the following steps in the data processing method of the tree-shaped data structure: obtaining network address rule data to be processed, wherein the network address rule data is used to represent a generation rule of a network address to be accessed; establishing the network address rule data into an initial tree-shaped data structure based on a memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; and converting the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information, wherein a memory of the target tree-shaped data structure is smaller than a memory of the initial tree-shaped data structure.
[0222] Alternatively, Figure 17 is a structural block diagram of a computer terminal according to an embodiment of the present application. As shown in Figure 17 , the computer terminal A can include one or more (only one is shown in the figure) processors 1702, a memory 1704, a storage controller, and a peripheral interface, wherein the peripheral interface is connected with a radio frequency module, an audio module, and a display.
[0223] The memory can be used to store software programs and modules, such as program instructions / modules corresponding to the data processing method and device of the tree-shaped data structure in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the data processing method of the tree-shaped data structure. The memory can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, a flash memory, or other non-volatile solid-state memories. In some examples, the memory can further include a memory remotely arranged with respect to the processor, which can be connected to the computer terminal A through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0224] The processor can call information and application programs stored in the memory through the transmission device to perform the following steps: obtaining network address rule data to be processed, wherein the network address rule data is used to represent a generation rule of a network address to be accessed; establishing the network address rule data as an initial tree-shaped data structure based on the memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; and converting the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information, wherein the memory of the target tree-shaped data structure is smaller than the memory of the initial tree-shaped data structure.
[0225] Optionally, the processor can further execute program codes of the following steps: in response to the memory of the network page being less than or equal to a memory threshold of the initial tree-shaped data structure, establishing the network address rule data as the initial tree-shaped data structure based on the memory of the network page.
[0226] Optionally, the processor can further execute program codes of the following steps: in response to the memory of the network page being less than or equal to the memory threshold, establishing the network address rule data as an initial tree-shaped data structure with the same memory as the memory of the network page.
[0227] Optionally, the processor can further execute program codes of the following steps: in response to the attribute information being a storage pointer of the network address rule data, adjusting an initial memory corresponding to the storage pointer in the initial tree-shaped data structure to a target memory to obtain the target tree-shaped data structure, wherein the storage pointer is used to store the network address rule data in the initial tree-shaped data structure.
[0228] Optionally, the processor can further execute program codes of the following steps: in the memory of the network page, determining a memory pointer corresponding to a memory aligned according to the initial memory; based on an offset of the memory pointer relative to the storage pointer, determining the target memory
[0229] Optionally, the processor can further execute program codes of the following steps: determining, as the target memory, a memory corresponding to the offset of the memory pointer relative to the storage pointer, wherein the target memory is segment page addressing, at least one first type of data bit in the segment page addressing is used to represent a segment, and at least one second type of data bit in the segment page addressing is used to represent a page.
[0230] Optionally, the processor can further execute program codes of the following steps: in response to the attribute information being a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, converting the initial tree-shaped data structure into the target tree-shaped data structure based on the node type.
[0231] Optionally, the processor can further execute program codes of the following steps: separating leaf nodes of the leaf node type and non-leaf nodes of the non-leaf node type from the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the node type includes the leaf node type and the non-leaf node type, the leaf node is used to store the network address rule data, and the non-leaf node does not store the network address rule data.
[0232] Optionally, the processor can further execute program codes of the following steps: in response to the rule adding instruction for the non-leaf node, adjusting the memory corresponding to the non-leaf node, wherein the memory corresponding to the adjusted non-leaf node includes the continuous first memory and the second memory, the first memory is used to store the node data of the non-leaf node, and the second memory is used to store the newly added network address rule data.
[0233] Optionally, the processor can further execute program codes of the following steps: in response to the attribute information being the rule chain table index corresponding to the network address rule data, storing the identification information of the rule chain table index in the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the rule chain table index is used to index the network address rule data in the initial tree-shaped data structure, and the identification information is used to indicate whether the initial tree-shaped data structure stores the rule chain table index or not.
[0234] Optionally, the processor can further execute program codes of the following steps: in response to the initial tree-shaped data structure storing the rule chain table index, canceling the storage of the rule chain table index in the initial tree-shaped data structure.
[0235] Optionally, the processor can further execute program codes of the following steps: in response to the memory of the target tree-shaped data structure not satisfying the predetermined memory, adjusting the memory of the target tree-shaped data structure to the predetermined memory.
[0236] By adopting the embodiment of the present application, a scheme of a data processing method of a tree-shaped data structure is provided. The network address rule data is established as an initial tree-shaped data structure through the memory of the network page corresponding to the network address, and the initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information of the network address rule, so that the memory can be controlled within a limited range, the performance of the tree-shaped data structure is basically unchanged, the technical effect of effectively utilizing the tree-shaped data structure is achieved, and the technical problem of the tree-shaped data structure being unable to be effectively utilized due to the excessively high memory occupancy rate is solved.
[0237] Those skilled in the art will understand that the structure shown in the figure is for illustrative purposes only, and the computer terminal may also be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, and other terminal devices. Figure 17 This does not limit the structure of the aforementioned electronic device. For example, computer terminal A may also include components that are more... Figure 17 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 17 The different configurations shown.
[0238] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0239] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 18 This is a schematic diagram of a computer terminal illustrating another data processing method using a tree-structured data structure according to an embodiment of this application. Figure 18 As shown, a computer terminal 180 (or mobile device) may include one or more processors 1802 (shown as 1802a, 1802b, ..., 1802n in the figure) (processor 1802 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 1804 for storing data, and a transmission module 1806 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 18 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, the computer terminal 180 may also include... Figure 18 The more or fewer components shown, or having the same Figure 18 The different configurations shown.
[0240] It should be noted that the one or more processors 1802 and / or other data processing circuitry described above can be generally referred to herein as "data processing circuitry." The data processing circuitry can be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuitry can be a single standalone processing module, or incorporated in whole or in part within any of the other elements of the computer terminal 180 (or mobile device). As referred to in embodiments of the present application, the data processing circuitry functions as a processor to control, for example, selection of variable resistance terminal paths connected to an interface.
[0241] The memory 1804 can be used to store software programs and modules for applications, such as program instructions / data storage means corresponding to the tree data structure data processing method in embodiments of the present application. The processor 1802 can execute various functions and data processing by running the software programs and modules stored in the memory 1804, i.e., implement the tree data structure data processing method described above. The memory 1804 can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 1804 can further include a memory remotely disposed relative to the processor 1802, which can be connected to the computer terminal 180 through a network. Examples of the network can include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0242] The transmission device 1806 is configured to receive or send data via a network. Examples of the network can include a wireless network provided by a communication provider of the computer terminal 180. In one example, the transmission device 1806 includes a network adapter (NIC), which can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 1806 can be a radio frequency (RF) module, which is configured to communicate with the Internet in a wireless manner.
[0243] The display can be, for example, a touch screen type liquid crystal display (LCD), which can enable a user to interact with a user interface of the computer terminal 180 (or mobile device).
[0244] Embodiment 4
[0245] The embodiment of the present application further provides a computer readable storage medium. Optionally, in the embodiment, the storage medium can be used to store program codes executed by the data processing method of the tree-shaped data structure provided in the first embodiment.
[0246] Optionally, in the embodiment, the storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0247] Optionally, in the embodiment, the storage medium is configured to store program codes for performing the following steps: obtaining network address rule data to be processed, wherein the network address rule data is used to represent a generation rule of a network address to be accessed; establishing the network address rule data into an initial tree-shaped data structure based on the memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; and converting the initial tree-shaped data structure into a target tree-shaped data structure based on the attribute information, wherein the memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure.
[0248] Optionally, the storage medium is further configured to store program codes for performing the following steps: in response to the memory of the network page being less than or equal to a memory threshold of the initial tree-shaped data structure, establishing the network address rule data into the initial tree-shaped data structure based on the memory of the network page.
[0249] Optionally, the storage medium is further configured to store program codes for performing the following steps: in response to the memory of the network page being less than or equal to the memory threshold, establishing the network address rule data into an initial tree-shaped data structure with the same memory as that of the network page.
[0250] Optionally, the storage medium is further configured to store program codes for performing the following steps: in response to the attribute information being a storage pointer of the network address rule data, adjusting an initial memory corresponding to the storage pointer in the initial tree-shaped data structure to a target memory to obtain the target tree-shaped data structure, wherein the storage pointer is used to store the network address rule data in the initial tree-shaped data structure.
[0251] Optionally, the storage medium is further configured to store program codes for performing the following steps: in the memory of the network page, determining a memory pointer corresponding to a memory aligned according to the initial memory; and determining the target memory based on an offset of the memory pointer relative to the storage pointer.
[0252] Optionally, the storage medium is further configured to store program code for performing the following step: determining, as the target memory, the memory corresponding to the offset of the memory pointer relative to the storage pointer, wherein the target memory is in a segment paging addressing, and at least one first type of data bit in the segment paging addressing is used to represent a segment, and at least one second type of data bit in the segment paging addressing is used to represent a page.
[0253] Optionally, the storage medium is further configured to store program code for performing the following step: converting the initial tree-shaped data structure into the target tree-shaped data structure based on the node type of the node corresponding to the network address rule data in the initial tree-shaped data structure in response to the attribute information being the node type.
[0254] Optionally, the storage medium is further configured to store program code for performing the following step: separating the leaf node of the leaf node type and the non-leaf node of the non-leaf node type from the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the node type includes the leaf node type and the non-leaf node type, the leaf node is used to store the network address rule data, and the non-leaf node does not store the network address rule data.
[0255] Optionally, the storage medium is further configured to store program code for performing the following step: adjusting the memory corresponding to the non-leaf node in response to the rule adding instruction for the non-leaf node, wherein the memory corresponding to the adjusted non-leaf node includes the continuous first memory and the second memory, the first memory is used to store the node data of the non-leaf node, and the second memory is used to store the newly added network address rule data.
[0256] Optionally, the storage medium is further configured to store program code for performing the following step: storing identification information of the rule chain table index corresponding to the network address rule data in the initial tree-shaped data structure to obtain the target tree-shaped data structure in response to the attribute information being the rule chain table index, wherein the rule chain table index is used to index the network address rule data in the initial tree-shaped data structure, and the identification information is used to indicate whether the initial tree-shaped data structure stores the rule chain table index or not.
[0257] Optionally, the storage medium is further configured to store program code for performing the following step: canceling the storage of the rule chain table index in the initial tree-shaped data structure in response to the initial tree-shaped data structure storing the rule chain table index.
[0258] Optionally, the storage medium is further configured to store program code for performing the following step: adjusting the memory of the target tree-shaped data structure to the predetermined memory in response to the memory of the target tree-shaped data structure not satisfying the predetermined memory.
[0259] The above embodiment numbers of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0260] In the above embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0261] In the several embodiments provided by the present application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the embodiment described above is only a schematic, for example, the division of units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.
[0262] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0263] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware or in the form of software functional unit.
[0264] The integrated unit, if realized in the form of software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of software product, which is stored in a storage medium and includes a plurality of instructions for making a computer device (which can be a personal computer, a server or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and various program code storage media.
[0265] The above merely describes the preferred embodiments of the present application, and it should be pointed out that, for those skilled in the art, some improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be considered as the protection scope of the present application.
Claims
1. A data processing method of a tree data structure, characterized by, The method comprises: obtaining network address rule data to be processed by calling a first interface, wherein the first interface comprises a first parameter, a parameter value of the first parameter is the network address rule data, and the network address rule data is used to represent a generation rule of a network address to be accessed; establishing the network address rule data as initial tree-shaped data structure based on memory of a network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; converting the initial tree-shaped data structure into target tree-shaped data structure based on the attribute information, wherein memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure; outputting the target tree-shaped data structure by calling a second interface, wherein the second interface comprises a second parameter, and a parameter value of the second parameter is the target tree-shaped data structure; wherein converting the initial tree-shaped data structure into target tree-shaped data structure based on the attribute information comprises: in response to the attribute information being a storage pointer of the network address rule data, determining, in the memory of the network page, a memory pointer corresponding to memory aligned with an initial memory corresponding to the storage pointer; determining, as a target memory corresponding to the initial memory, memory corresponding to an offset of the memory pointer relative to the storage pointer, wherein the target memory is a segment page addressing; and adjusting the initial memory to the target memory to obtain the target tree-shaped data structure.
2. A data processing method of a tree data structure, characterized by, The method comprises: obtaining network address rule data corresponding to an application, wherein the network address rule data is used to represent a generation rule of a network address to be accessed by the application; establishing the network address rule data as initial tree-shaped data structure based on memory of a network page corresponding to the network address, wherein the network address is used to enable the application to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; obtaining attribute information of the network address rule data in the initial tree-shaped data structure, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; converting the initial tree-shaped data structure into target tree-shaped data structure based on the attribute information, wherein memory of the target tree-shaped data structure is smaller than that of the initial tree-shaped data structure; controlling the application to perform access based on the target tree-shaped data structure; The attribute information is used for determining the network address rule data in the initial tree-shaped data structure.
3. The method of claim 2, wherein, The application is controlled to access based on the target tree-shaped data structure, including: In response to the network address to be queried matching the target tree-shaped data structure, the network address to be queried is converted into the network address, and the network page is accessed according to the network address.
4. A data processing method of a tree data structure, characterized by, It includes: Obtaining network address rule data to be processed, wherein the network address rule data is used to represent a generation rule of a network address to be accessed; The network address rule data is established as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address, wherein the network address is used to access the network page, and a node in the initial tree-shaped data structure is used to represent the network address rule data; In the initial tree-shaped data structure, attribute information of the network address rule data is obtained, wherein the attribute information is used to determine the network address rule data in the initial tree-shaped data structure; The initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information, wherein the memory of the target tree-shaped data structure is smaller than the memory of the initial tree-shaped data structure. The initial tree-shaped data structure is converted into a target tree-shaped data structure based on the attribute information, including: in response to the attribute information being a storage pointer of the network address rule data, determining a memory pointer corresponding to an initial memory aligned according to the storage pointer in the memory of the network page; the memory corresponding to the offset of the memory pointer relative to the storage pointer is determined as the target memory corresponding to the initial memory, wherein the target memory is segment page addressing; and the initial memory is adjusted to the target memory to obtain the target tree-shaped data structure.
5. The method of claim 4, wherein, The network address rule data is established as an initial tree-shaped data structure based on the memory of the network page corresponding to the network address, including: In response to the memory of the network page being less than or equal to a memory threshold of the initial tree-shaped data structure, the network address rule data is established as the initial tree-shaped data structure based on the memory of the network page; The network address rule data is established as the initial tree-shaped data structure based on the memory of the network page in response to the memory of the network page being less than or equal to the memory threshold of the initial tree-shaped data structure, including: In response to the memory of the network page being less than or equal to the memory threshold, the network address rule data is established as the initial tree-shaped data structure with the same memory as the memory of the network page.
6. The method of claim 4, wherein, The storage pointer is used to store the network address rule data in the initial tree-shaped data structure.
7. The method of claim 6, wherein, At least one first type of data bit in the segment page addressing is used to represent a segment, and at least one second type of data bit in the segment page addressing is used to represent a page.
8. The method of claim 4, wherein, Based on the attribute information, the initial tree-shaped data structure is converted into a target tree-shaped data structure, including: In response to the attribute information being a node type of a node corresponding to the network address rule data in the initial tree-shaped data structure, the initial tree-shaped data structure is converted into the target tree-shaped data structure based on the node type; The conversion of the initial tree-shaped data structure into the target tree-shaped data structure based on the node type includes separating leaf nodes of a leaf node type and non-leaf nodes of a non-leaf node type from the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the node type includes the leaf node type and the non-leaf node type, the leaf nodes are used to store the network address rule data, and the non-leaf nodes do not store the network address rule data.
9. The method of claim 8, wherein, The method further includes: In response to a rule adding instruction for the non-leaf node, the memory corresponding to the non-leaf node is adjusted, wherein the adjusted memory corresponding to the non-leaf node includes continuous first memory and second memory, the first memory is used to store node data of the non-leaf node, and the second memory is used to store newly added network address rule data.
10. The method of claim 4, wherein, Based on the attribute information, the initial tree-shaped data structure is converted into a target tree-shaped data structure, including: In response to the attribute information being a rule chain table index corresponding to the network address rule data, identification information of the rule chain table index is stored in the initial tree-shaped data structure to obtain the target tree-shaped data structure, wherein the rule chain table index is used to index the network address rule data in the initial tree-shaped data structure, and the identification information is used to indicate whether the initial tree-shaped data structure stores the rule chain table index.
11. The method of claim 10, wherein, The method further includes: In response to the initial tree-shaped data structure storing the rule chain table index, the initial tree-shaped data structure is stored without the rule chain table index.
12. The method according to any one of claims 4 to 11, characterized in that, The method further includes: In response to the memory of the target tree-shaped data structure not satisfying a predetermined memory, the memory of the target tree-shaped data structure is adjusted to the predetermined memory.
13. An electronic device, comprising: Including: A memory and a processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions, which, when executed by the processor, implement the steps of the method in any one of claims 1 to 12.
14. A method for isolation of inter-application access, characterized by, Including: An access request is obtained, wherein the access request is used to indicate that a first application requests to access a second application; In response to the access request, a target tree-shaped data structure smaller in memory than an initial tree-shaped data structure is invoked, wherein the target tree-shaped data structure is converted from the initial tree-shaped data structure based on attribute information of network address rule data corresponding to the first application, the attribute information is used to determine the network address rule data in the initial tree-shaped data structure, and the attribute information is obtained in the initial tree-shaped data structure, the initial tree-shaped data structure is established based on the network address rule data corresponding to a network page of a network address on the second application, a node in the initial tree-shaped data structure is used to represent the network address rule data, the network address rule data is used to represent a generation rule of the network address of the second application, the network address is used to enable the first application to access the network page to the second application, in response to the attribute information being a storage pointer of the network address rule data, the target tree-shaped data structure is obtained by adjusting initial memory corresponding to the storage pointer to target memory, the target memory is segment page addressing, and the target memory is memory corresponding to an offset of a memory pointer relative to the storage pointer, the memory pointer is determined in the memory of the network page according to the initial memory aligned memory; The first application accesses the second application based on the target tree-shaped data structure.
Citation Information
Patent Citations
Multi-domain network packet classification method
CN102420831A
ACL rule classification method, lookup method and device
CN112425131A