WO2022083190A1 - Data downloading method and apparatus, computer device, and storage medium - Google Patents
Data downloading method and apparatus, computer device, and storage medium Download PDFInfo
- Publication number
- WO2022083190A1 WO2022083190A1 PCT/CN2021/107049 CN2021107049W WO2022083190A1 WO 2022083190 A1 WO2022083190 A1 WO 2022083190A1 CN 2021107049 W CN2021107049 W CN 2021107049W WO 2022083190 A1 WO2022083190 A1 WO 2022083190A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- downloaded
- byte length
- file
- nodes
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 90
- 230000008569 process Effects 0.000 claims abstract description 35
- 238000012545 processing Methods 0.000 claims abstract description 29
- 230000001360 synchronised effect Effects 0.000 claims abstract description 29
- 238000004590 computer program Methods 0.000 claims description 30
- 230000004044 response Effects 0.000 claims description 26
- 238000005516 engineering process Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 6
- 238000001514 detection method Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 238000012546 transfer Methods 0.000 description 5
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
Definitions
- the present application relates to the field of Internet technologies, and in particular, to a data downloading method, apparatus, computer equipment and storage medium.
- a method for downloading data comprising:
- Data download is performed according to the data node to be downloaded.
- acquiring the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data includes:
- the downloaded data is obtained from the first file, and the number of nodes corresponding to the downloaded data is obtained from the second file.
- the method after responding to the data download request, the method further includes:
- the method after responding to the data download request, the method further includes:
- the downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file.
- synchronously storing the downloaded data in the first file according to a fixed byte length, and storing the number of nodes corresponding to the synchronously stored downloaded data in the second file includes:
- the actual byte length of the downloaded data is compared, and the comparison result obtained includes:
- the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
- a byte length comparison process is performed between the recorded byte length and the actual byte length, and a comparison result is obtained, and the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is the same as the actual byte length.
- Actual byte length inconsistencies include:
- a data download device includes:
- the data response acquisition module is used to respond to the data download request, and when there is synchronization data corresponding to the data download request, acquire the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
- the data comparison module is used to compare the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and obtain the comparison result;
- the data processing module is used to determine the data node to be downloaded according to the comparison result and the downloaded data;
- the data download module performs data download according to the data node to be downloaded.
- a computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
- Data download is performed according to the data node to be downloaded.
- Data download is performed according to the data node to be downloaded.
- the above data download method, device, computer equipment and storage medium by responding to the data download request, on the condition that there is synchronization data corresponding to the data download request, it is judged whether the download data and the number of nodes have been backed up in advance, when there is a synchronization
- the synchronized downloaded data and the number of nodes corresponding to the downloaded data are obtained, and the downloaded data is stored synchronously to prevent the loss of the previously downloaded data.
- Fixed byte length realizes the synchronous record of the byte length of the downloaded data, and compares the byte length of the downloaded data according to the preset fixed byte length and the number of nodes.
- the number of bytes of the downloaded data is processed, which simplifies the complex processing process of all the downloaded data, and the comparison result is obtained to verify whether the recorded byte length is consistent with the byte length of the downloaded data. According to the comparison The result and the downloaded data are used to determine the data node to be downloaded, and the data download process is performed starting from the data node to be downloaded, without re-downloading all the data, which saves data processing resources in the data download process.
- Fig. 1 is the application environment diagram of the data downloading method in one embodiment
- FIG. 2 is a schematic flowchart of a data download method in one embodiment
- FIG. 3 is a schematic flowchart of a data download method in another embodiment
- FIG. 4 is a schematic flowchart of a data downloading method in another embodiment
- FIG. 5 is a schematic flowchart of a data download method in yet another embodiment
- Fig. 6 is the schematic flow chart that there is no synchronization data in the data downloading method in one embodiment
- FIG. 7 is a schematic flowchart of a data downloading method in another embodiment
- FIG. 8 is a schematic flowchart of a data downloading method in another embodiment
- Fig. 9 is the application scene diagram of the data downloading method in one embodiment.
- FIG. 10 is a structural block diagram of a data downloading apparatus in one embodiment
- Figure 11 is a diagram of the internal structure of a computer device in one embodiment.
- the data downloading method provided in this application can be applied to the application environment shown in FIG. 1 .
- the terminal 102 responds to the data download request, and when there is synchronization data corresponding to the data download request, the terminal 102 first obtains the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data, and then according to the preset fixed bytes length and the number of nodes, the terminal 102 compares the actual byte length of the downloaded data to obtain the comparison result, then the terminal 102 determines the data node to be downloaded according to the comparison result and the downloaded data, and finally, the terminal 102 according to To download the data node, download the data.
- the terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
- a data download method is provided, and the method is applied to the terminal in FIG. 1 as an example for description, including the following steps:
- Step 202 responding to the data download request.
- the data download includes a situation in which there is synchronization data corresponding to the data download request and a situation in which there is no synchronization data corresponding to the data download request.
- the terminal will first perform network registration, that is, network registration, and ensure that the network can be activated, which is used to allocate IP (Internet Protocol, Internet Protocol) addresses, and ensuring that there is an IP address is a prerequisite for downloading.
- the download method can use the FTP (File Transfer Protocol, file transfer protocol) download method or the HTTP (Hyper Text Transfer Protocol, hypertext transfer protocol) download method, in other embodiments, other download methods can also be used, but not limited to It is a variety of download methods that provide download, and this program has nothing to do with the download method.
- the responding end of the data download request may be a user operation, or may be an automatic response download process after power off and restart, which may be but not limited to the above Response sending method.
- the terminal After the terminal responds to the data download request, before the data download, it will also perform detection processing to detect whether there is corresponding synchronization data.
- Step 204 when there is synchronization data corresponding to the data download request, acquire the downloaded data and the number of nodes corresponding to the downloaded data in the synchronization data.
- the synchronization data corresponding to the data download request includes the downloaded data and the number of nodes corresponding to the downloaded data.
- the permanent storage space may be hard disk storage such as Flash memory, which is a storage space that will not lose data due to power failure during the download process. non-volatile memory.
- the data is stored in the storage space, it will exist permanently, and other permanent storage spaces can also be used, including but not limited to various storage spaces that provide data storage. This storage space is associated with the terminal.
- the Fsync function must be called to immediately synchronize from the file buffer to the file written to the Flash memory or other hard disk storage, wherein the Fsync function belongs to a synchronization function in the computer operating system.
- Step 206 compare the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and obtain a comparison result.
- the fixed byte length is preset in advance. For example, it can be set to 10000 bytes or 20000 bytes. When it is not limited to the above byte length, only a fixed byte length needs to be set during the download process.
- the number of nodes is the number of nodes corresponding to the downloaded data, and the downloaded data has the corresponding actual byte length,
- the first comparison result is that the recorded byte length is consistent with the actual byte length
- the second comparison result is that the recorded byte length is inconsistent with the actual byte length.
- Step 208 Determine the data node to be downloaded according to the comparison result and the downloaded data.
- the comparison result includes a first comparison result in which the recorded byte length is consistent with the actual byte length and a second comparison result in which the recorded byte length is inconsistent with the actual byte length. According to different comparison results, different data nodes to be downloaded are determined, and the data nodes to be downloaded correspond to the downloaded data.
- the data node to be downloaded is determined according to the downloaded data, and the data node to be downloaded is determined according to the second comparison result.
- the comparison result is that the recorded byte length is inconsistent with the actual byte length
- delete the downloaded data when the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data, and delete the downloaded data whose byte length is greater than the recorded byte length.
- the deletion process is performed to obtain updated downloaded data, and according to the updated downloaded data, a data node to be downloaded is determined.
- step 210 data download is performed according to the data node to be downloaded.
- the data nodes to be downloaded include data nodes to be downloaded corresponding to the downloaded data associated with the first comparison result and data nodes to be downloaded corresponding to the updated downloaded data associated with the second comparison result.
- the terminal continues to start the data download process after the data node to be downloaded based on the data node to be downloaded determined by the first comparison result, or, through the second comparison result, according to the deletion
- the data download process after the data node to be downloaded continues.
- the synchronized data is obtained.
- the downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously to prevent the loss of the previously downloaded data.
- the The synchronous record of the byte length of the downloaded data compares the byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and compares the byte length of the downloaded data with the fixed byte length and the number of nodes.
- step 204 when there is synchronization data corresponding to the data download request, the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data are acquired, that is, step 204, include:
- Step 302 Extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data.
- the terminal detects the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file, and detects the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file Whether it exists, when the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file exists, it means that a part of the data has been downloaded before this, and the data has been backed up, and the extracted data is used to store the A first file of the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data.
- Step 304 Obtain the downloaded data from the first file, and obtain the number of nodes corresponding to the downloaded data from the second file.
- the terminal when the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file exists, it means that a part of the data has been downloaded before and the data has been backed up. At this time, the terminal can When continuing the download process after power off and restart, the terminal will obtain the number of nodes corresponding to the downloaded data in the first file that has been backed up and the downloaded data in the second file.
- step 202 after responding to the data download request, further includes:
- Step 402 when there is no synchronization data corresponding to the data download request, perform data download, and store the obtained downloaded data and the number of nodes corresponding to the downloaded data synchronously.
- the terminal After the terminal responds to the data download request, it will perform detection processing. When there is no synchronization data corresponding to the data download request, it indicates that the data has not been downloaded before. At this time, the terminal starts the download process, and the terminal downloads the data.
- the downloaded data and the number of nodes corresponding to the downloaded data are synchronously stored in the Flash memory or the hard disk in the file buffer. file and a second file for storing the number of nodes corresponding to the downloaded data.
- step 202 after responding to the data download request, further includes:
- Step 502 when there is no synchronization data corresponding to the data download request, perform data download, and create a first file for synchronously storing the downloaded data and a second file for synchronously storing the number of nodes corresponding to the downloaded data;
- the terminal After the terminal responds to the data download request, it will perform detection processing. When there is no synchronization data corresponding to the data download request, it means that the data has not been downloaded before. At this time, the terminal starts the download process, the terminal starts to download the data, and A first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data are created in the permanent storage space.
- Step 504 Store the downloaded data synchronously in the first file according to the fixed byte length, and store the number of nodes corresponding to the synchronously stored downloaded data in the second file.
- the first file and the second file download according to the fixed byte length. For example, if the fixed byte length of 10,000 bytes is set, it is 10,000 bytes each time.
- download The downloaded data corresponding to the fixed byte length of 10000 call the Faync function to synchronously store the downloaded data corresponding to the fixed byte length from the file buffer to the first file, when the downloaded data corresponding to the fixed byte length is synchronously completed , synchronously store the number of nodes corresponding to the downloaded data in the second file.
- the first file and the second file are both in the permanent storage space associated with the terminal, which can be written into Flash memory or other hard disk storage. middle.
- the downloaded data when there is no synchronization data corresponding to the data download request, by creating a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data, the downloaded The data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file, so that the downloaded data can be backed up.
- the downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file, that is, step 502 ,include:
- Step 602 Count the byte length of the data downloaded into the file buffer.
- the byte length of the data downloaded into the file cache is counted. It should be noted that the count here will not exceed the preset fixed byte length.
- the fixed byte length is 10000 bytes. Just from 0 to 10000 bytes.
- Step 604 when the counting result reaches the fixed byte length, synchronously store the downloaded data of the fixed byte length to the first file.
- the Fsync function is called, and the terminal synchronously stores the downloaded data corresponding to the fixed byte length from the file buffer to the first file.
- Step 606 When the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file.
- the terminal synchronously stores the downloaded data of the fixed byte length from the file buffer
- the number of nodes corresponding to the downloaded data is recorded in the second file, for example, according to the fixed byte length of 10000 words
- the downloaded data corresponding to 10,000 bytes is stored synchronously in the first file.
- the number of nodes is 1, the data has been downloaded in the second file.
- the corresponding number of nodes is 1. If the byte length of the downloaded data in the first file is 20000 bytes, the number of nodes is 2, and the number of nodes corresponding to the downloaded data in the second file is 2.
- Step 608 Clear the data in the file buffer and clear the counting result to zero, and return to the step of counting the byte length of the data downloaded into the file buffer until the download is completed or the power is turned off.
- the step of counting the byte length of the data in the terminal will repeat the above process until the download is completed or a power failure occurs. It should be noted that the subsequent downloaded data will continue to be counted and stored synchronously, and the previously downloaded data will not be Repeat the download again. In addition, if the synchronized downloaded data is not equal to the fixed byte length during the download process, it will return to the step of counting the byte length.
- step 206 the actual byte length of the downloaded data is compared to obtain a comparison result, that is, step 206, including:
- Step 702 Multiply the fixed byte length and the number of nodes to obtain the record byte length.
- the preset fixed byte length is multiplied by the number of nodes corresponding to the downloaded data in the second file, and the result obtained by multiplying the data is the record byte length.
- Step 704 performing a byte length comparison process on the recorded byte length and the actual byte length to obtain a comparison result.
- the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length and the actual byte length. inconsistent.
- the terminal performs a byte length comparison process between the recorded byte length obtained by multiplying the data with the actual byte length corresponding to the downloaded data in the first file, and the comparison result includes that the recorded byte length is consistent with the actual byte length Or the record byte length is inconsistent with the actual byte length.
- the actual byte length will not be less than the record byte length, because it is guaranteed during the download process.
- the downloaded data is synchronously completed in the first file, and after the synchronous storage in the first file is completed, the number of nodes is stored in the second file synchronously, so it is guaranteed that the actual byte length will not be less than the record byte. length.
- the byte length of the downloaded data is processed by fixing the byte length and the number of nodes, so as to simplify the complex processing process of all the downloaded data, and obtain a comparison result to verify that the recorded byte length is consistent with that of the downloaded data. Whether the byte length of the downloaded data is consistent.
- determining the data node to be downloaded includes:
- Step 802 when the comparison result is that the recorded byte length is consistent with the actual byte length, determine the data node to be downloaded according to the downloaded data.
- the terminal determines the node to be downloaded corresponding to the downloaded data according to the downloaded data corresponding to the actual byte length and through the downloaded data.
- Step 804 when the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data, according to the updated downloaded data. to determine the data node to be downloaded.
- the terminal will delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data. Through the updated downloaded data at this time, determine the data node to be downloaded corresponding to the updated byte length
- the present application further provides an application scenario where the above-mentioned data downloading method is applied.
- the application of the data downloading method in this application scenario is as follows:
- the terminal first registers with the network to ensure that the network can be activated, the network is activated to assign an IP address, and the terminal responds to the data download request. At this time, the terminal can choose to use the FTP download method or the HTTP download method. After that, a detection process is first performed to detect whether the first file for storing the downloaded data and the second file for storing the number of nodes corresponding to the downloaded data exist.
- the process of resuming the download after power failure is performed, and the downloaded data is obtained from the first file, and the corresponding data of the downloaded data is obtained from the second file.
- the number of nodes multiplies the fixed byte length and the data of the number of nodes to obtain the record byte length, compares the record byte length with the actual byte length, and obtains the comparison result.
- Download data determine the data node to be downloaded, and perform data download according to the data node to be downloaded.
- the actual byte length of the downloaded data is equal to 50000 bytes or greater than 50000 bytes.
- the data node to be downloaded is determined according to the downloaded data corresponding to the length of 50000 bytes, and the subsequent data download can be performed directly.
- the detection result is that the first file and the second file do not exist
- start the download process and create a first file for storing the downloaded data and a node number for storing the downloaded data corresponding to the data.
- the second file the byte length of the data downloaded into the file buffer is counted.
- the count result reaches the fixed byte length
- the downloaded data of the fixed byte length is synchronously stored in the first file.
- the number of nodes corresponding to the downloaded data is recorded in the second file, the data in the file buffer is cleared and the count result is cleared to zero, and the digital count of the data downloaded to the file buffer is returned. section length count steps until the download is complete or power is removed.
- the second file for storing the number of nodes corresponding to the downloaded data by responding to the data download request, it is detected whether the first file for storing the downloaded data and the second file for storing the number of nodes corresponding to the downloaded data exist, and it is judged whether the download data and the number of nodes have been checked.
- Pre-backup when there is synchronized data, obtain the downloaded data in the synchronized data and the number of nodes corresponding to the downloaded data, and store the downloaded data synchronously to prevent the loss of the previously downloaded data.
- the number of nodes and the preset fixed byte length realizes the synchronous record of the byte length of the downloaded data. According to the preset fixed byte length and the number of nodes, the byte length of the downloaded data is compared and processed.
- the byte length of the downloaded data is processed to simplify the complex processing of all downloaded data, and the comparison result is obtained to verify the byte length of the record and the byte length of the downloaded data. Whether it is consistent or not, according to the comparison result and the downloaded data, determine the data node to be downloaded, and perform data download processing with the data node to be downloaded as the starting point. When there is no synchronized data, by starting the download process, the data is synchronously stored in real time to achieve data backup processing.
- the download process of resumed download after power failure in the above embodiment realizes that after the power outage is restarted, the download can be resumed.
- a data downloading apparatus including: a data response acquisition module 1002, a data comparison module 1004, a data processing module 1006 and a data downloading module 1008, wherein:
- the data response acquisition module 1002 is used to respond to the data download request, and when there is synchronization data corresponding to the data download request, acquire the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
- the data comparison module 1004 is configured to perform comparison processing on the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, to obtain a comparison result;
- the data processing module 1006 is configured to determine the data node to be downloaded according to the comparison result and the downloaded data;
- the data download module 1008 is configured to download data according to the data node to be downloaded.
- the data response obtaining module is further configured to, in response to the data download request, extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data; from the first file
- the downloaded data is obtained from the second file, and the number of nodes corresponding to the downloaded data is obtained from the second file.
- the data response acquisition module is further configured to create a first file for storing the downloaded data and a first file for storing the downloaded data when there is no synchronization data corresponding to the data download request.
- the second file of the number of nodes corresponding to the data.
- the data response obtaining module is further configured to create a first file for storing the downloaded data and a first file for storing the number of nodes corresponding to the downloaded data when there is no synchronization data corresponding to the data download request.
- Second file The data response acquisition module is further configured to synchronously store the downloaded data in the first file according to the fixed byte length, and store the number of nodes corresponding to the synchronously stored downloaded data in the second file.
- the data response acquisition module is used to count the byte length of the data downloaded into the file buffer; when the counting result reaches the fixed byte length, the downloaded data of the fixed byte length is synchronously stored in the file buffer.
- the first file when the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file; clear the data in the file buffer and clear the count result, and return to the downloaded data. Steps to count byte lengths to the data in the file buffer until the download is complete or power is removed.
- the data comparison module is used to multiply data by the fixed byte length and the number of nodes to obtain the record byte length; perform byte length comparison processing on the record byte length and the actual byte length, A comparison result is obtained, and the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
- the data processing module is configured to determine the data node to be downloaded according to the downloaded data when the comparison result is that the recorded byte length is consistent with the actual byte length; when the comparison result is that the recorded byte length is the same as the actual byte length When the actual byte length is inconsistent, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data, and determine the data node to be downloaded according to the updated downloaded data.
- Each module in the above-mentioned data downloading apparatus may be implemented in whole or in part by software, hardware and combinations thereof.
- the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
- a computer device is provided, and the computer device may be a terminal, and its internal structure diagram may be as shown in FIG. 11 .
- the computer equipment includes a processor, memory, a communication interface, a display screen, and an input device connected by a system bus.
- the processor of the computer device is used to provide computing and control capabilities.
- the memory of the computer device includes a non-volatile storage medium, an internal memory.
- the nonvolatile storage medium stores an operating system and a computer program.
- the internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium.
- the communication interface of the computer device is used for wired or wireless communication with an external terminal, and the wireless communication can be realized by WIFI, operator network, NFC (Near Field Communication) or other technologies.
- the computer program when executed by the processor, implements a data downloading method.
- the display screen of the computer equipment may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment may be a touch layer covered on the display screen, or a button, a trackball or a touchpad set on the shell of the computer equipment , or an external keyboard, trackpad, or mouse.
- FIG. 11 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
- a computer device including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
- Data download is performed according to the data node to be downloaded.
- the processor further implements the following steps when executing the computer program:
- the processor further implements the following steps when executing the computer program:
- the processor further implements the following steps when executing the computer program:
- the processor further implements the following steps when executing the computer program:
- the processor further implements the following steps when executing the computer program:
- the processor further implements the following steps when executing the computer program:
- the data node to be downloaded is determined according to the downloaded data; when the comparison result is that the recorded byte length is inconsistent with the actual byte length, the byte length is greater than The downloaded data with the recorded byte length is deleted to obtain updated downloaded data, and a data node to be downloaded is determined according to the updated downloaded data.
- a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
- Data download is performed according to the data node to be downloaded.
- the computer program further implements the following steps when executed by the processor:
- the computer program further implements the following steps when executed by the processor:
- the computer program further implements the following steps when executed by the processor:
- the computer program further implements the following steps when executed by the processor:
- the computer program further implements the following steps when executed by the processor:
- the computer program further implements the following steps when executed by the processor:
- the data node to be downloaded is determined according to the downloaded data; when the comparison result is that the recorded byte length is inconsistent with the actual byte length, the byte length is greater than The downloaded data with the recorded byte length is deleted to obtain updated downloaded data, and a data node to be downloaded is determined according to the updated downloaded data.
- Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, or optical memory, and the like.
- Volatile memory may include random access memory (RAM) or external cache memory.
- the RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM).
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present application relates to a data downloading method and apparatus, a computer device, and a storage medium. The method comprises: responding to a data downloading request, and when synchronous data corresponding to the data downloading request exists, obtaining downloaded data in the synchronous data and number of nodes corresponding to the downloaded data; comparing an actual byte length of the downloaded data according to a preset fixed byte length and the number of nodes to obtain a comparison result; determining, according to the comparison result and the downloaded data, a node of data to be downloaded; and downloading the data according to the node of the data to be downloaded. According to the present method, data processing resources in a data downloading process can be saved.
Description
相关申请交叉引用Cross-reference to related applications
本申请要求于2020年10月19日递交的、标题为“数据下载方法、装置、计算机设备和存储介质”、申请号为2020111183798的中国专利申请的优先权,其公开内容通过引用全部结合在本申请中。This application claims the priority of the Chinese patent application entitled "Data Download Method, Apparatus, Computer Equipment and Storage Medium", filed on October 19, 2020, with application number 2020111183798, the disclosure of which is incorporated herein by reference in its entirety Applying.
本申请涉及互联网技术领域,特别是涉及一种数据下载方法、装置、计算机设备和存储介质。The present application relates to the field of Internet technologies, and in particular, to a data downloading method, apparatus, computer equipment and storage medium.
当前,随着互联网技术的飞速发展,基于网络传输协议的数据下载技术也日益发展起来,在网络传输出现问题的时候,为后续恢复数据传输,实现了断点续传的数据下载方案技术。At present, with the rapid development of Internet technology, data download technology based on network transmission protocol is also increasingly developed. When there is a problem with network transmission, the data download solution technology of continuous data transmission is realized for subsequent data transmission recovery.
在断点续传数据下载方案技术中,是当网络传输出错或者断网的情况下,提供重新在断点处进行继续下载数据的方案。In the technology of the data download solution for resuming data transmission at a breakpoint, it is a solution for continuing to download data at the breakpoint again when the network transmission is faulty or the network is disconnected.
然而,当发生断电情况时,此类断点续传数据下载方案技术并不能提供恢复继续下载数据,由于断电可以发生在任何时候,是不能预知的,一旦发生断电,会出现无法在断电之前的下载基础上继续运行这类不可避免的问题,导致需要重新进行数据下载,导致了数据处理资源的浪费。However, in the event of a power outage, this type of data download solution technology for resuming the data download cannot provide recovery and resume downloading of data. Since a power outage can occur at any time, it is unpredictable. Once a power outage occurs, there will be a The unavoidable problem of continuing to run on the basis of the download before the power failure leads to the need to re-download the data, resulting in a waste of data processing resources.
发明内容SUMMARY OF THE INVENTION
基于此,有必要针对上述技术问题,提供一种能够节约数据处理资源的数据下载方法、装置、计算机设备和存储介质。Based on this, it is necessary to provide a data download method, apparatus, computer device and storage medium that can save data processing resources in response to the above technical problems.
一种数据下载方法,所述方法包括:A method for downloading data, the method comprising:
响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data, and obtain the comparison result;
根据比对结果和已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;
根据待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
在其中一个实施例中,响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数包括:In one embodiment, in response to the data download request, when there is synchronization data corresponding to the data download request, acquiring the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data includes:
响应数据下载请求,提取用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件;In response to the data download request, extract the first file for storing the downloaded data and the second file for storing the number of nodes corresponding to the downloaded data;
从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数。The downloaded data is obtained from the first file, and the number of nodes corresponding to the downloaded data is obtained from the second file.
在其中一个实施例中,响应数据下载请求之后,还包括:In one embodiment, after responding to the data download request, the method further includes:
当不存在与数据下载请求对应的同步数据时,进行数据下载,对得到的已下载数据以及已下载数据对应的节点数进行同步存储。When there is no synchronization data corresponding to the data download request, data download is performed, and the obtained downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously.
在其中一个实施例中,响应数据下载请求之后,还包括:In one embodiment, after responding to the data download request, the method further includes:
当不存在与数据下载请求对应的同步数据时,进行数据下载,并创建用于同步存储已下载数据的第一文件和用于同步存储已下载数据对应的节点数的第二文件;When there is no synchronous data corresponding to the data download request, perform data download, and create a first file for synchronously storing the downloaded data and a second file for synchronously storing the number of nodes corresponding to the downloaded data;
将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。The downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file.
在其中一个实施例中,将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件包括:In one embodiment, synchronously storing the downloaded data in the first file according to a fixed byte length, and storing the number of nodes corresponding to the synchronously stored downloaded data in the second file includes:
对下载至文件缓冲区中的数据进行字节长度计数;Count the byte length of the data downloaded to the file buffer;
当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件;When the counting result reaches the fixed byte length, synchronously store the downloaded data of the fixed byte length to the first file;
当固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数;When the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file;
清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。Clear the data in the file buffer and clear the count result to zero, and return to the step of counting the byte length of the data downloaded to the file buffer until the download is completed or the power is turned off.
在其中一个实施例中,根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果包括:In one embodiment, according to the preset fixed byte length and the number of nodes, the actual byte length of the downloaded data is compared, and the comparison result obtained includes:
将固定字节长度和节点数进行数据相乘,得到记录字节长度;Multiply the fixed byte length and the number of nodes to obtain the record byte length;
将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致。Perform byte length comparison processing between the recorded byte length and the actual byte length, and obtain a comparison result. The comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
在其中一个实施例中,将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致包括:In one embodiment, a byte length comparison process is performed between the recorded byte length and the actual byte length, and a comparison result is obtained, and the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is the same as the actual byte length. Actual byte length inconsistencies include:
当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点;When the comparison result is that the recorded byte length is consistent with the actual byte length, according to the downloaded data, determine the data node to be downloaded;
当比对结果为记录字节长度与实际字节长度不一致时,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。When the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data, and determine the pending data according to the updated downloaded data. Download data nodes.
一种数据下载装置,所述装置包括:A data download device, the device includes:
数据响应获取模块,用于响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;The data response acquisition module is used to respond to the data download request, and when there is synchronization data corresponding to the data download request, acquire the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
数据比对模块,用于根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;The data comparison module is used to compare the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and obtain the comparison result;
数据处理模块,用于根据比对结果和已下载数据,确定待下载数据节点;The data processing module is used to determine the data node to be downloaded according to the comparison result and the downloaded data;
数据下载模块,根据待下载数据节点,进行数据下载。The data download module performs data download according to the data node to be downloaded.
一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现以下步骤:A computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data, and obtain the comparison result;
根据比对结果和已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;
根据待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:A computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data, and obtain the comparison result;
根据比对结果和已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;
根据待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
上述数据下载方法、装置、计算机设备和存储介质,通过响应数据下载请求,以存在与所述数据下载请求对应的同步数据为条件,判断是否对下载数据和节点数进行了预先备份,当存在同步数据时,获取同步的已下载数据和所述已下载数据对应的节点数,通过同步存储已下载数据,防止了之前已下载数据的丢失,基于同步的已下载数据对应的节点数和预设的固定字节长度,实现对已下载数据的字节长度的同步记录,根据预设的固定字节长度和节点数,对已下载数据的字节长度进行比对处理,通过固定字节长度和节点数对已下载数据的字节长度进行处理从而简化了对全部已下载数据的复杂处理过程,得到比对结果,以验证记录的字节长度与已下载数据的字节长度是否一致,根据比对结果和已下载数据,确定待下载数据节点,以待下载数据节点为起点进行数据下载处理,无需对全部数据重新进行下载,节约了数据下载过程的数据处理资源。The above data download method, device, computer equipment and storage medium, by responding to the data download request, on the condition that there is synchronization data corresponding to the data download request, it is judged whether the download data and the number of nodes have been backed up in advance, when there is a synchronization When the data is downloaded, the synchronized downloaded data and the number of nodes corresponding to the downloaded data are obtained, and the downloaded data is stored synchronously to prevent the loss of the previously downloaded data. Based on the synchronized downloaded data and the preset number of nodes Fixed byte length, realizes the synchronous record of the byte length of the downloaded data, and compares the byte length of the downloaded data according to the preset fixed byte length and the number of nodes. The number of bytes of the downloaded data is processed, which simplifies the complex processing process of all the downloaded data, and the comparison result is obtained to verify whether the recorded byte length is consistent with the byte length of the downloaded data. According to the comparison The result and the downloaded data are used to determine the data node to be downloaded, and the data download process is performed starting from the data node to be downloaded, without re-downloading all the data, which saves data processing resources in the data download process.
图1为一个实施例中数据下载方法的应用环境图;Fig. 1 is the application environment diagram of the data downloading method in one embodiment;
图2为一个实施例中数据下载方法的流程示意图;2 is a schematic flowchart of a data download method in one embodiment;
图3为另一个实施例中数据下载方法的流程示意图;3 is a schematic flowchart of a data download method in another embodiment;
图4为又一个实施例中数据下载方法的流程示意图;4 is a schematic flowchart of a data downloading method in another embodiment;
图5为还一个实施例中数据下载方法的流程示意图;5 is a schematic flowchart of a data download method in yet another embodiment;
图6为一个实施例中数据下载方法中不存在同步数据的流程示意图;Fig. 6 is the schematic flow chart that there is no synchronization data in the data downloading method in one embodiment;
图7为别的一个实施例中数据下载方法的流程示意图;7 is a schematic flowchart of a data downloading method in another embodiment;
图8为其他一个实施例中数据下载方法的流程示意图;8 is a schematic flowchart of a data downloading method in another embodiment;
图9为一个实施例中数据下载方法的应用场景图;Fig. 9 is the application scene diagram of the data downloading method in one embodiment;
图10为一个实施例中数据下载装置的结构框图;10 is a structural block diagram of a data downloading apparatus in one embodiment;
图11为一个实施例中计算机设备的内部结构图。Figure 11 is a diagram of the internal structure of a computer device in one embodiment.
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application.
本申请提供的数据下载方法,可以应用于如图1所示的应用环境中。其中,终端102响应数据下载请求,当存在与数据下载请求对应的同步数据时,终端102首先会获取同步数据中的已下载数据和已下载数据对应的节点数,然后根据预设的固定字节长度和节点数,终端102对已下载数据的实际字节长度进行比对处理,得到比对结果,接下来终端102根据比对结果和已下载数据,确定待下载数据节点,最后,终端102根据待下载数据节点,进行数据下载。终端102可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。The data downloading method provided in this application can be applied to the application environment shown in FIG. 1 . The terminal 102 responds to the data download request, and when there is synchronization data corresponding to the data download request, the terminal 102 first obtains the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data, and then according to the preset fixed bytes length and the number of nodes, the terminal 102 compares the actual byte length of the downloaded data to obtain the comparison result, then the terminal 102 determines the data node to be downloaded according to the comparison result and the downloaded data, and finally, the terminal 102 according to To download the data node, download the data. The terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
在一个实施例中,如图2所示,提供了一种数据下载方法,以该方法应用于图1中的终端为例进行说明,包括以下步骤:In one embodiment, as shown in FIG. 2 , a data download method is provided, and the method is applied to the terminal in FIG. 1 as an example for description, including the following steps:
步骤202,响应数据下载请求。 Step 202, responding to the data download request.
其中,数据下载包括当存在与数据下载请求对应的同步数据的情况以及当不存在与数据下载请求对应的同步数据的情况。Wherein, the data download includes a situation in which there is synchronization data corresponding to the data download request and a situation in which there is no synchronization data corresponding to the data download request.
具体地,终端首先会进行注网,即网络注册,以及确保可以激活网络,激活网络用以分配IP(Internet Protocol,互联网协议)地址,确保有IP地址是能够进行下载的前提,本实施例中,下载方式可以使用FTP(File Transfer Protocol,文件传输协议)下载方式或者HTTP(Hyper Text Transfer Protocol,超文本传输协议)下载方式,其他实施例中,当然也可以使用其他下载方式,可以但不限于是各种提供下载的下载方式,此方案与下载方 式无关。当终端接收到数据下载请求时,响应数据下载请求,在一实施例中,数据下载请求的响应端可以是用户操作,也可以是断电重启之后的自动响应下载流程,可以但不限于是以上的响应发送方式。终端响应数据下载请求之后,在数据下载之前,还会进行检测处理,检测是否存在对应的同步数据。Specifically, the terminal will first perform network registration, that is, network registration, and ensure that the network can be activated, which is used to allocate IP (Internet Protocol, Internet Protocol) addresses, and ensuring that there is an IP address is a prerequisite for downloading. In this embodiment, , the download method can use the FTP (File Transfer Protocol, file transfer protocol) download method or the HTTP (Hyper Text Transfer Protocol, hypertext transfer protocol) download method, in other embodiments, other download methods can also be used, but not limited to It is a variety of download methods that provide download, and this program has nothing to do with the download method. When the terminal receives the data download request, it responds to the data download request. In one embodiment, the responding end of the data download request may be a user operation, or may be an automatic response download process after power off and restart, which may be but not limited to the above Response sending method. After the terminal responds to the data download request, before the data download, it will also perform detection processing to detect whether there is corresponding synchronization data.
步骤204,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数。 Step 204, when there is synchronization data corresponding to the data download request, acquire the downloaded data and the number of nodes corresponding to the downloaded data in the synchronization data.
其中,数据下载请求对应的同步数据包括已下载数据和已下载数据对应的节点数。The synchronization data corresponding to the data download request includes the downloaded data and the number of nodes corresponding to the downloaded data.
具体地,当终端的永久存储空间中存在与数据下载请求对应的同步数据时,从永久存储空间中获取同步数据中的已下载数据和已下载数据对应的节点数。在一实施例中,此永久存储空间可以是Flash存储器等硬盘存储,此类存储不会因为下载过程发生断电而丢失数据的存储空间,其中,Flash存储器属于内存器件的一种,是一种非易失性内存。当数据存储入存储空间内会永久性的存在,也可以使用其他永久存储空间,可以但不限于是各种提供存储数据的存储空间,此存储空间与终端相关联,需要注意的是,数据一旦写入,必须调用Fsync函数即刻从文件缓冲区同步至写入Flash存储器或是其他硬盘存储的文件里,其中,Fsync函数属于计算机操作系统中的一种同步函数。Specifically, when there is synchronization data corresponding to the data download request in the permanent storage space of the terminal, the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data are acquired from the permanent storage space. In one embodiment, the permanent storage space may be hard disk storage such as Flash memory, which is a storage space that will not lose data due to power failure during the download process. non-volatile memory. When the data is stored in the storage space, it will exist permanently, and other permanent storage spaces can also be used, including but not limited to various storage spaces that provide data storage. This storage space is associated with the terminal. It should be noted that once the data is stored For writing, the Fsync function must be called to immediately synchronize from the file buffer to the file written to the Flash memory or other hard disk storage, wherein the Fsync function belongs to a synchronization function in the computer operating system.
步骤206,根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果。 Step 206 , compare the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and obtain a comparison result.
其中,固定字节长度是提前预先设置好的,例如,可以设置为10000字节或者20000字节,当不限于是以上字节长度,在下载过程中只需要设置一个固定的字节长度即可,节点数是已下载数据对应的节点数,已下载数据存在对应的实际字节长度,Among them, the fixed byte length is preset in advance. For example, it can be set to 10000 bytes or 20000 bytes. When it is not limited to the above byte length, only a fixed byte length needs to be set during the download process. , the number of nodes is the number of nodes corresponding to the downloaded data, and the downloaded data has the corresponding actual byte length,
具体地,读取同步数据中已下载数据对应的节点数,根据预设的固定字节长度和已下载数据对应的节点数,将固定字节长度和已下载数据对应的节点数进行数据相乘,得到记录字节长度,然后读取同步数据中的已下载数据,根据已下载数据得到相对应的实际字节长度,将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致,本实施例中,例如,当固定字节长度为10000字节,已下载数据对应的节点数为5,则可以得知终端至少已经下载了5*10000=50000的记录字节长度对应的字节数下载数据,此时,对已下载数据进行字节长度比对处理,比对处理只有两种结果,第一比对结果为记录字节长度与实际字节长度一致,第二比对结果为记录字节长度与实际字节长度不一致。Specifically, read the number of nodes corresponding to the downloaded data in the synchronization data, and multiply the fixed byte length and the number of nodes corresponding to the downloaded data according to the preset fixed byte length and the number of nodes corresponding to the downloaded data. , get the record byte length, then read the downloaded data in the synchronization data, get the corresponding actual byte length according to the downloaded data, compare the record byte length with the actual byte length, and get The comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length. In this embodiment, for example, when the fixed byte length is 10000 bytes, the downloaded data If the corresponding number of nodes is 5, it can be known that the terminal has downloaded at least the number of bytes of data corresponding to the record byte length of 5*10000=50000. There are only two results for the processing. The first comparison result is that the recorded byte length is consistent with the actual byte length, and the second comparison result is that the recorded byte length is inconsistent with the actual byte length.
步骤208,根据比对结果和已下载数据,确定待下载数据节点。Step 208: Determine the data node to be downloaded according to the comparison result and the downloaded data.
其中,比对结果包括记录字节长度与实际字节长度一致的第一比对结果以及记录字节长度与实际字节长度不一致的第二比对结果。根据不同的比对结果,确定不同的待下载数据节点,待下载数据节点对应已下载数据。The comparison result includes a first comparison result in which the recorded byte length is consistent with the actual byte length and a second comparison result in which the recorded byte length is inconsistent with the actual byte length. According to different comparison results, different data nodes to be downloaded are determined, and the data nodes to be downloaded correspond to the downloaded data.
具体地,根据第一比对结果和同步数据中的已下载数据,当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点,根据第二比对结果和同步数据中的已下载数据,当比对结果为记录字节长度与实际字节长度不一致时,对已下载数据进行删除处理,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。Specifically, according to the first comparison result and the downloaded data in the synchronization data, when the comparison result is that the recorded byte length is consistent with the actual byte length, the data node to be downloaded is determined according to the downloaded data, and the data node to be downloaded is determined according to the second comparison result. For the downloaded data in the result and synchronization data, when the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data, and delete the downloaded data whose byte length is greater than the recorded byte length. The deletion process is performed to obtain updated downloaded data, and according to the updated downloaded data, a data node to be downloaded is determined.
步骤210,根据待下载数据节点,进行数据下载。In step 210, data download is performed according to the data node to be downloaded.
其中,待下载数据节点包括根据第一比对结果相关联的已下载数据对应的待下载数据节点以及根据第二比对结果相关联的更新的已下载数据对应的待下载数据节点。The data nodes to be downloaded include data nodes to be downloaded corresponding to the downloaded data associated with the first comparison result and data nodes to be downloaded corresponding to the updated downloaded data associated with the second comparison result.
具体地,终端通过上述处理,通过第一比对结果,根据已下载数据所确定的待下载数据节点,继续开始待下载数据节点之后的数据下载过程,或者,通过第二比对结果,根据删除处理后更新的已下载数据所确定的待下载数据节点,继续开始待下载数据节点之后的数据下载过程。Specifically, through the above processing, the terminal continues to start the data download process after the data node to be downloaded based on the data node to be downloaded determined by the first comparison result, or, through the second comparison result, according to the deletion For the data node to be downloaded determined by the updated downloaded data after processing, the data download process after the data node to be downloaded continues.
上述数据下载方法中,通过响应数据下载请求,以存在与所述数据下载请求对应的同步数据为条件,判断是否对下载数据和节点数进行了预先备份,当存在同步数据时,获取同步的已下载数据和所述已下载数据对应的节点数,通过同步存储已下载数据,防止了之前已下载数据的丢失,基于同步的已下载数据对应的节点数和预设的固定字节长度,实现对已下载数据的字节长度的同步记录,根据预设的固定字节长度和节点数,对已下载数据的字节长度进行比对处理,通过固定字节长度和节点数对已下载数据的字节长度进行处理从而简化了对全部已下载数据的复杂处理过程,得到比对结果,以验证记录的字节长度与已下载数据的字节长度是否一致,根据比对结果和已下载数据,确定待下载数据节点,以待下载数据节点为起点进行数据下载处理,无需对全部数据重新进行下载,节约了数据下载过程的数据处理资源。In the above data download method, by responding to the data download request, on the condition that there is synchronization data corresponding to the data download request, it is judged whether the download data and the number of nodes have been backed up in advance, and when there is synchronization data, the synchronized data is obtained. The downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously to prevent the loss of the previously downloaded data. Based on the number of nodes corresponding to the synchronized downloaded data and the preset fixed byte length, the The synchronous record of the byte length of the downloaded data, compares the byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and compares the byte length of the downloaded data with the fixed byte length and the number of nodes. This simplifies the complex processing process of all downloaded data, and obtains the comparison result to verify whether the byte length of the record is consistent with the byte length of the downloaded data. According to the comparison result and the downloaded data, determine For the data node to be downloaded, the data download processing is performed starting from the data node to be downloaded, and there is no need to re-download all the data, which saves data processing resources in the data download process.
在其中一个实施例中,如图3所示,当存在与数据下载请求对应的同步数据时,获取所述同步数据中的已下载数据和所述已下载数据对应的节点数,即步骤204,包括:In one embodiment, as shown in FIG. 3 , when there is synchronization data corresponding to the data download request, the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data are acquired, that is, step 204, include:
步骤302,提取用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件。Step 302: Extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data.
具体地,终端会对第一文件中的已下载数据和第二文件中已下载数据对应的节点数进行检测,检测第一文件中的已下载数据和第二文件中已下载数据对应的节点数是否存在,当第一文件中的已下载数据和第二文件中已下载数据对应的节点数存在时,说明在此之前已经下载了一部分数据,并且对数据进行了备份,提取用于存储所述已下载数据的第一文件和用于存储所述已下载数据对应的节点数的第二文件。Specifically, the terminal detects the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file, and detects the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file Whether it exists, when the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file exists, it means that a part of the data has been downloaded before this, and the data has been backed up, and the extracted data is used to store the A first file of the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data.
步骤304,从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数。Step 304: Obtain the downloaded data from the first file, and obtain the number of nodes corresponding to the downloaded data from the second file.
具体地,当第一文件中的已下载数据和第二文件中已下载数据对应的节点数存在时,说明在此之前已经下载了一部分数据,并且对数据进行了备份,此时,终端可以进行断电重启后的继续下载流程,终端会获取已经备份好的第一文件中的已下载数据和第二文件中已下载数据对应的节点数。Specifically, when the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file exists, it means that a part of the data has been downloaded before and the data has been backed up. At this time, the terminal can When continuing the download process after power off and restart, the terminal will obtain the number of nodes corresponding to the downloaded data in the first file that has been backed up and the downloaded data in the second file.
本实施例中,通过以存在与所述数据下载请求对应的同步数据为条件,判断是否对下载数据和节点数进行了预先备份,当存在同步数据时,获取同步的已下载数据和所述已下载数据对应的节点数,通过同步存储已下载数据,能够防止之前已下载数据的丢失。In this embodiment, it is judged whether the download data and the number of nodes have been backed up in advance by taking the existence of synchronization data corresponding to the data download request as a condition, and when there is synchronization data, the synchronized downloaded data and the The number of nodes corresponding to the downloaded data, and by synchronously storing the downloaded data, the loss of the previously downloaded data can be prevented.
在其中一个实施例中,如图4所示,步骤202,响应数据下载请求之后,还包括:In one embodiment, as shown in FIG. 4 , step 202, after responding to the data download request, further includes:
步骤402,当不存在与数据下载请求对应的同步数据时,进行数据下载,对得到的已下载数据以及已下载数据对应的节点数进行同步存储。 Step 402 , when there is no synchronization data corresponding to the data download request, perform data download, and store the obtained downloaded data and the number of nodes corresponding to the downloaded data synchronously.
具体地,终端响应数据下载请求之后,会进行检测处理,当不存在与数据下载请求对应的同步数据时,说明之前未下载数据,此时的终端进行开始下载流程,终端进行数据下载,对得到的已下载数据以及已下载数据对应的节点数在文件缓冲区进行同步存储到Flash存储器或是硬盘中,在一实施例中,终端会在永久存储空间中创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件。Specifically, after the terminal responds to the data download request, it will perform detection processing. When there is no synchronization data corresponding to the data download request, it indicates that the data has not been downloaded before. At this time, the terminal starts the download process, and the terminal downloads the data. The downloaded data and the number of nodes corresponding to the downloaded data are synchronously stored in the Flash memory or the hard disk in the file buffer. file and a second file for storing the number of nodes corresponding to the downloaded data.
本实施例中,通过对得到的已下载数据以及已下载数据对应的节点数进行同步存储,能够达到用以后续的数据备份防止数据丢失。In this embodiment, by synchronously storing the obtained downloaded data and the number of nodes corresponding to the downloaded data, subsequent data backup can be used to prevent data loss.
在其中一个实施例中,如图5所示,步骤202,响应数据下载请求之后,还包括:In one embodiment, as shown in FIG. 5, step 202, after responding to the data download request, further includes:
步骤502,当不存在与数据下载请求对应的同步数据时,进行数据下载,并创建用于同步存储已下载数据的第一文件和用于同步存储已下载数据对应的节点数的第二文件; Step 502, when there is no synchronization data corresponding to the data download request, perform data download, and create a first file for synchronously storing the downloaded data and a second file for synchronously storing the number of nodes corresponding to the downloaded data;
具体地,终端响应数据下载请求之后,会进行检测处理,当不存在与数据下载请求对应的同步数据时,说明之前未下载数据,此时的终端进行开始下载流程,终端开始进行数据下载,并且在永久存储空间中创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件。Specifically, after the terminal responds to the data download request, it will perform detection processing. When there is no synchronization data corresponding to the data download request, it means that the data has not been downloaded before. At this time, the terminal starts the download process, the terminal starts to download the data, and A first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data are created in the permanent storage space.
步骤504,将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。Step 504: Store the downloaded data synchronously in the first file according to the fixed byte length, and store the number of nodes corresponding to the synchronously stored downloaded data in the second file.
具体地,创建第一文件和第二文件之后,按照固定字节长度进行下载,比如,设置10000字节的固定字节长度,就按每次10000字节,首先当下载至10000字节,将10000固定字节长度对应的已下载数据,调用Faync函数,将固定字节长度对应的已下载数据从文件缓存区同步存储至第一文件中,当固定字节长度对应的已下载数据同步完成时,将已下载数据对应的节点数同步存储到第二文件中完成同步存储后的第一文件和第二文件都在终端相关联的永久存储空间中,可以是写入Flash存储器或是其他硬盘存储中。Specifically, after creating the first file and the second file, download according to the fixed byte length. For example, if the fixed byte length of 10,000 bytes is set, it is 10,000 bytes each time. First, when downloading to 10,000 bytes, download The downloaded data corresponding to the fixed byte length of 10000, call the Faync function to synchronously store the downloaded data corresponding to the fixed byte length from the file buffer to the first file, when the downloaded data corresponding to the fixed byte length is synchronously completed , synchronously store the number of nodes corresponding to the downloaded data in the second file. After the synchronous storage is completed, the first file and the second file are both in the permanent storage space associated with the terminal, which can be written into Flash memory or other hard disk storage. middle.
本实施例中,当不存在与数据下载请求对应的同步数据时,通过创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件,将已下载的数据按固定字节长度同步存储至第一文件,将同步存储已下载的数据对应的节点数存储至第二文件,能够达到对已下载数据进行备份。In this embodiment, when there is no synchronization data corresponding to the data download request, by creating a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data, the downloaded The data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file, so that the downloaded data can be backed up.
在其中一个实施例中,如图6所示,将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件,即步骤502,包括:In one embodiment, as shown in FIG. 6 , the downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file, that is, step 502 ,include:
步骤602,对下载至文件缓冲区中的数据进行字节长度计数。Step 602: Count the byte length of the data downloaded into the file buffer.
具体地,对下载至文件缓存区中的数据进行字节长度计数,需要注意的是,此处的计数是不会超过预先设置的固定字节长度的,例如固定字节长度为10000字节,就从0至10000字节。Specifically, the byte length of the data downloaded into the file cache is counted. It should be noted that the count here will not exceed the preset fixed byte length. For example, the fixed byte length is 10000 bytes. Just from 0 to 10000 bytes.
步骤604,当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件。 Step 604, when the counting result reaches the fixed byte length, synchronously store the downloaded data of the fixed byte length to the first file.
具体地,当计数结果达到固定字节长度时,此时,调用Fsync函数,终端将固定字节长度对应的已下载数据从文件缓冲区同步存储至第一文件中。Specifically, when the count result reaches the fixed byte length, at this time, the Fsync function is called, and the terminal synchronously stores the downloaded data corresponding to the fixed byte length from the file buffer to the first file.
步骤606,当固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数。Step 606: When the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file.
具体地,当终端通过将固定字节长度的已下载数据从文件缓冲区同步存储完成时,此时,在第二文件中记载已下载数据对应的节点数,例如,按照固定字节长度10000字节进行下载,当达到10000字节的固定字节长度时,将10000字节对应的已下载数据同步存储至第一文件完成时,此时记节点数为1,则第二文件中已下载数据对应的节点数为1,若第一文件中的已下载数据的字节长度为20000字节时,此时记节点数为2,则第二文件中已下载数据对应的节点数为2。Specifically, when the terminal synchronously stores the downloaded data of the fixed byte length from the file buffer, at this time, the number of nodes corresponding to the downloaded data is recorded in the second file, for example, according to the fixed byte length of 10000 words When the fixed byte length of 10,000 bytes is reached, the downloaded data corresponding to 10,000 bytes is stored synchronously in the first file. When the number of nodes is 1, the data has been downloaded in the second file. The corresponding number of nodes is 1. If the byte length of the downloaded data in the first file is 20000 bytes, the number of nodes is 2, and the number of nodes corresponding to the downloaded data in the second file is 2.
步骤608,清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。Step 608: Clear the data in the file buffer and clear the counting result to zero, and return to the step of counting the byte length of the data downloaded into the file buffer until the download is completed or the power is turned off.
具体地,当文件缓冲区里的已下载数据的字节长度达到固定字节长度时并且同步存储完成之后,清除文件缓冲区中的数据,并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,终端将重复以上流程直至下载完成或发生断电,需要注意的是,是继续对后续下载的数据进行计数和同步存储处理,之前已经下载过的数据不再重复下载。此外,在下载过程中如果同步的已下载数据不等于固定字节长度会返回至进行字节长度计数的步骤。Specifically, when the byte length of the downloaded data in the file buffer reaches the fixed byte length and the synchronous storage is completed, the data in the file buffer is cleared, the counting result is cleared to zero, and a response to the download to the file buffer is returned. The step of counting the byte length of the data in the terminal will repeat the above process until the download is completed or a power failure occurs. It should be noted that the subsequent downloaded data will continue to be counted and stored synchronously, and the previously downloaded data will not be Repeat the download again. In addition, if the synchronized downloaded data is not equal to the fixed byte length during the download process, it will return to the step of counting the byte length.
本实施例中,通过同步存储已下载数据,能够达到防止了之前已下载数据的丢失,基于同步的已下载数据对应的节点数和预设的固定字节长度,实现对已下载数据的字节长度的同步记录。In this embodiment, by synchronously storing the downloaded data, it is possible to prevent the loss of the previously downloaded data, and based on the number of nodes corresponding to the synchronized downloaded data and the preset fixed byte length, the bytes of the downloaded data can be stored. The length of the sync record.
在其中一个实施例中,如图7所示,根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果,即步骤206,包括:In one embodiment, as shown in FIG. 7 , according to the preset fixed byte length and the number of nodes, the actual byte length of the downloaded data is compared to obtain a comparison result, that is, step 206, including:
步骤702,将固定字节长度和节点数进行数据相乘,得到记录字节长度。Step 702: Multiply the fixed byte length and the number of nodes to obtain the record byte length.
具体地,将预设的固定字节长度与第二文件中已下载数据对应的节点数进行数据相 乘,得到数据相乘的结果为记录字节长度。例如,预设的固定字节长度为10000字节,第二文件中已下载数据对应的节点数为5,则数据相乘为5*10000=50000,得到记录字节长度为50000的数值。Specifically, the preset fixed byte length is multiplied by the number of nodes corresponding to the downloaded data in the second file, and the result obtained by multiplying the data is the record byte length. For example, the preset fixed byte length is 10000 bytes, and the number of nodes corresponding to the downloaded data in the second file is 5, then the data is multiplied to 5*10000=50000, and the value of the record byte length is 50000.
步骤704,将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致。 Step 704, performing a byte length comparison process on the recorded byte length and the actual byte length to obtain a comparison result. The comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length and the actual byte length. inconsistent.
具体地,终端将数据相乘得到的记录字节长度与第一文件中已下载数据对应的实际字节长度进行字节长度比对处理,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致,需要注意的是,当记录字节长度与实际字节长度不一致时,实际字节长度不会小于记录字节长度,因为在开始下载流程中保证了已下载数据是先同步完成到第一文件中,当完成第一文件中的同步存储之后,才将节点数同步存储进入第二文件中的,所以保证了实际字节长度不会小于记录字节长度。Specifically, the terminal performs a byte length comparison process between the recorded byte length obtained by multiplying the data with the actual byte length corresponding to the downloaded data in the first file, and the comparison result includes that the recorded byte length is consistent with the actual byte length Or the record byte length is inconsistent with the actual byte length. It should be noted that when the record byte length is inconsistent with the actual byte length, the actual byte length will not be less than the record byte length, because it is guaranteed during the download process. The downloaded data is synchronously completed in the first file, and after the synchronous storage in the first file is completed, the number of nodes is stored in the second file synchronously, so it is guaranteed that the actual byte length will not be less than the record byte. length.
本实施例中,通过固定字节长度和节点数对已下载数据的字节长度进行处理,能够达到简化对全部已下载数据的复杂处理过程,得到比对结果,以验证记录的字节长度与已下载数据的字节长度是否一致。In this embodiment, the byte length of the downloaded data is processed by fixing the byte length and the number of nodes, so as to simplify the complex processing process of all the downloaded data, and obtain a comparison result to verify that the recorded byte length is consistent with that of the downloaded data. Whether the byte length of the downloaded data is consistent.
在其中一个实施例中,如图8所示,根据比对结果和已下载数据,确定待下载数据节点,即步骤208,包括:In one embodiment, as shown in FIG. 8 , according to the comparison result and the downloaded data, determining the data node to be downloaded, that is, step 208 , includes:
步骤802,当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点。 Step 802, when the comparison result is that the recorded byte length is consistent with the actual byte length, determine the data node to be downloaded according to the downloaded data.
具体地,当比对结果为记录字节长度与实际字节长度一致时,终端根据实际字节长度对应的已下载数据,通过已下载数据,确定已下载数据对应的待下载节点。Specifically, when the comparison result is that the recorded byte length is consistent with the actual byte length, the terminal determines the node to be downloaded corresponding to the downloaded data according to the downloaded data corresponding to the actual byte length and through the downloaded data.
步骤804,当比对结果为记录字节长度与实际字节长度不一致时,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。 Step 804, when the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data, according to the updated downloaded data. to determine the data node to be downloaded.
具体地,当比对结果为记录字节长度与实际字节长度不一致时,终端会进行删除处理,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,通过此时的更新的已下载数据,确定与更新的字节长度对应的待下载数据节点Specifically, when the comparison result is that the recorded byte length is inconsistent with the actual byte length, the terminal will delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data. Through the updated downloaded data at this time, determine the data node to be downloaded corresponding to the updated byte length
本实施例中,通过根据比对结果和已下载数据,确定待下载数据节点,以待下载数据节点为起点进行数据下载处理,能够无需对全部数据重新进行下载,达到节约数据下载过程的数据处理资源。In this embodiment, by determining the data node to be downloaded according to the comparison result and the downloaded data, and performing data download processing with the data node to be downloaded as a starting point, it is possible to save all data from downloading again, thus saving data processing in the data download process. resource.
在一个应用实例中,如图9所示,本申请还提供一种应用场景,该应用场景应用上述的数据下载方法。具体地,该数据下载方法在该应用场景的应用如下:In an application example, as shown in FIG. 9 , the present application further provides an application scenario where the above-mentioned data downloading method is applied. Specifically, the application of the data downloading method in this application scenario is as follows:
在其中一个实施例中,终端首先注册网络,确保可以激活网络,激活网络用以分配IP地址,终端响应数据下载请求,此时可以选择使用FTP下载方式或者HTTP下载方式,当终端接收数据下载请求之后,首先进行检测处理,检测用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件是否存在。In one of the embodiments, the terminal first registers with the network to ensure that the network can be activated, the network is activated to assign an IP address, and the terminal responds to the data download request. At this time, the terminal can choose to use the FTP download method or the HTTP download method. After that, a detection process is first performed to detect whether the first file for storing the downloaded data and the second file for storing the number of nodes corresponding to the downloaded data exist.
在其中一个实施例中,当检测结果为第一文件和第二文件存在时,进行断电续传下载流程,从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数将固定字节长度与和节点数进行数据相乘,得到记录字节长度,将记录字节长度与实际字节长度进行字节长度比较处理,得到比对结果,根据比对结果和已下载数据,确定待下载数据节点,根据待下载数据节点,进行数据下载。例如,设置固定字节长度为10000字节,已下载数据对应的节点数为5,则可以得知终端至少已经下载了5*10000=50000字节的记录字节长度对应的字节数下载数据,已下载数据的实际字节长度为等于50000字节或者大于50000字节,当等于50000字节时,表明在断电发生的时刻,第一文件和第二文件中的内容已经全部同步完成,此时根据50000字节长度对应的已下载数据,确定待下载的数据节点,直接进行其后的数据下载即可。当大于50000字节时,表明在断电发生的时候第一文 件中的数据同步完成时,第二文件中对应的节点数还没有来得及记录就出现了断电情况。此时需要保证第一文件中的已下载数据和第二文件中已下载数据对应的节点数的一致性,将大于50000字节的数据进行删除,根据50000字节其后的数据继续进行下载。In one of the embodiments, when the detection result is that the first file and the second file exist, the process of resuming the download after power failure is performed, and the downloaded data is obtained from the first file, and the corresponding data of the downloaded data is obtained from the second file. The number of nodes multiplies the fixed byte length and the data of the number of nodes to obtain the record byte length, compares the record byte length with the actual byte length, and obtains the comparison result. Download data, determine the data node to be downloaded, and perform data download according to the data node to be downloaded. For example, if the fixed byte length is set to 10000 bytes and the number of nodes corresponding to the downloaded data is 5, it can be known that the terminal has downloaded at least the number of bytes corresponding to the record byte length of 5*10000=50000 bytes. , the actual byte length of the downloaded data is equal to 50000 bytes or greater than 50000 bytes. When it is equal to 50000 bytes, it indicates that at the moment of power failure, the contents of the first file and the second file have been synchronized. At this time, the data node to be downloaded is determined according to the downloaded data corresponding to the length of 50000 bytes, and the subsequent data download can be performed directly. When it is greater than 50000 bytes, it indicates that when the data synchronization in the first file is completed when the power failure occurs, the power failure occurs before the corresponding number of nodes in the second file has time to be recorded. At this time, it is necessary to ensure the consistency of the number of nodes corresponding to the downloaded data in the first file and the downloaded data in the second file, delete data larger than 50,000 bytes, and continue downloading according to the data after 50,000 bytes.
在其中一个实施例中,当检测结果为第一文件和第二文件不存在时,进行开始下载流程,创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件,对下载至文件缓冲区中的数据进行字节长度计数,当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件,当述固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数,清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。例如,设置固定字节为10000字节,按照10000字节进行下载,当下载至文件缓存区中的数据达到10000字节时,调用Fsync函数,将10000字节对应的已下载数据同步存储至Flash存储器里的第一文件中,当同步存储完成以后,节点数为1,将节点数记录到Flash存储器里的第二文件中,以此类推。需要注意的是,下载过程中必须按照固定字节长度进行计数下载。在文件缓冲区中同样可以创建两个文件来用以存储下载至文件缓冲区的数据,当数据按照固定字节写入到文件缓存区的文件中,必须调用Fsync同步函数将文件缓冲区数据即刻写入Flash存储器中的文件中。In one embodiment, when the detection result is that the first file and the second file do not exist, start the download process, and create a first file for storing the downloaded data and a node number for storing the downloaded data corresponding to the data. In the second file, the byte length of the data downloaded into the file buffer is counted. When the count result reaches the fixed byte length, the downloaded data of the fixed byte length is synchronously stored in the first file. When the synchronous storage of the downloaded data of the length is completed, the number of nodes corresponding to the downloaded data is recorded in the second file, the data in the file buffer is cleared and the count result is cleared to zero, and the digital count of the data downloaded to the file buffer is returned. section length count steps until the download is complete or power is removed. For example, set the fixed byte to 10000 bytes, download according to 10000 bytes, when the data downloaded to the file buffer reaches 10000 bytes, call the Fsync function to store the downloaded data corresponding to 10000 bytes in Flash synchronously In the first file in the memory, after the synchronous storage is completed, the number of nodes is 1, and the number of nodes is recorded in the second file in the Flash memory, and so on. It should be noted that the download process must be counted and downloaded according to the fixed byte length. Two files can also be created in the file buffer to store the data downloaded to the file buffer. When the data is written to the file in the file buffer according to fixed bytes, the Fsync synchronization function must be called to immediately transfer the data to the file buffer. Write to a file in Flash memory.
本实施例中,通过响应数据下载请求,检测用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件是否存在,判断是否对下载数据和节点数进行了预先备份,当存在同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数,通过同步存储已下载数据,防止了之前已下载数据的丢失,基于同步的已下载数据对应的节点数和预设的固定字节长度,实现对已下载数据的字节长度的同步记录,根据预设的固定字节长度和节点数,对已下载数据的字节长度进行比对处理,通过固定字节长度和节点数对已下载数据的字节长度进行处理从而简化了对全部已下载数据的复杂处理过程,得到比对结果,以验证记录的字节长度与已下载数据的字节长度是否一致,根据比对结果和已下载数据,确定待下载数据节点,以待下载数据节点为起点进行数据下载处理。当不存在同步数据时,通过开始下载流程,对数据进行实时同步存储,达到了数据的备份处理。上述实施例的断电续传下载流程,实现了在断电重启之后,还可以进行续传,现有的断点续传在断电后由于没有数据备份,突发断电状况导致缓存的数据消失,需要重新进行下载,而本方案通过开始下载流程对第一文件和第二文件进行了备份处理,在断电之后,可以达到延续待下载数据节点继续下载的效果,无需对全部数据重新进行下载,节约了数据下载过程的数据处理资源。In this embodiment, by responding to the data download request, it is detected whether the first file for storing the downloaded data and the second file for storing the number of nodes corresponding to the downloaded data exist, and it is judged whether the download data and the number of nodes have been checked. Pre-backup, when there is synchronized data, obtain the downloaded data in the synchronized data and the number of nodes corresponding to the downloaded data, and store the downloaded data synchronously to prevent the loss of the previously downloaded data. The number of nodes and the preset fixed byte length realizes the synchronous record of the byte length of the downloaded data. According to the preset fixed byte length and the number of nodes, the byte length of the downloaded data is compared and processed. Fixed byte length and number of nodes The byte length of the downloaded data is processed to simplify the complex processing of all downloaded data, and the comparison result is obtained to verify the byte length of the record and the byte length of the downloaded data. Whether it is consistent or not, according to the comparison result and the downloaded data, determine the data node to be downloaded, and perform data download processing with the data node to be downloaded as the starting point. When there is no synchronized data, by starting the download process, the data is synchronously stored in real time to achieve data backup processing. The download process of resumed download after power failure in the above embodiment realizes that after the power outage is restarted, the download can be resumed. In the existing resumed download after the power outage, because there is no data backup after the power outage, the sudden power failure causes the cached data. If the file disappears, it needs to be downloaded again. In this solution, the first file and the second file are backed up by starting the download process. After the power is turned off, the effect of continuing the download of the data node to be downloaded can be achieved, and there is no need to redo all the data. Downloading saves data processing resources in the data downloading process.
应该理解的是,虽然上述实施例中各流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,各流程图的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that, although the steps in the flowcharts in the above-mentioned embodiments are sequentially displayed according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, the execution of these steps is not strictly limited to the order, and these steps may be performed in other orders. Moreover, at least a part of the steps in each flowchart may include multiple steps or multiple stages, these steps or stages are not necessarily executed at the same time, but may be executed at different times, and the execution sequence of these steps or stages is also It does not have to be performed sequentially, but may be performed alternately or alternately with other steps or at least a portion of the steps or stages within the other steps.
在一个实施例中,如图10所示,提供了一种数据下载装置,包括:数据响应获取模块1002、数据比对模块1004、数据处理模块1006和数据下载模块1008,其中:In one embodiment, as shown in FIG. 10, a data downloading apparatus is provided, including: a data response acquisition module 1002, a data comparison module 1004, a data processing module 1006 and a data downloading module 1008, wherein:
数据响应获取模块1002用于响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;The data response acquisition module 1002 is used to respond to the data download request, and when there is synchronization data corresponding to the data download request, acquire the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
数据比对模块1004用于根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;The data comparison module 1004 is configured to perform comparison processing on the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, to obtain a comparison result;
数据处理模块1006用于根据比对结果和已下载数据,确定待下载数据节点;The data processing module 1006 is configured to determine the data node to be downloaded according to the comparison result and the downloaded data;
数据下载模块1008用于根据待下载数据节点,进行数据下载。The data download module 1008 is configured to download data according to the data node to be downloaded.
在其中一个实施例中,数据响应获取模块还用于响应数据下载请求,提取用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件;从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数。In one embodiment, the data response obtaining module is further configured to, in response to the data download request, extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data; from the first file The downloaded data is obtained from the second file, and the number of nodes corresponding to the downloaded data is obtained from the second file.
在其中一个实施例中,响应数据下载请求之后,数据响应获取模块还用于当不存在与数据下载请求对应的同步数据时,创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件。In one of the embodiments, after responding to the data download request, the data response acquisition module is further configured to create a first file for storing the downloaded data and a first file for storing the downloaded data when there is no synchronization data corresponding to the data download request. The second file of the number of nodes corresponding to the data.
在其中一个实施例中,数据响应获取模块还用于当不存在与数据下载请求对应的同步数据时,创建用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件。数据响应获取模块还用于将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。In one embodiment, the data response obtaining module is further configured to create a first file for storing the downloaded data and a first file for storing the number of nodes corresponding to the downloaded data when there is no synchronization data corresponding to the data download request. Second file. The data response acquisition module is further configured to synchronously store the downloaded data in the first file according to the fixed byte length, and store the number of nodes corresponding to the synchronously stored downloaded data in the second file.
在其中一个实施例中,数据响应获取模块用于对下载至文件缓冲区中的数据进行字节长度计数;当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件;当述固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数;清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。In one embodiment, the data response acquisition module is used to count the byte length of the data downloaded into the file buffer; when the counting result reaches the fixed byte length, the downloaded data of the fixed byte length is synchronously stored in the file buffer. The first file; when the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file; clear the data in the file buffer and clear the count result, and return to the downloaded data. Steps to count byte lengths to the data in the file buffer until the download is complete or power is removed.
在其中一个实施例中,数据比对模块用于将固定字节长度和节点数进行数据相乘,得到记录字节长度;将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致。In one of the embodiments, the data comparison module is used to multiply data by the fixed byte length and the number of nodes to obtain the record byte length; perform byte length comparison processing on the record byte length and the actual byte length, A comparison result is obtained, and the comparison result includes that the recorded byte length is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
在其中一个实施例中,数据处理模块用于当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点;当比对结果为记录字节长度与实际字节长度不一致时,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。In one embodiment, the data processing module is configured to determine the data node to be downloaded according to the downloaded data when the comparison result is that the recorded byte length is consistent with the actual byte length; when the comparison result is that the recorded byte length is the same as the actual byte length When the actual byte length is inconsistent, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data, and determine the data node to be downloaded according to the updated downloaded data.
关于数据下载装置的具体限定可以参见上文中对于数据下载装置方法的限定,在此不再赘述。上述数据下载装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the data downloading apparatus, reference may be made to the above limitation on the method of the data downloading apparatus, which will not be repeated here. Each module in the above-mentioned data downloading apparatus may be implemented in whole or in part by software, hardware and combinations thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图11所示。该计算机设备包括通过系统总线连接的处理器、存储器、通信接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的通信接口用于与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、运营商网络、NFC(近场通信)或其他技术实现。该计算机程序被处理器执行时以实现一种数据下载方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。In one embodiment, a computer device is provided, and the computer device may be a terminal, and its internal structure diagram may be as shown in FIG. 11 . The computer equipment includes a processor, memory, a communication interface, a display screen, and an input device connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium, an internal memory. The nonvolatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for wired or wireless communication with an external terminal, and the wireless communication can be realized by WIFI, operator network, NFC (Near Field Communication) or other technologies. The computer program, when executed by the processor, implements a data downloading method. The display screen of the computer equipment may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment may be a touch layer covered on the display screen, or a button, a trackball or a touchpad set on the shell of the computer equipment , or an external keyboard, trackpad, or mouse.
本领域技术人员可以理解,图11中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 11 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得 到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data to obtain the comparison result;
根据比对结果和已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;
根据待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
响应数据下载请求,提取用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件;从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数。In response to the data download request, extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data; obtain the downloaded data from the first file, and obtain the downloaded data from the second file The number of nodes corresponding to the data.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
当不存在与数据下载请求对应的同步数据时,进行数据下载,对得到的已下载数据以及已下载数据对应的节点数进行同步存储。When there is no synchronization data corresponding to the data download request, data download is performed, and the obtained downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
当不存在与数据下载请求对应的同步数据时,进行数据下载,并创建用于同步存储已下载数据的第一文件和用于同步存储已下载数据对应的节点数的第二文件。将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。When there is no synchronous data corresponding to the data download request, data download is performed, and a first file for synchronously storing the downloaded data and a second file for synchronously storing the number of nodes corresponding to the downloaded data are created. The downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
对下载至文件缓冲区中的数据进行字节长度计数;当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件;当述固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数;清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。Count the byte length of the data downloaded to the file buffer; when the counting result reaches the fixed byte length, store the downloaded data of the fixed byte length to the first file synchronously; when the fixed byte length has been downloaded When the data synchronization storage is completed, record the number of nodes corresponding to the downloaded data in the second file; clear the data in the file buffer and clear the count result, and return the byte length count of the data downloaded to the file buffer. steps until the download is complete or the power is turned off.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
将固定字节长度和节点数进行数据相乘,得到记录字节长度;将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致。Multiply the fixed byte length and the number of nodes to obtain the record byte length; compare the record byte length with the actual byte length to obtain the comparison result, which includes the record byte length It is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:In one embodiment, the processor further implements the following steps when executing the computer program:
当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点;当比对结果为记录字节长度与实际字节长度不一致时,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。When the comparison result is that the recorded byte length is consistent with the actual byte length, the data node to be downloaded is determined according to the downloaded data; when the comparison result is that the recorded byte length is inconsistent with the actual byte length, the byte length is greater than The downloaded data with the recorded byte length is deleted to obtain updated downloaded data, and a data node to be downloaded is determined according to the updated downloaded data.
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
响应数据下载请求,当存在与数据下载请求对应的同步数据时,获取同步数据中的已下载数据和已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;
根据预设的固定字节长度和节点数,对已下载数据的实际字节长度进行比对处理,得到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data, and obtain the comparison result;
根据比对结果和已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;
根据待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
响应数据下载请求,提取用于存储已下载数据的第一文件和用于存储已下载数据对应的节点数的第二文件;从第一文件中获取已下载数据,从第二文件中获取已下载数据对应的节点数。In response to the data download request, extract a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data; obtain the downloaded data from the first file, and obtain the downloaded data from the second file The number of nodes corresponding to the data.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
当不存在与数据下载请求对应的同步数据时,进行数据下载,对得到的已下载数据以及已下载数据对应的节点数进行同步存储。When there is no synchronization data corresponding to the data download request, data download is performed, and the obtained downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
当不存在与数据下载请求对应的同步数据时,进行数据下载,并创建用于同步存储已下载数据的第一文件和用于同步存储已下载数据对应的节点数的第二文件。将已下载的数据按固定字节长度同步存储至第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。When there is no synchronous data corresponding to the data download request, data download is performed, and a first file for synchronously storing the downloaded data and a second file for synchronously storing the number of nodes corresponding to the downloaded data are created. The downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
对下载至文件缓冲区中的数据进行字节长度计数;当计数结果达到固定字节长度时,将固定字节长度的已下载数据同步存储至第一文件;当述固定字节长度的已下载数据同步存储完成时,在第二文件中记录已下载数据对应的节点数;清除文件缓冲区中的数据并将计数结果清零,返回对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。Count the byte length of the data downloaded to the file buffer; when the counting result reaches the fixed byte length, store the downloaded data of the fixed byte length synchronously to the first file; when the fixed byte length has been downloaded When the data synchronization storage is completed, record the number of nodes corresponding to the downloaded data in the second file; clear the data in the file buffer and clear the count result, and return the byte length count of the data downloaded to the file buffer. steps until the download is complete or the power is turned off.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
将固定字节长度和节点数进行数据相乘,得到记录字节长度;将记录字节长度与实际字节长度进行字节长度比对处理,得到比对结果,比对结果包括记录字节长度与实际字节长度一致或记录字节长度与实际字节长度不一致。Multiply the fixed byte length and the number of nodes to obtain the record byte length; compare the record byte length with the actual byte length to obtain the comparison result, which includes the record byte length It is consistent with the actual byte length or the recorded byte length is inconsistent with the actual byte length.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:In one embodiment, the computer program further implements the following steps when executed by the processor:
当比对结果为记录字节长度与实际字节长度一致时,根据已下载数据,确定待下载数据节点;当比对结果为记录字节长度与实际字节长度不一致时,将字节长度大于记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据更新的已下载数据,确定待下载数据节点。When the comparison result is that the recorded byte length is consistent with the actual byte length, the data node to be downloaded is determined according to the downloaded data; when the comparison result is that the recorded byte length is inconsistent with the actual byte length, the byte length is greater than The downloaded data with the recorded byte length is deleted to obtain updated downloaded data, and a data node to be downloaded is determined according to the updated downloaded data.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-OnlyMemory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(RandomAccessMemory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(StaticRandomAccessMemory,SRAM)或动态随机存取存储器(DynamicRandomAccessMemory,DRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage In the medium, when the computer program is executed, it may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the various embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, or optical memory, and the like. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, the RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM).
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features It is considered to be the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present application, and the descriptions thereof are specific and detailed, but should not be construed as a limitation on the scope of the invention patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the scope of protection of the patent of the present application shall be subject to the appended claims.
Claims (14)
- 一种数据下载方法,包括:A data download method, comprising:响应数据下载请求,当存在与所述数据下载请求对应的同步数据时,获取所述同步数据中的已下载数据和所述已下载数据对应的节点数;In response to the data download request, when there is synchronization data corresponding to the data download request, obtain the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;根据预设的固定字节长度和所述节点数,对所述已下载数据的实际字节长度进行比对处理,得到比对结果;According to the preset fixed byte length and the number of nodes, compare the actual byte length of the downloaded data to obtain a comparison result;根据所述比对结果和所述已下载数据,确定待下载数据节点;According to the comparison result and the downloaded data, determine the data node to be downloaded;根据所述待下载数据节点,进行数据下载。Data download is performed according to the data node to be downloaded.
- 根据权利要求1所述的方法,其中,所述响应数据下载请求,当存在与所述数据下载请求对应的同步数据时,获取所述同步数据中的已下载数据和所述已下载数据对应的节点数包括:The method according to claim 1, wherein, in the response to the data download request, when there is synchronization data corresponding to the data download request, the downloaded data in the synchronization data and the corresponding data of the downloaded data are acquired. The number of nodes includes:响应数据下载请求,提取用于存储所述已下载数据的第一文件和用于存储所述已下载数据对应的节点数的第二文件;In response to the data download request, extracting a first file for storing the downloaded data and a second file for storing the number of nodes corresponding to the downloaded data;从所述第一文件中获取已下载数据,从所述第二文件中获取已下载数据对应的节点数。The downloaded data is obtained from the first file, and the number of nodes corresponding to the downloaded data is obtained from the second file.
- 根据权利要求1所述的方法,还包括:在所述响应数据下载请求之后,The method of claim 1, further comprising: after said responding to the data download request,当不存在与所述数据下载请求对应的同步数据时,进行数据下载,对得到的已下载数据以及所述已下载数据对应的节点数进行同步存储。When there is no synchronization data corresponding to the data download request, data download is performed, and the obtained downloaded data and the number of nodes corresponding to the downloaded data are stored synchronously.
- 根据权利要求1所述的方法,还包括:在所述响应数据下载请求之后,The method of claim 1, further comprising: after said responding to the data download request,当不存在与所述数据下载请求对应的同步数据时,进行数据下载,并创建用于同步存储所述已下载数据的第一文件和用于同步存储所述已下载数据对应的节点数的第二文件;When there is no synchronous data corresponding to the data download request, perform data download, and create a first file for synchronously storing the downloaded data and a first file for synchronously storing the number of nodes corresponding to the downloaded data. two documents;将已下载的数据按固定字节长度同步存储至所述第一文件,将同步存储的已下载数据对应的节点数存储至第二文件。The downloaded data is synchronously stored in the first file according to the fixed byte length, and the number of nodes corresponding to the synchronously stored downloaded data is stored in the second file.
- 根据权利要求4所述的方法,其中,所述将已下载的数据按固定字节长度同步存储至所述第一文件,将同步存储的已下载数据对应的节点数存储至第二文件包括:The method according to claim 4, wherein the synchronously storing the downloaded data in the first file according to a fixed byte length, and storing the number of nodes corresponding to the synchronously stored downloaded data in the second file comprises:对下载至文件缓冲区中的数据进行字节长度计数;Count the byte length of the data downloaded to the file buffer;当计数结果达到所述固定字节长度时,将所述固定字节长度的已下载数据同步存储至所述第一文件;When the counting result reaches the fixed byte length, synchronously storing the downloaded data of the fixed byte length to the first file;当所述述所述固定字节长度的已下载数据同步存储完成时,在所述第二文件中记录已下载数据对应的节点数;When the synchronous storage of the downloaded data of the fixed byte length is completed, record the number of nodes corresponding to the downloaded data in the second file;清除所述文件缓冲区中的数据并将所述计数结果清零,返回所述对下载至文件缓冲区中的数据进行字节长度计数的步骤,直至下载完成或断电。Clear the data in the file buffer and clear the count result to zero, and return to the step of counting the byte length of the data downloaded into the file buffer until the download is completed or the power is turned off.
- 根据权利要求1所述的方法,其中,所述根据预设的固定字节长度和所述节点数,对所述已下载数据的实际字节长度进行比对处理,得到比对结果包括:The method according to claim 1, wherein the comparing the actual byte length of the downloaded data according to the preset fixed byte length and the number of nodes, and obtaining a comparison result comprises:将所述固定字节长度和所述节点数进行数据相乘,得到记录字节长度;Multiply data by the fixed byte length and the number of nodes to obtain the record byte length;将所述记录字节长度与所述实际字节长度进行字节长度比对处理,得到比对结果,所述比对结果包括所述记录字节长度与所述实际字节长度一致或所述记录字节长度与所述实际字节长度不一致。Perform a byte length comparison process on the recorded byte length and the actual byte length to obtain a comparison result, where the comparison result includes that the recorded byte length is consistent with the actual byte length or the The recorded byte length is inconsistent with the actual byte length.
- 根据权利要求6所述的方法,其中,所述根据所述比对结果和所述已下载数据,确定待下载数据节点包括:The method according to claim 6, wherein the determining the data node to be downloaded according to the comparison result and the downloaded data comprises:当所述比对结果为所述记录字节长度与所述实际字节长度一致时,根据所述已下载数据,确定待下载数据节点;When the comparison result is that the recorded byte length is consistent with the actual byte length, determine the data node to be downloaded according to the downloaded data;当所述比对结果为所述记录字节长度与所述实际字节长度不一致时,将所述字节长度大于所述记录字节长度的已下载数据进行删除处理,得到更新的已下载数据,根据所述更新的已下载数据,确定所述待下载数据节点。When the comparison result is that the recorded byte length is inconsistent with the actual byte length, delete the downloaded data whose byte length is greater than the recorded byte length to obtain updated downloaded data , and determine the data node to be downloaded according to the updated downloaded data.
- 根据权利要求1所述的方法,还包括:在响应数据下载请求之后以及在数据下载之前,检测是否存在与所述数据下载请求对应的同步数据。The method of claim 1, further comprising: after responding to the data download request and before the data download, detecting whether there is synchronization data corresponding to the data download request.
- 根据权利要求8所述的方法,其中,与所述数据下载请求对应的同步数据包括已下载数据和已下载数据对应的节点数。The method of claim 8, wherein the synchronization data corresponding to the data download request includes the downloaded data and the number of nodes corresponding to the downloaded data.
- 根据权利要求1所述的方法,其中,所述比对结果包括记录字节长度与实际字节长度一致的第一比对结果以及记录字节长度与实际字节长度不一致的第二比对结果;The method according to claim 1, wherein the comparison result comprises a first comparison result in which the recorded byte length is consistent with the actual byte length and a second comparison result in which the recorded byte length is inconsistent with the actual byte length ;所述方法还包括:根据不同的比对结果,确定不同的待下载数据节点;The method further includes: determining different data nodes to be downloaded according to different comparison results;其中,所述待下载数据节点对应已下载数据。The node of the data to be downloaded corresponds to the downloaded data.
- 根据权利要求4所述的方法,还包括:在创建所述第一文件和所述第二文件之后,按照固定字节长度进行数据下载。The method according to claim 4, further comprising: after creating the first file and the second file, performing data download according to a fixed byte length.
- 一种数据下载装置,包括:A data download device, comprising:数据响应获取模块,用于响应数据下载请求,当存在与所述数据下载请求对应的同步数据时,获取所述同步数据中的已下载数据和所述已下载数据对应的节点数;a data response acquisition module, configured to respond to the data download request, when there is synchronization data corresponding to the data download request, acquire the downloaded data in the synchronization data and the number of nodes corresponding to the downloaded data;数据比对模块,用于根据预设的固定字节长度和所述节点数,对所述已下载数据的实际字节长度进行比对处理,得到比对结果;a data comparison module, configured to perform a comparison process on the actual byte length of the downloaded data according to a preset fixed byte length and the number of nodes to obtain a comparison result;数据处理模块,用于根据所述比对结果和所述已下载数据,确定待下载数据节点;a data processing module, configured to determine a data node to be downloaded according to the comparison result and the downloaded data;数据下载模块,用于根据所述待下载数据节点,进行数据下载。A data download module, configured to download data according to the data node to be downloaded.
- 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其中,所述处理器执行所述计算机程序时实现权利要求1至11中任一项所述的方法的步骤。A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor, when executing the computer program, implements the steps of the method of any one of claims 1 to 11.
- 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现权利要求1至11中任一项所述的方法的步骤。A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of any one of claims 1 to 11.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011118379.8A CN112291317B (en) | 2020-10-19 | 2020-10-19 | Data downloading method, device, computer equipment and storage medium |
CN202011118379.8 | 2020-10-19 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022083190A1 true WO2022083190A1 (en) | 2022-04-28 |
Family
ID=74496451
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/107049 WO2022083190A1 (en) | 2020-10-19 | 2021-07-19 | Data downloading method and apparatus, computer device, and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112291317B (en) |
WO (1) | WO2022083190A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115801766A (en) * | 2022-11-28 | 2023-03-14 | 中国银行股份有限公司 | Data downloading method and device |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112291317B (en) * | 2020-10-19 | 2023-11-24 | 深圳市广和通无线股份有限公司 | Data downloading method, device, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101582924A (en) * | 2009-06-19 | 2009-11-18 | 深圳市五巨科技有限公司 | Data transmission method of mobile terminal and device thereof |
CN103227812A (en) * | 2013-03-19 | 2013-07-31 | 青岛海信宽带多媒体技术有限公司 | Downloading method and device supporting breakpoint resuming in intelligent equipment |
CN104363271A (en) * | 2014-10-28 | 2015-02-18 | 广东欧珀移动通信有限公司 | File breakpoint resuming method and device |
US20180198843A1 (en) * | 2017-01-11 | 2018-07-12 | Microsoft Technology Licensing, Llc | Nonconsecutive File Downloading |
CN110336871A (en) * | 2019-07-01 | 2019-10-15 | 江苏满运软件科技有限公司 | A kind of document handling method, device, storage medium and electronic equipment |
CN112291317A (en) * | 2020-10-19 | 2021-01-29 | 深圳市广和通无线股份有限公司 | Data downloading method and device, computer equipment and storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101291195B (en) * | 2008-05-23 | 2011-01-19 | 中兴通讯股份有限公司 | File downloading method, system and terminal realizing breaker point continuous transmission |
CN101771494A (en) * | 2008-12-29 | 2010-07-07 | 深圳市维信联合科技有限公司 | Data transmission method and data transmission device |
CN104166567A (en) * | 2014-08-12 | 2014-11-26 | 广州金山网络科技有限公司 | Method and device for downloading network stream data |
-
2020
- 2020-10-19 CN CN202011118379.8A patent/CN112291317B/en active Active
-
2021
- 2021-07-19 WO PCT/CN2021/107049 patent/WO2022083190A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101582924A (en) * | 2009-06-19 | 2009-11-18 | 深圳市五巨科技有限公司 | Data transmission method of mobile terminal and device thereof |
CN103227812A (en) * | 2013-03-19 | 2013-07-31 | 青岛海信宽带多媒体技术有限公司 | Downloading method and device supporting breakpoint resuming in intelligent equipment |
CN104363271A (en) * | 2014-10-28 | 2015-02-18 | 广东欧珀移动通信有限公司 | File breakpoint resuming method and device |
US20180198843A1 (en) * | 2017-01-11 | 2018-07-12 | Microsoft Technology Licensing, Llc | Nonconsecutive File Downloading |
CN110336871A (en) * | 2019-07-01 | 2019-10-15 | 江苏满运软件科技有限公司 | A kind of document handling method, device, storage medium and electronic equipment |
CN112291317A (en) * | 2020-10-19 | 2021-01-29 | 深圳市广和通无线股份有限公司 | Data downloading method and device, computer equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115801766A (en) * | 2022-11-28 | 2023-03-14 | 中国银行股份有限公司 | Data downloading method and device |
Also Published As
Publication number | Publication date |
---|---|
CN112291317B (en) | 2023-11-24 |
CN112291317A (en) | 2021-01-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101644666B1 (en) | Programming model for synchronizing browser caches across devices and web services | |
CN107832100B (en) | APK plug-in loading method and terminal thereof | |
WO2019019643A1 (en) | Application program hot update method and apparatus, and terminal and storage medium | |
WO2018049888A1 (en) | Application data migration method and device | |
US20160055062A1 (en) | Systems and Methods for Maintaining a Virtual Failover Volume of a Target Computing System | |
CN106569738B (en) | A kind of method and device for deleting cascade snapshot | |
WO2022083190A1 (en) | Data downloading method and apparatus, computer device, and storage medium | |
CN102521289B (en) | File synchronization method, device and system | |
CN111966530A (en) | Application system disaster recovery switching method, device, computer equipment and storage medium | |
US11593230B2 (en) | Efficient mechanism for data protection against cloud region failure or site disasters and recovery time objective (RTO) improvement for backup applications | |
CN114238399A (en) | Cache flushing system, method, apparatus, computer device and storage medium | |
CN108369547A (en) | The tail portion of daily record in persistence main memory | |
WO2018049883A1 (en) | File operation method and device | |
CN119961211A (en) | Data migration method, device, computer equipment and storage medium | |
WO2020151337A1 (en) | Distributed file processing method and apparatus, computer device and storage medium | |
CN113157487A (en) | Data recovery method and apparatus thereof | |
CN105786650A (en) | Data management method and device | |
CN114328097A (en) | A file monitoring method, device, electronic device and storage medium | |
CN106547485B (en) | Data migration method and device | |
US11514002B2 (en) | Indexing splitter for any pit replication | |
CN109522177A (en) | A kind of task daily record processing system, method and device | |
CN113467698A (en) | Writing method and device based on file system, computer equipment and storage medium | |
US20200012433A1 (en) | System and method for orchestrated application protection | |
CN112162756B (en) | Software product deployment method, apparatus, computer equipment and storage medium | |
CN110543460B (en) | A data synchronization method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 07/09/2023). |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21881610 Country of ref document: EP Kind code of ref document: A1 |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21881610 Country of ref document: EP Kind code of ref document: A1 |