WO2021174836A1 - Differential package generation method and apparatus, computer device, and storage medium - Google Patents

Differential package generation method and apparatus, computer device, and storage medium Download PDF

Info

Publication number
WO2021174836A1
WO2021174836A1 PCT/CN2020/119049 CN2020119049W WO2021174836A1 WO 2021174836 A1 WO2021174836 A1 WO 2021174836A1 CN 2020119049 W CN2020119049 W CN 2020119049W WO 2021174836 A1 WO2021174836 A1 WO 2021174836A1
Authority
WO
WIPO (PCT)
Prior art keywords
character string
character
group
file
string group
Prior art date
Application number
PCT/CN2020/119049
Other languages
French (fr)
Chinese (zh)
Inventor
李桃
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021174836A1 publication Critical patent/WO2021174836A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Definitions

  • This application relates to the technical field of software upgrades, and in particular to a differential packet generation method, device, computer device, and computer storage medium.
  • Differential upgrade is one of the main ways to upgrade the software of electronic equipment.
  • the main process of using the differential upgrade method to upgrade the software is: calculate the different parts of the new file and the old file of the software to be upgraded, pack and compress the different parts into a differential package (ie upgrade patch), and send the differential package to the electronic device. Combine the difference package and the old file of the software to be upgraded into a new file.
  • the inventor has realized that the difference packet generated by the existing difference packet generation algorithm is relatively large, and it takes a long time to generate the difference packet.
  • a differential packet generation method includes:
  • the sequence number combination in the first character string group is a sequence number array
  • the difference value combination corresponding to the second character string is a difference value array
  • a differential packet generating device includes:
  • An obtaining module used to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
  • the first dividing module is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file into The first string group;
  • the second dividing module is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into The second string group;
  • the search module is used to search for similar character strings of each second character string in the second character string group from the first character string group, and to compare each second character in the second character string group
  • the sequence number combination of similar character strings in the first character string group is a sequence number array
  • the calculation module is used to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character
  • the difference combination corresponding to each second character string in the string group is a difference array
  • the compression module is used to compress the sequence number array and the difference value array into a difference packet.
  • a computer device includes a processor, and the processor implements the following steps when the processor is used to execute a computer program stored in a memory:
  • the sequence number combination in the first character string group is a sequence number array
  • the difference value combination corresponding to the second character string is a difference value array
  • the fourth aspect of the present application provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the sequence number combination in the first character string group is a sequence number array
  • the difference value combination corresponding to the second character string is a difference value array
  • the difference packet of the present application includes the sequence number array and the difference value array, and occupies a small storage space; it also reduces the time for generating the difference packet of the present invention, so the present invention reduces the size of the difference packet and improves the generation The efficiency of the differential package.
  • Fig. 1 is a flowchart of a differential packet generation method provided by an embodiment of the present application.
  • Fig. 2 is a structural diagram of a differential packet generating device provided by an embodiment of the present application.
  • Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • the differential packet generation method of the present application is applied to one or more computer devices.
  • the computer device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions.
  • Its hardware includes, but is not limited to, a microprocessor and an application specific integrated circuit (ASIC) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), embedded equipment, etc.
  • ASIC application specific integrated circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Processor
  • embedded equipment etc.
  • the computer device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the computer device can interact with the user through a keyboard, a mouse, a remote control, a touch panel, or a voice control device.
  • FIG. 1 is a flowchart of a differential packet generation method provided in Embodiment 1 of the present application.
  • the differential packet generation method is applied to a computer device.
  • the differential package generating method generates a differential package for software upgrade.
  • the differential packet generation method includes:
  • the version information of the software to be upgraded may be obtained from a mobile phone terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library to obtain the The old file of the software to be upgraded; searching for the file of the latest version of the software to be upgraded from a local version file library to obtain the new file of the software to be upgraded.
  • the local version file library stores multiple historical versions of the software to be upgraded and files of the latest version.
  • the local version file library can store files with the version information of the given software to be upgraded as V1.0.0, V1.0.1, and V1.0.2.
  • the files with version information of V1.0.0 and V1.0.1 are files of two historical versions of the given software to be upgraded, and the file with version information of V1.0.2 is the file of the latest version of the given software to be upgraded.
  • the version information of the software to be upgraded may be obtained from a computer terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library, and all files are obtained.
  • the method before the obtaining the old file and the new file of the software to be upgraded, the method further includes:
  • the client uses a given hash algorithm to hash the old file to obtain the description information of the old file; the old file in the local version of the file library is hashed to get the local The description information of the old file; if the description information of the client’s old file is consistent with that of the local old file, the old file is valid; if the description of the client’s old file is inconsistent with the local old file’s description, the old file is inconsistent.
  • the file is illegal.
  • the separator in the old file may include: line break, space character, tab character, etc.
  • the old file is divided into multiple first strings according to the space characters in the old file, where the content of the old file is "I am not robot", and the multiple first strings obtained are ⁇ "I",” am”,”not”,”robot” ⁇ .
  • the combining the plurality of first character strings according to the order in the old file into a first character string group includes:
  • the multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
  • the content of the old file is "I am not robot, he is a robot", and the multiple first strings obtained are ⁇ "I”,”am”,”not”,”robot”,”,”,” he”,”is”,”a”,”robot” ⁇ .
  • the foremost first character string among the repeated first character strings may be retained in the order of the preceding and the next, and the first character strings other than the foremost first character string among the repeated first character strings may be deleted.
  • the delimiters in the new file may include: line breaks, space characters, tabs, and so on.
  • the old file is divided into multiple first strings according to the space characters in the new file, where the content of the new file is "I am a robot", and the multiple first strings obtained are ⁇ "I",” am",”a”,”robot” ⁇ .
  • a second string in the second string group is "pingan", the number of characters in the second string is 6, the 0th character is “p”, the first character is “i”, and the number of characters in the second string is 6.
  • Two characters are “n”, the third character is “g”, the fourth character is "a”, and the fifth character is "n”.
  • One of the first string in the first string group is "pintai”, the number of characters in the first string is 6, the 0th character is "p”, the first character is "i”, the second is The character is "n”, the third character is "t”, the fourth character is "a”, and the fifth character is "i".
  • An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of each second character string in the second character string group and the intermediate binary value of similar character strings of the second character string.
  • a second character string is "pingan”
  • the intermediate binary value of the second character string is "0000000111000011010011101110110011111000011101110”.
  • the similar character string of the second character string is "pintai”
  • the intermediate binary value of the similar character string of the second character string is "1110000110100111011101100111111010011000011101001”.
  • An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of the second character string and the intermediate binary value of the similar character string of the second character string as "1110000001100100001110001001001001100000000000111".
  • the bzip2 algorithm may be used to compress the difference array into a difference file, compress the serial number array into a serial number file, and combine the difference file and the serial number file into a difference package. Before compressing the difference value array, the binary value in the difference value array may be converted into a hexadecimal value.
  • sequence number array may not be compressed, and the difference file and the sequence number array are combined into one difference package.
  • the client When the client receives the difference packet, it can decompress the difference packet, and decompress the difference value array and the sequence number array.
  • the old file is divided into multiple character strings according to the separator in the old file in the client, the multiple character strings are combined into a third character string group according to the order in the old file, and the The binary value combination of the third string group is a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
  • the differential package generation method of the first embodiment obtains the old file and the new file of the software to be upgraded, the old file and the new file are text files; the old file is divided into a plurality of files according to the separator in the old file A first character string, combining the plurality of first character strings according to the order in the old file into a first character string group; dividing the new file into a plurality of first character strings according to the separator in the new file Two character strings, combining the multiple second character strings according to the order in the new file into a second character string group; searching for each of the second character string groups from the first character string group Similar character strings of a second character string, combining the sequence numbers of similar character strings of each second character string in the second character string group in the first character string group into a sequence number array; The difference between each second character string in the two character string group and the similar character string of the second character string in the first character string group, and each second character in the second character string group The difference value combination corresponding to the string is a difference value array; the sequence number
  • the method further includes:
  • the differential package is sent to the client, so that the client generates the new file according to the differential package and the old file.
  • the difference package includes a difference file and a serial number file. Decompressing the difference package can obtain the difference value array and the serial number array.
  • Customers can divide the old file into multiple character strings according to the separator in the old file in the client, and combine the multiple character strings into a third character string group according to the order in the old file, Combine the binary values of the third character string group into a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
  • the method further includes:
  • the differential package can be sent to each distributed server, and when the client requests the differential package, the differential package can be returned to the client through the distributed server to increase the download of the client. efficient.
  • Fig. 2 is a structural diagram of a differential packet generating device provided in the second embodiment of the present application.
  • the differential packet generating device 20 is applied to a computer device.
  • the difference package generation of this device is to generate a difference package for software upgrade.
  • the differential packet generating device 20 may include an acquisition module 201, a first division module 202, a second division module 203, a search module 204, a calculation module 205, and a compression module 206.
  • the obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, and the old files and the new files are text files.
  • the version information of the software to be upgraded may be obtained from a mobile phone terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library to obtain the The old file of the software to be upgraded; searching for the file of the latest version of the software to be upgraded from a local version file library to obtain the new file of the software to be upgraded.
  • the local version file library stores multiple historical versions of the software to be upgraded and files of the latest version.
  • the local version file library can store files with the version information of the given software to be upgraded as V1.0.0, V1.0.1, and V1.0.2.
  • the files with version information of V1.0.0 and V1.0.1 are files of two historical versions of the given software to be upgraded, and the file with version information of V1.0.2 is the file of the latest version of the given software to be upgraded.
  • the version information of the software to be upgraded may be obtained from a computer terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library, and all files are obtained.
  • the method before the obtaining the old file and the new file of the software to be upgraded, the method further includes:
  • the client uses a given hash algorithm to hash the old file to obtain the description information of the old file; the old file in the local version of the file library is hashed to obtain the local The description information of the old file; if the description information of the client’s old file is consistent with that of the local old file, the old file is valid; if the description of the client’s old file is inconsistent with the local old file’s description, the old file is inconsistent.
  • the file is illegal.
  • the first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group.
  • the separator in the old file may include: line break, space character, tab character, etc.
  • the old file is divided into multiple first strings according to the space characters in the old file, where the content of the old file is "I am not robot", and the multiple first strings obtained are ⁇ "I",” am”,”not”,”robot” ⁇ .
  • the combining the plurality of first character strings according to the order in the old file into a first character string group includes:
  • the multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
  • the content of the old file is "I am not robot, he is a robot", and the multiple first strings obtained are ⁇ "I”,”am”,”not”,”robot”,”,”,” he”,”is”,”a”,”robot” ⁇ .
  • the foremost first character string among the repeated first character strings may be retained in the order of the preceding and the next, and the first character strings other than the foremost first character string among the repeated first character strings may be deleted.
  • the second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group.
  • the delimiters in the new file may include: line breaks, space characters, tabs, and so on.
  • the old file is divided into multiple first strings according to the space characters in the new file, where the content of the new file is "I am a robot", and the multiple first strings obtained are ⁇ "I",” am",”a”,”robot” ⁇ .
  • the search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group.
  • the sequence number combination of similar character strings of the character string in the first character string group is a sequence number array.
  • a second character string in the second character string group is "pingan", the number of characters in the second character string is 6, the 0th character is “p”, the first character is “i”, and the first character is “i”.
  • Two characters are "n”, the third character is “g”, the fourth character is "a”, and the fifth character is "n”.
  • One of the first string in the first string group is "pintai”, the number of characters in the first string is 6, the 0th character is "p”, the first character is "i”, the second is The character is "n”, the third character is "t”, the fourth character is "a”, and the fifth character is "i".
  • the calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group.
  • the difference combination corresponding to each second character string in the character string group is a difference array.
  • An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of each second character string in the second character string group and the intermediate binary value of similar character strings of the second character string.
  • a second character string is "pingan”
  • the intermediate binary value of the second character string is "0000000111000011010011101110110011111000011101110”.
  • the similar character string of the second character string is "pintai”
  • the intermediate binary value of the similar character string of the second character string is "1110000110100111011101100111111010011000011101001”.
  • An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of the second character string and the intermediate binary value of the similar character string of the second character string as "1110000001100100001110001001001001100000000000111".
  • the compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
  • the bzip2 algorithm may be used to compress the difference array into a difference file, compress the serial number array into a serial number file, and combine the difference file and the serial number file into a difference package. Before compressing the difference value array, the binary value in the difference value array may be converted into a hexadecimal value.
  • sequence number array may not be compressed, and the difference file and the sequence number array are combined into one difference package.
  • the client When the client receives the difference packet, it can decompress the difference packet, and decompress the difference value array and the sequence number array.
  • the old file is divided into multiple character strings according to the separator in the old file in the client, the multiple character strings are combined into a third character string group according to the order in the old file, and the The binary value combination of the third string group is a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
  • the differential package generating device 20 of the second embodiment obtains the old file and the new file of the software to be upgraded, the old file and the new file are text files; the old file is divided into multiple files according to the separator in the old file.
  • a first character string combining the multiple first character strings according to the order in the old file into a first character string group; dividing the new file into a plurality of characters according to the separator in the new file
  • a second character string combining the multiple second character strings according to the order in the new file into a second character string group; searching for the second character string group in the first character string group
  • the similar character strings of each second character string, the sequence numbers of the similar character strings of each second character string in the second character string group in the first character string group are combined into a sequence number array;
  • the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group is calculated by dividing each second character string in the second character string group
  • the difference value combination corresponding to the character string is
  • the differential packet generating device 20 may further include: a sending module, configured to send the differential packet to the client in response to a download request from the client, so that the client can perform the The difference package and the old file generate the new file.
  • a sending module configured to send the differential packet to the client in response to a download request from the client, so that the client can perform the The difference package and the old file generate the new file.
  • the difference package includes a difference file and a serial number file. Decompressing the difference package can obtain the difference value array and the serial number array.
  • Customers can divide the old file into multiple character strings according to the separator in the old file in the client, and combine the multiple character strings into a third character string group according to the order in the old file, Combine the binary values of the third character string group into a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
  • the differential packet generating device 20 may further include: a distribution module, configured to distribute the differential packet to a server.
  • the differential package can be sent to each distributed server, and when the client requests the differential package, the differential package can be returned to the client through the distributed server to increase the download of the client. efficient.
  • This embodiment provides a computer storage medium on which a computer program is stored.
  • the steps in the embodiment of the differential packet generation method described above are implemented, for example, 101-106 shown in FIG. 1:
  • each module in the above-mentioned device embodiment is realized, for example, the modules 201-206 in Fig. 2:
  • the obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
  • the first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group;
  • the second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group;
  • the search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group.
  • the sequence number combination of similar character strings of the character string in the first character string group is an array of sequence numbers;
  • the calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group.
  • the difference combination corresponding to each second character string in the character string group is a difference array;
  • the compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
  • FIG. 3 is a schematic diagram of a computer device provided in Embodiment 4 of this application.
  • the computer device 30 includes a memory 301, a processor 302, and a computer program 303 that is stored in the memory 301 and can run on the processor 302, such as a differential packet generation program.
  • the processor 302 executes the computer program 303, the steps in the embodiment of the above-mentioned differential packet generation method are implemented, for example, 101-106 shown in Fig. 1:
  • each module in the above-mentioned device embodiment is realized, for example, the modules 201-206 in Fig. 2:
  • the obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
  • the first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group;
  • the second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group;
  • the search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group.
  • the sequence number combination of similar character strings of the character string in the first character string group is an array of sequence numbers;
  • the calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group.
  • the difference combination corresponding to each second string in the string group is a difference array;
  • the compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
  • the computer program 303 may be divided into one or more modules, and the one or more modules are stored in the memory 301 and executed by the processor 302 to complete the method.
  • the one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 303 in the computer device 30.
  • the computer program 303 can be divided into the acquisition module 201, the first division module 202, the second division module 203, the search module 204, the calculation module 205, and the compression module 206 in FIG. 2.
  • the specific functions of each module refer to the embodiments. two.
  • the computer device 30 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the schematic diagram 3 is only an example of the computer device 30 and does not constitute a limitation on the computer device 30. It may include more or less components than those shown in the figure, or combine certain components, or be different.
  • the computer device 30 may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 302 may be a central processing unit (Central Processing Unit, CPU), other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor can be a microprocessor or the processor 302 can also be any conventional processor, etc.
  • the processor 302 is the control center of the computer device 30, which uses various interfaces and lines to connect the entire computer device 30. Various parts.
  • the memory 301 can be used to store the computer program 303, and the processor 302 implements the computer device by running or executing the computer program or module stored in the memory 301 and calling data stored in the memory 301 30 various functions.
  • the memory 301 may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; the storage data area may Data (such as audio data, etc.) created according to the use of the computer device 30 and the like are stored.
  • the memory 301 may include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • non-volatile memory such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • the integrated module of the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through a computer program.
  • the computer program can be stored in a computer storage medium. When executed by the processor, the following steps can be implemented:
  • the sequence number combination in the first character string group is a sequence number array
  • the difference value combination corresponding to the second character string is a difference value array
  • the computer program includes computer program code
  • the computer program code may be in the form of source code, object code, executable file, or some intermediate forms.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) .
  • modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional modules in the various embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware, or in the form of hardware plus software functional modules.
  • the above-mentioned integrated modules implemented in the form of software functional modules may be stored in a computer-readable storage medium, and the computer-readable storage medium may be volatile or non-volatile.
  • the above-mentioned software function module is stored in a storage medium and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor execute the following steps:
  • the sequence number combination in the first character string group is a sequence number array
  • the difference value combination corresponding to the second character string is a difference value array
  • all the above-mentioned data can also be stored in a node of a blockchain.
  • the serial number array and the difference value array, etc. these data can be stored in the blockchain node.
  • the blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.

Landscapes

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

Abstract

A differential package generation method and a related device. The method comprises: acquiring an old file and a new file of software to be upgraded; dividing the old file into a plurality of first character strings, and combining the plurality of first character strings into a first character string group according to the order in the old file; dividing the new file into a plurality of second character strings, and combining the plurality of second character strings into a second character string group according to the order in the new file; combining sequence numbers in the first character string group of a similar character string of each second character string in the second character string group into a sequence number array; calculating the difference value of each second character string in the second character string group and a similar character string of the second character string in the first character string group, and combining a difference value corresponding to each second character string in the second character string group into a difference value array (105); and compressing the sequence number array and the difference value array into a differential package (106). The present method improves the efficiency of generating a differential package.

Description

差分包生成方法方法、装置、计算机设备及存储介质Differential packet generation method, device, computer equipment and storage medium
本申请要求于2020年3月4日提交中国专利局、申请号为CN202010144853.8,发明名称为“差分包生成方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on March 4, 2020, the application number is CN202010144853.8, and the invention title is "Differential Packet Generation Method and Related Equipment", the entire content of which is incorporated herein by reference Applying.
技术领域Technical field
本申请涉及软件升级技术领域,具体涉及一种差分包生成方法、装置、计算机装置及计算机存储介质。This application relates to the technical field of software upgrades, and in particular to a differential packet generation method, device, computer device, and computer storage medium.
背景技术Background technique
差分升级是电子设备软件升级的一种主要方式。用差分升级方法升级软件的主要过程为:计算出待升级软件的新文件和老文件的不同部分,将不同部分打包压缩成差分包(即升级补丁),将差分包发送给电子设备,电子设备将差分包和待升级软件的老文件合并成新文件。然而,发明人意识到现有的差分包生成算法生成的差分包较大,生成差分包耗费的时间较长。Differential upgrade is one of the main ways to upgrade the software of electronic equipment. The main process of using the differential upgrade method to upgrade the software is: calculate the different parts of the new file and the old file of the software to be upgraded, pack and compress the different parts into a differential package (ie upgrade patch), and send the differential package to the electronic device. Combine the difference package and the old file of the software to be upgraded into a new file. However, the inventor has realized that the difference packet generated by the existing difference packet generation algorithm is relatively large, and it takes a long time to generate the difference packet.
发明内容Summary of the invention
一种差分包生成方法,所述方法包括:A differential packet generation method, the method includes:
获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
一种差分包生成装置,所述装置包括:A differential packet generating device, the device includes:
获取模块,用于获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;An obtaining module, used to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
第一划分模块,用于根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;The first dividing module is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file into The first string group;
第二划分模块,用于根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;The second dividing module is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into The second string group;
查找模块,用于从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;The search module is used to search for similar character strings of each second character string in the second character string group from the first character string group, and to compare each second character in the second character string group The sequence number combination of similar character strings in the first character string group is a sequence number array;
计算模块,用于计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;The calculation module is used to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character The difference combination corresponding to each second character string in the string group is a difference array;
压缩模块,用于将所述序号数组和所述差值数组压缩为差分包。The compression module is used to compress the sequence number array and the difference value array into a difference packet.
一种计算机装置,所述计算机装置包括处理器,所述处理器用于执行存储器中存储的计算机程序时实现如下步骤:A computer device includes a processor, and the processor implements the following steps when the processor is used to execute a computer program stored in a memory:
获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
本申请的第四方面提供一种计算机存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:The fourth aspect of the present application provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
本申请的差分包包括所述序号数组和所述差值数组,所占存储空间小;也就减少了生成本发明的差分包的时间,所以本发明减小了差分包的大小和提升了生成差分包的效率。The difference packet of the present application includes the sequence number array and the difference value array, and occupies a small storage space; it also reduces the time for generating the difference packet of the present invention, so the present invention reduces the size of the difference packet and improves the generation The efficiency of the differential package.
附图说明Description of the drawings
图1是本申请实施例提供的差分包生成方法的流程图。Fig. 1 is a flowchart of a differential packet generation method provided by an embodiment of the present application.
图2是本申请实施例提供的差分包生成装置的结构图。Fig. 2 is a structural diagram of a differential packet generating device provided by an embodiment of the present application.
图3是本申请实施例提供的计算机装置的示意图。Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present application.
具体实施方式Detailed ways
为了能够更清楚地理解本申请的上述目的、特征和优点,下面结合附图和具体实施例对本申请进行详细描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。In order to be able to understand the above objectives, features and advantages of the application more clearly, the application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the application and the features in the embodiments can be combined with each other if there is no conflict.
在下面的描述中阐述了很多具体细节以便于充分理解本申请,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In the following description, many specific details are set forth in order to fully understand the present application. The described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体 的实施例的目的,不是旨在于限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of this application. The terms used in the specification of the application herein are only for the purpose of describing specific embodiments, and are not intended to limit the application.
优选地,本申请的差分包生成方法应用在一个或者多个计算机装置中。所述计算机装置是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。Preferably, the differential packet generation method of the present application is applied to one or more computer devices. The computer device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions. Its hardware includes, but is not limited to, a microprocessor and an application specific integrated circuit (ASIC) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), embedded equipment, etc.
所述计算机装置可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述计算机装置可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。The computer device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The computer device can interact with the user through a keyboard, a mouse, a remote control, a touch panel, or a voice control device.
实施例一Example one
图1是本申请实施例一提供的差分包生成方法的流程图。所述差分包生成方法应用于计算机装置。FIG. 1 is a flowchart of a differential packet generation method provided in Embodiment 1 of the present application. The differential packet generation method is applied to a computer device.
所述差分包生成方法生成用于软件升级的差分包。The differential package generating method generates a differential package for software upgrade.
如图1所示,所述差分包生成方法包括:As shown in Figure 1, the differential packet generation method includes:
101,获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件。101. Obtain an old file and a new file of the software to be upgraded, where the old file and the new file are text files.
在一具体实施例中,可以从手机终端获取所述待升级软件的版本信息;从本地版本文件库查找版本信息与所述手机终端的所述待升级软件的版本信息一致的文件,得到所述待升级软件的所述老文件;从本地版本文件库查找所述待升级软件的最新版本的文件,得到所述待升级软件的所述新文件。本地版本文件库中存储所述待升级软件的多个历史版本和最新版本的文件。In a specific embodiment, the version information of the software to be upgraded may be obtained from a mobile phone terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library to obtain the The old file of the software to be upgraded; searching for the file of the latest version of the software to be upgraded from a local version file library to obtain the new file of the software to be upgraded. The local version file library stores multiple historical versions of the software to be upgraded and files of the latest version.
例如,从一个给定手机终端获取一个给定待升级软件的版本信息为V1.0.1;从本地版本文件库查找版本信息为V1.0.1的文件,得到给定待升级软件的版本信息为V1.0.1的老文件;从本地版本文件库查找给定待升级软件的最新版本的文件,得到给定待升级软件的版本信息为V1.0.2的新文件。本地版本文件库中可以存储给定待升级软件的版本信息为V1.0.0、V1.0.1、V1.0.2的文件。其中版本信息为V1.0.0、V1.0.1的文件为给定待升级软件的两个历史版本的文件,版本信息为V1.0.2的文件为给定待升级软件的最新版本的文件。For example, obtain the version information of a given software to be upgraded from a given mobile phone terminal as V1.0.1; search for a file with version information of V1.0.1 from the local version file library, and obtain the version information of the given software to be upgraded as V1. 0.1 old file; search the file of the latest version of the given software to be upgraded from the local version file library, and get the new file with the version information of the given software to be upgraded as V1.0.2. The local version file library can store files with the version information of the given software to be upgraded as V1.0.0, V1.0.1, and V1.0.2. The files with version information of V1.0.0 and V1.0.1 are files of two historical versions of the given software to be upgraded, and the file with version information of V1.0.2 is the file of the latest version of the given software to be upgraded.
在另一具体实施例中,可以从电脑终端获取所述待升级软件的版本信息;从本地版本文件库查找版本信息与所述手机终端的所述待升级软件的版本信息一致的文件,得到所述待升级软件的所述老文件;从本地版本文件库查找所述待升级软件的最新版本的文件,得到所述待升级软件的所述新文件。In another specific embodiment, the version information of the software to be upgraded may be obtained from a computer terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library, and all files are obtained. The old file of the software to be upgraded; the file of the latest version of the software to be upgraded is searched from a local version file library to obtain the new file of the software to be upgraded.
在另一实施例中,在所述获取待升级软件的老文件和新文件之前,所述方法还包括:In another embodiment, before the obtaining the old file and the new file of the software to be upgraded, the method further includes:
获取所述老文件的描述信息;Obtaining description information of the old file;
根据所述老文件的描述信息判断所述老文件是否合法。Determine whether the old file is legal according to the description information of the old file.
例如,从客户端获取老文件的描述信息,客户端采用给定哈希算法对老文件进行哈希计算可以得到老文件的描述信息;对本地版本文件库中的老文件进行哈希计算得到本地的老文件的描述信息;若客户端的老文件的描述信息与本地的老文件的描述信息一致,则老文件合法;若客户端的老文件的描述信息与本地的老文件的描述信息不一致,则老文件不合法。For example, to obtain the description information of the old file from the client, the client uses a given hash algorithm to hash the old file to obtain the description information of the old file; the old file in the local version of the file library is hashed to get the local The description information of the old file; if the description information of the client’s old file is consistent with that of the local old file, the old file is valid; if the description of the client’s old file is inconsistent with the local old file’s description, the old file is inconsistent. The file is illegal.
102,根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组。102. Divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings according to the order in the old file into a first character string group .
所述老文件中的分隔符可以包括:换行符、空格符和制表符等。The separator in the old file may include: line break, space character, tab character, etc.
例如,根据老文件中的空格符将老文件划分为多个第一字符串,其中,老文件的内容为“I am not robot”,得到的多个第一字符串为{“I”,“am”,“not”,“robot”}。将多个第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4]},其中,b[1]=“I”,b[2]=“am”,b[3]=“not”,b[4]=“robot”。For example, the old file is divided into multiple first strings according to the space characters in the old file, where the content of the old file is "I am not robot", and the multiple first strings obtained are {"I"," am","not","robot"}. Combine multiple first character strings in the order in the old file into a first character string group {b[1],b[2],b[3],b[4]}, where b[1 ]="I", b[2]="am", b[3]="not", b[4]="robot".
在一具体实施例中,所述将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组包括:In a specific embodiment, the combining the plurality of first character strings according to the order in the old file into a first character string group includes:
删除所述多个第一字符串中重复的第一字符串,得到多个去重后的第一字符串;Deleting repeated first character strings in the multiple first character strings to obtain multiple deduplicated first character strings;
将所述多个去重后的第一字符串按照在所述老文件中的顺序组合为所述第一字符串组。The multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
例如,老文件的内容为“I am not robot,he is a robot”,得到的多个第一字符串为{“I”,“am”,“not”,“robot”,“,”,“he”,“is”,“a”,“robot”}。删除多个第一字符串中重复的第一字符串“robot”,得到多个去重后的第一字符串{“I”,“am”,“not”,“robot”,“,”,“he”,“is”,“a”},将多个去重后的第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]},其中,b[1]=“I”,b[2]=“am”,b[3]=“not”,b[4]=“robot”,b[5]=”,”,b[6]=”he”,b[7]=”is”,b[8]=”a”。For example, the content of the old file is "I am not robot, he is a robot", and the multiple first strings obtained are {"I","am","not","robot",","," he","is","a","robot"}. Delete the repeated first string "robot" in multiple first strings, and get multiple deduplicated first strings {"I","am","not","robot",",", "He", "is", "a"}, combine multiple deduplicated first character strings according to the order in the old file into a first character string group {b[1],b[2] ,b[3],b[4],b[5],b[6],b[7],b[8]}, where b[1]="I", b[2]="am ", b[3]="not", b[4]="robot", b[5]=",", b[6]="he", b[7]="is", b[8 ]="a".
可以按照前后顺序保留所述重复的第一字符串中最前的第一字符串,删除所述重复的第一字符串中除最前的第一字符串之外的第一字符串。The foremost first character string among the repeated first character strings may be retained in the order of the preceding and the next, and the first character strings other than the foremost first character string among the repeated first character strings may be deleted.
103,根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组。103. Divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into a second character string group .
所述新文件中的分隔符可以包括:换行符、空格符和制表符等。The delimiters in the new file may include: line breaks, space characters, tabs, and so on.
例如,根据新文件中的空格符将老文件划分为多个第一字符串,其中,新文件的内容为“I am a robot”,得到的多个第一字符串为{“I”,“am”,“a”,“robot”}。将多个第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4]},其中,b[1]=“I”,b[2]=“am”,b[3]=“a”,b[4]=“robot”。For example, the old file is divided into multiple first strings according to the space characters in the new file, where the content of the new file is "I am a robot", and the multiple first strings obtained are {"I"," am","a","robot"}. Combine multiple first character strings in the order in the old file into a first character string group {b[1],b[2],b[3],b[4]}, where b[1 ]="I", b[2]="am", b[3]="a", b[4]="robot".
104,从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组。104. Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similarity of each second character string in the second character string group The sequence number combination of the character string in the first character string group is a sequence number array.
所述从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串包括:The searching for similar character strings of each second character string in the second character string group from the first character string group includes:
(1)对于所述第二字符串组中的任意一个第二字符串A i,确定第二字符串A i包含的字符的数量m i,确定第二字符串A i的各个字符a ix,x=0,1,2,…,m i-1。 (1) For any of the second character string in a second set of string A i, m i is determined the number of the second string of characters included in A i, determining the character of the second string of each A i is a ix, x=0,1,2,...,m i -1.
(2)对于所述第一字符串组中的任意一个第一字符串B j,确定第一字符串B j包含的字符的数量n j,确定第一字符串b j的各个字符b jy,y=0,1,2,…,n j-1。 (2) For any set of the first character string in a first character string B j, B j determines that the character string contains a first number n j, determining a first string of characters in each of b j b jy, y=0,1,2,...,n j -1.
(3)计算第二字符串A i与所述第一字符串组中的每个第一字符串B j的各个中间编辑距离v ij(x+1,y+1),x=0,1,2,…,m i-1,y=0,1,2,…,n j-1: (3) Calculate the respective intermediate edit distances v ij (x+1,y+1) between the second character string A i and each first character string B j in the first character string group, x=0,1 ,2,...,m i -1, y=0,1,2,...,n j -1:
Figure PCTCN2020119049-appb-000001
Figure PCTCN2020119049-appb-000001
其中,v ij(x,0)=x,v ij(0,y)=y,第二字符串A i与所述第一字符串组中的每个第一字符串B j的编辑距离为v ij(m i,n j)。 Wherein, v ij (x, 0) = x, v ij (0, y) = y, the edit distance between the second character string A i and each first character string B j in the first character string group is v ij (m i ,n j ).
例如,第二字符串组中的一个第二字符串为“pingan”,第二字符串包含的字符的数量为6,第0个字符为“p”,第1个字符为“i”,第2个字符为“n”,第3个字符为“g”,第4个字符为“a”,第5个字符为“n”。第一字符串组中的一个第一字符串为“pintai”,第一字符串包含的字符的数量为6,第0个字符为“p”,第1个字符为“i”,第2个字符为“n”,第3个字符为“t”,第4个字符为“a”,第5个字符为“i”。根据上述公式逐个计算中间编辑距离v(1,2)、v(2,1)、v(2,2)、v(2,3)、v(3,2)、v(3,3)、v(3,4)、v(4,3)、v(4,4)、v(4,5)、v(5,4)、v(5,4)、v(5,5)、v(5,6)和v(6,5)。根据上述公式和v(5,6)、v(6,5)计算第 二字符串与第一字符串的编辑距离v(6,6)。For example, a second string in the second string group is "pingan", the number of characters in the second string is 6, the 0th character is "p", the first character is "i", and the number of characters in the second string is 6. Two characters are "n", the third character is "g", the fourth character is "a", and the fifth character is "n". One of the first string in the first string group is "pintai", the number of characters in the first string is 6, the 0th character is "p", the first character is "i", the second is The character is "n", the third character is "t", the fourth character is "a", and the fifth character is "i". Calculate the intermediate edit distances v(1,2), v(2,1), v(2,2), v(2,3), v(3,2), v(3,3), one by one according to the above formula v(3,4), v(4,3), v(4,4), v(4,5), v(5,4), v(5,4), v(5,5), v (5,6) and v(6,5). Calculate the edit distance v(6,6) between the second character string and the first character string according to the above formula and v(5,6) and v(6,5).
(4)从所述第一字符串组中查找与第二字符串A i的编辑距离最小的第一字符串,将所述编辑距离最小的第一字符串作为第二字符串A i的相似字符串。 (4) find the minimum of the first character string and the second string A i of the string edit distance from the first set, the minimum first string edit distance as a second similar string of A i String.
105,计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组。105. Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and combine the second character string in the second character string group The difference combination corresponding to each second character string of is a difference array.
所述计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值包括:The calculating the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group includes:
对所述第二字符串组中的每个第二字符串的二进制值和该第二字符串在所述第一字符串组中的相似字符串的二进制值进行对齐处理,得到所述第二字符串组中的每个第二字符串的中间二进制值和该第二字符串在所述第一字符串组中的相似字符串的中间二进制值。例如,若第二字符串的二进制值和该第二字符串的相似字符串的二进制值的长度不一致,则长度长的二进制值不变,在长度短的二进制值前逐个补零,直到两个二进制值的长度一致,得到长度一致的第二字符串的中间二进制值和第二字符串在第一字符串组中的相似字符串的中间二进制值。Align the binary value of each second character string in the second character string group with the binary value of the second character string in the first character string group to obtain the second character string The intermediate binary value of each second character string in the character string group and the intermediate binary value of the similar character string of the second character string in the first character string group. For example, if the binary value of the second character string is inconsistent with the length of the binary value of the similar character string of the second character string, the long binary value remains unchanged, and zeros are added one by one before the short binary value until two The lengths of the binary values are the same, and the intermediate binary value of the second character string with the same length and the intermediate binary value of the similar character string of the second character string in the first character string group are obtained.
采用异或算法计算所述第二字符串组中的每个第二字符串的中间二进制值与该第二字符串的相似字符串的中间二进制值的差值。An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of each second character string in the second character string group and the intermediate binary value of similar character strings of the second character string.
例如,一个第二字符串为“pingan”,该第二字符串的中间二进制值为“0000000111000011010011101110110011111000011101110”。该第二字符串的相似字符串为“pintai”,该第二字符串的相似字符串的中间二进制值为“1110000110100111011101100111111010011000011101001”。采用异或算法计算该第二字符串的中间二进制值与该第二字符串的相似字符串的中间二进制值的差值为“1110000001100100001110001001001001100000000000111”。For example, if a second character string is "pingan", the intermediate binary value of the second character string is "0000000111000011010011101110110011111000011101110". The similar character string of the second character string is "pintai", and the intermediate binary value of the similar character string of the second character string is "1110000110100111011101100111111010011000011101001". An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of the second character string and the intermediate binary value of the similar character string of the second character string as "1110000001100100001110001001001001100000000000111".
106,将所述序号数组和所述差值数组压缩为差分包。106. Compress the sequence number array and the difference value array into a difference packet.
可以采用bzip2算法将所述差值数组压缩为差分文件,将所述序号数组压缩为序号文件,将所述差分文件和序号文件合并为一个差分包。在压缩所述差值数组之前,可以将所述差值数组中的二进制值转换为十六进制值。The bzip2 algorithm may be used to compress the difference array into a difference file, compress the serial number array into a serial number file, and combine the difference file and the serial number file into a difference package. Before compressing the difference value array, the binary value in the difference value array may be converted into a hexadecimal value.
在另一实施例中,所述序号数组可以不压缩,将所述差分文件和序号数组合并为一个差分包。In another embodiment, the sequence number array may not be compressed, and the difference file and the sequence number array are combined into one difference package.
当客户端接收到差分包时,可以对所述差分包进行解压,解压得到所述差值数组和所述序号数组。根据客户端中的所述老文件中的分隔符将所述老文件划分为多个字符串,将多个字符串按照在所述老文件中的顺序组合为第三字符串组,将所述第三字符串组的二进制值组合为二进制数组。根据所述序号数组查找与所述差值数组中每个二进制值对应的所述二进制数组中的二进制值,将所述差值数组中每个二进制值与该二进制值对应的所述二进制数组中的二进制值进行异或运算,可以得到所述新文件的数组,将所述新文件的数组转换为字符串,得到所述新文件。When the client receives the difference packet, it can decompress the difference packet, and decompress the difference value array and the sequence number array. The old file is divided into multiple character strings according to the separator in the old file in the client, the multiple character strings are combined into a third character string group according to the order in the old file, and the The binary value combination of the third string group is a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
实施例一的差分包生成方法获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;将所述序号数组和所述差值数组压缩为差分包。实施 例一减小了所述差分包的大小和提升生成所述差分包的效率。The differential package generation method of the first embodiment obtains the old file and the new file of the software to be upgraded, the old file and the new file are text files; the old file is divided into a plurality of files according to the separator in the old file A first character string, combining the plurality of first character strings according to the order in the old file into a first character string group; dividing the new file into a plurality of first character strings according to the separator in the new file Two character strings, combining the multiple second character strings according to the order in the new file into a second character string group; searching for each of the second character string groups from the first character string group Similar character strings of a second character string, combining the sequence numbers of similar character strings of each second character string in the second character string group in the first character string group into a sequence number array; The difference between each second character string in the two character string group and the similar character string of the second character string in the first character string group, and each second character in the second character string group The difference value combination corresponding to the string is a difference value array; the sequence number array and the difference value array are compressed into a difference packet. The first embodiment reduces the size of the differential packet and improves the efficiency of generating the differential packet.
在另一实施例中,所述方法还包括:In another embodiment, the method further includes:
响应于客户端的下载请求,将所述差分包发送给所述客户端,使所述客户端根据所述差分包和所述老文件生成所述新文件。In response to the download request of the client, the differential package is sent to the client, so that the client generates the new file according to the differential package and the old file.
所述差分包包括差分文件和序号文件,对所述差分包进行解压,可以得到所述差值数组和所述序号数组。客户都可以根据客户端中的所述老文件中的分隔符将所述老文件划分为多个字符串,将多个字符串按照在所述老文件中的顺序组合为第三字符串组,将所述第三字符串组的二进制值组合为二进制数组。根据所述序号数组查找与所述差值数组中每个二进制值对应的所述二进制数组中的二进制值,将所述差值数组中每个二进制值与该二进制值对应的所述二进制数组中的二进制值进行异或运算,可以得到所述新文件的数组,将所述新文件的数组转换为字符串,得到所述新文件。The difference package includes a difference file and a serial number file. Decompressing the difference package can obtain the difference value array and the serial number array. Customers can divide the old file into multiple character strings according to the separator in the old file in the client, and combine the multiple character strings into a third character string group according to the order in the old file, Combine the binary values of the third character string group into a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
在另一实施例中,所述方法还包括:In another embodiment, the method further includes:
将所述差分包分发给服务器。Distribute the differential package to the server.
在一具体实施例中,可以将所述差分包发送至各个分布式服务器中,当客户端请求所述差分包时,可以通过分布式服务器将所述差分包返回给客户端,增加客户端的下载效率。In a specific embodiment, the differential package can be sent to each distributed server, and when the client requests the differential package, the differential package can be returned to the client through the distributed server to increase the download of the client. efficient.
实施例二Example two
图2是本申请实施例二提供的差分包生成装置的结构图。所述差分包生成装置20应用于计算机装置。本装置的差分包生成是生成用于软件升级的差分包。如图2所示,所述差分包生成装置20可以包括获取模块201、第一划分模块202、第二划分模块203、查找模块204、计算模块205、压缩模块206。Fig. 2 is a structural diagram of a differential packet generating device provided in the second embodiment of the present application. The differential packet generating device 20 is applied to a computer device. The difference package generation of this device is to generate a difference package for software upgrade. As shown in FIG. 2, the differential packet generating device 20 may include an acquisition module 201, a first division module 202, a second division module 203, a search module 204, a calculation module 205, and a compression module 206.
获取模块201,用于获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件。The obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, and the old files and the new files are text files.
在一具体实施例中,可以从手机终端获取所述待升级软件的版本信息;从本地版本文件库查找版本信息与所述手机终端的所述待升级软件的版本信息一致的文件,得到所述待升级软件的所述老文件;从本地版本文件库查找所述待升级软件的最新版本的文件,得到所述待升级软件的所述新文件。本地版本文件库中存储所述待升级软件的多个历史版本和最新版本的文件。In a specific embodiment, the version information of the software to be upgraded may be obtained from a mobile phone terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library to obtain the The old file of the software to be upgraded; searching for the file of the latest version of the software to be upgraded from a local version file library to obtain the new file of the software to be upgraded. The local version file library stores multiple historical versions of the software to be upgraded and files of the latest version.
例如,从一个给定手机终端获取一个给定待升级软件的版本信息为V1.0.1;从本地版本文件库查找版本信息为V1.0.1的文件,得到给定待升级软件的版本信息为V1.0.1的老文件;从本地版本文件库查找给定待升级软件的最新版本的文件,得到给定待升级软件的版本信息为V1.0.2的新文件。本地版本文件库中可以存储给定待升级软件的版本信息为V1.0.0、V1.0.1、V1.0.2的文件。其中版本信息为V1.0.0、V1.0.1的文件为给定待升级软件的两个历史版本的文件,版本信息为V1.0.2的文件为给定待升级软件的最新版本的文件。For example, obtain the version information of a given software to be upgraded from a given mobile phone terminal as V1.0.1; search for a file with version information of V1.0.1 from the local version file library, and obtain the version information of the given software to be upgraded as V1. 0.1 old file; search the file of the latest version of the given software to be upgraded from the local version file library, and get the new file with the version information of the given software to be upgraded as V1.0.2. The local version file library can store files with the version information of the given software to be upgraded as V1.0.0, V1.0.1, and V1.0.2. The files with version information of V1.0.0 and V1.0.1 are files of two historical versions of the given software to be upgraded, and the file with version information of V1.0.2 is the file of the latest version of the given software to be upgraded.
在另一具体实施例中,可以从电脑终端获取所述待升级软件的版本信息;从本地版本文件库查找版本信息与所述手机终端的所述待升级软件的版本信息一致的文件,得到所述待升级软件的所述老文件;从本地版本文件库查找所述待升级软件的最新版本的文件,得到所述待升级软件的所述新文件。In another specific embodiment, the version information of the software to be upgraded may be obtained from a computer terminal; a file whose version information is consistent with the version information of the software to be upgraded of the mobile phone terminal is searched from a local version file library, and all files are obtained. The old file of the software to be upgraded; the file of the latest version of the software to be upgraded is searched from a local version file library to obtain the new file of the software to be upgraded.
在另一实施例中,在所述获取待升级软件的老文件和新文件之前,所述方法还包括:In another embodiment, before the obtaining the old file and the new file of the software to be upgraded, the method further includes:
获取所述老文件的描述信息;Obtaining description information of the old file;
根据所述老文件的描述信息判断所述老文件是否合法。Determine whether the old file is legal according to the description information of the old file.
例如,从客户端获取老文件的描述信息,客户端采用给定哈希算法对老文件进行哈希计算可以得到老文件的描述信息;对本地版本文件库中的老文件进行哈希计算得到本地的老文件的描述信息;若客户端的老文件的描述信息与本地的老文件的描述信息一致,则老文件合法;若客户端的老文件的描述信息与本地的老文件的描述信息不一致,则老文件 不合法。For example, to obtain the description information of the old file from the client, the client uses a given hash algorithm to hash the old file to obtain the description information of the old file; the old file in the local version of the file library is hashed to obtain the local The description information of the old file; if the description information of the client’s old file is consistent with that of the local old file, the old file is valid; if the description of the client’s old file is inconsistent with the local old file’s description, the old file is inconsistent. The file is illegal.
第一划分模块202,用于根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组。The first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group.
所述老文件中的分隔符可以包括:换行符、空格符和制表符等。The separator in the old file may include: line break, space character, tab character, etc.
例如,根据老文件中的空格符将老文件划分为多个第一字符串,其中,老文件的内容为“I am not robot”,得到的多个第一字符串为{“I”,“am”,“not”,“robot”}。将多个第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4]},其中,b[1]=“I”,b[2]=“am”,b[3]=“not”,b[4]=“robot”。For example, the old file is divided into multiple first strings according to the space characters in the old file, where the content of the old file is "I am not robot", and the multiple first strings obtained are {"I"," am","not","robot"}. Combine multiple first character strings in the order in the old file into a first character string group {b[1],b[2],b[3],b[4]}, where b[1 ]="I", b[2]="am", b[3]="not", b[4]="robot".
在一具体实施例中,所述将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组包括:In a specific embodiment, the combining the plurality of first character strings according to the order in the old file into a first character string group includes:
删除所述多个第一字符串中重复的第一字符串,得到多个去重后的第一字符串;Deleting repeated first character strings in the multiple first character strings to obtain multiple deduplicated first character strings;
将所述多个去重后的第一字符串按照在所述老文件中的顺序组合为所述第一字符串组。The multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
例如,老文件的内容为“I am not robot,he is a robot”,得到的多个第一字符串为{“I”,“am”,“not”,“robot”,“,”,“he”,“is”,“a”,“robot”}。删除多个第一字符串中重复的第一字符串“robot”,得到多个去重后的第一字符串{“I”,“am”,“not”,“robot”,“,”,“he”,“is”,“a”},将多个去重后的第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]},其中,b[1]=“I”,b[2]=“am”,b[3]=“not”,b[4]=“robot”,b[5]=”,”,b[6]=”he”,b[7]=”is”,b[8]=”a”。For example, the content of the old file is "I am not robot, he is a robot", and the multiple first strings obtained are {"I","am","not","robot",","," he","is","a","robot"}. Delete the repeated first string "robot" in multiple first strings, and get multiple deduplicated first strings {"I","am","not","robot",",", "He", "is", "a"}, combine multiple deduplicated first character strings according to the order in the old file into a first character string group {b[1],b[2] ,b[3],b[4],b[5],b[6],b[7],b[8]}, where b[1]="I", b[2]="am ", b[3]="not", b[4]="robot", b[5]=",", b[6]="he", b[7]="is", b[8 ]="a".
可以按照前后顺序保留所述重复的第一字符串中最前的第一字符串,删除所述重复的第一字符串中除最前的第一字符串之外的第一字符串。The foremost first character string among the repeated first character strings may be retained in the order of the preceding and the next, and the first character strings other than the foremost first character string among the repeated first character strings may be deleted.
第二划分模块203,用于根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组。The second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group.
所述新文件中的分隔符可以包括:换行符、空格符和制表符等。The delimiters in the new file may include: line breaks, space characters, tabs, and so on.
例如,根据新文件中的空格符将老文件划分为多个第一字符串,其中,新文件的内容为“I am a robot”,得到的多个第一字符串为{“I”,“am”,“a”,“robot”}。将多个第一字符串按照在所述老文件中的顺序组合为第一字符串组{b[1],b[2],b[3],b[4]},其中,b[1]=“I”,b[2]=“am”,b[3]=“a”,b[4]=“robot”。For example, the old file is divided into multiple first strings according to the space characters in the new file, where the content of the new file is "I am a robot", and the multiple first strings obtained are {"I"," am","a","robot"}. Combine multiple first character strings in the order in the old file into a first character string group {b[1],b[2],b[3],b[4]}, where b[1 ]="I", b[2]="am", b[3]="a", b[4]="robot".
查找模块204,用于从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组。The search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group. The sequence number combination of similar character strings of the character string in the first character string group is a sequence number array.
所述从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串包括:The searching for similar character strings of each second character string in the second character string group from the first character string group includes:
(1)对于所述第二字符串组中的任意一个第二字符串A i,确定第二字符串A i包含的字符的数量m i,确定第二字符串A i的各个字符a ix,x=0,1,2,…,m i-1。 (1) For any of the second character string in a second set of string A i, m i is determined the number of the second string of characters included in A i, determining the character of the second string of each A i is a ix, x=0,1,2,...,m i -1.
(2)对于所述第一字符串组中的任意一个第一字符串B j,确定第一字符串B j包含的字符的数量n j,确定第一字符串b j的各个字符b jy,y=0,1,2,…,n j-1。 (2) For any set of the first character string in a first character string B j, B j determines that the character string contains a first number n j, determining a first string of characters in each of b j b jy, y=0,1,2,...,n j -1.
(3)计算第二字符串A i与所述第一字符串组中的每个第一字符串B j的各个中间编辑距离v ij(x+1,y+1),x=0,1,2,…,m i-1,y=0,1,2,…,n j-1: (3) Calculate the respective intermediate edit distances v ij (x+1,y+1) between the second character string A i and each first character string B j in the first character string group, x=0,1 ,2,...,m i -1, y=0,1,2,...,n j -1:
Figure PCTCN2020119049-appb-000002
Figure PCTCN2020119049-appb-000002
其中,v ij(x,0)=x,v ij(0,y)=y,第二字符串A i与所述第一字符串组中的每个第一字符 串B j的编辑距离为v ij(m i,n j)。 Wherein, v ij (x, 0) = x, v ij (0, y) = y, the edit distance between the second character string A i and each first character string B j in the first character string group is v ij (m i ,n j ).
例如,第二字符串组中的一个第二字符串为“pingan”,第二字符串包含的字符的数量为6,第0个字符为“p”,第1个字符为“i”,第2个字符为“n”,第3个字符为“g”,第4个字符为“a”,第5个字符为“n”。第一字符串组中的一个第一字符串为“pintai”,第一字符串包含的字符的数量为6,第0个字符为“p”,第1个字符为“i”,第2个字符为“n”,第3个字符为“t”,第4个字符为“a”,第5个字符为“i”。根据上述公式逐个计算中间编辑距离v(1,2)、v(2,1)、v(2,2)、v(2,3)、v(3,2)、v(3,3)、v(3,4)、v(4,3)、v(4,4)、v(4,5)、v(5,4)、v(5,4)、v(5,5)、v(5,6)和v(6,5)。根据上述公式和v(5,6)、v(6,5)计算第二字符串与第一字符串的编辑距离v(6,6)。For example, a second character string in the second character string group is "pingan", the number of characters in the second character string is 6, the 0th character is "p", the first character is "i", and the first character is "i". Two characters are "n", the third character is "g", the fourth character is "a", and the fifth character is "n". One of the first string in the first string group is "pintai", the number of characters in the first string is 6, the 0th character is "p", the first character is "i", the second is The character is "n", the third character is "t", the fourth character is "a", and the fifth character is "i". Calculate the intermediate edit distances v(1,2), v(2,1), v(2,2), v(2,3), v(3,2), v(3,3), one by one according to the above formula v(3,4), v(4,3), v(4,4), v(4,5), v(5,4), v(5,4), v(5,5), v (5,6) and v(6,5). Calculate the edit distance v(6,6) between the second character string and the first character string according to the above formula and v(5,6) and v(6,5).
(4)从所述第一字符串组中查找与第二字符串A i的编辑距离最小的第一字符串,将所述编辑距离最小的第一字符串作为第二字符串A i的相似字符串。 (4) find the minimum of the first character string and the second string A i of the string edit distance from the first set, the minimum first string edit distance as a second similar string of A i String.
计算模块205,用于计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组。The calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group. The difference combination corresponding to each second character string in the character string group is a difference array.
所述计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值包括:The calculating the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group includes:
对所述第二字符串组中的每个第二字符串的二进制值和该第二字符串在所述第一字符串组中的相似字符串的二进制值进行对齐处理,得到所述第二字符串组中的每个第二字符串的中间二进制值和该第二字符串在所述第一字符串组中的相似字符串的中间二进制值。例如,若第二字符串的二进制值和该第二字符串的相似字符串的二进制值的长度不一致,则长度长的二进制值不变,在长度短的二进制值前逐个补零,直到两个二进制值的长度一致,得到长度一致的第二字符串的中间二进制值和第二字符串在第一字符串组中的相似字符串的中间二进制值。Align the binary value of each second character string in the second character string group with the binary value of the second character string in the first character string group to obtain the second character string The intermediate binary value of each second character string in the character string group and the intermediate binary value of the similar character string of the second character string in the first character string group. For example, if the binary value of the second character string is inconsistent with the length of the binary value of the similar character string of the second character string, the long binary value remains unchanged, and zeros are added one by one before the short binary value until two The lengths of the binary values are the same, and the intermediate binary value of the second character string with the same length and the intermediate binary value of the similar character string of the second character string in the first character string group are obtained.
采用异或算法计算所述第二字符串组中的每个第二字符串的中间二进制值与该第二字符串的相似字符串的中间二进制值的差值。An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of each second character string in the second character string group and the intermediate binary value of similar character strings of the second character string.
例如,一个第二字符串为“pingan”,该第二字符串的中间二进制值为“0000000111000011010011101110110011111000011101110”。该第二字符串的相似字符串为“pintai”,该第二字符串的相似字符串的中间二进制值为“1110000110100111011101100111111010011000011101001”。采用异或算法计算该第二字符串的中间二进制值与该第二字符串的相似字符串的中间二进制值的差值为“1110000001100100001110001001001001100000000000111”。For example, if a second character string is "pingan", the intermediate binary value of the second character string is "0000000111000011010011101110110011111000011101110". The similar character string of the second character string is "pintai", and the intermediate binary value of the similar character string of the second character string is "1110000110100111011101100111111010011000011101001". An exclusive OR algorithm is used to calculate the difference between the intermediate binary value of the second character string and the intermediate binary value of the similar character string of the second character string as "1110000001100100001110001001001001100000000000111".
压缩模块206,用于将所述序号数组和所述差值数组压缩为差分包。The compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
可以采用bzip2算法将所述差值数组压缩为差分文件,将所述序号数组压缩为序号文件,将所述差分文件和序号文件合并为一个差分包。在压缩所述差值数组之前,可以将所述差值数组中的二进制值转换为十六进制值。The bzip2 algorithm may be used to compress the difference array into a difference file, compress the serial number array into a serial number file, and combine the difference file and the serial number file into a difference package. Before compressing the difference value array, the binary value in the difference value array may be converted into a hexadecimal value.
在另一实施例中,所述序号数组可以不压缩,将所述差分文件和序号数组合并为一个差分包。In another embodiment, the sequence number array may not be compressed, and the difference file and the sequence number array are combined into one difference package.
当客户端接收到差分包时,可以对所述差分包进行解压,解压得到所述差值数组和所述序号数组。根据客户端中的所述老文件中的分隔符将所述老文件划分为多个字符串,将多个字符串按照在所述老文件中的顺序组合为第三字符串组,将所述第三字符串组的二进制值组合为二进制数组。根据所述序号数组查找与所述差值数组中每个二进制值对应的所述二进制数组中的二进制值,将所述差值数组中每个二进制值与该二进制值对应的所述二进制数组中的二进制值进行异或运算,可以得到所述新文件的数组,将所述新文件的数组转换为字符串,得到所述新文件。When the client receives the difference packet, it can decompress the difference packet, and decompress the difference value array and the sequence number array. The old file is divided into multiple character strings according to the separator in the old file in the client, the multiple character strings are combined into a third character string group according to the order in the old file, and the The binary value combination of the third string group is a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
实施例二的差分包生成装置20获取待升级软件的老文件和新文件,所述老文件和所 述新文件为文本文件;根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;将所述序号数组和所述差值数组压缩为差分包。实施例二生成用于软件升级的差分包,减小了所述差分包的大小和提升生成所述差分包的效率。The differential package generating device 20 of the second embodiment obtains the old file and the new file of the software to be upgraded, the old file and the new file are text files; the old file is divided into multiple files according to the separator in the old file. A first character string, combining the multiple first character strings according to the order in the old file into a first character string group; dividing the new file into a plurality of characters according to the separator in the new file A second character string, combining the multiple second character strings according to the order in the new file into a second character string group; searching for the second character string group in the first character string group The similar character strings of each second character string, the sequence numbers of the similar character strings of each second character string in the second character string group in the first character string group are combined into a sequence number array; The difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group is calculated by dividing each second character string in the second character string group The difference value combination corresponding to the character string is a difference value array; the sequence number array and the difference value array are compressed into a difference packet. The second embodiment generates a differential package for software upgrade, which reduces the size of the differential package and improves the efficiency of generating the differential package.
在另一实施例中,所述差分包生成装置20还可以包括:发送模块,用于响应于客户端的下载请求,将所述差分包发送给所述客户端,使所述客户端根据所述差分包和所述老文件生成所述新文件。In another embodiment, the differential packet generating device 20 may further include: a sending module, configured to send the differential packet to the client in response to a download request from the client, so that the client can perform the The difference package and the old file generate the new file.
所述差分包包括差分文件和序号文件,对所述差分包进行解压,可以得到所述差值数组和所述序号数组。客户都可以根据客户端中的所述老文件中的分隔符将所述老文件划分为多个字符串,将多个字符串按照在所述老文件中的顺序组合为第三字符串组,将所述第三字符串组的二进制值组合为二进制数组。根据所述序号数组查找与所述差值数组中每个二进制值对应的所述二进制数组中的二进制值,将所述差值数组中每个二进制值与该二进制值对应的所述二进制数组中的二进制值进行异或运算,可以得到所述新文件的数组,将所述新文件的数组转换为字符串,得到所述新文件。The difference package includes a difference file and a serial number file. Decompressing the difference package can obtain the difference value array and the serial number array. Customers can divide the old file into multiple character strings according to the separator in the old file in the client, and combine the multiple character strings into a third character string group according to the order in the old file, Combine the binary values of the third character string group into a binary array. Find the binary value in the binary array corresponding to each binary value in the difference value array according to the sequence number array, and put each binary value in the difference value array with the binary value in the binary array corresponding to the binary value Perform an exclusive OR operation on the binary value of to obtain the array of the new file, and convert the array of the new file into a character string to obtain the new file.
在另一实施例中,所述差分包生成装置20还可以包括:分发模块,用于将所述差分包分发给服务器。In another embodiment, the differential packet generating device 20 may further include: a distribution module, configured to distribute the differential packet to a server.
在一具体实施例中,可以将所述差分包发送至各个分布式服务器中,当客户端请求所述差分包时,可以通过分布式服务器将所述差分包返回给客户端,增加客户端的下载效率。In a specific embodiment, the differential package can be sent to each distributed server, and when the client requests the differential package, the differential package can be returned to the client through the distributed server to increase the download of the client. efficient.
实施例三Example three
本实施例提供一种计算机存储介质,该计算机存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述差分包生成方法实施例中的步骤,例如图1所示的101-106:This embodiment provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the embodiment of the differential packet generation method described above are implemented, for example, 101-106 shown in FIG. 1:
101,获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;101. Obtain an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
102,根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;102. Divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings according to the order in the old file into a first character string group ;
103,根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;103. Divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into a second character string group ;
104,从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;104. Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similarity of each second character string in the second character string group The sequence number combination of the character string in the first character string group is a sequence number array;
105,计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;105. Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and combine the second character string in the second character string group The difference combination corresponding to each second character string of is a difference array;
106,将所述序号数组和所述差值数组压缩为差分包。106. Compress the sequence number array and the difference value array into a difference packet.
或者,该计算机程序被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-206:Or, when the computer program is executed by the processor, the function of each module in the above-mentioned device embodiment is realized, for example, the modules 201-206 in Fig. 2:
获取模块201,用于获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;The obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
第一划分模块202,用于根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;The first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group;
第二划分模块203,用于根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;The second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group;
查找模块204,用于从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;The search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group. The sequence number combination of similar character strings of the character string in the first character string group is an array of sequence numbers;
计算模块205,用于计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;The calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group. The difference combination corresponding to each second character string in the character string group is a difference array;
压缩模块206,用于将所述序号数组和所述差值数组压缩为差分包。The compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
实施例四Example four
图3为本申请实施例四提供的计算机装置的示意图。所述计算机装置30包括存储器301、处理器302以及存储在所述存储器301中并可在所述处理器302上运行的计算机程序303,例如差分包生成程序。所述处理器302执行所述计算机程序303时实现上述差分包生成方法实施例中的步骤,例如图1所示的101-106:FIG. 3 is a schematic diagram of a computer device provided in Embodiment 4 of this application. The computer device 30 includes a memory 301, a processor 302, and a computer program 303 that is stored in the memory 301 and can run on the processor 302, such as a differential packet generation program. When the processor 302 executes the computer program 303, the steps in the embodiment of the above-mentioned differential packet generation method are implemented, for example, 101-106 shown in Fig. 1:
101,获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;101. Obtain an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
102,根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;102. Divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings according to the order in the old file into a first character string group ;
103,根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;103. Divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into a second character string group ;
104,从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;104. Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similarity of each second character string in the second character string group The sequence number combination of the character string in the first character string group is a sequence number array;
105,计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;105. Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and combine the second character string in the second character string group The difference combination corresponding to each second character string of is a difference array;
106,将所述序号数组和所述差值数组压缩为差分包。106. Compress the sequence number array and the difference value array into a difference packet.
或者,该计算机程序被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-206:Or, when the computer program is executed by the processor, the function of each module in the above-mentioned device embodiment is realized, for example, the modules 201-206 in Fig. 2:
获取模块201,用于获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;The obtaining module 201 is configured to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
第一划分模块202,用于根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;The first dividing module 202 is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file Is the first string group;
第二划分模块203,用于根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;The second dividing module 203 is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings in the order in the new file Is the second string group;
查找模块204,用于从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;The search module 204 is configured to search for similar character strings of each second character string in the second character string group from the first character string group, and search for each second character string in the second character string group. The sequence number combination of similar character strings of the character string in the first character string group is an array of sequence numbers;
计算模块205,用于计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;The calculation module 205 is configured to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character string and the similar character string in the first character string group. The difference combination corresponding to each second string in the string group is a difference array;
压缩模块206,用于将所述序号数组和所述差值数组压缩为差分包。The compression module 206 is configured to compress the sequence number array and the difference value array into a difference packet.
示例性的,所述计算机程序303可以被分割成一个或多个模块,所述一个或者多个模块被存储在所述存储器301中,并由所述处理器302执行,以完成本方法。所述一个或 多个模块可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序303在所述计算机装置30中的执行过程。例如,所述计算机程序303可以被分割成图2中的获取模块201、第一划分模块202、第二划分模块203、查找模块204、计算模块205、压缩模块206,各模块具体功能参见实施例二。Exemplarily, the computer program 303 may be divided into one or more modules, and the one or more modules are stored in the memory 301 and executed by the processor 302 to complete the method. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 303 in the computer device 30. For example, the computer program 303 can be divided into the acquisition module 201, the first division module 202, the second division module 203, the search module 204, the calculation module 205, and the compression module 206 in FIG. 2. For the specific functions of each module, refer to the embodiments. two.
所述计算机装置30可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。本领域技术人员可以理解,所述示意图3仅仅是计算机装置30的示例,并不构成对计算机装置30的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述计算机装置30还可以包括输入输出设备、网络接入设备、总线等。The computer device 30 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. Those skilled in the art can understand that the schematic diagram 3 is only an example of the computer device 30 and does not constitute a limitation on the computer device 30. It may include more or less components than those shown in the figure, or combine certain components, or be different. For example, the computer device 30 may also include input and output devices, network access devices, buses, and so on.
所称处理器302可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器302也可以是任何常规的处理器等,所述处理器302是所述计算机装置30的控制中心,利用各种接口和线路连接整个计算机装置30的各个部分。The so-called processor 302 may be a central processing unit (Central Processing Unit, CPU), other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor 302 can also be any conventional processor, etc. The processor 302 is the control center of the computer device 30, which uses various interfaces and lines to connect the entire computer device 30. Various parts.
所述存储器301可用于存储所述计算机程序303,所述处理器302通过运行或执行存储在所述存储器301内的计算机程序或模块,以及调用存储在存储器301内的数据,实现所述计算机装置30的各种功能。所述存储器301可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机装置30的使用所创建的数据(比如音频数据等)等。此外,存储器301可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。The memory 301 can be used to store the computer program 303, and the processor 302 implements the computer device by running or executing the computer program or module stored in the memory 301 and calling data stored in the memory 301 30 various functions. The memory 301 may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; the storage data area may Data (such as audio data, etc.) created according to the use of the computer device 30 and the like are stored. In addition, the memory 301 may include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
所述计算机装置30集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机存储介质中,该计算机程序在被处理器执行时,可实现如下步骤:If the integrated module of the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer storage medium. When executed by the processor, the following steps can be implemented:
获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) .
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块 的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, the functional modules in the various embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, or in the form of hardware plus software functional modules.
上述以软件功能模块的形式实现的集成的模块,可以存储在一个计算机可读取存储介质中,所述计算机可读存储介质可以是易失性的,也可以是非易失性的。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行以下步骤:The above-mentioned integrated modules implemented in the form of software functional modules may be stored in a computer-readable storage medium, and the computer-readable storage medium may be volatile or non-volatile. The above-mentioned software function module is stored in a storage medium and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor execute the following steps:
获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
在另一实施例中,本申请所提供的差分包生成方法,为进一步保证上述所有出现的数据的私密和安全性,上述所有数据还可以存储于一区块链的节点中。例如序号数组和差值数组等,这些数据均可存储在区块链节点中。In another embodiment, in the differential packet generation method provided by the present application, in order to further ensure the privacy and security of all the above-mentioned data, all the above-mentioned data can also be stored in a node of a blockchain. For example, the serial number array and the difference value array, etc., these data can be stored in the blockchain node.
需要说明的是,本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。It should be noted that the blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他模块或步骤,单数不排除复数。系统权利要求中陈述的多个模块或装置也可以由一个模块或装置通过软件或者硬件来实现。第一,第二等词语用来表示名称,而并不表示任何特定的顺序。For those skilled in the art, it is obvious that the present application is not limited to the details of the foregoing exemplary embodiments, and the present application can be implemented in other specific forms without departing from the spirit or basic characteristics of the application. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of this application is defined by the appended claims rather than the above description, and therefore it is intended to fall into the claims. All changes in the meaning and scope of the equivalent elements of are included in this application. Any associated diagram marks in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "including" does not exclude other modules or steps, and the singular does not exclude the plural. Multiple modules or devices stated in the system claims can also be implemented by one module or device through software or hardware. Words such as first and second are used to denote names, but do not denote any specific order.
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the application and not to limit them. Although the application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the application can be Make modifications or equivalent replacements without departing from the spirit and scope of the technical solution of the present application.

Claims (20)

  1. 一种差分包生成方法,其中,所述方法包括:A differential packet generation method, wherein the method includes:
    获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
    根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
    根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
    从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
    计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
    将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
  2. 如权利要求1所述的方法,其中,所述将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组包括:The method of claim 1, wherein the combining the plurality of first character strings into a first character string group according to the order in the old file comprises:
    删除所述多个第一字符串中重复的第一字符串,得到多个去重后的第一字符串;Deleting repeated first character strings in the multiple first character strings to obtain multiple deduplicated first character strings;
    将所述多个去重后的第一字符串按照在所述老文件中的顺序组合为所述第一字符串组。The multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
  3. 如权利要求1所述的方法,其中,所述从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串包括:The method according to claim 1, wherein said searching for similar character strings of each second character string in said second character string group from said first character string group comprises:
    对于所述第二字符串组中的任意一个第二字符串A i,确定第二字符串A i包含的字符的数量m i,确定第二字符串A i的各个字符a ix,x=0,1,2,…,m i-1; For any set of the second character string in a second string A i, m i is determined the number of the second string of characters included in A i, determining the character of the second string of each A i is a ix, x = 0 ,1,2,…,m i -1;
    对于所述第一字符串组中的任意一个第一字符串B j,确定第一字符串B j包含的字符的数量n j,确定第一字符串b j的各个字符b jy,y=0,1,2,…,n j-1; For any set of the first character string is a first character string B j, B j determines that the character string contains a first number n j, determining a first string of characters in each of b j b jy, y = 0 ,1,2,…,n j -1;
    计算第二字符串A i与所述第一字符串组中的每个第一字符串B j的各个中间编辑距离v ij(x+1,y+1),x=0,1,2,…,m i-1,y=0,1,2,…,n j-1: Calculate the respective intermediate edit distances v ij (x+1,y+1) between the second character string A i and each first character string B j in the first character string group, x=0,1,2, …,M i -1, y=0,1,2,…,n j -1:
    Figure PCTCN2020119049-appb-100001
    Figure PCTCN2020119049-appb-100001
    其中,v ij(x,0)=x,v ij(0,y)=y,第二字符串A i与所述第一字符串组中的每个第一字符串B j的编辑距离为v ij(m i,n j); Wherein, v ij (x, 0) = x, v ij (0, y) = y, the edit distance between the second character string A i and each first character string B j in the first character string group is v ij (m i ,n j );
    从所述第一字符串组中查找与第二字符串A i的编辑距离最小的第一字符串,将所述编辑距离最小的第一字符串作为第二字符串A i的相似字符串。 Find character string from the first set and the second character string edit distances A i minimum first string, the first string edit distance is a minimum string similar second string of A i.
  4. 如权利要求1所述的方法,其中,所述计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值包括:The method of claim 1, wherein the calculating the difference between each second character string in the second character string group and a similar character string in the first character string group of the second character string Values include:
    对所述第二字符串组中的每个第二字符串的二进制值和该第二字符串在所述第一字符串组中的相似字符串的二进制值进行对齐处理,得到所述第二字符串组中的每个第二字符串的中间二进制值和该第二字符串在所述第一字符串组中的相似字符串的中间二进制值。Align the binary value of each second character string in the second character string group with the binary value of the second character string in the first character string group to obtain the second character string The intermediate binary value of each second character string in the character string group and the intermediate binary value of the similar character string of the second character string in the first character string group.
  5. 如权利要求1-4中任一项所述的方法,其中,在所述获取待升级软件的老文件和新文件之前,所述方法还包括:The method according to any one of claims 1 to 4, wherein, before the obtaining the old file and the new file of the software to be upgraded, the method further comprises:
    获取所述老文件的描述信息;Obtaining description information of the old file;
    根据所述老文件的描述信息判断所述老文件是否合法。Determine whether the old file is legal according to the description information of the old file.
  6. 如权利要求1-4中任一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    响应于客户端的下载请求,将所述差分包发送给所述客户端,使所述客户端根据所述差分包和所述老文件生成所述新文件。In response to the download request of the client, the differential package is sent to the client, so that the client generates the new file according to the differential package and the old file.
  7. 如权利要求1-4中任一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    将所述差分包分发送给服务器。The differential packet is sent to the server separately.
  8. 一种差分包生成装置,其中,所述装置包括:A differential packet generating device, wherein the device includes:
    获取模块,用于获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;An obtaining module, used to obtain old files and new files of the software to be upgraded, where the old files and the new files are text files;
    第一划分模块,用于根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;The first dividing module is configured to divide the old file into a plurality of first character strings according to the separator in the old file, and combine the plurality of first character strings in the order in the old file into The first string group;
    第二划分模块,用于根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;The second dividing module is configured to divide the new file into a plurality of second character strings according to the separator in the new file, and combine the plurality of second character strings according to the order in the new file into The second string group;
    查找模块,用于从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;The search module is used to search for similar character strings of each second character string in the second character string group from the first character string group, and to compare each second character in the second character string group The sequence number combination of similar character strings in the first character string group is a sequence number array;
    计算模块,用于计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;The calculation module is used to calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between the second character The difference combination corresponding to each second character string in the string group is a difference array;
    压缩模块,用于将所述序号数组和所述差值数组压缩为差分包。The compression module is used to compress the sequence number array and the difference value array into a difference packet.
  9. 一种计算机装置,其中,所述计算机装置包括处理器,所述处理器用于执行存储器中存储的计算机程序以实现如下步骤:A computer device, wherein the computer device includes a processor, and the processor is configured to execute a computer program stored in a memory to implement the following steps:
    获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
    根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
    根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
    从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
    计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
    将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
  10. 如权利要求9所述的计算机装置,其中,所述将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组包括:9. The computer device according to claim 9, wherein said combining the plurality of first character strings into a first character string group according to the order in the old file comprises:
    删除所述多个第一字符串中重复的第一字符串,得到多个去重后的第一字符串;Deleting repeated first character strings in the multiple first character strings to obtain multiple deduplicated first character strings;
    将所述多个去重后的第一字符串按照在所述老文件中的顺序组合为所述第一字符串组。The multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
  11. 如权利要求9所述的计算机装置,其中,所述从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串包括:9. The computer device according to claim 9, wherein said searching for similar character strings of each second character string in said second character string group from said first character string group comprises:
    对于所述第二字符串组中的任意一个第二字符串A i,确定第二字符串A i包含的字符的数量m i,确定第二字符串A i的各个字符a ix,x=0,1,2,…,m i-1; For any set of the second character string in a second string A i, m i is determined the number of the second string of characters included in A i, determining the character of the second string of each A i is a ix, x = 0 ,1,2,…,m i -1;
    对于所述第一字符串组中的任意一个第一字符串B j,确定第一字符串B j包含的字符的数量n j,确定第一字符串b j的各个字符b jy,y=0,1,2,…,n j-1; For any set of the first character string is a first character string B j, B j determines that the character string contains a first number n j, determining a first string of characters in each of b j b jy, y = 0 ,1,2,…,n j -1;
    计算第二字符串A i与所述第一字符串组中的每个第一字符串B j的各个中间编辑距离v ij(x+1,y+1),x=0,1,2,…,m i-1,y=0,1,2,…,n j-1: Calculate the respective intermediate edit distances v ij (x+1,y+1) between the second character string A i and each first character string B j in the first character string group, x=0,1,2, …,M i -1, y=0,1,2,…,n j -1:
    Figure PCTCN2020119049-appb-100002
    Figure PCTCN2020119049-appb-100002
    其中,v ij(x,0)=x,v ij(0,y)=y,第二字符串A i与所述第一字符串组中的每个第一字符串B j的编辑距离为v ij(m i,n j); Wherein, v ij (x, 0) = x, v ij (0, y) = y, the edit distance between the second character string A i and each first character string B j in the first character string group is v ij (m i ,n j );
    从所述第一字符串组中查找与第二字符串A i的编辑距离最小的第一字符串,将所述编辑距离最小的第一字符串作为第二字符串A i的相似字符串。 Find character string from the first set and the second character string edit distances A i minimum first string, the first string edit distance is a minimum string similar second string of A i.
  12. 如权利要求9所述的计算机装置,其中,所述计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值包括:9. The computer device according to claim 9, wherein said calculating the difference between each second character string in said second character string group and the similar character string of said second character string in said first character string group Differences include:
    对所述第二字符串组中的每个第二字符串的二进制值和该第二字符串在所述第一字符串组中的相似字符串的二进制值进行对齐处理,得到所述第二字符串组中的每个第二字符串的中间二进制值和该第二字符串在所述第一字符串组中的相似字符串的中间二进制值。Align the binary value of each second character string in the second character string group with the binary value of the second character string in the first character string group to obtain the second character string The intermediate binary value of each second character string in the character string group and the intermediate binary value of the similar character string of the second character string in the first character string group.
  13. 如权利要求9-12中任一项所述的计算机装置,其中,在所述获取待升级软件的老文件和新文件之前,所述处理器用于执行存储器中存储的计算机程序还实现如下步骤:The computer device according to any one of claims 9-12, wherein, before said acquiring the old file and the new file of the software to be upgraded, the processor is configured to execute the computer program stored in the memory to further implement the following steps:
    获取所述老文件的描述信息;Obtaining description information of the old file;
    根据所述老文件的描述信息判断所述老文件是否合法。Determine whether the old file is legal according to the description information of the old file.
  14. 如权利要求9-12中任一项所述的计算机装置,其中,所述处理器用于执行存储器中存储的计算机程序还实现如下步骤:The computer device according to any one of claims 9-12, wherein the processor is configured to execute the computer program stored in the memory and further implements the following steps:
    响应于客户端的下载请求,将所述差分包发送给所述客户端,使所述客户端根据所述差分包和所述老文件生成所述新文件。In response to the download request of the client, the differential package is sent to the client, so that the client generates the new file according to the differential package and the old file.
  15. 如权利要求9-12中任一项所述的计算机装置,其中,所述处理器用于执行存储器中存储的计算机程序还实现如下步骤:The computer device according to any one of claims 9-12, wherein the processor is configured to execute the computer program stored in the memory and further implements the following steps:
    将所述差分包分发送给服务器。The differential packet is sent to the server separately.
  16. 一种计算机存储介质,所述计算机存储介质上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如下步骤:A computer storage medium having a computer program stored on the computer storage medium, wherein the following steps are implemented when the computer program is executed by a processor:
    获取待升级软件的老文件和新文件,所述老文件和所述新文件为文本文件;Acquiring an old file and a new file of the software to be upgraded, where the old file and the new file are text files;
    根据所述老文件中的分隔符将所述老文件划分为多个第一字符串,将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组;Dividing the old file into a plurality of first character strings according to the separator in the old file, and combining the plurality of first character strings according to the order in the old file into a first character string group;
    根据所述新文件中的分隔符将所述新文件划分为多个第二字符串,将所述多个第二字符串按照在所述新文件中的顺序组合为第二字符串组;Dividing the new file into a plurality of second character strings according to the separator in the new file, and combining the plurality of second character strings according to the order in the new file into a second character string group;
    从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串,将所述第二字符串组中的每个第二字符串的相似字符串在所述第一字符串组中的序号组合为序号数组;Search for similar character strings of each second character string in the second character string group from the first character string group, and compare the similar character strings of each second character string in the second character string group The sequence number combination in the first character string group is a sequence number array;
    计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值,将所述第二字符串组中的每个第二字符串对应的差值组合为差值数组;Calculate the difference between each second character string in the second character string group and the similar character string of the second character string in the first character string group, and calculate the difference between each second character string in the second character string group The difference value combination corresponding to the second character string is a difference value array;
    将所述序号数组和所述差值数组压缩为差分包。Compressing the sequence number array and the difference value array into a difference packet.
  17. 如权利要求16所述的计算机存储介质,其中,所述将所述多个第一字符串按照在所述老文件中的顺序组合为第一字符串组包括:15. The computer storage medium of claim 16, wherein the combining the plurality of first character strings into a first character string group according to the order in the old file comprises:
    删除所述多个第一字符串中重复的第一字符串,得到多个去重后的第一字符串;Deleting repeated first character strings in the multiple first character strings to obtain multiple deduplicated first character strings;
    将所述多个去重后的第一字符串按照在所述老文件中的顺序组合为所述第一字符串 组。The multiple deduplicated first character strings are combined into the first character string group according to the order in the old file.
  18. 如权利要求16所述的计算机存储介质,其中,所述从所述第一字符串组中查找所述第二字符串组中的每个第二字符串的相似字符串包括:15. The computer storage medium according to claim 16, wherein said searching for similar character strings of each second character string in said second character string group from said first character string group comprises:
    对于所述第二字符串组中的任意一个第二字符串A i,确定第二字符串A i包含的字符的数量m i,确定第二字符串A i的各个字符a ix,x=0,1,2,…,m i-1; For any set of the second character string in a second string A i, m i is determined the number of the second string of characters included in A i, determining the character of the second string of each A i is a ix, x = 0 ,1,2,…,m i -1;
    对于所述第一字符串组中的任意一个第一字符串B j,确定第一字符串B j包含的字符的数量n j,确定第一字符串b j的各个字符b jy,y=0,1,2,…,n j-1; For any set of the first character string is a first character string B j, B j determines that the character string contains a first number n j, determining a first string of characters in each of b j b jy, y = 0 ,1,2,…,n j -1;
    计算第二字符串A i与所述第一字符串组中的每个第一字符串B j的各个中间编辑距离v ij(x+1,y+1),x=0,1,2,…,m i-1,y=0,1,2,…,n j-1: Calculate the respective intermediate edit distances v ij (x+1,y+1) between the second character string A i and each first character string B j in the first character string group, x=0,1,2, …,M i -1, y=0,1,2,…,n j -1:
    Figure PCTCN2020119049-appb-100003
    Figure PCTCN2020119049-appb-100003
    其中,v ij(x,0)=x,v ij(0,y)=y,第二字符串A i与所述第一字符串组中的每个第一字符串B j的编辑距离为v ij(m i,n j); Wherein, v ij (x, 0) = x, v ij (0, y) = y, the edit distance between the second character string A i and each first character string B j in the first character string group is v ij (m i ,n j );
    从所述第一字符串组中查找与第二字符串A i的编辑距离最小的第一字符串,将所述编辑距离最小的第一字符串作为第二字符串A i的相似字符串。 Find character string from the first set and the second character string edit distances A i minimum first string, the first string edit distance is a minimum string similar second string of A i.
  19. 如权利要求16所述的计算机存储介质,其中,所述计算所述第二字符串组中的每个第二字符串与该第二字符串在所述第一字符串组中的相似字符串的差值包括:The computer storage medium according to claim 16, wherein the calculation of each second character string in the second character string group and the similar character string of the second character string in the first character string group The differences include:
    对所述第二字符串组中的每个第二字符串的二进制值和该第二字符串在所述第一字符串组中的相似字符串的二进制值进行对齐处理,得到所述第二字符串组中的每个第二字符串的中间二进制值和该第二字符串在所述第一字符串组中的相似字符串的中间二进制值。Align the binary value of each second character string in the second character string group with the binary value of the second character string in the first character string group to obtain the second character string The intermediate binary value of each second character string in the character string group and the intermediate binary value of the similar character string of the second character string in the first character string group.
  20. 如权利要求16-19中任一项所述的计算机存储介质,其中,在所述获取待升级软件的老文件和新文件之前,所述计算机程序被处理器执行时还实现如下步骤:22. The computer storage medium according to any one of claims 16-19, wherein, before said acquiring the old file and the new file of the software to be upgraded, the following steps are further implemented when the computer program is executed by the processor:
    获取所述老文件的描述信息;Obtaining description information of the old file;
    根据所述老文件的描述信息判断所述老文件是否合法。Determine whether the old file is legal according to the description information of the old file.
PCT/CN2020/119049 2020-03-04 2020-09-29 Differential package generation method and apparatus, computer device, and storage medium WO2021174836A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010144853.8A CN111522574B (en) 2020-03-04 2020-03-04 Differential packet generation method and related equipment
CN202010144853.8 2020-03-04

Publications (1)

Publication Number Publication Date
WO2021174836A1 true WO2021174836A1 (en) 2021-09-10

Family

ID=71910309

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/119049 WO2021174836A1 (en) 2020-03-04 2020-09-29 Differential package generation method and apparatus, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN111522574B (en)
WO (1) WO2021174836A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522574B (en) * 2020-03-04 2024-05-03 平安科技(深圳)有限公司 Differential packet generation method and related equipment
CN115202708A (en) * 2022-07-14 2022-10-18 小米汽车科技有限公司 Updating method, device, medium and vehicle
CN117632210A (en) * 2022-08-17 2024-03-01 荣耀终端有限公司 Upgrade package generation method, installation method, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7003534B2 (en) * 2002-11-18 2006-02-21 Innopath Software, Inc. Generating difference files using module information of embedded software components
CN105786563A (en) * 2016-02-19 2016-07-20 联州(上海)信息科技有限公司 Device, system and method for achieving software online update
CN107835206A (en) * 2017-09-19 2018-03-23 平安普惠企业管理有限公司 Data-updating method, server and computer-readable recording medium
CN108762798A (en) * 2017-04-25 2018-11-06 腾讯科技(深圳)有限公司 A kind of method and device of incremental update file
CN111522574A (en) * 2020-03-04 2020-08-11 平安科技(深圳)有限公司 Differential packet generation method and related equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6425125B1 (en) * 1999-03-30 2002-07-23 Microsoft Corporation System and method for upgrading client software
US7143115B2 (en) * 2003-04-15 2006-11-28 Pocket Soft, Inc. Method and apparatus for finding differences between two computer files efficiently in linear time and for using these differences to update computer files
CN107885526A (en) * 2017-11-17 2018-04-06 苏州蜗牛数字科技股份有限公司 A kind of file updating method and system
CN108256587A (en) * 2018-02-05 2018-07-06 武汉斗鱼网络科技有限公司 Determining method, apparatus, computer and the storage medium of a kind of similarity of character string
CN110231947A (en) * 2019-05-21 2019-09-13 深圳壹账通智能科技有限公司 A kind of update of plug-in method, equipment, server and the storage medium of application program

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7003534B2 (en) * 2002-11-18 2006-02-21 Innopath Software, Inc. Generating difference files using module information of embedded software components
CN105786563A (en) * 2016-02-19 2016-07-20 联州(上海)信息科技有限公司 Device, system and method for achieving software online update
CN108762798A (en) * 2017-04-25 2018-11-06 腾讯科技(深圳)有限公司 A kind of method and device of incremental update file
CN107835206A (en) * 2017-09-19 2018-03-23 平安普惠企业管理有限公司 Data-updating method, server and computer-readable recording medium
CN111522574A (en) * 2020-03-04 2020-08-11 平安科技(深圳)有限公司 Differential packet generation method and related equipment

Also Published As

Publication number Publication date
CN111522574B (en) 2024-05-03
CN111522574A (en) 2020-08-11

Similar Documents

Publication Publication Date Title
WO2021174836A1 (en) Differential package generation method and apparatus, computer device, and storage medium
US10614032B2 (en) Quick filename lookup using name hash
CN110168523B (en) Change monitoring cross-graph query
CN111897818B (en) Data storage method, device, electronic equipment and storage medium
CN108762898B (en) Thread interface management method, terminal equipment and computer readable storage medium
WO2017032170A1 (en) Method and apparatus for importing mirror image file
CN111857550A (en) Method, apparatus and computer readable medium for data deduplication
CN113553300B (en) File processing method and device, readable medium and electronic equipment
CN111651424B (en) Data processing method, device, data node and storage medium
CN112947986B (en) Multi-version code sign-on control method, device, client and storage medium
CN112001159B (en) Document generation method and device, electronic equipment and storage medium
CN111104259B (en) Database recovery method and device and storage medium
CN112328592A (en) Data storage method, electronic device and computer readable storage medium
CN113918602A (en) Data caching method and device and electronic equipment
CN113434122A (en) Multi-role page creation method and device, server and readable storage medium
CN112733510A (en) Financial certificate generation method, device, equipment and computer readable storage medium
AU2019350694B2 (en) Identification of records for post-cloning tenant identifier translation
CN113742332A (en) Data storage method, device, equipment and storage medium
CN111143461A (en) Mapping relation processing system and method and electronic equipment
US9201937B2 (en) Rapid provisioning of information for business analytics
US11822803B2 (en) Method, electronic device and computer program product for managing data blocks
US8224822B2 (en) Template based entity transformation
US11500896B2 (en) Method and system for selectively separating organization data according to business division
CN115190136B (en) Data storage method, data transmission method and computing equipment
US20210342333A1 (en) Partial updates in data collections in a data storage system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20923625

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20923625

Country of ref document: EP

Kind code of ref document: A1