CN114327996A - A data storage method, device, storage medium and electronic device - Google Patents
A data storage method, device, storage medium and electronic device Download PDFInfo
- Publication number
- CN114327996A CN114327996A CN202011064118.2A CN202011064118A CN114327996A CN 114327996 A CN114327996 A CN 114327996A CN 202011064118 A CN202011064118 A CN 202011064118A CN 114327996 A CN114327996 A CN 114327996A
- Authority
- CN
- China
- Prior art keywords
- data
- unit data
- data block
- unit
- check value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000013500 data storage Methods 0.000 title claims abstract description 68
- 238000000034 method Methods 0.000 title claims abstract description 59
- 230000005540 biological transmission Effects 0.000 claims abstract description 48
- 239000012634 fragment Substances 0.000 claims abstract description 36
- 238000011084 recovery Methods 0.000 claims abstract description 13
- 238000004590 computer program Methods 0.000 claims description 8
- 238000010586 diagram Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 9
- 238000012795 verification Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 7
- 238000004422 calculation algorithm Methods 0.000 description 6
- 238000004364 calculation method Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 6
- 125000004122 cyclic group Chemical group 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 239000003795 chemical substances by application Substances 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000007726 management method Methods 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
- 238000009877 rendering Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Landscapes
- Detection And Correction Of Errors (AREA)
Abstract
Description
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种数据存储方法、装置、存储介质及电子设备。The present application relates to the field of computer technology, and in particular, to a data storage method, apparatus, storage medium, and electronic device.
背景技术Background technique
当需要对较大的数据进行传输时,例如需要对手机重装系统,也就是俗称的刷机时,往往采用通用串行总线(Universal Serial Bus,USB)数据线连接手机与刷机设备进行数据的传输。然而现有的数据传输过程仅仅只是将数据从原始数据模块中存放到对应的目的存储模块中,无法避免在数据传输过程中出现数据丢失的情况,影响了数据的完整性。When larger data needs to be transmitted, such as the need to reinstall the mobile phone system, which is commonly known as flashing, a Universal Serial Bus (USB) data cable is often used to connect the mobile phone and the flashing device for data transmission. . However, the existing data transmission process only stores data from the original data module to the corresponding destination storage module, which cannot avoid data loss during the data transmission process, which affects the integrity of the data.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了一种数据存储方法、装置、存储介质及电子设备,可以通过对比校验值,判断数据片段的传输是否完整,提高了数据传输的安全性与可靠性。所述技术方案如下:The embodiments of the present application provide a data storage method, device, storage medium and electronic device, which can judge whether the transmission of a data segment is complete by comparing a check value, thereby improving the security and reliability of data transmission. The technical solution is as follows:
第一方面,本申请实施例提供了一种数据存储方法,所述方法包括:In a first aspect, an embodiment of the present application provides a data storage method, the method comprising:
当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值;When the unit data block in the original data is received by the original storage module, obtain the first check value in the unit data block;
获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值;Acquire the data fragment of the unit data block, and calculate the second check value of the unit data block;
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, the data segment in the unit data block is stored according to the restoration address of the destination storage module.
进一步的,所述获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值,包括:Further, the acquiring the data segment of the unit data block and calculating the second check value of the unit data block includes:
当所述单元数据块为原始数据的第一个单元数据块时,获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与初始基准值,计算所述单元数据块的第二校验值。When the unit data block is the first unit data block of the original data, obtain the data segment of the unit data block, and calculate the unit data block based on the data segment in the unit data block and the initial reference value The second check value of .
进一步的,所述当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储,包括:Further, when the first check value matches the second check value of the unit data block, the data fragment in the unit data block is stored according to the restoration address of the destination storage module. ,include:
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述原始数据在目的存储模块中的初始存储地址,对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, the data segment in the unit data block is processed according to the initial storage address of the original data in the destination storage module. storage.
进一步的,所述获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值,包括:Further, the acquiring the data segment of the unit data block and calculating the second check value of the unit data block includes:
基于所述原始数据中单元数据块的排列顺序获取所述单元数据块的上一个单元数据块,将所述上一个单元数据块对应的第二校验值确定为所述单元数据块的校验基准值;The last unit data block of the unit data block is acquired based on the arrangement order of the unit data blocks in the original data, and the second check value corresponding to the last unit data block is determined as the check value of the unit data block Reference value;
获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与所述校验基准值,计算所述单元数据块的第二校验值。A data segment of the unit data block is acquired, and based on the data segment in the unit data block and the check reference value, a second check value of the unit data block is calculated.
进一步的,所述当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储之前,还包括:Further, when the first check value matches the second check value of the unit data block, the data fragment in the unit data block is stored according to the restoration address of the destination storage module. Before, also included:
将复原固定地址加上所述目的存储模块中原始数据的已接收数据长度,生成所述单元数据块的复原地址,所述复原固定地址为所述原始数据在目的存储模块中的初始存储地址。The restored fixed address is added to the received data length of the original data in the destination storage module to generate the restored address of the unit data block, where the restored fixed address is the initial storage address of the original data in the destination storage module.
进一步的,所述方法还包括:Further, the method also includes:
采用所述数据片段的数据长度对所述已接收数据长度进行更新。The received data length is updated with the data length of the data segment.
进一步的,所述方法还包括:Further, the method also includes:
当所述单元数据块为所述原始数据的最后一个单位数据块时,在目的存储模块中获取存储数据的数据长度,所述存储数据为在所述目的存储模块中,以所述原始数据在所述目的存储模块中的初始存储地址为首地址,长度为已接收数据长度的数据;When the unit data block is the last unit data block of the original data, the data length of the stored data is obtained in the destination storage module, the stored data is in the destination storage module, and the original data is stored in the destination storage module. The initial storage address in the purpose storage module is the first address, and the length is the data of the received data length;
当所述存储数据的数据长度与所述原始数据的数据长度不相同时,输出数据错误通知。When the data length of the stored data is different from the data length of the original data, a data error notification is output.
进一步的,所述方法还包括:Further, the method also includes:
当所述第一校验值和所述第二校验值不匹配时,输出传输错误通知。When the first check value and the second check value do not match, a transmission error notification is output.
第二方面,本申请实施例提供了一种数据存储装置,所述装置包括:In a second aspect, an embodiment of the present application provides a data storage device, the device comprising:
第一校验值获取模块,用于当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值;a first check value obtaining module, configured to obtain the first check value in the unit data block when the unit data block in the original data is received by the original storage module;
第二校验值获取模块,用于获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值;A second check value obtaining module, configured to obtain the data segment of the unit data block, and calculate the second check value of the unit data block;
数据存储模块,用于当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。A data storage module, configured to perform a data fragment in the unit data block according to the restoration address of the destination storage module when the first check value matches the second check value of the unit data block. storage.
进一步的,所述第二校验值获取模块,具体用于:Further, the second check value obtaining module is specifically used for:
当所述单元数据块为原始数据的第一个单元数据块时,获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与初始基准值,计算所述单元数据块的第二校验值。When the unit data block is the first unit data block of the original data, obtain the data segment of the unit data block, and calculate the unit data block based on the data segment in the unit data block and the initial reference value The second check value of .
进一步的,所述数据存储模块,具体用于:Further, the data storage module is specifically used for:
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述原始数据在目的存储模块中的初始存储地址,对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, the data segment in the unit data block is processed according to the initial storage address of the original data in the destination storage module. storage.
进一步的,所述第二校验值获取模块,包括:Further, the second check value acquisition module includes:
基准值获取单元,用于基于所述原始数据中单元数据块的排列顺序获取所述单元数据块的上一个单元数据块,将所述上一个单元数据块对应的第二校验值确定为所述单元数据块的校验基准值;The reference value obtaining unit is configured to obtain the last unit data block of the unit data block based on the arrangement order of the unit data blocks in the original data, and determine the second check value corresponding to the last unit data block as the The verification reference value of the unit data block;
校验值计算单元,用于获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与所述校验基准值,计算所述单元数据块的第二校验值。A check value calculation unit, configured to acquire data segments of the unit data block, and calculate a second check value of the unit data block based on the data segments in the unit data block and the check reference value.
进一步的,所述装置还包括:Further, the device also includes:
复原地址生成模块,用于将复原固定地址加上所述目的存储模块中原始数据的已接收数据长度,生成所述单元数据块的复原地址,所述复原固定地址为所述原始数据在目的存储模块中的初始存储地址。A restoration address generation module is used to add the restoration fixed address to the received data length of the original data in the destination storage module to generate the restoration address of the unit data block, and the restoration fixed address is the original data stored in the destination The initial storage address in the module.
进一步的,所述装置还包括:Further, the device also includes:
接收长度更新模块,用于采用所述数据片段的数据长度对所述已接收数据长度进行更新。A receiving length updating module, configured to update the received data length by using the data length of the data segment.
进一步的,所述装置还包括:Further, the device also includes:
数据长度校验模块,用于当所述单元数据块为所述原始数据的最后一个单位数据块时,在目的存储模块中获取存储数据的数据长度,所述存储数据为在所述目的存储模块中,以所述原始数据在所述目的存储模块中的初始存储地址为首地址,长度为已接收数据长度的数据;A data length check module, for when the unit data block is the last unit data block of the original data, obtain the data length of the stored data in the destination storage module, and the stored data is stored in the destination storage module In, with the initial storage address of the original data in the destination storage module as the first address, and the length is the data of the received data length;
当所述存储数据的数据长度与所述原始数据的数据长度不相同时,输出数据错误通知。When the data length of the stored data is different from the data length of the original data, a data error notification is output.
进一步的,所述装置还包括:Further, the device also includes:
传输错误输出模块,用于当所述第一校验值和所述第二校验值不匹配时,输出传输错误通知。A transmission error output module, configured to output a transmission error notification when the first check value and the second check value do not match.
第三方面,本申请实施例提供一种计算机存储介质,所述计算机存储介质存储有多条指令,所述指令适于由处理器加载并执行上述的方法步骤。In a third aspect, an embodiment of the present application provides a computer storage medium, where the computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above method steps.
第四方面,本申请实施例提供一种电子设备,可包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行上述的方法步骤。In a fourth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded by the processor and execute the above method steps .
本申请一些实施例提供的技术方案带来的有益效果至少包括:The beneficial effects brought by the technical solutions provided by some embodiments of the present application include at least:
在本申请一个或多个实施例中,获取单元数据块中的第一校验值,并基于所述单元数据块的数据片段计算第二校验值,当所述第一校验值与所述第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。通过对比第一校验值和第二校验值,判断数据片段的传输是否完整,保证了数据传输过程中数据的完整性。In one or more embodiments of the present application, a first check value in a unit data block is obtained, and a second check value is calculated based on a data segment of the unit data block. When the second check value matches, the data segment in the unit data block is stored according to the restoration address of the destination storage module. By comparing the first check value and the second check value, it is determined whether the transmission of the data segment is complete, which ensures the integrity of the data during the data transmission process.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1是本申请实施例提供的一种数据存储方法的流程示意图;1 is a schematic flowchart of a data storage method provided by an embodiment of the present application;
图2是本申请实施例提供的一种计算第二校验值的举例示意图;FIG. 2 is an exemplary schematic diagram of calculating a second check value provided by an embodiment of the present application;
图3是本申请实施例提供的另一种数据存储方法的流程示意图;3 is a schematic flowchart of another data storage method provided by an embodiment of the present application;
图4是本申请实施例提供的一种计算复原地址的举例示意图;4 is a schematic diagram illustrating an example of calculating a restoration address provided by an embodiment of the present application;
图5是本申请实施例提供的一种数据存储装置的结构示意图;5 is a schematic structural diagram of a data storage device provided by an embodiment of the present application;
图6是本申请实施例提供的一种第二校验值获取模块的结构示意图;6 is a schematic structural diagram of a second check value obtaining module provided by an embodiment of the present application;
图7是本申请实施例提供的另一种数据存储装置的结构示意图;7 is a schematic structural diagram of another data storage device provided by an embodiment of the present application;
图8是本申请实施例提供的一种电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
在本申请的描述中,需要理解的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。在本申请的描述中,需要说明的是,除非另有明确的规定和限定,“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其他步骤或单元。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。此外,在本申请的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。In the description of the present application, it should be understood that the terms "first", "second" and the like are used for descriptive purposes only, and should not be construed as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise expressly specified and defined, "including" and "having" and any modifications thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally also includes For other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood in specific situations. Also, in the description of the present application, unless otherwise specified, "a plurality" means two or more. "And/or", which describes the association relationship of the associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship.
本申请实施例提供的数据存储方法可依赖于计算机程序实现,可运行于基于冯诺依曼体系的数据存储装置上。该计算机程序可集成在应用中,也可作为独立的工具类应用运行。其中本申请实施例中的数据存储装置可以是USB数据线中的管理模块,也可以是包含有目的存储模块的用户终端,原始存储模块和目的存储模块均可以为存储设备,或者可以为存储设备中用于进行数据存储的模块;所述用户终端和存储设备具体可以包括但不限于:手机、个人电脑、平板电脑、手持设备、车载设备、可穿戴设备、计算设备或连接到无线调制解调器的其它处理设备等。在不同的网络中终端设备可以叫做不同的名称,例如:用户设备、接入终端、用户单元、用户站、移动站、移动台、远方站、远程终端、移动设备、用户终端、终端、无线通信设备、用户代理或用户装置、蜂窝电话、无绳电话、5G网络或未来演进网络中的终端设备等。The data storage method provided by the embodiments of the present application can be implemented by relying on a computer program, and can run on a data storage device based on the von Neumann system. The computer program can be integrated into an application or run as a stand-alone utility application. The data storage device in the embodiment of the present application may be a management module in a USB data cable, or may be a user terminal including a purpose storage module. Both the original storage module and the purpose storage module may be storage devices, or may be storage devices. The module used for data storage in the user terminal; the user terminal and storage device may specifically include but are not limited to: mobile phone, personal computer, tablet computer, handheld device, vehicle-mounted device, wearable device, computing device or other devices connected to the wireless modem processing equipment, etc. Terminal equipment may be called by different names in different networks, for example: user equipment, access terminal, subscriber unit, subscriber station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication Equipment, user agent or user equipment, cellular phone, cordless phone, terminal equipment in 5G network or future evolution network, etc.
下面结合具体的实施例对本申请提供的数据存储方法进行详细说明。The data storage method provided by the present application will be described in detail below with reference to specific embodiments.
请参见图1,为本申请实施例提供了一种数据存储方法的流程示意图。如图1所示,本申请实施例的所述方法可以包括以下步骤S101-S103。Referring to FIG. 1 , a schematic flowchart of a data storage method is provided in an embodiment of the present application. As shown in FIG. 1 , the method in this embodiment of the present application may include the following steps S101-S103.
S101,当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值。S101, when a unit data block in the original data is received by the original storage module, obtain a first check value in the unit data block.
所述原始数据,即为需要进行传输的数据,原始数据保存在原始存储模块中,当需要传输时原始存储模块将原始数据经由数据存储装置传输至目的存储模块,所述原始存储模块即为数据的发送端。The original data is the data that needs to be transmitted, and the original data is stored in the original storage module. When the transmission is required, the original storage module transmits the original data to the destination storage module via the data storage device, and the original storage module is the data. the sender.
所述单元数据块,是指进行原始数据的传输时,由于原始数据较大,将原始数据分为多个数据片段依次传输,一个单元数据块中包括一个数据片段和该数据片段的第一校验值。所述第一校验值,即为根据同单元数据块中的数据片段计算出的校验值,第一校验值与数据片段由原始存储模块一并发送给数据存储装置。The unit data block refers to that when the original data is transmitted, due to the large size of the original data, the original data is divided into multiple data segments and transmitted in sequence, and a unit data block includes a data segment and the first calibration of the data segment. test value. The first check value is the check value calculated according to the data fragment in the data block of the same unit, and the first check value and the data fragment are sent to the data storage device by the original storage module.
校验值可以采用循环冗余校验(Cyclic Redundancy Check,CRC)所得出的循环冗余校验码,简称循环码,是一种具有检错、纠错能力的校验码,CRC校验值的长度可以任意选定。采用CRC进行校验的原理为:对需要校验的数据进行多项式计算,并将得到的结果附在该数据的后面,同时接收设备也执行相同的算法得到一个校验值并与前面得到的结果相比较,以保证数据传输的正确性和完整性。The check value can be a cyclic redundancy check code obtained by cyclic redundancy check (Cyclic Redundancy Check, CRC), referred to as a cyclic code, which is a check code with error detection and error correction capabilities. The length can be arbitrarily selected. The principle of using CRC for verification is: perform polynomial calculation on the data to be verified, and attach the obtained result to the back of the data. At the same time, the receiving device also executes the same algorithm to obtain a verification value, which is the same as the previous result. Compare to ensure the correctness and integrity of data transmission.
CRC校验值算法涉及的校验数据长度、多项式、初始值和结果异或值等可以在数据存储装置出厂时就设置完成,也可以在原始存储模块、目的存储模块或数据存储装置上进行设置。The check data length, polynomial, initial value and result XOR value involved in the CRC check value algorithm can be set when the data storage device leaves the factory, or can be set on the original storage module, destination storage module or data storage device .
第一校验值的校验数据长度可以在原始存储模块或数据存储装置上进行预先设定,获取单元数据块中的第一校验值,即为获取单元数据块中末尾长度为校验数据长度的数据。The length of the check data of the first check value can be preset on the original storage module or data storage device, and obtaining the first check value in the unit data block is to obtain the end length of the unit data block as the check data. length of data.
进一步的,原始存储模块可以在单元数据块中加上一位还原校验位,若数据存储装置识别到还原校验位为0,则该单元数据块中的内容需要进行校验才能进行存储,若数据存储装置识别到还原校验位为1,则该单元数据块中的内容不需要校验可以直接进行存储。Further, the original storage module can add a restoration check digit to the unit data block. If the data storage device recognizes that the restoration check digit is 0, then the content in the unit data block needs to be verified before it can be stored. If the data storage device recognizes that the restoration check bit is 1, the content in the unit data block can be directly stored without checking.
S102,获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值。S102: Acquire a data segment of the unit data block, and calculate a second check value of the unit data block.
数据存储装置上采用与原始存储模块相同的校验算法,对获取到的所述单元数据块的数据片段采用该校验算法进行校验得到第二校验值。The data storage device adopts the same check algorithm as that of the original storage module, and the obtained data segment of the unit data block is checked by the check algorithm to obtain a second check value.
例如,数据存储装置中设置计算CRC校验值的算法中,校验数据长度为4bit,用于计算的多项式为二位十六进制值03,初始值为二位十六进制值00。如图2所示为一种计算第二校验值的举例示意图,获取到单元数据块中的数据为“202010011000”,可提取出该单元数据块的第一校验值为“1000”,数据片段为“20201001”。数据存储装置对数据片段按照设置算法计算,可得出第二校验值“1000”。第一校验值与第二校验值相同则表示该单元数据块的数据片段传输完整。For example, in the algorithm for calculating the CRC check value set in the data storage device, the length of the check data is 4 bits, the polynomial used for calculation is the two-digit hexadecimal value 03, and the initial value is the two-digit hexadecimal value 00. Figure 2 is a schematic diagram of an example of calculating the second check value. The obtained data in the unit data block is "202010011000", and the first check value of the unit data block can be extracted as "1000". Fragment is "20201001". The data storage device calculates the data segment according to the setting algorithm, and can obtain the second check value "1000". If the first check value is the same as the second check value, it indicates that the data segment of the unit data block is transmitted completely.
S103,当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。S103, when the first check value matches the second check value of the unit data block, store the data segment in the unit data block according to the restoration address of the destination storage module.
所述目的存储模块为原始存储模块经由数据存储装置传输原始数据的接收端,数据存储装置将接收到的数据片段根据接收顺序在目的存储模块的复原地址上进行保存并生成存储数据。The destination storage module is the receiving end for the original storage module to transmit the original data via the data storage device, and the data storage device stores the received data fragments at the restoration address of the destination storage module according to the receiving sequence and generates storage data.
若所述第一校验值与所述单元数据块的第二校验值相同,则数据存储装置确认所述单元数据块中的数据片段传输完整且正确,将该数据片段保存在目的存储模块对应的复原地址上。If the first check value is the same as the second check value of the unit data block, the data storage device confirms that the transmission of the data segment in the unit data block is complete and correct, and saves the data segment in the destination storage module on the corresponding recovery address.
进一步的,当原始数据的所有单元数据块都传输完成时,目的存储模块可以根据复原地址提取出存储数据,所述存储数据就是从原始存储模块发送到目的存储模块的原始数据。Further, when all the unit data blocks of the original data are transmitted, the destination storage module can extract the stored data according to the restoration address, and the stored data is the original data sent from the original storage module to the destination storage module.
在本申请实施例中,获取单元数据块中的第一校验值,并基于所述单元数据块的数据片段计算第二校验值,当所述第一校验值与所述第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。通过对比第一校验值和第二校验值,判断数据片段的传输是否完整,保证了数据传输过程中数据的完整性。In the embodiment of the present application, the first check value in the unit data block is obtained, and the second check value is calculated based on the data segment of the unit data block. When the verification values match, the data segment in the unit data block is stored according to the restoration address of the destination storage module. By comparing the first check value and the second check value, it is determined whether the transmission of the data segment is complete, which ensures the integrity of the data during the data transmission process.
请参见图3,为本申请实施例提供了一种数据存储方法的流程示意图。如图3所示,本申请实施例的所述方法可以包括以下步骤S201-S208。Referring to FIG. 3 , a schematic flowchart of a data storage method is provided in an embodiment of the present application. As shown in FIG. 3 , the method in this embodiment of the present application may include the following steps S201-S208.
S201,当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值。S201, when a unit data block in the original data is received by the original storage module, obtain a first check value in the unit data block.
具体可参见S101,此处不再赘述。For details, refer to S101, which will not be repeated here.
S202,基于所述原始数据中单元数据块的排列顺序获取所述单元数据块的上一个单元数据块,将所述上一个单元数据块对应的第二校验值确定为所述单元数据块的校验基准值。S202: Acquire the last unit data block of the unit data block based on the arrangement order of the unit data blocks in the original data, and determine the second check value corresponding to the last unit data block as the value of the unit data block. Check the reference value.
所述校验基准值,为计算单元数据块中计算数据片段的校验值的初始值,能够对校验值的结果产生影响。校验基准值会根据不同的单元数据块进行变化,上一个单元数据块的第二校验值为所述单元数据块的校验基准值,即上一个单元数据块的校验结果将会影响所述单元数据块的校验结果,在校验所说单元数据块的数据片段的完整性的同时,也对上一次校验结果进行了验证,增强了数据传输的安全性和可靠性。The check reference value is the initial value of the check value of the calculated data segment in the calculation unit data block, and can affect the result of the check value. The check reference value will change according to different unit data blocks. The second check value of the previous unit data block is the check reference value of the unit data block, that is, the check result of the previous unit data block will affect the The verification result of the unit data block not only verifies the integrity of the data segment of the unit data block, but also verifies the previous verification result, which enhances the security and reliability of data transmission.
例如,若上一个单元数据块的第二校验值为四位二进制数1011,将第二校验值转换为二位十六进制数0B,则数据存储装置确认0B为所述单元数据块的校验基准值,也就是所述单元数据块计算第二校验值时用到的初始值。For example, if the second check value of the previous unit data block is a four-digit binary number 1011, and the second check value is converted into a two-digit hexadecimal number 0B, the data storage device confirms that 0B is the unit data block , that is, the initial value used when the unit data block calculates the second check value.
进一步的,数据存储装置确定了校验基准值后,将所述校验基准值发送至原始存储模块,原始存储模块基于接收到的校验基准值与所述单元数据块的数据片段计算所述单元数据块的第一校验值。也可以在数据存储装置在确认了上一个单元数据块传输完整后,可以向原始存储模块发送单元块传输完成通知,原始存储模块可以直接将上一个单元数据块的第一校验值作为所述单元数据块的校验基准值,并基于该基准值与所属单元数据块的数据片段计算第一校验值。Further, after the data storage device determines the check reference value, it sends the check reference value to the original storage module, and the original storage module calculates the check reference value based on the received check reference value and the data segment of the unit data block. The first check value of the unit data block. Alternatively, after the data storage device confirms that the transmission of the previous unit data block is complete, it may send a unit block transmission completion notification to the original storage module, and the original storage module may directly use the first check value of the previous unit data block as the The check reference value of the unit data block, and the first check value is calculated based on the reference value and the data segment of the unit data block to which it belongs.
进一步的,可以根据所述单元数据块的顺序增加第一校验值与第二校验值的校验数据长度,原始存储模块根据所述单元数据块的校验数据长度生成第一校验值,数据存储装置根据同样的校验数据长度计算第二校验值。例如,一种可行的增加校验数据长度的方法,校验数据长度与单元数据块的顺序相同,第一个单元数据块的校验数据长度为1bit,第n个单元数据块的校验长度为n bit。Further, the check data length of the first check value and the second check value can be increased according to the order of the unit data blocks, and the original storage module generates the first check value according to the check data length of the unit data block. , and the data storage device calculates the second check value according to the same length of the check data. For example, a feasible method for increasing the length of the check data is that the length of the check data is in the same order as the unit data block, the length of the check data of the first unit data block is 1 bit, and the length of the check data of the nth unit data block is 1 bit. is n bits.
进一步的,校验基准值也可以是作为CRC校验值计算中的多项式或结果异或值等来计算所述单元数据块的第二校验值。Further, the check reference value may also be used as a polynomial in the calculation of the CRC check value or the result XOR value, etc. to calculate the second check value of the unit data block.
进一步的,若所述单元数据块为原始数据的第一个单元数据块,此时就不存在上一个单元数据块,则所述单元数据块的校验基准值为预先设定的初始基准值,所述初始基准值可以在数据存储装置出厂时就设置完成,也可以在原始存储模块、目的存储模块或数据存储装置上进行设置,或者使用上一次传输数据时的最后一个单元数据块的第二校验值。Further, if the unit data block is the first unit data block of the original data, and there is no previous unit data block at this time, the check reference value of the unit data block is a preset initial reference value. , the initial reference value can be set when the data storage device leaves the factory, or it can be set on the original storage module, the destination storage module or the data storage device, or the first data block of the last unit data block in the last transmission of data can be used. Two check values.
S203,获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与所述校验基准值,计算所述单元数据块的第二校验值。S203: Acquire a data fragment of the unit data block, and calculate a second check value of the unit data block based on the data fragment in the unit data block and the check reference value.
将所述校验基准值作为初始值,计算所述单元数据块中的数据片段的CRC校验值,将得到的结果作为所述单元数据块的第二校验值。同样的,所述单元数据块的第二校验值将会作为下一个单元数据块的校验基准值。Using the check reference value as an initial value, calculate the CRC check value of the data segment in the unit data block, and use the obtained result as the second check value of the unit data block. Likewise, the second check value of the unit data block will be used as the check reference value of the next unit data block.
S204,将复原固定地址加上所述目的存储模块中原始数据的已接收数据长度,生成所述单元数据块的复原地址,所述复原固定地址为所述原始数据在目的存储模块中的初始存储地址。S204, adding the restored fixed address to the received data length of the original data in the destination storage module to generate a restored address of the unit data block, where the restored fixed address is the initial storage of the original data in the destination storage module address.
所述复原固定地址,为原始数据在目的存储模块中存储的初始地址,是一个预先设定的用于存储原始数据的首地址,可以在目的存储模块出厂时就设置完成,也可以在原始存储模块或数据存储装置上进行设置并发送给目的存储模块,或在目的存储模块上进行设置。当然,在所述目的存储模块中存储有历史数据时,可以将存储历史数据后的第一个地址作为用于存储原始数据的复原固定地址。The restoration fixed address is the initial address of the original data stored in the destination storage module, which is a preset first address for storing the original data, which can be set when the destination storage module leaves the factory, or can be stored in the original storage module. The setting is made on the module or data storage device and sent to the destination storage module, or the setting is made on the destination storage module. Of course, when historical data is stored in the destination storage module, the first address after storing the historical data may be used as the restoration fixed address for storing the original data.
所述目的存储模块中原始数据的已接收长度,是指目的存储模块中,已经进行存储的与所述单元数据块中数据片段属于同一原始数据的其余数据片段的总长度。所述复原地址,就是所述单元数据块中的数据片段在目的存储模块中进行存储的首地址,将复原固定地址加上已接收长度,可以计算出所述复原地址。The received length of the original data in the destination storage module refers to the total length of other data segments in the destination storage module that have been stored and belong to the same original data as the data segments in the unit data block. The restoration address is the first address where the data segment in the unit data block is stored in the destination storage module, and the restoration address can be calculated by adding the restoration fixed address to the received length.
例如,如图4所示为一种计算复原地址的举例示意图,数据存储装置中设置的复原固定地址为0000,获取到已接收长度为500bit,则复原固定地址加上已接收长度可以得到所述单元数据块的复原地址为01F4。For example, as shown in Figure 4 is a schematic diagram of an example of calculating the restoration address, the restoration fixed address set in the data storage device is 0000, and the received length obtained is 500 bits, then the restoration fixed address and the received length can be obtained. The recovery address of the unit data block is 01F4.
进一步的,一种可行的计算复原地址的方法为:将上一个单元数据块的复原地址加上上一个单元数据块中数据片段的长度,得到所述单元数据块的复原地址。Further, a feasible method for calculating the restoration address is: adding the restoration address of the previous unit data block to the length of the data fragment in the previous unit data block to obtain the restoration address of the unit data block.
进一步的,若所述单元数据块为原始数据的第一个单元数据块,则此时的已接收长度为0,复原固定地址即为所述单元数据块的复原地址。Further, if the unit data block is the first unit data block of the original data, the received length at this time is 0, and the restoration fixed address is the restoration address of the unit data block.
S205,判断所述第一校验值和所述单元数据块的第二校验值是否相匹配。S205: Determine whether the first check value matches the second check value of the unit data block.
判断所述第一校验值与所述单元数据块的第二校验值是否相同,若相同则执行S206,若不相同直接执行S207。It is judged whether the first check value is the same as the second check value of the unit data block, and if they are the same, S206 is executed, and if they are not the same, S207 is directly executed.
S206,当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述原始数据在目的存储模块中的初始存储地址,对所述单元数据块中的数据片段进行存储。S206, when the first check value matches the second check value of the unit data block, according to the initial storage address of the original data in the destination storage module, perform a check on the data in the unit data block. Fragments are stored.
若所述第一校验值和所述单元数据块的第二校验值相同,即所述单元数据块中的数据片段传输完整,数据存储装置将所述单元数据块的数据片段保存在目的存储模块中的复原地址中。If the first check value and the second check value of the unit data block are the same, that is, the data fragments in the unit data block are transmitted completely, the data storage device stores the data fragments of the unit data block in the destination In the recovery address in the memory module.
S207,采用所述数据片段的数据长度对所述已接收数据长度进行更新。S207, using the data length of the data segment to update the received data length.
所述单元数据块中的数据片段保存在目的存储模块中后,将已接收数据长度加上所述单元数据块中的数据片段的长度,将得到的结果确认为已接收数据长度,以供下一个单元数据块计算复原地址。After the data fragment in the unit data block is stored in the destination storage module, add the length of the received data to the length of the data fragment in the unit data block, and confirm the result as the received data length for the next step. A unit data block calculates the recovery address.
S208,当所述第一校验值和所述第二校验值不匹配时,输出传输错误通知。S208, when the first check value and the second check value do not match, output a transmission error notification.
若所述第一校验值和所述单元数据块的第二校验值不相同,即所述单元数据块中的数据片段传输不完整或出现了错误,则向原始存储模块发送传输错误通知,通知原始存储数据模块传输出现错误。If the first check value and the second check value of the unit data block are different, that is, the data segment in the unit data block is incompletely transmitted or has an error, a transmission error notification is sent to the original storage module , which informs the original storage data module that there was an error in the transmission.
进一步的,当原始存储数据模块接收到传输错误通知时,会重新计算第一校验值并发送所述单元数据块。若原始存储数据模块在一个原始数据的传输中接收到的传输错误通知超过错误通知阈值,则会输出错误警告,通知相关技术人员对可能出现的问题进行排查。所述错误通知阈值,是指一个原始数据的传输中接收到传输错误通知个数的一个临界值,超过这个值代表数据传输过程出现了问题。Further, when the original storage data module receives the transmission error notification, it will recalculate the first check value and send the unit data block. If the transmission error notification received by the original storage data module during the transmission of an original data exceeds the error notification threshold, it will output an error warning to notify the relevant technical personnel to troubleshoot possible problems. The error notification threshold refers to a critical value of the number of transmission error notifications received in the transmission of an original data, and exceeding this value indicates that there is a problem in the data transmission process.
进一步的,当所述单元数据块为所述原始数据的最后一个单位数据块时,在目的存储模块中获取存储数据的数据长度,所述存储数据为在所述目的存储模块中,以所述原始数据在所述目的存储模块中的初始存储地址为首地址,长度为已接收数据长度的数据;Further, when the unit data block is the last unit data block of the original data, the data length of the stored data is obtained in the destination storage module, and the stored data is in the destination storage module, with the The initial storage address of the original data in the destination storage module is the first address, and the length is the data of the received data length;
当所述存储数据的数据长度与所述原始数据的数据长度不相同时,输出数据错误通知。When the data length of the stored data is different from the data length of the original data, a data error notification is output.
所述单元数据块为原始数据的最后一个单元数据块,并将数据片段保存到目的存储模块中后,获取目的存储模块中存储数据的数据长度,将存储数据的长度与原始数据的长度进行对比。The unit data block is the last unit data block of the original data, and after the data fragment is stored in the destination storage module, the data length of the stored data in the destination storage module is obtained, and the length of the stored data is compared with the length of the original data. .
若所述存储数据的数据长度与所述原始数据的数据长度相同,则数据存储装置确认所述原始数据已经传输完毕且传输数据完整,可以输出传输完成通知。If the data length of the stored data is the same as the data length of the original data, the data storage device confirms that the original data has been transmitted and the transmitted data is complete, and can output a transmission completion notification.
若所述存储数据的数据长度与所述原始数据的数据长度不相同,则数据存储装置确认所述原始数据的传输不完整,输出数据错误通知。If the data length of the stored data is different from the data length of the original data, the data storage device confirms that the transmission of the original data is incomplete, and outputs a data error notification.
进一步的,一种确认所述单元数据块为最后一个单元数据块的方法为:若所述单元数据块中的数据片段的长度小于原始存储模块的单次传输长度,则确认所述单元数据块为最后一个单元数据块。所述单次传输长度,为原始存储模块将原始数据按照单次传输长度分为多个数据片段。Further, a method for confirming that the unit data block is the last unit data block is: if the length of the data fragment in the unit data block is less than the single transmission length of the original storage module, then confirming the unit data block. is the last unit data block. The single transmission length means that the original storage module divides the original data into multiple data segments according to the single transmission length.
在本申请实施例中,获取单元数据块中的第一校验值,将上一个单元数据块的第二校验值作为校验基准值,并基于所述单元数据块的数据片段和校验基准值计算所述单元数据块的第二校验值,在保证了所述单元数据块的数据片段传输完整正确的同时,再一次验证了上一个单元数据块的校验结果,提高了数据传输的完整性与可靠性。In the embodiment of the present application, the first check value in the unit data block is acquired, the second check value of the previous unit data block is used as the check reference value, and the check value is based on the data fragment sum of the unit data block. The reference value calculates the second check value of the unit data block, while ensuring that the data fragment transmission of the unit data block is complete and correct, the check result of the previous unit data block is verified again, and the data transmission is improved. integrity and reliability.
通过原始数据的已接收长度和初始存储地址计算复原地址,确定所述单元数据块的数据片段的存储位置,方便查找和提取存储数据,同时方便在传输完成时比较存储数据与原始数据的长度,确认数据传输是否完整。当所述第一校验值与所述第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储,若不匹配则输出传输错误通知,让原始存储模块重新传输所述单元数据块,进一步提高了数据传输的可靠性。The recovery address is calculated by the received length of the original data and the initial storage address, and the storage location of the data segment of the unit data block is determined, which is convenient for searching and extracting the stored data, and at the same time, it is convenient to compare the length of the stored data and the original data when the transmission is completed, Confirm that the data transfer is complete. When the first check value matches the second check value, store the data segment in the unit data block according to the restoration address of the destination storage module, and output a transmission error notification if they do not match , allowing the original storage module to retransmit the unit data block, which further improves the reliability of data transmission.
下面将结合附图5-附图7,对本申请实施例提供的数据存储设备进行详细介绍。需要说明的是,附图5-附图7中的数据存储设备,用于执行本申请图1-图4所示实施例的方法,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图1-图4所示的实施例。The data storage device provided by the embodiment of the present application will be described in detail below with reference to FIG. 5 to FIG. 7 . It should be noted that the data storage devices in FIG. 5 to FIG. 7 are used to execute the methods of the embodiments shown in FIG. 1 to FIG. 4 of the present application. For the convenience of description, only the data storage devices related to the embodiments of the present application are shown. For some, specific technical details are not disclosed, please refer to the embodiments shown in FIG. 1 to FIG. 4 of the present application.
请参见图5,其示出了本申请一个示例性实施例提供的数据存储装置的结构示意图。该数据存储装置可以通过软件、硬件或者两者的结合实现成为装置的全部或一部分。该装置1包括第一校验值获取模块11、第二校验值获取模块12和数据存储模块13。Please refer to FIG. 5 , which shows a schematic structural diagram of a data storage device provided by an exemplary embodiment of the present application. The data storage device can be implemented as a whole or a part of the device through software, hardware or a combination of the two. The
第一校验值获取模块11,用于当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值;The first check
第二校验值获取模块12,用于获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值;The second check
数据存储模块13,用于当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。The
可选的,所述第二校验值获取模块12,具体用于:Optionally, the second check
当所述单元数据块为原始数据的第一个单元数据块时,获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与初始基准值,计算所述单元数据块的第二校验值。When the unit data block is the first unit data block of the original data, obtain the data segment of the unit data block, and calculate the unit data block based on the data segment in the unit data block and the initial reference value The second check value of .
可选的,所述数据存储模块13,具体用于:Optionally, the
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述原始数据在目的存储模块中的初始存储地址,对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, according to the initial storage address of the original data in the destination storage module, the data fragment in the unit data block is processed. storage.
可选的,如图6所示,所述第二校验值获取模块12,包括:Optionally, as shown in FIG. 6 , the second check
基准值获取单元121,用于基于所述原始数据中单元数据块的排列顺序获取所述单元数据块的上一个单元数据块,将所述上一个单元数据块对应的第二校验值确定为所述单元数据块的校验基准值;The reference
校验值计算单元122,用于获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与所述校验基准值,计算所述单元数据块的第二校验值。A check
可选的,所述装置1还包括:Optionally, the
复原地址生成模块14,用于将复原固定地址加上所述目的存储模块中原始数据的已接收数据长度,生成所述单元数据块的复原地址,所述复原固定地址为所述原始数据在目的存储模块中的初始存储地址。The restoration
可选的,所述装置1还包括:Optionally, the
接收长度更新模块15,用于采用所述数据片段的数据长度对所述已接收数据长度进行更新。The received
可选的,所述装置1还包括:Optionally, the
数据长度校验模块16,用于当所述单元数据块为所述原始数据的最后一个单位数据块时,在目的存储模块中获取存储数据的数据长度,所述存储数据为在所述目的存储模块中,以所述原始数据在所述目的存储模块中的初始存储地址为首地址,长度为已接收数据长度的数据;The data
当所述存储数据的数据长度与所述原始数据的数据长度不相同时,输出数据错误通知。When the data length of the stored data is different from the data length of the original data, a data error notification is output.
可选的,所述装置1还包括:Optionally, the
传输错误输出模块17,用于当所述第一校验值和所述第二校验值不匹配时,输出传输错误通知。The transmission
如7所示,为另一种数据存储装置的结构示意图。As shown in FIG. 7 , it is a schematic structural diagram of another data storage device.
在本申请实施例中,获取单元数据块中的第一校验值,并基于所述单元数据块的数据片段计算第二校验值,当所述第一校验值与所述第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。通过对比第一校验值和第二校验值,判断数据片段的传输是否完整,保证了数据传输过程中数据的完整性。In the embodiment of the present application, the first check value in the unit data block is obtained, and the second check value is calculated based on the data segment of the unit data block. When the verification values match, the data segment in the unit data block is stored according to the restoration address of the destination storage module. By comparing the first check value and the second check value, it is determined whether the transmission of the data segment is complete, which ensures the integrity of the data during the data transmission process.
需要说明的是,上述实施例提供的数据存储装置在执行数据存储方法时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的数据存储装置与数据存储方法实施例属于同一构思,其体现实现过程详见方法实施例,这里不再赘述。It should be noted that, when the data storage device provided in the above embodiment executes the data storage method, only the division of the above functional modules is used as an example for illustration. In practical applications, the above functions may be allocated to different functional modules as required , that is, dividing the internal structure of the device into different functional modules to complete all or part of the functions described above. In addition, the data storage device and the data storage method embodiments provided by the above embodiments belong to the same concept, and the implementation process of the data storage device is described in the method embodiments, which will not be repeated here.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
本申请实施例还提供了一种计算机存储介质,所述计算机存储介质可以存储有多条指令,所述指令适于由处理器加载并执行如上述图1-图4所示实施例的所述数据存储方法,具体执行过程可以参见图1-图4所示实施例的具体说明,在此不进行赘述。An embodiment of the present application further provides a computer storage medium, where the computer storage medium can store a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-described embodiments shown in FIG. 1 to FIG. 4 . For the data storage method, for the specific execution process, reference may be made to the specific description of the embodiments shown in FIG. 1 to FIG. 4 , which will not be repeated here.
本申请还提供了一种计算机程序产品,该计算机程序产品存储有至少一条指令,所述至少一条指令由所述处理器加载并执行如上述图1-图4所示实施例的所述数据存储方法,具体执行过程可以参见图1-图4所示实施例的具体说明,在此不进行赘述。The present application also provides a computer program product, the computer program product stores at least one instruction, and the at least one instruction is loaded by the processor and executes the data storage according to the embodiment shown in FIG. 1 to FIG. 4 . For the specific execution process, reference may be made to the specific descriptions of the embodiments shown in FIG. 1 to FIG. 4 , which will not be repeated here.
请参见图8,为本申请实施例提供了一种电子设备的结构示意图。如图8所示,所述电子设备1000可以包括:至少一个处理器1001,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。Please refer to FIG. 8 , which provides a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 8 , the
其中,通信总线1002用于实现这些组件之间的连接通信。Among them, the
其中,用户接口1003可以包括显示屏(Display)、摄像头(Camera),可选用户接口1003还可以包括标准的有线接口、无线接口。The
其中,网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。Wherein, the
其中,处理器1001可以包括一个或者多个处理核心。处理器1001利用各种借口和线路连接整个服务器1000内的各个部分,通过运行或执行存储在存储器1005内的指令、程序、代码集或指令集,以及调用存储在存储器1005内的数据,执行服务器1000的各种功能和处理数据。可选的,处理器1001可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器1001可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示屏所需要显示的内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器1001中,单独通过一块芯片进行实现。The
其中,存储器1005可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。可选的,该存储器1005包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器1005可用于存储指令、程序、代码、代码集或指令集。存储器1005可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现上述各个方法实施例的指令等;存储数据区可存储上面各个方法实施例中涉及到的数据等。存储器1005可选的还可以是至少一个位于远离前述处理器1001的存储装置。如图8所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及数据存储应用程序。The
在图8所示的电子设备1000中,用户接口1003主要用于为用户提供输入的接口,获取用户输入的数据;而处理器1001可以用于调用存储器1005中存储的数据存储应用程序,并具体执行以下操作:In the
当由原始存储模块接收到原始数据中的单元数据块时,获取所述单元数据块中的第一校验值;When the unit data block in the original data is received by the original storage module, obtain the first check value in the unit data block;
获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值;Acquire the data fragment of the unit data block, and calculate the second check value of the unit data block;
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, the data segment in the unit data block is stored according to the restoration address of the destination storage module.
在一个实施例中,所述处理器1001在执行获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值时,具体执行以下操作:In one embodiment, when the
当所述单元数据块为原始数据的第一个单元数据块时,获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与初始基准值,计算所述单元数据块的第二校验值。When the unit data block is the first unit data block of the original data, obtain the data segment of the unit data block, and calculate the unit data block based on the data segment in the unit data block and the initial reference value The second check value of .
在一个实施例中,所述处理器1001在执行当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储时,具体执行以下操作:In one embodiment, when the first check value matches the second check value of the unit data block, the
当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述原始数据在目的存储模块中的初始存储地址,对所述单元数据块中的数据片段进行存储。When the first check value matches the second check value of the unit data block, the data segment in the unit data block is processed according to the initial storage address of the original data in the destination storage module. storage.
在一个实施例中,所述处理器1001在执行获取所述单元数据块的数据片段,并计算所述单元数据块的第二校验值时,具体执行以下操作:In one embodiment, when the
基于所述原始数据中单元数据块的排列顺序获取所述单元数据块的上一个单元数据块,将所述上一个单元数据块对应的第二校验值确定为所述单元数据块的校验基准值;The last unit data block of the unit data block is acquired based on the arrangement order of the unit data blocks in the original data, and the second check value corresponding to the last unit data block is determined as the check value of the unit data block Reference value;
获取所述单元数据块的数据片段,并基于所述单元数据块中的数据片段与所述校验基准值,计算所述单元数据块的第二校验值。A data segment of the unit data block is acquired, and based on the data segment in the unit data block and the check reference value, a second check value of the unit data block is calculated.
在一个实施例中,所述处理器1001在执行当所述第一校验值和所述单元数据块的第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储之前,还执行以下操作:In one embodiment, when the first check value matches the second check value of the unit data block, the
将复原固定地址加上所述目的存储模块中原始数据的已接收数据长度,生成所述单元数据块的复原地址,所述复原固定地址为所述原始数据在目的存储模块中的初始存储地址。The restored fixed address is added to the received data length of the original data in the destination storage module to generate the restored address of the unit data block, where the restored fixed address is the initial storage address of the original data in the destination storage module.
在一个实施例中,所述处理器1001在执行所述数据存储方法时,还执行以下操作:In one embodiment, when executing the data storage method, the
采用所述数据片段的数据长度对所述已接收数据长度进行更新。The received data length is updated with the data length of the data segment.
在一个实施例中,所述处理器1001在执行所述数据存储方法时,还执行以下操作:In one embodiment, when executing the data storage method, the
当所述单元数据块为所述原始数据的最后一个单位数据块时,在目的存储模块中获取存储数据的数据长度,所述存储数据为在所述目的存储模块中,以所述原始数据在所述目的存储模块中的初始存储地址为首地址,长度为已接收数据长度的数据;When the unit data block is the last unit data block of the original data, the data length of the stored data is obtained in the destination storage module, the stored data is in the destination storage module, and the original data is stored in the destination storage module. The initial storage address in the purpose storage module is the first address, and the length is the data of the received data length;
当所述存储数据的数据长度与所述原始数据的数据长度不相同时,输出数据错误通知。When the data length of the stored data is different from the data length of the original data, a data error notification is output.
在一个实施例中,所述处理器1001在执行所述数据存储方法时,还执行以下操作:In one embodiment, when executing the data storage method, the
当所述第一校验值和所述第二校验值不匹配时,输出传输错误通知。When the first check value and the second check value do not match, a transmission error notification is output.
在本申请实施例中,获取单元数据块中的第一校验值,并基于所述单元数据块的数据片段计算第二校验值,当所述第一校验值与所述第二校验值相匹配时,根据所述目的存储模块的复原地址对所述单元数据块中的数据片段进行存储。通过对比第一校验值和第二校验值,判断数据片段的传输是否完整,保证了数据传输过程中数据的完整性。In the embodiment of the present application, the first check value in the unit data block is obtained, and the second check value is calculated based on the data segment of the unit data block. When the verification values match, the data segment in the unit data block is stored according to the restoration address of the destination storage module. By comparing the first check value and the second check value, it is determined whether the transmission of the data segment is complete, which ensures the integrity of the data during the data transmission process.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体或随机存储记忆体等。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 program can be stored in a computer-readable storage medium. During execution, the processes of the embodiments of the above-mentioned methods may be included. Wherein, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, or a random storage memory, and the like.
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。The above disclosures are only the preferred embodiments of the present application, and of course, the scope of the rights of the present application cannot be limited by this. Therefore, equivalent changes made according to the claims of the present application are still within the scope of the present application.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011064118.2A CN114327996A (en) | 2020-09-30 | 2020-09-30 | A data storage method, device, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011064118.2A CN114327996A (en) | 2020-09-30 | 2020-09-30 | A data storage method, device, storage medium and electronic device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114327996A true CN114327996A (en) | 2022-04-12 |
Family
ID=81033101
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011064118.2A Pending CN114327996A (en) | 2020-09-30 | 2020-09-30 | A data storage method, device, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114327996A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114884731A (en) * | 2022-05-07 | 2022-08-09 | 江苏红光仪表厂有限公司 | Information remote transmission system for industrial automation instrument |
CN115473717A (en) * | 2022-09-05 | 2022-12-13 | 杭州思拓瑞吉科技有限公司 | Energy storage system time sequence data verification method based on co-prime power remainder |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070061670A1 (en) * | 2005-08-30 | 2007-03-15 | Shih W H | Digital data transmission error checking method and system |
CN102752283A (en) * | 2012-05-30 | 2012-10-24 | 福建省三奥信息科技股份有限公司 | Method and system for transmitting files with large data sizes |
CN107483157A (en) * | 2017-09-01 | 2017-12-15 | 郑州云海信息技术有限公司 | A kind of CRC check method and system based on FPGA |
CN109818748A (en) * | 2018-12-28 | 2019-05-28 | 北京奇安信科技有限公司 | Data transmission method, equipment, system and medium |
CN109947368A (en) * | 2019-03-21 | 2019-06-28 | 记忆科技(深圳)有限公司 | Data reliability detection method, device, computer equipment and storage medium |
CN111176885A (en) * | 2019-12-31 | 2020-05-19 | 浪潮电子信息产业股份有限公司 | Data verification method and related device for distributed storage system |
-
2020
- 2020-09-30 CN CN202011064118.2A patent/CN114327996A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070061670A1 (en) * | 2005-08-30 | 2007-03-15 | Shih W H | Digital data transmission error checking method and system |
CN102752283A (en) * | 2012-05-30 | 2012-10-24 | 福建省三奥信息科技股份有限公司 | Method and system for transmitting files with large data sizes |
CN107483157A (en) * | 2017-09-01 | 2017-12-15 | 郑州云海信息技术有限公司 | A kind of CRC check method and system based on FPGA |
CN109818748A (en) * | 2018-12-28 | 2019-05-28 | 北京奇安信科技有限公司 | Data transmission method, equipment, system and medium |
CN109947368A (en) * | 2019-03-21 | 2019-06-28 | 记忆科技(深圳)有限公司 | Data reliability detection method, device, computer equipment and storage medium |
CN111176885A (en) * | 2019-12-31 | 2020-05-19 | 浪潮电子信息产业股份有限公司 | Data verification method and related device for distributed storage system |
Non-Patent Citations (1)
Title |
---|
周延森: "数据结构", 31 January 2019, 北京邮电大学出版社, pages: 2 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114884731A (en) * | 2022-05-07 | 2022-08-09 | 江苏红光仪表厂有限公司 | Information remote transmission system for industrial automation instrument |
CN114884731B (en) * | 2022-05-07 | 2024-02-23 | 江苏红光仪表厂有限公司 | Information remote transmission system for industrial automation instrument |
CN115473717A (en) * | 2022-09-05 | 2022-12-13 | 杭州思拓瑞吉科技有限公司 | Energy storage system time sequence data verification method based on co-prime power remainder |
CN115473717B (en) * | 2022-09-05 | 2023-09-01 | 杭州思拓瑞吉科技有限公司 | Energy storage system time sequence data verification method based on prime power remainder |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110399118B (en) | Random number generation method and device, storage medium and electronic equipment | |
CN110875850B (en) | Firmware upgrading method and system, readable storage medium and terminal equipment | |
CN108063818B (en) | Data downloading method, device, terminal and computer readable storage medium | |
CN109922049B (en) | Verification device and method based on block chain | |
CN113972990B (en) | Data verification method and device, storage medium and electronic equipment | |
EP3819802A1 (en) | Data consistency checking method and data uploading/downloading apparatus | |
CN110647490B (en) | Data transmission method, device, equipment and computer storage medium | |
CN114327996A (en) | A data storage method, device, storage medium and electronic device | |
CN105553727A (en) | Method, device and system for updating configuration information | |
CN112968907B (en) | Data transmission method, data storage method, data query method, medium and device | |
CN106331152B (en) | Method and device for realizing information synchronization between modules | |
CN111865557A (en) | Check code generation method and device | |
CN112800476A (en) | Data desensitization method and device and electronic equipment | |
CN111176685A (en) | Upgrading method and device | |
CN103731424B (en) | A kind of transmission method of network data, apparatus and system | |
CN108596120B (en) | Target detection method and device based on deep learning | |
CN110770720B (en) | Resource searching method and related products | |
CN107391170B (en) | Upgrading method and device supporting multiple schemes and computer equipment | |
CN106021003A (en) | Intelligent terminal repairing method, intelligent terminal, and server | |
CN113132484A (en) | Data transmission method and device | |
US20210110041A1 (en) | Displaying a bios update progress | |
CN112463067A (en) | Data protection method and equipment in NVMe-oF scene | |
CN113542308B (en) | Information processing method, system and storage medium, electronic device | |
CN116560706A (en) | Differential upgrading method and device for electric energy meter and server | |
JP5376990B2 (en) | Relay device and relay method of relay device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |