A method, device, equipment and storage medium for automatically saving a mirror image
By building a dictionary tree to automatically identify and record effective change commands for containers, a clear dockerfile is generated, which solves the problems of redundant images and unclear content when saving containers, and improves the storage efficiency and manageability.
Patent Information
- Application Number
- CN202111453309.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2041-12-01
AI Technical Summary
When storing containers, the prior art results in redundant mirroring and the added tools and installation packages cannot be clearly displayed, affecting subsequent iterations and development efficiency.
By building a dictionary tree, it automatically recognizes and records the user's effective change commands, and iterates the nodes of the dictionary tree in real time to generate a clear dockerfile to save the container.
Reduces the probability of redundant files and no hierarchy in the image, can clearly display all effective change commands, and improves the efficiency and manageability of container storage.
Smart Images

Figure CN114371958B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of autonomous driving technology, and in particular to a method, device, equipment and storage medium for automatically saving a mirror image subject. Background Art
[0002] Currently, the way to preserve the modified contents of the container is to save it through the official container operation instructions. The saving process is to treat all modifications in the read-write layer after the container is created as a new image layer, thereby generating a new image.
[0003] However, the method of saving containers by calling the official container operation instructions has the following defects:
[0004] When people pack all the changes into one layer, there are not only many cache files left by users when debugging and running tasks, which makes the new image bloated, but also this way of saving cannot show what tools and installation packages are added like the image building of Dockerfile. This results in users (including the user who saved the container) not being able to clearly understand the content of the image when reusing it after a period of time, which is not conducive to subsequent iterations.
[0005] Many public documents point out that the best way to save containers is Dockerfile. However, in the actual work process of users, they often want to save containers after a period of experimentation, or temporarily save containers for reconstruction when there is a need to migrate clusters or nodes. For each container, if users are required to manually record the tools they want to add and rewrite them into Dockerfile every time they operate, it is difficult to achieve and will also affect the development efficiency of users' own projects.
[0006] Therefore, the current way to achieve the purpose of container preservation in the industry is still to call the official container operation instructions to preserve the container. Summary of the invention
[0007] To this end, the technical problem solved by the embodiments of the present application is to provide a method, device, equipment and storage medium for automatic preservation of an image body, which can automatically identify and record the user's valid modification commands, and iterate the valid modification commands in real time. This can not only greatly reduce the probability of redundant files and no layering in the final image, but also clearly display all valid modification commands to the user when using Dockerfile to save the container.
[0008] In order to solve the above technical problems, the technical solutions adopted in this application are as follows:
[0009] In a first aspect, an embodiment of the present application provides a method for automatically saving an image subject, comprising:
[0010] S1: Get all index bodies related to the last valid modification command;
[0011] S2: constructing a dictionary tree based on the last valid modification information of all last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond one to one;
[0012] S3: according to the last valid modification command input by the user, obtaining the last valid modification information of the index subject corresponding to the last valid modification command;
[0013] S4: iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body;
[0014] S5: converting the last valid modification command into a Dockerfile according to the user's request to save the container;
[0015] S6: Store the Dockerfile and create a new image based on the Dockerfile.
[0016] Further, the S4 includes:
[0017] Determine whether the last valid modification information corresponding to the index body is consistent with the last valid modification information corresponding to the index body:
[0018] If yes, then replace the previous valid modification information corresponding to the index body with the next valid modification information corresponding to the index body;
[0019] If not, a new node corresponding to the last valid modification information of the index body is created in the dictionary tree.
[0020] Furthermore, the S1 includes:
[0021] S11: Obtain the last valid modification information of all the index entities;
[0022] S12: identifying each of the previous valid change information, and obtaining the recognition results corresponding to each of the previous valid change information; and creating nodes corresponding to each of the recognition results corresponding to each of the previous valid change information one by one according to the recognition results corresponding to each of the previous valid change information;
[0023] S13: Use data stream to connect each node to form a dictionary tree.
[0024] Preferably, S11' is further included between S11 and S12, and S11' includes:
[0025] Sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information;
[0026] The S13 includes:
[0027] Data streams are used to connect each node according to the hierarchical relationship to form a dictionary tree.
[0028] More preferably, S11" is further included between S11 and S12, and S11" includes:
[0029] Define a starting node.
[0030] Preferably, the last valid change information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S12 includes:
[0031] S121: converting the previous path of the index subject into a first character string group consisting of a plurality of first character strings, where the first character strings are used to correspond to the name of the index subject of the current layer;
[0032] S122: setting the current subscript to point to the first first string in the first string group, and traversing each first string in sequence according to the arrangement order of the first strings in the first string group;
[0033] S123: For the first string pointed to by the current subscript, determine whether the pointed-to first string exists in the child node mapping key of the current dictionary tree pointer:
[0034] If yes, point the current dictionary tree pointer to the child node pointer corresponding to the corresponding child node mapping key, and then continue to move the subscript of the first string group to the next first string of the first string group;
[0035] If not, create a new child node with the current dictionary tree pointer as the parent node.
[0036] More preferably, the creating a new child node with the current dictionary tree pointer as the parent node includes:
[0037] Create a new child node, assign the path of the index body of the new child node to be the merged path of the path recorded by the node pointed to by the current dictionary tree pointer and the current first string, assign the last modification time of the index body of the new child node to be the most recent modification time of the merged path queried in the container, and assign the sub-index body of the new child node to be an empty set;
[0038] Add the mapping relationship of <first string, new child node pointer address> to the mapping key value table of the current node, then reset the current dictionary tree pointer to the starting node of the dictionary tree, and continue to traverse the valid change information of the next row.
[0039] Furthermore, the last valid modification information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S3 includes:
[0040] S31: sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information;
[0041] S32: Set a Boolean variable that records the change status of the last valid modification information; assign a value to the Boolean variable, the value being true or false, wherein true indicates that the last valid modification information has been changed, and false indicates that the last valid modification information has not been changed, and the initial value of the Boolean variable is false.
[0042] Preferably, the S4 includes:
[0043] S41: converting the subsequent path of the index subject into a second string group consisting of a plurality of strings, where the second string is used to correspond to the index subject name of the current layer;
[0044] S42: setting the current index to the first second character string in the second character string group, and traversing each second character string according to the arrangement order of the second character strings in the second character string group;
[0045] S43: For the second string pointed to by the current subscript, determine whether the second string pointed to by the current subscript exists in the child node mapping key of the current dictionary tree pointer:
[0046] If yes, execute S44;
[0047] If not, change the value of the Boolean variable from false to true, and then create a new child node;
[0048] S44: Determine whether the pointed second string is the last string of the second string group:
[0049] If yes, execute S45;
[0050] If not, execute S46;
[0051] S45: Determine that the last path of the index body is a complete path, detect the latest update time of the complete path of the corresponding index body stored in the dictionary tree, and determine whether the latest update time of the complete path of the corresponding index body is the same as the last modification time:
[0052] If so, keep the value of the Boolean variable as false, and do not change the latest update time of the complete path of the corresponding index body in the dictionary tree;
[0053] If not, change the value of the Boolean variable from false to true, and change the latest update time of the complete path of the corresponding index body in the dictionary tree to the last modification time;
[0054] S46: If the next path of the index body is determined to be an incomplete path, the current dictionary tree pointer is pointed to the child node pointer corresponding to the corresponding child node mapping key, and then the subscript of the second string group is continuously moved to the next second string of the second string group.
[0055] More preferably, the S3 further includes S33, and the S33 includes:
[0056] S331: according to the hierarchical relationship of the last valid modification information, obtain the last path of the index body of the last valid modification information of the previous row and the last path of the index body of the last valid modification information of the current row;
[0057] S332: Compare the next path of the index body of the next valid modification information of the previous row with the next path of the index body of the next valid modification information of the current row to obtain the next path difference;
[0058] The S4 also includes S47, and the S47 includes:
[0059] S471: converting the subsequent path difference into a second character string group consisting of a plurality of second character strings, where the second character strings are used to correspond to the index subject name of the current layer;
[0060] S472: setting the current index to the first second character string in the second character string group, and traversing each second character string in the order in which the second character strings are arranged in the second character string group, and repeating S43 to S46.
[0061] Preferably, the S5 includes:
[0062] S51: Create a new Dockerfile file in the reserved context folder;
[0063] S52: traverse all the last valid modification information, and determine whether the initial letter combination of the format of the current last valid modification information is cp or mv:
[0064] If yes, add the source index body corresponding to the last valid change information to the Dockerfile through the context folder;
[0065] If not, add a run that conforms to the dockerfile syntax before the current and last valid change information to form a new dockerfile statement, and add the new dockerfile statement and the current and last valid change information; the corresponding source index body is added to the dockerfile;
[0066] S53: Display the Dockerfile and all the last valid modification information to the user.
[0067] In a second aspect, an embodiment of the present application provides a device for automatically saving an image body, comprising:
[0068] A first acquisition module is used to acquire all index bodies related to the last valid modification command;
[0069] A construction module, used to construct a dictionary tree of the last valid modification information based on all the last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond to each other one by one;
[0070] A second acquisition module, configured to acquire, according to the last valid modification command input by the user, the last valid modification information of the index subject corresponding to the last valid modification command;
[0071] A processing module, used for iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body;
[0072] The conversion module is used to convert the valid modification command into a Dockerfile according to the user's request to save the container;
[0073] The storage and creation module is used to store Dockerfile and create a new image based on Dockerfile.
[0074] In a third aspect, an embodiment of the present application provides a device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of any one of the above-mentioned methods for automatically saving an image body when executing the computer program.
[0075] In a fourth aspect, an embodiment of the present application provides a storage medium, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the step of automatically saving the image body of any one of the above items is implemented.
[0076] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:
[0077] 1. In an embodiment of the present application, a dictionary tree based on the last valid change information of all the index subjects is first constructed; then, according to the judgment result of the last valid change information corresponding to the index subject and the last valid change information corresponding to the index subject, the corresponding node of the dictionary tree is iterated or a new node of the dictionary tree is created. Compared with the existing method of calling the official container operation instructions for container storage, since the last valid change information can be used to replace the last valid change information for node update, the probability of redundant files and no stratification in the final image is reduced. At the same time, compared with the existing dockerfile container storage method, by creating and iterating the nodes of the dictionary tree, all valid change commands can be clearly displayed to the user.
[0078] 2. In the embodiment of the present application, since the last valid change information is still sorted in lexicographical order, when the user traverses the dictionary tree according to the last path of the last valid change information of each row, he only needs to consider whether the complete path of the row is a new path and whether it has the latest update time. For the intermediate path encountered during the search, it must be logically checked by the last valid change information of the previous row, so there is no need to judge each row of valid change information, which greatly improves the recognition efficiency of the last valid change information.
[0079] 3. In the embodiment of the present application, the next path of the index body of the next valid change information of the previous row and the current row is compared to obtain the next path difference, and then the path difference is directly converted into a second string group for traversal, thereby further improving the recognition efficiency of the next valid change information. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] Figure 1 It is a flowchart of a method for automatically saving a mirrored subject provided by the first exemplary embodiment of the present application.
[0081] Figure 2 It is a structural schematic diagram of a mirror body automatic storage device provided by the twelfth exemplary embodiment of the present application.
[0082] Figure 3 It is a structural schematic diagram of a device provided by the thirteenth exemplary embodiment of the present application. DETAILED DESCRIPTION
[0083] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.
[0084] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0085] The term "comprise" and any variations thereof in the specification and claims of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0086] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0087] Terminology explanation:
[0088] A container is a standard software unit that includes file resources, system resources, and development environment dependencies. Each container can directly use the CPU, memory, and hard disk on the physical machine where it is located, and its performance is close to that of a physical machine. Through the virtualization of the operating system layer of the container, all applications use the same operating system to reduce the waste of hardware resources and avoid software conflicts including runtime libraries. In the latest existing architectures, most training tasks need to be completed in containers with the help of distributed training workflows in clusters.
[0089] A container image is a special file system. In addition to providing the programs, libraries, and resource configurations required for the container runtime, it also contains some configuration parameters (e.g., environment variables) prepared for runtime. An image does not contain dynamic data, and its content does not change after it is created. Its essence is the result of multiple image layers being mounted in sequence, and the container's file system is a readable and writable environment added after the image is mounted in read-only mode.
[0090] Container preservation is a method based on the image structure to persist the readable and writable environment as an image layer. It can record the changes in the container and save it as a new image.
[0091] The container file system is a relatively independent organization. The three structures of the read-write part (including the read-write layer and container space), the inner layer and the read-only layer together constitute the lower file system required by a container, and together with the group and namespace environment where the echohello process is located, constitute the container file system.
[0092] The image script file is a script interpreted by the Docker program. It consists of multiple instructions, each of which corresponds to a command in the operating system terminal interface. The Docker program generates a customized image by reading the image script file.
[0093] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0094] Figure 1 The figure shows a method for automatically saving an image subject provided by the first exemplary embodiment of the present application, the method comprising:
[0095] S1: Get all index bodies related to the last valid modification command;
[0096] S2: constructing a dictionary tree based on the last valid modification information of all last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond one to one;
[0097] S3: according to the last valid modification command input by the user, obtaining the last valid modification information of the index subject corresponding to the last valid modification command;
[0098] S4: iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body;
[0099] S5: converting the last valid modification command into a Dockerfile according to the user's request to save the container;
[0100] S6: Store the Dockerfile and create a new image based on the Dockerfile.
[0101] The first exemplary embodiment of the present application first constructs a dictionary tree based on the last valid change information of all the index subjects; then, according to the judgment result of the last valid change information corresponding to the index subject and the last valid change information corresponding to the index subject, it iterates the corresponding node of the dictionary tree or creates a new node of the dictionary tree. Compared with the existing method of calling the official container operation instructions for container storage, since the last valid change information can be used to replace the last valid change information for node update, the probability of redundant files and no stratification in the final image is reduced. At the same time, compared with the existing dockerfile container storage method, by creating and iteratively updating the nodes of the dictionary tree, all valid change commands can be clearly displayed to the user.
[0102] It should be noted that the valid modification command refers to a delete command, a copy command, a modify command and a move command that operate on the readable and writable part of the container.
[0103] It should be noted that the previous valid modification command may refer to the initialized valid modification command, or any valid modification command after the execution of the initialized valid modification command; the subsequent valid modification command is relative to the previous valid modification command, and any valid modification command after the previous valid modification command belongs to the subsequent valid modification command.
[0104] It should be noted that the index subject includes but is not limited to a file or a folder, and may also be any other subject that can implement the method for automatically saving an image subject of the first exemplary embodiment of the present application.
[0105] The second exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the first exemplary embodiment. The difference between the second exemplary embodiment and the first exemplary embodiment is as follows:
[0106] The S4 includes:
[0107] Determine whether the last valid modification information corresponding to the index body is consistent with the last valid modification information corresponding to the index body:
[0108] If yes, then replace the previous valid modification information corresponding to the index body with the next valid modification information corresponding to the index body;
[0109] If not, a new node corresponding to the last valid modification information of the index body is created in the dictionary tree.
[0110] The second exemplary embodiment of the present application creates and iteratively updates the nodes of the dictionary tree by using the consistency judgment between the last valid modification information and the previous valid modification information, so that the dictionary tree can be updated in real time.
[0111] The third exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the second exemplary embodiment. The difference between the third exemplary embodiment and the second exemplary embodiment is as follows:
[0112] The S1 includes:
[0113] S11: Obtain the last valid modification information of all the index entities;
[0114] S12: identifying each of the previous valid change information, and obtaining the recognition results corresponding to each of the previous valid change information; and creating nodes corresponding to each of the recognition results corresponding to each of the previous valid change information one by one according to the recognition results corresponding to each of the previous valid change information;
[0115] S13: Use data stream to connect each node to form a dictionary tree.
[0116] By implementing the third exemplary embodiment of the present application, the construction of the dictionary tree can be accurately and effectively realized. The fourth exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the third exemplary embodiment. The difference between the method and the third exemplary embodiment is as follows:
[0117] S11' is also included between S11 and S12, and S11' includes:
[0118] Sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information;
[0119] The S13 includes:
[0120] Data streams are used to connect each node according to the hierarchical relationship to form a dictionary tree.
[0121] By implementing the fourth exemplary embodiment of the present application, the hierarchy of valid modification commands is clarified, so that all valid modification commands can be displayed to the user in a more intuitive and organized manner.
[0122] The fifth exemplary embodiment of the present application provides a method for automatically saving a mirrored subject, which is further improved on the basis of the fourth exemplary embodiment. The difference between the fifth exemplary embodiment and the fourth exemplary embodiment is as follows:
[0123] S11" is also included between S11 and S12, and S11" includes:
[0124] Define a starting node.
[0125] By implementing the fifth exemplary embodiment of the present application, the organization of displaying effective modification commands can be further improved.
[0126] The sixth exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the fourth exemplary embodiment. The difference between the sixth exemplary embodiment and the fourth exemplary embodiment is as follows:
[0127] The last valid modification information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S12 includes:
[0128] S121: converting the previous path of the index subject into a first character string group consisting of a plurality of first character strings, where the first character strings are used to correspond to the name of the index subject of the current layer;
[0129] S122: setting the current subscript to point to the first first string in the first string group, and traversing each first string in sequence according to the arrangement order of the first strings in the first string group;
[0130] S123: For the first string pointed to by the current subscript, determine whether the pointed-to first string exists in the child node mapping key of the current dictionary tree pointer:
[0131] If yes, point the current dictionary tree pointer to the child node pointer corresponding to the corresponding child node mapping key, and then continue to move the subscript of the first string group to the next first string of the first string group;
[0132] If not, create a new child node with the current dictionary tree pointer as the parent node.
[0133] By implementing a method for automatically saving a mirror body provided by the sixth exemplary embodiment of the present application, it is possible to accurately and comprehensively create nodes of a dictionary tree using the last valid modification information.
[0134] The seventh exemplary embodiment of the present application provides a method for automatically saving a mirrored subject, which is further improved on the basis of the sixth exemplary embodiment. The difference between the seventh exemplary embodiment and the sixth exemplary embodiment is as follows:
[0135] The method of creating a new child node with the current dictionary tree pointer as the parent node includes:
[0136] Create a new child node, assign the path of the index body of the new child node to be the merged path of the path recorded by the node pointed to by the current dictionary tree pointer and the current first string, assign the last modification time of the index body of the new child node to be the most recent modification time of the merged path queried in the container, and assign the sub-index body of the new child node to be an empty set;
[0137] Add the mapping relationship of <first string, new child node pointer address> to the mapping key value table of the current node, then reset the current dictionary tree pointer to the starting node of the dictionary tree, and continue to traverse the valid change information of the next row.
[0138] By implementing the seventh exemplary embodiment of the present application, a new child node is created with the current pointer as the parent node.
[0139] The eighth exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the second exemplary embodiment. The eighth exemplary embodiment of the present application is different from the second exemplary embodiment in the following aspects:
[0140] Furthermore, the last valid modification information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S3 includes:
[0141] S31: sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information;
[0142] S32: Set a Boolean variable that records the change status of the last valid modification information; assign a value to the Boolean variable, the value being true or false, wherein true indicates that the last valid modification information has been changed, and false indicates that the last valid modification information has not been changed, and the initial value of the Boolean variable is false.
[0143] By implementing the eighth exemplary embodiment of the present application, by sorting out the hierarchical relationship of the effective modification information, it is possible to effectively correspond to the hierarchical relationship of the dictionary tree and improve the subsequent judgment efficiency.
[0144] The ninth exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the eighth exemplary embodiment. The difference between the ninth exemplary embodiment and the eighth exemplary embodiment is as follows:
[0145] The S4 includes:
[0146] S41: converting the subsequent path of the index subject into a second string group consisting of a plurality of strings, where the second string is used to correspond to the index subject name of the current layer;
[0147] S42: setting the current index to the first second character string in the second character string group, and traversing each second character string according to the arrangement order of the second character strings in the second character string group;
[0148] S43: For the second string pointed to by the current subscript, determine whether the second string pointed to by the current subscript exists in the child node mapping key of the current dictionary tree pointer:
[0149] If yes, execute S44;
[0150] If not, change the value of the Boolean variable from false to true, and then create a new child node;
[0151] S44: Determine whether the pointed second string is the last string of the second string group:
[0152] If yes, execute S45;
[0153] If not, execute S46;
[0154] S45: Determine that the last path of the index body is a complete path, detect the latest update time of the complete path of the corresponding index body stored in the dictionary tree, and determine whether the latest update time of the complete path of the corresponding index body is the same as the last modification time:
[0155] If so, keep the value of the Boolean variable as false, and do not change the latest update time of the complete path of the corresponding index body in the dictionary tree;
[0156] If not, change the value of the Boolean variable from false to true, and change the latest update time of the complete path of the corresponding index body in the dictionary tree to the last modification time;
[0157] S46: If the next path of the index body is determined to be an incomplete path, the current dictionary tree pointer is pointed to the child node pointer corresponding to the corresponding child node mapping key, and then the subscript of the second string group is continuously moved to the next second string of the second string group.
[0158] By implementing the ninth exemplary embodiment of the present application, since the last valid change information is still sorted in lexicographical order, when the user traverses the dictionary tree according to the last path of the last valid change information of each row, he only needs to consider whether the complete path of the row is a new path and whether it has the latest update time. For the intermediate path encountered during the search, it must be logically checked by the last valid change information of the previous row, so there is no need to judge each row of valid change information, which greatly improves the recognition efficiency of the last valid change information.
[0159] The tenth exemplary embodiment of the present application provides a method for automatically saving an image subject, which is further improved on the basis of the ninth exemplary embodiment. The tenth exemplary embodiment is different from the ninth exemplary embodiment in the following aspects:
[0160] The S3 also includes S33, and the S33 includes:
[0161] S331: according to the hierarchical relationship of the last valid modification information, obtain the last path of the index body of the last valid modification information of the previous row and the last path of the index body of the last valid modification information of the current row;
[0162] S332: Compare the next path of the index body of the next valid modification information of the previous row with the next path of the index body of the next valid modification information of the current row to obtain the next path difference;
[0163] The S4 also includes S47, and the S47 includes:
[0164] S471: converting the subsequent path difference into a second character string group consisting of a plurality of second character strings, where the second character strings are used to correspond to the index subject name of the current layer;
[0165] S472: setting the current index to the first second character string in the second character string group, and traversing each second character string in the order in which the second character strings are arranged in the second character string group, and repeating S43 to S46.
[0166] The tenth exemplary embodiment of the present application obtains the difference in the next path by comparing the next path of the index body of the next valid change information of the previous row and the current row, and then directly converts the path difference into a second string group for traversal, thereby further improving the recognition efficiency of the next valid change information.
[0167] For example, the next path of the index body of the last valid change information of the current row is a / b / c / f. Then, according to the lexicographical order, there must be a / b / c, the next path of the index body of the last valid change information, before a / b / c / f. Therefore, you only need to compare a / b / c / f with a / b / c, and get the difference between the two as / c. Then, convert / c directly into the second string group, and then directly traverse the second string group.
[0168] The tenth exemplary embodiment of the present application provides a method for automatically saving a mirrored subject, which is a further improvement made in all the above embodiments, and the specific improvements are as follows:
[0169] The S5 includes:
[0170] S51: Create a new Dockerfile file in the reserved context folder;
[0171] S52: traverse all the last valid modification information, and determine whether the initial letter combination of the format of the current last valid modification information is cp or mv:
[0172] If yes, add the source index body corresponding to the last valid change information to the Dockerfile through the context folder;
[0173] If not, add a run that conforms to the dockerfile syntax before the current and last valid change information to form a new dockerfile statement, and add the new dockerfile statement and the current and last valid change information; the corresponding source index body is added to the dockerfile;
[0174] S53: Display the Dockerfile and all the last valid modification information to the user.
[0175] By implementing the eleventh exemplary embodiment of the present application, the last valid change information can be effectively converted into a mirror script text and displayed to the user.
[0176] It should be noted that the cp, namely copy, specifically refers to “copy”; the mv, namely move, specifically refers to “move”.
[0177] Figure 2 The twelfth exemplary embodiment of the present application provides an automatic image main body preservation device, which corresponds one-to-one to the automatic image main body preservation method in the above embodiment, and the device includes:
[0178] A first acquisition module is used to acquire all index bodies related to the last valid modification command;
[0179] A construction module, used to construct a dictionary tree of the last valid modification information based on all the last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond to each other one by one;
[0180] A second acquisition module, configured to acquire, according to the last valid modification command input by the user, the last valid modification information of the index subject corresponding to the last valid modification command;
[0181] A processing module, used for iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body;
[0182] The conversion module is used to convert the valid modification command into a Dockerfile according to the user's request to save the container;
[0183] The storage and creation module is used to store Dockerfile and create a new image based on Dockerfile.
[0184] Each module of the above-mentioned automatic image main body preservation device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module above.
[0185] Figure 3 It is a device provided by the thirteenth exemplary embodiment of the present application, and the device is an electronic device. The device can be a server. The device includes a processor, a memory and a communication interface connected by a system bus. Among them, the processor of the device is used to provide computing and control capabilities. The memory of the device can be implemented by any type of volatile or non-volatile storage device or a combination thereof, and the volatile or non-volatile storage device includes but is not limited to: a disk, an optical disk, an EEPROM, an EPROM, an SRAM, a ROM, a magnetic storage, a flash memory, and a PROM. The memory of the device provides an environment for the operation of the operating system and computer programs stored therein. The communication interface of the device is a network interface, and the network interface is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps of the automatic preservation method of the mirror body described in the above embodiment are implemented.
[0186] The fourteenth exemplary embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the automatic preservation method of the mirror body described in the above embodiment are implemented. The storage medium includes but is not limited to: ROM, RAM, CD-ROM, magnetic disk, and floppy disk.
[0187] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device described in the present application is divided into different functional units or modules to complete all or part of the functions described above.
[0188] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for automatically saving an image subject, characterized in that: include: S1: Get all index bodies related to the last valid modification command; S2: constructing a dictionary tree based on the last valid modification information of all last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond one to one; S3: according to the last valid modification command input by the user, obtaining the last valid modification information of the index subject corresponding to the last valid modification command; S4: iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body; S5: converting the last valid modification command into a Dockerfile according to the user's request to save the container; S6: Store the Dockerfile and create a new image based on the Dockerfile.
2. The method for automatically saving an image subject according to claim 1, characterized in that: The S4 includes: Determine whether the last valid modification information corresponding to the index body is consistent with the last valid modification information corresponding to the index body: If yes, then replace the previous valid modification information corresponding to the index body with the next valid modification information corresponding to the index body; If not, a new node corresponding to the last valid modification information of the index body is created in the dictionary tree.
3. The method for automatically saving an image subject according to claim 2, characterized in that: The S1 includes: S11: Obtain the last valid modification information of all the index entities; S12: identifying each of the previous valid change information, and obtaining the recognition results corresponding to each of the previous valid change information; and creating nodes corresponding to each of the recognition results corresponding to each of the previous valid change information one by one according to the recognition results corresponding to each of the previous valid change information; S13: Use data stream to connect each node to form a dictionary tree.
4. The method for automatically saving an image subject according to claim 3, characterized in that: S11' is also included between S11 and S12, and S11' includes: Sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information; The S13 includes: Data streams are used to connect each node according to the hierarchical relationship to form a dictionary tree.
5. The method for automatically saving an image subject according to claim 4, characterized in that: S11" is also included between S11 and S12, and S11" includes: Define a starting node.
6. The method for automatically saving an image subject according to claim 3, characterized in that: The last valid modification information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S12 includes: S121: converting the previous path of the index subject into a first character string group consisting of a plurality of first character strings, where the first character strings are used to correspond to the name of the index subject of the current layer; S122: setting the current subscript to point to the first first string in the first string group, and traversing each first string in sequence according to the arrangement order of the first strings in the first string group; S123: For the first string pointed to by the current subscript, determine whether the pointed-to first string exists in the child node mapping key of the current dictionary tree pointer: If yes, point the current dictionary tree pointer to the child node pointer corresponding to the corresponding child node mapping key, and then continue to move the subscript of the first string group to the next first string of the first string group; If not, create a new child node with the current dictionary tree pointer as the parent node.
7. The method for automatically saving an image subject according to claim 6, characterized in that: The method of creating a new child node with the current dictionary tree pointer as the parent node includes: Create a new child node, assign the path of the index body of the new child node to be the merged path of the path recorded by the node pointed to by the current dictionary tree pointer and the current first string, assign the last modification time of the index body of the new child node to be the most recent modification time of the merged path queried in the container, and assign the sub-index body of the new child node to be an empty set; Add the mapping relationship of <first string, new child node pointer address> to the mapping key value table of the current node, then reset the current dictionary tree pointer to the starting node of the dictionary tree, and continue to traverse the valid change information of the next row.
8. The method for automatically saving an image subject according to claim 2, characterized in that: The last valid modification information includes the last path of the index body, the last modification time of the index body, and the last node of the sub-index body; S3 includes: S31: sorting all the last valid modification information in lexicographic order to obtain the hierarchical relationship of the last valid modification information; S32: Set a Boolean variable that records the change status of the last valid modification information; assign a value to the Boolean variable, the value being true or false, wherein true indicates that the last valid modification information has been changed, and false indicates that the last valid modification information has not been changed, and the initial value of the Boolean variable is false.
9. The method for automatically saving an image subject according to claim 8, characterized in that: The S4 includes: S41: converting the subsequent path of the index subject into a second string group consisting of a plurality of strings, where the second string is used to correspond to the index subject name of the current layer; S42: setting the current index to the first second character string in the second character string group, and traversing each second character string according to the arrangement order of the second character strings in the second character string group; S43: For the second string pointed to by the current subscript, determine whether the second string pointed to by the current subscript exists in the child node mapping key of the current dictionary tree pointer: If yes, execute S44; If not, change the value of the Boolean variable from false to true, and then create a new child node; S44: Determine whether the pointed second string is the last string of the second string group: If yes, execute S45; If not, execute S46; S45: Determine that the last path of the index body is a complete path, detect the latest update time of the complete path of the corresponding index body stored in the dictionary tree, and determine whether the latest update time of the complete path of the corresponding index body is the same as the last modification time: If so, keep the value of the Boolean variable as false, and do not change the latest update time of the complete path of the corresponding index body in the dictionary tree; If not, change the value of the Boolean variable from false to true, and change the latest update time of the complete path of the corresponding index body in the dictionary tree to the last modification time; S46: If the next path of the index body is determined to be an incomplete path, the current dictionary tree pointer is pointed to the child node pointer corresponding to the corresponding child node mapping key, and then the subscript of the second string group is continuously moved to the next second string of the second string group.
10. The method for automatically saving an image subject according to claim 9, characterized in that: The S3 also includes S33, and the S33 includes: S331: according to the hierarchical relationship of the last valid modification information, obtain the last path of the index body of the last valid modification information of the previous row and the last path of the index body of the last valid modification information of the current row; S332: Compare the next path of the index body of the next valid modification information of the previous row with the next path of the index body of the next valid modification information of the current row to obtain the next path difference; The S4 also includes S47, and the S47 includes: S471: converting the subsequent path difference into a second character string group consisting of a plurality of second character strings, where the second character strings are used to correspond to the index subject name of the current layer; S472: setting the current index to the first second character string in the second character string group, and traversing each second character string in the order in which the second character strings are arranged in the second character string group, and repeating S43 to S46.
11. The method for automatically saving an image subject according to any one of claims 1 to 10, characterized in that: The S5 includes: S51: Create a new Dockerfile file in the reserved context folder; S52: traverse all the last valid modification information, and determine whether the initial letter combination of the format of the current last valid modification information is cp or mv, wherein cp means copy; and mv means move: If yes, add the source index body corresponding to the last valid change information to the Dockerfile through the context folder; If not, add a run that conforms to the dockerfile syntax before the current and last valid change information to form a new dockerfile statement, and add the new dockerfile statement and the current and last valid change information; the corresponding source index body is added to the dockerfile; S53: Display the Dockerfile and all the last valid modification information to the user.
12. A device for automatically saving a mirror image, characterized in that: include: A first acquisition module is used to acquire all index bodies related to the last valid modification command; A construction module, used to construct a dictionary tree of the last valid modification information based on all the last valid modification commands, wherein the last valid modification information, the index body, and the nodes of the dictionary tree correspond to each other one by one; A second acquisition module, configured to acquire, according to the last valid modification command input by the user, the last valid modification information of the index subject corresponding to the last valid modification command; A processing module, used for iterating corresponding nodes of the dictionary tree or creating new nodes of the dictionary tree according to the judgment result of the last valid modification information corresponding to the index body and the previous valid modification information corresponding to the index body; The conversion module is used to convert the valid modification command into a Dockerfile according to the user's request to save the container; The storage and creation module is used to store Dockerfile and create a new image based on Dockerfile.
13. A device, characterized in that The method comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein when the processor executes the computer program, the steps of the method for automatically saving the mirror body as described in any one of claims 1 to 11 are implemented.
14. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the step of automatically saving the mirror body as described in any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Index structure based on dictionary tree, data query optimization method and main memory manager
CN110347685A
File directory storage method, retrieval method and device
WO2013097115A1