CN115328497A - File merging method and device, electronic equipment and readable storage medium - Google Patents

File merging method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN115328497A
CN115328497A CN202211041979.8A CN202211041979A CN115328497A CN 115328497 A CN115328497 A CN 115328497A CN 202211041979 A CN202211041979 A CN 202211041979A CN 115328497 A CN115328497 A CN 115328497A
Authority
CN
China
Prior art keywords
segment
target
newly added
merged
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211041979.8A
Other languages
Chinese (zh)
Inventor
解志达
李辉
何朝斌
马恩杰
徐玮
魏臻
时安然
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202211041979.8A priority Critical patent/CN115328497A/en
Publication of CN115328497A publication Critical patent/CN115328497A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a file merging method and device, electronic equipment and a readable storage medium, relates to the internet technology, and particularly relates to the fields of cloud native application, file merging and Helm Chart. The specific implementation scheme comprises the following steps: and acquiring the newly added file fragment and the target file fragment corresponding to the newly added file fragment. And acquiring segment parameters of the newly added file segments, wherein the segment parameters are used for indicating the preset merging rules corresponding to the newly added file segments. And merging the newly added file segments into the target file segments according to the segment parameters. As the user only needs to provide the newly added file segments, the newly added file segments can be merged into the target file segments, and the target file is updated. The technical threshold of file merging is reduced, and the problems possibly occurring in merging are reduced.

Description

File merging method and device, electronic equipment and readable storage medium
Technical Field
The disclosure relates to the internet technology, in particular to the fields of cloud native application, file merging and Helm Chart.
Background
Deployment of applications on a cloud platform by a helmholper (Kubernetes, K8 s) system is a common method for implementing cloud native applications. When the cloud native application is deployed on K8s, the application can be deployed on K8s based on a steering wheel (Helm) tool and according to the parameters imported by a Chart (Chart) data packet for deploying the application.
At present, when a user needs to modify Helm Chart, the Helm Chart needs to be edited integrally, the operation difficulty is high, and errors are easy to occur.
Disclosure of Invention
The disclosure provides a file merging method, a file merging device, an electronic device and a readable storage medium, which can merge Helm Chart written by a user with other Helm Chart, reduce the technical threshold of modifying the Helm Chart and reduce errors occurring when the Helm Chart is modified.
According to a first aspect of the present disclosure, there is provided a file merging method, including: and acquiring the newly added file fragment and the target file fragment corresponding to the newly added file fragment. And acquiring segment parameters of the newly added file segments, wherein the segment parameters are used for indicating the preset merging rules corresponding to the newly added file segments. And merging the newly added file segments into the target file segments according to the segment parameters.
According to a second aspect of the present disclosure, there is provided a file merging apparatus including: and the acquisition module is used for acquiring the newly added file fragments and the target file fragments corresponding to the newly added file fragments. The acquisition module is further used for acquiring segment parameters of the newly added file segments, and the segment parameters are used for indicating the preset merging rules corresponding to the newly added file segments. And the merging module is used for merging the newly added file segments into the target file segments according to the segment parameters.
According to a third aspect of the present disclosure, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as provided in the first aspect.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method provided according to the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method provided according to the first aspect.
The method comprises the steps of obtaining a newly added file segment and a target file segment corresponding to the newly added file segment. And acquiring a preset merging rule corresponding to the newly added file fragment according to the fragment parameter of the newly added file fragment. And finally, merging the newly added file segments into the target file segments according to the segment parameters. As the user only needs to provide the newly added file segments, the newly added file segments can be merged into the target file segments, and the target file is updated. The technical threshold of file merging is reduced, and the problems possibly occurring in merging are reduced.
It should be understood that the statements in this section are not intended to identify key or critical features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a schematic flowchart of a file merging method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of S130 in a file merging method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of S210 when the segment types are hash dictionaries and complex arrays in a file merging method according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram of file merging when a segment type is a hash dictionary in a file merging method according to an embodiment of the present disclosure;
fig. 5 is a schematic diagram of file merging when a fragment type is a complex array in a file merging method according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram of file merging when a segment type is a simple array in a file merging method according to an embodiment of the present disclosure;
fig. 7 is a schematic composition diagram of a file merging device according to an embodiment of the present disclosure;
FIG. 8 shows a schematic block diagram of an example electronic device 800 that may be used to implement embodiments of the present disclosure;
fig. 9 is a schematic diagram of file merging when a fragment type is a range template in a file merging method according to an embodiment of the present disclosure;
fig. 10 is a schematic composition diagram of a file merging device according to an embodiment of the present disclosure;
FIG. 11 shows a schematic block diagram of an example electronic device 1100 that may be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Deployment of applications on a cloud platform through a K8s system is a common method for implementing cloud native applications. At present, when a cloud native application is deployed on K8s, the deployment of the application on K8s can be realized by importing parameters for deploying the application according to a Chart package based on a hellm tool.
However, because the writing of the Chart packet is complex, a great deal of effort is needed to learn how to write, when the generated Chart packet is modified, the sentences in the generated Chart packet need to be rewritten, the technical threshold is high, and most people cannot master and use the Chart packet.
In view of this, the present application provides a file merging method, including: and acquiring the newly added file fragment and the target file fragment corresponding to the newly added file fragment. And acquiring segment parameters of the newly added file segments, wherein the segment parameters are used for indicating the preset merging rules corresponding to the newly added file segments. And merging the newly added file segments into the target file segments according to the segment parameters.
As the user only needs to provide the newly added file segments, the newly added file segments can be merged into the target file segments, and the target file is updated. The technical threshold of file merging is reduced, and the problems possibly occurring in merging are reduced.
Fig. 1 is a schematic flowchart of a file merging method according to an embodiment of the present disclosure. The method can be applied to electronic equipment, and the electronic equipment can be a smart phone, a tablet computer, a notebook computer, a desktop computer or a customized terminal and the like. The operating system of these devices may be an Android (Android) system, a Windows (Windows) system, an apple Mobile operating system (iOS), an apple operating system (Mac OS) or a Hongmon OS (Harmony OS), a Linnaus system (Linux), and the like, and the disclosure is not limited thereto.
In this application, a file is taken as a Chart package in hellm Chart as an example, and a file merging method is described, as shown in fig. 1, the file merging method includes:
s110, acquiring the newly added file fragment and the target file fragment corresponding to the newly added file fragment.
In some embodiments, the newly added file fragment (extension) may be an incomplete hellmchart template fragment. Helm Chart can be considered a relaxed Markup Language (yaml) formatted file, and yaml refers to a template sentence written in Go template Language. Target file fragments (target charges, target) are also called base templates, which are the Chart templates to be merged. The target file segment may be a complete Chart template, or a template that can be completed only after extension is incorporated. The target document fragment may also be a new template merged by the base template and extension. For example, if the target file segment a + the newly added file segment a1= the target file segment b; target file segment b + new file segment b1= target file segment c. And when the newly added file segment a1 is merged into the target file segment a to obtain a target file segment b, the target file segment a is the base template. And when the newly added file segment b1 is merged into the target file segment b to obtain a target file segment c, the target file segment b is a base template.
And S120, acquiring fragment parameters of the newly added file fragments.
In some embodiments, the segment parameter is used to indicate a preset merge rule corresponding to the newly added file segment.
In this disclosure, different newly added file segments correspond to different preset merging rules, and the preset merging rules are used to indicate how to specifically merge some newly added file segments. For example, when the newly added file segment is divided into configuration classes such as configuration files (ConfigMap) and secret (secret) by the production requirement, the newly added file segment may be added to the tail of the target file segment for merging, since the configuration class file does not need to consider the volume in principle. For other types of resources, the corresponding statements in the target file segment can be matched according to the types and names (names) contained in the newly added file segments, and replacement and combination can be performed.
And S130, merging the newly added file segments into the target file segments according to the segment parameters.
In some embodiments, after the preset merging rule is determined according to the segment parameter, the newly added file segments are merged into the target file segments according to the preset merging rule.
In this embodiment, the newly added file segment and the target file segment corresponding to the newly added file segment are obtained. And acquiring a preset merging rule corresponding to the newly added file fragment according to the fragment parameter of the newly added file fragment. And finally, merging the newly added file segments into the target file segments according to the segment parameters. As the user only needs to provide the newly added file segments, the newly added file segments can be merged into the target file segments, and the target file is updated. The technical threshold of file merging is reduced, and the problems possibly occurring in merging are reduced.
Fig. 2 is a schematic flowchart of S130 in a file merging method according to an embodiment of the present disclosure.
In some embodiments, the fragment parameters include: segment type, segment identifier, segment start stop line, and routing information.
Referring to fig. 2, merging the newly added file segments into the target file segment according to the segment parameters includes:
s210, determining a corresponding preset merging rule according to the fragment type.
In some embodiments, the fragment types may include a hash dictionary (hash), a simple array (simple list), a complex array (complex list), a range template, a single line template, and so forth. Different fragment types correspond to a preset combination rule.
Fig. 3 is a schematic flowchart of S210 when the segment types are hash dictionaries and complex arrays in the file merging method according to the embodiment of the present disclosure.
In some embodiments, referring to fig. 3, when the fragment type is a hash dictionary and a complex array, S210 includes:
and S310, matching sentences with the same segment identifiers in the target segments to be merged according to the corresponding segment identifiers.
In some embodiments, the fragment identifier may be an Identity document (id), a key name (key), a name (name), or the like. The fragment identifier may be used to distinguish other nodes at the same level.
Fig. 4 is a schematic diagram of file merging when a segment type is a hash dictionary in a file merging method according to an embodiment of the present disclosure, and fig. 5 is a schematic diagram of file merging when a segment type is a complex array in a file merging method according to an embodiment of the present disclosure.
Referring to fig. 4, where key _ a _ b1 is a key name, it can be used as a fragment identifier in fig. 4. Referring to fig. 5, where name: a. name: b. name: d may be used as a fragment identifier.
And S320, if the sentences with the same segment identifiers exist, replacing the parameters in the newly added file segments into the target segments to be merged.
In some embodiments, referring to fig. 4, the value of key _ a _ b1 in the newly added file segment is value2', and the value of key _ a _ b1 in the target segment to be merged is value2. The preset merge rule is to replace value2 with value 2'.
S330, if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
In some embodiments, referring to fig. 5, the added file segment includes a name: d, and the target fragment to be merged does not include the name: d. then the preset merge rule is to merge the name: dvalus: str _4 is added to the target file segment.
In this embodiment, the file merging can be performed more accurately by determining whether to perform replacement or addition in the target segment to be merged by the segment identifier.
Fig. 6 is a schematic diagram of file merging when a segment type is a simple array in a file merging method according to an embodiment of the present disclosure.
In some embodiments, when the segment type is a simple array, parameters in the newly added file segment are replaced into the target segment to be merged according to the routing information.
Referring to fig. 6, the key _ a in the newly added file fragment has three parameters: srt _1', srt _2', srt _3'. There are also three parameters under key _ a in the target fragment to be merged: srt _1, srt _2, srt _3. Then the preset merging rule is to replace srt _1, srt _2 and srt _3 correspondingly with srt _1', srt _2' and srt _3'.
In this embodiment, when the segment type is a simple array, parameters in the newly added file segment are replaced into the target segment to be merged according to the routing information, so that file merging can be performed more accurately.
In some embodiments, because Helm Chart is approximately viewed as a relaxed yaml formatted file, template statements are referred to in yaml. Template statements can be divided into two categories, one being range templates and one being single line templates. The scope template includes template statements beginning with "if", "range", "with", "define", etc., and corresponding to "end". The single line template is the other template statement of the non-range template.
In some embodiments, when the fragment type is a single-line template, the level of the single-line template may be determined according to the indentation of the single-line template.
The Helm-Chart can still use indentation to determine the level relationship, and when "{ { xxx | nindent n } }, { { xxx | indent n } }" exists in the template statement, n is regarded as indentation, wherein for { -xxx } }, 0 indentation is regarded. Statements with the same indentation are considered to be the same level.
And if no statement exists in the corresponding hierarchy, adding the statement in the newly added file segment to the corresponding hierarchy in the target segment to be merged. And if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
Fig. 7 is a schematic diagram of file merging when the fragment type is a single-line template in a file merging method according to an embodiment of the present disclosure.
Referring to fig. 7, the single-line template in the newly added document fragment is "somePorts: the main is main. "somePorts: main: main "is indented to 1. The target segment to be merged includes a level indented to 1, which is not subordinate to the "spec" level. In this case, "somePorts: main "is added directly to the end of the corresponding hierarchy in the target fragment to be merged.
In this embodiment, when the fragment type is the single-line template, the level of the single-line template is determined according to the indentation of the single-line template, and the merging rule is determined according to whether a statement exists in the level, so that file merging can be performed more accurately.
In some embodiments, when the segment type is a range template and the target template statement includes a segment identifier, statements having the same segment identifier are matched in the target segment to be merged according to the corresponding segment identifier. And if the sentences with the same fragment identifiers exist, replacing the parameters in the newly added file fragments into the target fragments to be merged. And if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
Fig. 8 is a schematic diagram of file merging when a fragment type is a range template in a file merging method according to an embodiment of the present disclosure.
By way of example, referring to fig. 8, the range templates in the newly added file segment are:
{{-if.Values.havaSpec}}
Spec:
somePorts:
main:main
{{-end}}
here, the fragment identifier "if" is attributed to "spec", but the fragment identifier of "if" is not present in the target fragments to be merged. In this case, the range template in the newly added file segment may be directly added to the end of "spec" in the target segment to be merged.
In this embodiment, when the segment type is the range template and the target template statement includes the segment identifier, it is determined whether to perform replacement or addition in the target segment to be merged by the segment identifier, so that file merging can be performed more accurately.
In some implementations, when the fragment type is a scope template and the target template statement does not include a fragment identifier, the scope template can be treated as a single-line template.
The level of the scope template is determined according to the indentation of the scope template. And if no statement exists in the corresponding level, adding the statement in the newly added file segment to the corresponding level in the target segment to be merged. And if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
Fig. 9 is a schematic diagram of file merging when a fragment type is a range template in a file merging method according to an embodiment of the present disclosure.
By way of example, referring to fig. 9, the range templates in the newly added file segment are:
spec:
somePorts:
{{-range.Values.ports}}
{{.key}}:{{.values}}
{{-end}}
wherein no fragment identifier is included. In this case, the indentation of "somePorts" may be determined to be 1, and the value under "somePorts" in the newly added file fragment is merged to the end under "somePorts" in the target fragment to be merged according to the routing information and the indentation of "somePorts".
In this embodiment, when the type of the segment is the range template and the target template sentence does not include the segment identifier, the range template may be treated as a single-line template, that is, the level of the range template is determined according to the indentation of the range template, and the merging rule is determined according to whether the sentence exists in the level, so that the file merging may be performed more accurately.
S220, in the target file segment, determining a target segment to be merged according to the segment start-stop line and the routing information.
In some embodiments, as an example, the following is described by taking a complex array as an example:
if the complex array is:
A:
AA:www
AB:
-key:key1
value:values1
-key:key2
value:values2
start-stop behavior a: value is values2.Key1 has routing information of A → AA → AB.
And according to the start-stop line and the routing information, positioning the corresponding target fragment to be merged in the target file fragment.
And S230, combining the newly added file segment and the target segment to be combined according to a preset combination rule.
In some embodiments, the newly added file segment may be merged with the target segment to be merged according to the preset merging rule shown in S210.
In some embodiments, the merging of the newly added file segment and the target segment to be merged is described by taking a hash, a simple array, and a complex array as examples.
For example, the first line to the last line of the newly added file segment may be taken as a root to be stacked, and then it is determined whether the segment type of the newly added file segment that is popped out of the stack is hash, simple array, or complex array.
And if the fragment is the hash or the single object in the complex array, judging whether the popped fragment exists in the target fragment to be merged. And if not, inserting the target fragments to be merged according to the routing information. And if the hash exists, and the popped fragment exists in the target fragment to be merged, pushing each key in the ash. And if the target fragment is the simple array, replacing the corresponding parameters in the target fragment to be merged according to the routing information. If the complex array is adopted, each segment identifier in the complex array is pushed. And repeating the steps until the stack is empty.
In this embodiment, a corresponding preset merging rule is determined according to the type of the segment, and the newly added file segment is merged with the target segment to be merged according to the preset merging rule, so that the technical threshold of file merging can be more effectively reduced, and problems that may occur during merging are further reduced.
It should be noted that, the combination manner of the range template and the single line template is already described in S210, and is not described herein again.
In an exemplary embodiment, an embodiment of the present disclosure further provides a file merging device, which may be used to implement the file merging method provided in the foregoing embodiment.
Fig. 10 is a schematic composition diagram of a file merging device according to an embodiment of the present disclosure.
As shown in fig. 10, a file merging apparatus includes: the obtaining module 1001 is configured to obtain a newly added file segment and a target file segment corresponding to the newly added file segment. The obtaining module 1001 is further configured to obtain a segment parameter of the newly added file segment, where the segment parameter is used to indicate a preset merging rule corresponding to the newly added file segment. The merging module 1002 is configured to merge the newly added file segments into the target file segments according to the segment parameters.
In some embodiments, the fragment parameters include: segment type, segment identifier, segment start stop line, and routing information. The merging module 1002 is specifically configured to determine a corresponding preset merging rule according to the fragment type. And in the target file segment, determining a target segment to be merged according to the segment start-stop line and the routing information. And merging the newly added file segment and the target segment to be merged according to a preset merging rule.
In some embodiments, the merging module 1002 is specifically configured to, when the fragment type is a hash dictionary and a complex array, match statements having the same fragment identifier in the target fragment to be merged according to the corresponding fragment identifier. And if the sentences with the same segment identifiers exist, replacing the parameters in the newly added file segments into the target segments to be merged. And if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
In some embodiments, the merging module 1002 is specifically configured to, when the fragment type is a simple array, replace a parameter in the newly added file fragment into the target fragment to be merged according to the routing information.
In some embodiments, the merge module 1002 is specifically configured to determine the level of the single-line template according to the indentation of the single-line template when the fragment type is the single-line template. And if no statement exists in the corresponding hierarchy, adding the statement in the newly added file segment to the corresponding hierarchy in the target segment to be merged. And if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
In some embodiments, the merging module 1002 is specifically configured to, when the segment type is a range template and the target template statement includes a segment identifier, match statements having the same segment identifier in the target segments to be merged according to the corresponding segment identifier. And if the sentences with the same fragment identifiers exist, replacing the parameters in the newly added file fragments into the target fragments to be merged. And if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
In some embodiments, the merging module 1002 is specifically configured to determine the level of the scope template according to the indentation of the scope template when the type of the segment is the scope template and the target template statement does not include the segment identifier. And if no statement exists in the corresponding level, adding the statement in the newly added file segment to the corresponding level in the target segment to be merged. And if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, and do not violate the customs of public sequences.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method as provided in the above embodiments.
In an exemplary embodiment, the readable storage medium may be a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method according to the above embodiments.
In an exemplary embodiment, the computer program product comprises a computer program which, when executed by a processor, implements a method according to the provision in the above embodiments.
FIG. 11 shows a schematic block diagram of an example electronic device 1100 that may be used to implement embodiments of the present disclosure.
Electronic devices are intended to represent various forms of digital computers, such as, for example, in-car computers, laptop computers, tablet computers, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 11, the device 1100 comprises a computing unit 1101, which may perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a Random Access Memory (RAM) 1103. In the RAM 1103, various programs and data necessary for the operation of the device 1100 may also be stored. The calculation unit 1101, the ROM 1102, and the RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
A number of components in device 1100 connect to I/O interface 1105, including: an input unit 1106 such as a keyboard, a mouse, and the like; an output unit 1107 such as various types of displays, speakers, and the like; a storage unit 1108 such as a magnetic disk, optical disk, or the like; and a communication unit 1109 such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 1109 allows the device 1100 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
The computing unit 1101 can be a variety of general purpose and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 1101 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and the like. The calculation unit 1101 performs the respective methods and processes described above, such as a page rendering method. For example, in some embodiments, the page rendering method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 1105. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 1100 via ROM 1102 and/or communication unit 1109. When the computer program is loaded into RAM 1103 and executed by the computing unit 1101, one or more steps of the page rendering method described above may be performed. Alternatively, in other embodiments, the computing unit 1101 may be configured to perform the file merging method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program code, when executed by the processor or controller, causes the functions/acts specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (17)

1. A method for merging files, the method comprising:
acquiring a newly added file segment and a target file segment corresponding to the newly added file segment;
acquiring segment parameters of the newly added file segments, wherein the segment parameters are used for indicating a preset merging rule corresponding to the newly added file segments;
and merging the newly-added file segments into the target file segments according to the segment parameters.
2. The method of claim 1, wherein the segment parameters comprise: segment type, segment identifier, segment start stop line, and routing information;
merging the newly added file segments into the target file segments according to the segment parameters, including:
determining a corresponding preset merging rule according to the fragment type;
in the target file segment, determining a target segment to be merged according to the segment start-stop line and the routing information;
and merging the newly added file segment and the target segment to be merged according to the preset merging rule.
3. The method according to claim 2, wherein the determining the corresponding preset merge rule according to the fragment type comprises:
when the fragment types are Hash dictionaries and complex arrays, matching sentences with the same fragment identifiers in the target fragments to be merged according to the corresponding fragment identifiers;
if the sentences with the same segment identifiers exist, replacing parameters in the newly added file segments into the target segments to be merged;
and if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
4. The method according to claim 2, wherein the determining the corresponding preset merge rule according to the fragment type comprises:
and when the fragment type is a simple array, replacing parameters in the newly added file fragments into the target fragments to be merged according to the routing information.
5. The method according to claim 2, wherein the determining the corresponding preset merge rule according to the fragment type comprises:
when the fragment type is a single-line template, judging the level of the single-line template according to the indentation of the single-line template;
if no statement exists in the corresponding level, adding the statement in the newly added file segment to the corresponding level in the target segment to be merged;
and if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
6. The method according to claim 2, wherein the determining the corresponding preset merge rule according to the segment type comprises:
when the fragment type is a range template and a target template statement comprises the fragment identifier, matching statements with the same fragment identifier in the target fragment to be merged according to the corresponding fragment identifier;
if the sentences with the same segment identifiers exist, replacing parameters in the newly added file segments into the target segments to be merged;
and if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragments to be merged.
7. The method according to claim 2, wherein the determining the corresponding preset merge rule according to the fragment type comprises:
when the fragment type is a range template and the target template statement does not comprise the fragment identifier, judging the level of the range template according to the indentation of the range template;
if no statement exists in the corresponding level, adding the statement in the newly added file segment to the corresponding level in the target segment to be merged;
and if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
8. A file merging apparatus, comprising:
the acquisition module is used for acquiring newly added file fragments and target file fragments corresponding to the newly added file fragments;
the acquisition module is further used for acquiring fragment parameters of the newly added file fragments, and the fragment parameters are used for indicating preset merging rules corresponding to the newly added file fragments;
and the merging module is used for merging the newly-added file segments into the target file segments according to the segment parameters.
9. The apparatus of claim 8, wherein the segment parameters comprise: segment type, segment identifier, segment start stop row, and routing information;
the merging module is specifically configured to determine a corresponding preset merging rule according to the fragment type;
in the target file segment, determining a target segment to be merged according to the segment start-stop line and the routing information;
and merging the newly added file segment and the target segment to be merged according to the preset merging rule.
10. The apparatus according to claim 9, wherein the merging module is specifically configured to, when the segment types are hash dictionaries and complex arrays, match statements having the same segment identifier in the target segments to be merged according to the corresponding segment identifier;
if the sentences with the same segment identifiers exist, replacing parameters in the newly added file segments into the target segments to be merged;
and if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragment to be merged.
11. The apparatus according to claim 9, wherein the merging module is specifically configured to, when the segment type is a simple array, replace a parameter in the newly added file segment with the target segment to be merged according to the routing information.
12. The apparatus according to claim 9, wherein the merging module is specifically configured to determine the level of the single-line template according to the indentation of the single-line template when the fragment type is the single-line template;
if no statement exists in the corresponding level, adding the statement in the newly added file segment to the corresponding level in the target segment to be merged;
and if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
13. The apparatus according to claim 9, wherein the merging module is specifically configured to, when the segment type is a range template and a target template statement includes the segment identifier, match a statement with the same segment identifier in the target segment to be merged according to the corresponding segment identifier;
if the sentences with the same segment identifiers exist, replacing parameters in the newly added file segments into the target segments to be merged;
and if the sentences with the same fragment identifiers do not exist, adding the sentences in the newly added file fragments to the tail of the target fragment to be merged.
14. The apparatus of claim 9, wherein the merging module is specifically configured to determine a level of the scope template according to an indentation of the scope template when the type of the segment is a scope template and the target template sentence does not include the segment identifier;
if no statement exists in the corresponding hierarchy, adding the statement in the newly added file segment to the corresponding hierarchy in the target segment to be merged;
and if the sentences exist in the corresponding levels, adding the sentences in the newly added file segments to the tail of the corresponding levels in the target segments to be merged.
15. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method according to any one of claims 1-7.
17. A computer program product, characterized in that it comprises a computer program which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202211041979.8A 2022-08-29 2022-08-29 File merging method and device, electronic equipment and readable storage medium Pending CN115328497A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211041979.8A CN115328497A (en) 2022-08-29 2022-08-29 File merging method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211041979.8A CN115328497A (en) 2022-08-29 2022-08-29 File merging method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115328497A true CN115328497A (en) 2022-11-11

