Detailed Description
In order to better understand the technical solutions, the technical solutions of the embodiments of the present specification are described in detail below with reference to the drawings and specific embodiments, and it should be understood that the specific features of the embodiments and embodiments of the present specification are detailed descriptions of the technical solutions of the embodiments of the present specification, and are not limitations of the technical solutions of the present specification, and the technical features of the embodiments and embodiments of the present specification may be combined with each other without conflict.
In a first aspect, as shown in fig. 1, an embodiment of the present specification provides a method for compressing a link structure log, including the following steps:
s102, obtaining an original link structure log generated by one-time calling, wherein the original link structure log comprises node information of a plurality of nodes;
specifically, the system automatically generates an original link structure log at each call, and thus the original link structure log generated by one call of the system can be obtained by reading or receiving and the like, wherein the original link structure log includes node information of a plurality of nodes, the node information of each other node includes a number of the node and called interface information, the number of the node is used for identifying the position of the node in the link structure log, and the interface information may include one or more information of called packet name, class name, number of method parameters and the like. Preferably, the interface information includes a called package name, a class name, and a number of method parameters.
Specifically, the original link structure log is generated by one-time calling, so that any one node in the original link structure log and other nodes all have a common prefix.
For example, the obtained original link structure log specifically includes the following:
0,com.alipay.pcardcore.common.util.cache.Cachemanger.getKeyStrategy(1)
0.1,com.alipay.pcardcore.common.util.drm.manager.DrmResourceManager.findResourceByName(2)
0.1.1,com.alipay.imock.core.pool.contorller.EnvContorller.isProd()
0.2,com.alipay.pcardcore.common.util.cache.Cachemanger.getobject(3)
as can be seen from the above description, the original link structure log includes node information of 4 nodes, i.e., node 0, node 0.1, node 0.1.1, and node 0.2, and any one of the 4 nodes has a common prefix with other nodes.
S104, extracting node pairs with the maximum common prefix from the original link structure logs, and selecting one node from the node pairs with the maximum common prefix as a main node;
in an optional implementation manner, node contents of every two nodes in the original link structure log may be compared to obtain a comparison result; and extracting node pairs with the maximum common prefix according to the comparison result, and then selecting one node from the node pairs as the main node. The node may be randomly selected from the node pair with the largest common prefix as the master node, or a node meeting the condition may be selected from the node pair with the largest common prefix as the master node according to a preset condition, which is not limited in this application. The preset condition may be that a node with a large length or a node with a small length is used as the master node, or that a node before the node is used as the master node, which is not limited in this application.
For example, 4 nodes, 0,0.1, 0.1.1 and 0.2, are taken as examples, and the comparison result obtained by comparing 0 with 3 nodes, 0.1 and 0.2 respectively, shows that (0,0.1) has a common prefix length of 33, (0,0.1.1) has a common prefix length of 11, and (0,0.2) has a common prefix length of 55, since 55>33>11, the node pair with the largest common prefix can be extracted as (0,0.2) according to the comparison result, and then 0.2 is randomly selected from (0,0.2) as the master node.
In the embodiment of the present application, each node pair includes two nodes.
In another alternative embodiment, the original link structure log may be sorted according to method signatures; and extracting node pairs with the maximum common prefix from the sorted original link structure logs, and selecting one node from the node pairs with the maximum common prefix as a main node.
Specifically, after the original link structure logs are sorted according to the method signatures, two nodes sorted at the top have the maximum common prefix, so that the two nodes sorted at the top can be node pairs with the maximum common prefix, then one node is selected from the node pair as a master node, and the node sorted at the top is usually selected from the node pair with the maximum common prefix as the master node; of course, the nodes ranked after the node pair with the largest common prefix may also be selected as the master node, and the application is not particularly limited. In the following, the node with the largest common prefix is selected as the node with the highest rank as the master node.
For example, the nodes in the original link structure log are arranged in the order as follows:
0,com.alipay.pcardcore.common.util.cache.Cachemanger.getKeyStrategy(1)
0.2,com.alipay.pcardcore.common.util.cache.Cachemanger.getobject(3)
0.1,com.alipay.pcardcore.common.util.drm.manager.DrmResourceManager.findResourceByName(2)
0.1.1,com.alipay.imock.core.pool.contorller.EnvContorller.isProd()
as can be seen from the above, the pair of nodes sorted in the first two nodes (0,0.2) contains a common prefix of "com.alicay.pcardcore.common.util.cache.cacheanger.get" for 55 characters, and the pair of nodes (0,0.1) contains a common prefix of "com.alicay.pcardcore.common.util.33 characters; and (0,0.1.1) the pair of nodes contains 11 characters with common prefix "com.alipay." and since 55>33>11, the node pair with the largest common prefix can be extracted as (0,0.2), and since node 0 is ranked in the front in (0,0.2), 0 is selected as the master node.
S106, acquiring a common prefix of each other node except the main node and the main node in the original link structure log;
specifically, after the master node is acquired through step S104, prefix matching is then performed on each of the other nodes in the original link structure log, except for the master node, with the master node, and a common prefix of each of the other nodes with the master node is acquired.
For example, after randomly selecting 0.2 from (0,0.2) as the master node, prefix matching is performed on 3 nodes of 0,0.1, 0.1.1 and 0.2, to obtain 55 characters in total of a common prefix included in the pair of nodes of (0.2,0) and 33 characters in total of a common prefix included in the pair of nodes of (0.2, 0.1); and (0.2,0.1.1) the pair of nodes contains a common prefix of "com.
In an optional implementation manner of the present application, after the original link structure log is sorted according to the method signature, a common prefix of every two adjacent nodes in the sorted original link structure log is obtained, and therefore, the common prefix of every two adjacent nodes can also be obtained as a common prefix of a node and the master node that are sorted in the two adjacent nodes.
For example, the nodes in the original link structure log are arranged after being sequenced to obtain 55 characters in total, where a common prefix included in the adjacent node (0,0.2) is "com.alipay.pcardcore.common.util.cache.cachenger.get", and since 0.2 is sequenced later and 0 is a master node, it can be determined that the common prefix of (0,0.2) is the above 55 characters; accordingly, the adjacent node (0.2,0.1) includes 33 characters with a common prefix "com.alipay.pcardcore.common.util.", and since 0.1 is ordered later and 0 is the master node, it can be determined that the common prefix of (0,0.1) is the above 33 characters; and the adjacent node (0.1,0.1.1) contains 11 characters of common prefix "com.alipay.", and based on the same reason, the common prefix of (0,0.1.1) can be determined to be the 11 characters.
S108, compressing the obtained common prefix of each other node and the main node to obtain a compressed link structure log.
Specifically, the obtained common prefix of each other node and the master node can be compressed in a gzip compression mode or the like, so that a compressed link structure log is obtained; because only the common prefix of each other node and the main node is compressed, but the content of the main node and each other node except the common prefix corresponding to the node is not compressed, the content of the main node and each other node except the common prefix corresponding to the node can be obtained from the compressed link structure log; that is, in the compressed link structure log, all contents of the master node and contents other than the common prefix corresponding to each other node are in an uncompressed state.
In an optional implementation manner, when compressing the common prefix, which is obtained by compressing the common prefix that each other node except the master node and the master node have, the content of the common prefix that each other node and the master node have may be compressed to a length value of the common prefix corresponding to the node.
For example, the common prefixes of 3 pairs of nodes are respectively 55>33>11, and thus, the node pair with the largest common prefix is selected as the node pair (0,0.2) corresponding to 55, and 0 or 0.2 is used as the master node; if 0 is taken as the main node, compressing the common prefixes corresponding to 0.1,0.1.1 and 0.2, so that the content compression of the common prefix corresponding to 0.1 is 33 of the length of the common prefix of (0, 0.1); the content of the common prefix corresponding to 0.1.1 is compressed into (0,0.1.1), and the length of the common prefix is 11; the content of the common prefix corresponding to 0.1 is compressed into the length of the common prefix of (0,0.2) which is 55; the compressed link structure log is specifically as follows:
0,com.alipay.pcardcore.common.util.cache.Cachemanger.getKeyStrategy(1)
0.2,{55}Cachemanger.getobject(3)
0.1,{33}drm.manager.DrmResourceManager.findResourceByName(2)
0.1.1,{11}imock.core.pool.contorller.EnvContorller.isProd()
as can be seen from the above, since the content of the common prefix of each other node and the master node is compressed to the length value of the common prefix corresponding to the node, all the content of each other node is restored through the compressed length value and the master node.
For example, taking 0.2 in the compressed link structure log as an example, since the compressed content of the common prefix corresponding to 0.2 is 55, the content of the first 55 characters is selected from the content of the master node 0 and is filled into the content of 0.2, so that 0.2, {55} cachenger. getobject (3) is reduced to 0.2, com.alipay. pcardcore. common. u.u.u.he. cachemanger. getobject (3), and the above operation is performed on each other node except the master node in the compressed link structure log, so that all the content of each other node can be reduced; therefore, the compressed link structure log can be read while ensuring a certain compression ratio.
In a second aspect, based on the same inventive concept, an embodiment of this specification provides an apparatus for compressing a link structure log, please refer to fig. 2, including:
an original log obtaining unit 201, configured to obtain an original link structure log generated by one-time invocation, where the original link structure log includes node information of multiple nodes;
a master node selecting unit 202, configured to extract a node pair with a largest common prefix from the original link structure log, and select a node from the node pair with the largest common prefix as a master node;
a common prefix obtaining unit 203, configured to obtain a common prefix between each other node in the original link structure log, except for the master node, and the master node;
a compressing unit 204, configured to compress the obtained common prefix between each other node and the master node, so as to obtain a compressed link structure log.
In an optional manner, the master node selecting unit 202 is further configured to sort the original link structure logs according to the method signatures, and obtain two top nodes in the sorted original link structure logs as the node pair with the largest common prefix.
In an optional manner, the master node selecting unit 202 is further configured to select a node ranked before from the ranked original link structure logs as the master node.
In an optional manner, the master node selecting unit 202 is further configured to compare node contents of every two nodes in the original link structure log during processing of each task of the current batch processing by executing all threads, so as to obtain a comparison result; and extracting the node pairs with the maximum common prefix according to the comparison result.
In an optional manner, the compressing unit 204 is further configured to compress the content of the common prefix that each other node has with the master node to the length value of the common prefix corresponding to the node.
In a third aspect, based on the same inventive concept as the method for compressing the link structure log in the foregoing embodiment, the present invention further provides a server, as shown in fig. 3, including a memory 304, a processor 302, and a computer program stored on the memory 304 and executable on the processor 302, wherein the processor 302 executes the program to implement the steps of any one of the methods for processing the batch processing task described above.
Where in fig. 3 a bus architecture (represented by bus 300), bus 300 may include any number of interconnected buses and bridges, bus 300 linking together various circuits including one or more processors, represented by processor 302, and memory, represented by memory 304. The bus 300 may also link together various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. Bus interface 305305 provides an interface between bus 300 and receiver 301 and transmitter 303. The receiver 301 and the transmitter 303 may be the same element, i.e., a transceiver, providing a means for communicating with various other apparatus over a transmission medium. The processor 302 is responsible for managing the bus 300 and general processing, and the memory 304 may be used for storing data used by the processor 302 in performing operations.
In a fourth aspect, based on the inventive concept of the compression method of the link structure log as in the previous embodiments, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, realizes the steps of any one of the methods of the compression method of the link structure log as described above.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present specification have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all changes and modifications that fall within the scope of the specification.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present specification without departing from the spirit and scope of the specification. Thus, if such modifications and variations of the present specification fall within the scope of the claims of the present specification and their equivalents, the specification is intended to include such modifications and variations.