Family

ID=83927480

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211041979.8A Pending CN115328497A (en) 2022-08-29 2022-08-29 File merging method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115328497A (en)

Similar Documents

Publication Publication Date Title
CN113342345A (en) Operator fusion method and device of deep learning framework
CN113836314B (en) Knowledge graph construction method, device, equipment and storage medium
CN112528641A (en) Method and device for establishing information extraction model, electronic equipment and readable storage medium
CN113392346A (en) Path processing method and device for resource file, electronic equipment and storage medium
CN112508115A (en) Method, apparatus, device and computer storage medium for building node representation model
CN111597107A (en) Information output method and device and electronic equipment
CN113869046B (en) Method, device and equipment for processing natural language text and storage medium
CN115408034A (en) Vehicle-mounted controller upgrading method and device, electronic equipment and storage medium
CN115328497A (en) File merging method and device, electronic equipment and readable storage medium
CN114138358A (en) Application program starting optimization method, device, equipment and storage medium
CN111931524B (en) Method, apparatus, device and storage medium for outputting information
CN113987118A (en) Corpus acquisition method, apparatus, device and storage medium
CN111292205B (en) Judicial data analysis method, device, equipment and storage medium
CN113869042A (en) Text title generation method and device, electronic equipment and storage medium
CN112487765A (en) Method and device for generating notification text
CN112559547A (en) Method and device for determining consistency among multiple storage object copies
CN112541346A (en) Abstract generation method and device, electronic equipment and readable storage medium
CN114281981B (en) News brief report generation method and device and electronic equipment
CN113822057B (en) Location information determination method, location information determination device, electronic device, and storage medium
CN115965018B (en) Training method of information generation model, information generation method and device
CN112989797B (en) Model training and text expansion methods, devices, equipment and storage medium
CN117411939A (en) Serialized data analysis method, device, equipment and storage medium
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN117407468A (en) Method and device for displaying generated content, electronic equipment and storage medium
CN113254826A (en) Dump file processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination