[go: up one dir, main page]

CN114968963A - File overwriting method, device and electronic device - Google Patents

File overwriting method, device and electronic device Download PDF

Info

Publication number
CN114968963A
CN114968963A CN202110194994.5A CN202110194994A CN114968963A CN 114968963 A CN114968963 A CN 114968963A CN 202110194994 A CN202110194994 A CN 202110194994A CN 114968963 A CN114968963 A CN 114968963A
Authority
CN
China
Prior art keywords
overwriting
file
overwrite
content
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110194994.5A
Other languages
Chinese (zh)
Inventor
黎海兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202110194994.5A priority Critical patent/CN114968963A/en
Publication of CN114968963A publication Critical patent/CN114968963A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations

Landscapes

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

Abstract

The invention provides a method and a device for overwriting a file and electronic equipment, wherein the method comprises the following steps: acquiring an overwriting instruction; the overwrite write instruction includes at least: the method comprises the steps that a file identifier of a target file needing to be overwritten, a storage position identifier of overwriting content and an overwriting position are obtained; and according to the overwriting instruction, writing the overwriting content into the overwriting position in the target file. According to the method, based on the data contained in the overwriting instruction, the overwriting content is written into the target file at the storage position of the target file to be overwritten, and the target file does not need to be overwritten after being read out from the storage position, so that the data volume of reading and writing data is reduced, and the overwriting performance is improved.

Description

文件覆盖写方法、装置和电子设备File overwriting method, device and electronic device

技术领域technical field

本发明涉及文件存储技术领域,尤其是涉及一种文件覆盖写方法、装置和电子设备。The present invention relates to the technical field of file storage, and in particular, to a file overwriting method, device and electronic device.

背景技术Background technique

相关技术中,分布式文件系统对文件的写入方式通常只支持追加写,不支持覆盖写。为了对分布式文件系统中的文件进行覆盖写,通常需要用户通过终端设备将待覆盖写文件从分布式文件系统中读取出来,然后在终端设备中将待覆盖写文件与预设的覆盖写内容进行合并,再将合并后的文件写入分布式文件系统中,并将分布式文件系统中的待覆盖写文件对应的原文件删除,以完成对待覆盖写文件的覆盖写。但是该方式在对文件进行覆盖写时,需要将分布式文件系统中的文件读取到本地的终端设备上进行文件的合并,还要将本地的合并文件再次写入分布式文件系统中,导致读数据和写数据的数据量均较大,影响覆盖写性能。In the related art, the way of writing to a file in a distributed file system usually only supports append writing, and does not support overwriting. In order to overwrite the files in the distributed file system, the user usually needs to read the file to be overwritten from the distributed file system through the terminal device, and then the file to be overwritten and the preset overwrite write in the terminal device. The contents are merged, the merged file is written into the distributed file system, and the original file corresponding to the file to be overwritten in the distributed file system is deleted, so as to complete the overwrite of the file to be overwritten. However, when overwriting the file in this method, it needs to read the file in the distributed file system to the local terminal device to merge the file, and also write the local merged file into the distributed file system again, resulting in The amount of data read and written is large, which affects the overwrite performance.

发明内容SUMMARY OF THE INVENTION

本发明的目的在于提供一种文件覆盖写方法、装置和电子设备,以减少对文件覆盖写时读数据和写数据的数据量,提高覆盖写性能。The purpose of the present invention is to provide a file overwriting method, device and electronic device, so as to reduce the amount of data read and write when overwriting a file and improve the overwriting performance.

第一方面,本发明实施例提供了一种文件覆盖写方法,该方法包括:获取覆盖写指令;其中,该覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;根据该覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。In a first aspect, an embodiment of the present invention provides a method for overwriting a file. The method includes: acquiring an overwriting instruction; wherein the overwriting instruction at least includes: a file identifier of a target file to be overwritten, an overwriting content Storage location identification and overwrite location; according to the overwrite instruction, write the overwrite content to the overwrite location in the target file.

在可选的实施方式中,上述覆盖写位置包括:覆盖写起始地址和覆盖写长度;其中,该覆盖写长度与覆盖写内容的长度相同;上述根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上的步骤,包括:根据目标文件的文件标识和覆盖写内容的存储位置标识,确定出目标文件和覆盖写内容;从目标文件中的覆盖写起始地址开始,将目标文件中覆盖写长度的内容替换为覆盖写内容。In an optional embodiment, the above-mentioned overwriting position includes: an overwriting start address and an overwriting length; wherein, the overwriting length is the same as the length of the overwriting content; the overwriting content is written according to the overwriting instruction above. The steps on the overwriting position in the target file include: determining the target file and the overwriting content according to the file identifier of the target file and the storage location identifier of the overwriting content; starting from the overwriting starting address in the target file, adding The content of the overwrite length in the target file is replaced with the overwrite content.

在可选的实施方式中,上述覆盖写指令保存在指定数据库中;上述获取覆盖写指令的步骤,包括:判断该指定数据库中是否存在覆盖写指令;如果存在,获取该覆盖写指令。In an optional implementation manner, the above-mentioned overwriting instruction is stored in a designated database; the above-mentioned step of obtaining an overwriting instruction includes: judging whether there is an overwriting instruction in the designated database; if so, acquiring the overwriting instruction.

在可选的实施方式中,上述需要进行覆盖写的目标文件保存在预设的分布式文件系统中;该指定数据库中的覆盖写指令通过下述方式获取:如果接收到用户发送的覆盖写请求,从覆盖写请求中提取覆盖写内容、覆盖写位置和需要进行覆盖的目标文件的文件标识;将该覆盖写内容写入分布式文件系统中,得到该覆盖写内容的存储位置标识;拼接目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,得到目标文件的覆盖写指令;将该覆盖写指令保存至指定数据库中。In an optional implementation manner, the above-mentioned target file that needs to be overwritten is stored in a preset distributed file system; the overwrite instruction in the specified database is obtained in the following manner: if an overwrite request sent by a user is received , extract the overwriting content, the overwriting location and the file identifier of the target file to be overwritten from the overwriting request; write the overwriting content into the distributed file system to obtain the storage location identifier of the overwriting content; splicing the target The file identifier of the file, the storage location identifier of the overwritten content, and the overwritten location are used to obtain an overwritten instruction of the target file; the overwritten instruction is stored in a designated database.

在可选的实施方式中,上述根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上的步骤之后,该方法还包括:删除覆盖写指令,以及该存储位置标识对应的文件中的覆盖写内容。In an optional implementation manner, after the above step of writing the overwriting content to the overwriting position in the target file according to the overwriting instruction, the method further includes: deleting the overwriting instruction, and identifying the file corresponding to the storage position Overwrite content in .

在可选的实施方式中,上述方法还包括:接收用户发送的目标文件的读取请求;判断指定数据库中是否存在目标文件的覆盖写指令;如果存在,根据目标文件的覆盖写指令,从分布式文件系统中读取该覆盖写指令对应的覆盖写内容和目标文件,将覆盖写内容和目标文件进行合并,将合并后的目标文件返回给所述用户;如果不存在,从分布式文件系统中读取目标文件,将读取的目标文件返回给所述用户。In an optional embodiment, the above method further includes: receiving a read request of the target file sent by the user; judging whether there is an overwrite instruction of the target file in the specified database; if there is, according to the overwrite instruction of the target file, from the distribution Read the overwrite content and target file corresponding to the overwrite instruction in the file system, merge the overwrite content and the target file, and return the merged target file to the user; if it does not exist, from the distributed file system The target file is read in, and the read target file is returned to the user.

在可选的实施方式中,上述分布式文件系统中存储有目标文件的覆盖写版本号;上述将覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识的步骤之后,该方法还包括:接收分布式文件系统返回的目标文件的覆盖写版本号;将该覆盖写版本号写入覆盖写指令中;上述根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上的步骤之后,该方法还包括:将分布式文件系统中的覆盖写版本号,更新为覆盖写指令中的覆盖写版本号与一的加和。In an optional embodiment, the overwrite version number of the target file is stored in the above-mentioned distributed file system; after the above-mentioned step of writing the overwrite content into the distributed file system and obtaining the storage location identifier of the overwrite content, the The method further includes: receiving an overwrite version number of the target file returned by the distributed file system; writing the overwrite version number into an overwrite instruction; and writing the overwrite content into the overwrite instruction in the target file according to the overwrite instruction. After the step on the location, the method further includes: updating the overwrite version number in the distributed file system to the sum of the overwrite version number and one in the overwrite instruction.

在可选的实施方式中,上述目标文件包括多个副本文件;根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上的步骤,包括:针对目标文件的每个副本文件,根据覆盖写指令,将该覆盖写内容写入当前副本文件中的覆盖写位置上。In an optional embodiment, the above-mentioned target file includes a plurality of duplicate files; according to the overwrite instruction, the step of writing the overwrite content to the overwrite position in the target file includes: for each duplicate file of the target file, According to the overwriting instruction, the overwriting content is written to the overwriting position in the current copy file.

在可选的实施方式中,上述方法还包括:针对目标文件的每个副本文件,判断覆盖写内容是否成功写入当前副本文件中的覆盖写位置上;如果未成功写入,自动修复当前副本文件,并将覆盖写内容重新写入当前副本文件中,直到当前副本文件覆盖写成功。In an optional embodiment, the above method further includes: for each copy file of the target file, judging whether the overwriting content is successfully written to the overwriting position in the current copy file; if it is not successfully written, automatically repairing the current copy file, and rewrite the overwritten content to the current copy file until the current copy file is overwritten successfully.

第二方面,本发明实施例提供了一种文件覆盖写装置,该装置包括:指令获取模块,用于获取覆盖写指令;其中,该覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;覆盖写模块,用于根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。In a second aspect, an embodiment of the present invention provides a file overwriting device, the device includes: an instruction acquisition module for acquiring an overwriting instruction; wherein the overwriting instruction at least includes: a file of a target file that needs to be overwritten Identify, identify the storage location of the overwrite content and the overwrite location; the overwrite module is used to write the overwrite content to the overwrite location in the target file according to the overwrite instruction.

第三方面,本发明实施例提供了一种电子设备,该电子设备包括处理器和存储器,该存储器存储有能够被处理器执行的机器可执行指令,该处理器执行机器可执行指令以实现前述实施方式任一项所述的文件覆盖写方法。In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device includes a processor and a memory, where the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the foregoing The file overwriting method according to any one of the embodiments.

第四方面,本发明实施例提供了一种机器可读存储介质,该机器可读存储介质存储有机器可执行指令,该机器可执行指令在被处理器调用和执行时,该机器可执行指令促使处理器实现前述实施方式任一项所述的文件覆盖写方法。In a fourth aspect, embodiments of the present invention provide a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions The processor is caused to implement the file overwriting method described in any one of the foregoing embodiments.

本发明实施例带来了以下有益效果:The embodiments of the present invention have brought the following beneficial effects:

本发明提供的一种文件覆盖写方法、装置和电子设备,首先获取覆盖写指令;该覆盖写指令至少包括需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;然后根据覆盖写指令,将该覆盖写内容写入目标文件中的覆盖写位置上。该方式基于覆盖写指令中包含的数据,在需要进行覆盖写的目标文件的存储位置上,将覆盖写内容写入目标文件中,无需将目标文件从存储位置中读取出来后再进行覆盖写,从而减少了读数据和写数据的数据量,提升了覆盖写性能。In a file overwriting method, device and electronic device provided by the present invention, an overwriting instruction is first obtained; the overwriting instruction at least includes a file identifier of a target file to be overwritten, a storage location identifier of the overwriting content and an overwriting location ; Then according to the overwriting instruction, write the overwriting content to the overwriting position in the target file. This method is based on the data contained in the overwrite instruction. In the storage location of the target file that needs to be overwritten, the overwrite content is written into the target file, and there is no need to read the target file from the storage location and then overwrite. , thereby reducing the amount of data read and written, and improving the overwrite performance.

本发明的其他特征和优点将在随后的说明书中阐述,或者,部分特征和优点可以从说明书推知或毫无疑义地确定,或者通过实施本发明的上述技术即可得知。Additional features and advantages of the present invention will be set forth in the description which follows, or some may be inferred or unambiguously determined from the description, or may be learned by practicing the above-described techniques of the present invention.

为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施方式,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present invention more clearly understood, the preferred embodiments are exemplified below, and are described in detail as follows in conjunction with the accompanying drawings.

附图说明Description of drawings

为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the specific embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the specific embodiments or the prior art. Obviously, the accompanying drawings in the following description The drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.

图1为本发明实施例提供的一种文件覆盖写方法的流程图;1 is a flowchart of a file overwriting method provided by an embodiment of the present invention;

图2为本发明实施例提供的另一种文件覆盖写方法的流程图;2 is a flowchart of another method for overwriting a file provided by an embodiment of the present invention;

图3为本发明实施例提供的另一种文件覆盖写方法的流程图;3 is a flowchart of another file overwriting method provided by an embodiment of the present invention;

图4为本发明实施例提供的一种文件覆盖写示意图;FIG. 4 is a schematic diagram of file overwriting according to an embodiment of the present invention;

图5为本发明实施例提供的一种文件覆盖写装置的结构示意图;5 is a schematic structural diagram of a file overwriting device according to an embodiment of the present invention;

图6为本发明实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. The components of the embodiments of the invention generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations.

因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。Thus, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

分布式文件系统(Distributed File System,DFS)通常是指文件系统管理的物理存储资源不一定直接连接在本地节点上,而是通过计算机网络与节点(可简单的理解为一台计算机)相连;或是若干不同的逻辑磁盘分区或卷标组合在一起而形成的完整的有层次的文件系统。例如,带目录树的分布式文件系统HDFS(Hadoop Distributed Filesystem,Hadoop分布式文件系统),该HDFS上的文件被水平切割成定长的数据块来存储;该类分布式文件系统可以存储用户上传的文件,也可以对用户提供相应的文件系统操作,例如,卷操作、目录操作、文件操作(创建文件、上传文件内容、读取文件、删除文件等)等。Distributed File System (DFS) usually means that the physical storage resources managed by the file system are not necessarily directly connected to the local node, but are connected to the node (which can be simply understood as a computer) through a computer network; or It is a complete hierarchical file system formed by combining several different logical disk partitions or volume labels. For example, a distributed file system HDFS (Hadoop Distributed Filesystem) with a directory tree, the files on the HDFS are horizontally cut into fixed-length data blocks for storage; this type of distributed file system can store user uploads It can also provide users with corresponding file system operations, such as volume operations, directory operations, and file operations (create files, upload file content, read files, delete files, etc.).

目前的分布式文件系统对文件的写入方式通常只支持追加写,不支持覆盖写。为了对分布式文件系统中的文件进行覆盖写,通常需要通过终端设备将待覆盖写文件从分布式文件系统中读取出来,然后在终端设备(相当于本地)中将待覆盖写文件与预设的覆盖写内容进行合并,再将合并后的文件写入分布式文件系统中,并将分布式文件系统中的待覆盖写文件对应的原文件删除。由于该方式需要从分布式文件系统中对文件进行多次读/写操作,导致读数据和写数据的数据量均较大,影响了覆盖写性能。The current distributed file system generally only supports append writing, but does not support overwriting. In order to overwrite the file in the distributed file system, it is usually necessary to read the file to be overwritten from the distributed file system through the terminal device, and then in the terminal device (equivalent to local), the file to be overwritten and the pre-written file need to be read out. The set overwrite content is merged, the merged file is written into the distributed file system, and the original file corresponding to the file to be overwritten in the distributed file system is deleted. Because this method needs to perform multiple read/write operations on the file from the distributed file system, the amount of data read and written is large, which affects the overwrite performance.

例如,分布式文件系统中的原文件为1GB,覆盖写内容为1MB,在对原文件进行覆盖写时,需要从分布式文件系统中将1GB的原文件读取出来,在终端设备上将1MB的覆盖写内容覆盖写到1GB的原文件中的对应位置上,然后将合并后的1GB文件写入分布式文件系统中,并删除分布式文件系统中的1GB原文件,该方式为了覆盖写1MB的覆盖写内容,需要读取1GB的文件和重写入1GB的文件,相当于读、写均放大了1000倍,导致读数据和写数据的数据量均较大,也可以理解为出现了读、写放大的问题。For example, the original file in the distributed file system is 1GB, and the overwritten content is 1MB. When overwriting the original file, the original file of 1GB needs to be read from the distributed file system, and the 1MB file needs to be read out on the terminal device. The overwritten content is overwritten to the corresponding position in the 1GB original file, and then the merged 1GB file is written into the distributed file system, and the 1GB original file in the distributed file system is deleted. This method is to overwrite 1MB The overwrite content of the 1GB file needs to be read and rewritten, which is equivalent to 1000 times of read and write, resulting in a large amount of data read and written, which can also be understood as the occurrence of read and write data. , Write enlargement problem.

基于上述问题,本发明实施例提供了一种文件覆盖写方法、装置和电子设备,该技术可以应用于各种分布式文件系统中对文件的覆盖写场景中。为了便于对本发明实施例进行理解,首先对本发明实施例所公开的一种文件覆盖写方法进行详细介绍,如图1所示,该方法包括如下步骤:Based on the above problems, embodiments of the present invention provide a file overwriting method, apparatus, and electronic device, and the technology can be applied to file overwriting scenarios in various distributed file systems. In order to facilitate the understanding of the embodiments of the present invention, a file overwriting method disclosed in the embodiments of the present invention is first introduced in detail. As shown in FIG. 1 , the method includes the following steps:

步骤S102,获取覆盖写指令;该覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置。Step S102, acquiring an overwriting instruction; the overwriting instruction at least includes: a file identifier of a target file to be overwritten, a storage location identifier of the overwriting content, and an overwriting location.

上述覆盖写指令可以是保存在预设的数据库或者存储系统中的数据,该数据通常具有指令属性;该覆盖写指令也可以是用户通过终端设备发送的指令,该终端设备可以是移动终端(例如,手机、平板电脑等),也可以是计算机。上述覆盖写指令中可以包含有需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,还可以包括其他内容,在此不再一一列举。The above-mentioned overwriting instruction may be data stored in a preset database or a storage system, and the data usually has an instruction attribute; the overwriting instruction may also be an instruction sent by a user through a terminal device, and the terminal device may be a mobile terminal (such as a mobile terminal). , mobile phone, tablet, etc.), or a computer. The above-mentioned overwriting instruction may include the file identifier of the target file to be overwritten, the storage location identifier of the overwriting content, and the overwriting location, and may also include other contents, which will not be listed one by one here.

在具体实现时,上述需要覆盖写的目标文件通常是保存在分布式文件系统中的,该目标文件的文件标识可以是目标文件的文件名称或者其他用于唯一标识文件的代号等;上述覆盖写内容可以理解为用户想要覆盖的内容,该覆盖写内容可以是用户预先上传至分布式文件系统中的,上述覆盖写内容的存储位置标识也即是覆盖写内容在分布式文件系统中的存储位置对应的文件标识,例如,用户上传覆盖写内容,服务器接收到该覆盖写内容后自动将该覆盖写内容作为临时文件写入分布式文件系统中,此时,覆盖写内容的存储位置标识为该临时文件的文件标识。上述覆盖写位置也可以理解为用户想要在目标文件中将覆盖写内容写入的位置,该覆盖写位置可以是目标文件中的某个位置,或者某段范围等。In the specific implementation, the above-mentioned target file that needs to be overwritten is usually stored in a distributed file system, and the file identifier of the target file can be the file name of the target file or other code names used to uniquely identify the file, etc.; the above-mentioned overwrite The content can be understood as the content that the user wants to overwrite. The overwritten content can be uploaded to the distributed file system in advance by the user. The storage location identifier of the overwritten content is also the storage of the overwritten content in the distributed file system. The file identifier corresponding to the location. For example, when the user uploads the overwritten content, the server automatically writes the overwritten content as a temporary file into the distributed file system after receiving the overwritten content. At this time, the storage location identifier of the overwritten content is The file ID of this temporary file. The above-mentioned overwriting position can also be understood as a position where the user wants to write the overwriting content in the target file, and the overwriting position may be a certain position in the target file, or a certain range.

步骤S104,根据上述覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。Step S104, according to the above-mentioned overwriting instruction, write the overwriting content to the overwriting position in the target file.

根据覆盖写指令中包含的目标文件的文件表示和覆盖写内容的存储位置标识,可以确定出目标文件以及覆盖写内容,例如,当目标文件和覆盖写内容保存在分布式文件系统中时,根据目标文件的文件标识和覆盖写内容的存储位置标识,从分布式文件系统中确定出该目标文件和覆盖写内容。在对目标文件进行覆盖写时,首先在目标文件中查询覆盖写位置,然后在查询到的覆盖写位置上写入覆盖写内容。According to the file representation of the target file contained in the overwrite instruction and the storage location identifier of the overwritten content, the target file and the overwritten content can be determined. For example, when the target file and the overwritten content are stored in the distributed file system, according to The file identifier of the target file and the storage location identifier of the overwritten content are determined from the distributed file system. When overwriting the target file, first query the overwriting position in the target file, and then write the overwriting content at the inquired overwriting position.

在具体实现时,完成上述覆盖写指令指示的覆盖写操作后,可以删除该覆盖写指令,以及覆盖写指令中的存储位置标识处的覆盖写内容,从而完成对目标文件的覆盖写。In specific implementation, after the overwrite operation indicated by the overwrite instruction is completed, the overwrite instruction and the overwrite content at the storage location identifier in the overwrite instruction can be deleted, thereby completing the overwrite of the target file.

本发明实施例提供的一种文件覆盖写方法,首先获取覆盖写指令;该覆盖写指令至少包括需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;然后根据覆盖写指令,将该覆盖写内容写入目标文件中的覆盖写位置上。该方式基于覆盖写指令中包含的数据,在需要进行覆盖写的目标文件的存储位置上,将覆盖写内容写入目标文件中,无需将目标文件从存储位置中读取出来后再进行覆盖写,从而减少了读数据和写数据的数据量,提升了覆盖写性能。In a file overwriting method provided by an embodiment of the present invention, an overwriting instruction is first obtained; the overwriting instruction at least includes a file identifier of a target file to be overwritten, a storage location identifier of the overwriting content, and an overwriting location; and then according to The overwrite instruction writes the overwrite content to the overwrite position in the target file. This method is based on the data contained in the overwrite instruction. In the storage location of the target file that needs to be overwritten, the overwrite content is written into the target file, and there is no need to read the target file from the storage location and then overwrite. , thereby reducing the amount of data read and written, and improving the overwrite performance.

本发明实施例还提供了另一种文件覆盖写方法,该方法在上述实施例方法的基础上实现;该方法重点描述根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上的具体过程(通过下述步骤S204-S206实现);如图2所示,该方法包括如下步骤:The embodiment of the present invention also provides another method for overwriting a file, which is implemented on the basis of the method in the above-mentioned embodiment; the method focuses on writing the overwriting content to the overwriting position in the target file according to the overwriting instruction. The specific process (implemented through the following steps S204-S206); as shown in Figure 2, the method includes the following steps:

步骤S202,获取覆盖写指令;该覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;其中,该覆盖写位置包括:覆盖写起始地址和覆盖写长度。Step S202, obtaining an overwriting instruction; the overwriting instruction at least includes: the file identifier of the target file to be overwritten, the storage location identifier of the overwriting content, and the overwriting position; wherein, the overwriting position includes: the overwriting start address and overwrite length.

上述覆盖写起始地址可以是用户输入的、目标文件中的地址。由于分布式文件系统中的文件,通常是被水平分割成多个定长的数据块来存储的,因而,该覆盖写起始地址可以是目标文件对应的某个数据块上的某个位置。上述覆盖写长度可以是用户输入的长度值,该长度值与用户写入的覆盖写内容的长度相同;也可以是根据用户输入的覆盖写内容的长度计算得到的长度值。在具体实现时,用户上传覆盖写内容时,系统会将该覆盖写内容保存在分布式文件系统中的指定位置(相当于上述存储位置)上,以供后续在分布式文件系统中对目标文件进行覆盖写时使用。The above-mentioned overwriting start address may be the address in the target file input by the user. Since a file in a distributed file system is usually divided horizontally into multiple fixed-length data blocks for storage, the overwriting start address may be a certain position on a certain data block corresponding to the target file. The above-mentioned overwriting length may be a length value input by the user, which is the same as the length of the overwriting content written by the user, or a length value calculated according to the length of the overwriting content input by the user. In the specific implementation, when the user uploads the overwritten content, the system will save the overwritten content in the specified location (equivalent to the above-mentioned storage location) in the distributed file system, so that the target file can be subsequently updated in the distributed file system. Used when overwriting.

步骤S204,根据目标文件的文件标识和覆盖写内容的存储位置标识,确定出目标文件和覆盖写内容。Step S204: Determine the target file and the overwritten content according to the file identifier of the target file and the storage location identifier of the overwritten content.

在具体实现时,由于上述覆盖写内容已预先保存在分布式文件系统的存储位置上,因而可根据覆盖写指令中的目标文件的文件标识和覆盖写内容的存储位置标识,从分布式文件系统中确定出目标文件和覆盖写内容。In the specific implementation, since the above-mentioned overwriting content has been pre-saved in the storage location of the distributed file system, the file identifier of the target file in the overwriting instruction and the storage location identifier of the overwriting content can be stored in the distributed file system from the distributed file system. Determine the target file and overwrite the content.

步骤S206,从目标文件中的覆盖写起始地址开始,将目标文件中覆盖写长度的内容替换为覆盖写内容。Step S206, starting from the start address of overwriting in the target file, replace the content of the overwriting length in the target file with the overwriting content.

根据覆盖写指令中包含的覆盖写起始地址,从目标文件中确定出该覆盖写起始地址对应的位置,从该位置开始将覆盖写内容写入目标文件中,覆盖写内容在目标文件中写入的长度与覆盖写指令中指示的覆盖写长度相同,从而可以根据用户需求,在分布式文件系统中对目标文件进行覆盖写,避免了在将目标文件读取出来,在本地进行覆盖写的读、写数据放大问题。According to the overwrite start address contained in the overwrite instruction, the position corresponding to the overwrite start address is determined from the target file, and the overwrite content is written into the target file from this position, and the overwrite content is in the target file. The write length is the same as the overwrite length indicated in the overwrite instruction, so that the target file can be overwritten in the distributed file system according to user needs, avoiding the need to read the target file and overwrite locally. read and write data amplification problems.

步骤S208,删除上述覆盖写指令,以及存储位置标识对应的文件中的覆盖写内容,以完成对目标文件的覆盖写。Step S208, delete the above-mentioned overwriting instruction and the overwriting content in the file corresponding to the storage location identifier, so as to complete the overwriting to the target file.

当目标文件中的覆盖写长度的内容替换为覆盖写内容后,删除本次执行的覆盖写指令,同时删除存储位置标识对应的文件中的覆盖写内容,从而完成本次覆盖写指令指示的、对目标文件的覆盖写。When the content of the overwrite length in the target file is replaced with the overwrite content, the overwrite instruction executed this time is deleted, and the overwrite content in the file corresponding to the storage location identifier is deleted, so as to complete the overwrite instruction indicated by the current overwrite instruction, Overwrite to the target file.

上述文件覆盖写方法,首先获取覆盖写指令,进而根据覆盖写指令中指示的目标文件的文件标识和覆盖写内容的存储位置标识,确定出目标文件和覆盖写内容;然后从目标文件中的覆盖写起始地址开始,将目标文件中覆盖写长度的内容替换为覆盖写内容;再删除上述覆盖写指令,以及存储位置标识对应的文件中的覆盖写内容,以完成对目标文件的覆盖写。该方式根据覆盖写指令,在需要覆盖写的目标文件的存储位置上将覆盖写内容覆盖到目标文件中,无需将目标文件全部读出来,在本地与覆盖写内容中合并后再写回目标文件的存储位置,从而极大地提升了覆盖写性能,也提升了覆盖写效率。The above-mentioned file overwriting method, first obtains an overwriting instruction, and then determines the target file and overwriting content according to the file identifier of the target file indicated in the overwriting instruction and the storage location identifier of the overwriting content; then from the overwriting in the target file Starting from the writing start address, replace the content of the overwrite length in the target file with the overwrite content; then delete the above overwrite instruction and the overwrite content in the file corresponding to the storage location identifier to complete the overwrite of the target file. In this method, according to the overwrite instruction, the overwrite content is overwritten into the target file at the storage location of the target file that needs to be overwritten. It is not necessary to read out all the target files, merge the local and overwrite content, and then write back the target file. This greatly improves the overwrite performance and the overwrite efficiency.

本发明实施例还提供了另一种文件覆盖写方法,该方法在上述实施例方法的基础上实现;该方法重点描述覆盖写指令保存在指定数据库中、需要进行覆盖写的目标文件保存在预设的分布式文件系统中时,获取覆盖写指令的具体过程(通过下述步骤S310-S312实现);如图3所示,该方法包括如下步骤:The embodiment of the present invention also provides another method for overwriting a file, which is implemented on the basis of the method in the above-mentioned embodiment; the method focuses on describing that the overwriting instruction is stored in a specified database, and the target file that needs to be overwritten is stored in a preset In the set distributed file system, the specific process of obtaining the overwrite instruction (implemented by the following steps S310-S312); as shown in FIG. 3, the method includes the following steps:

步骤S302,如果接收到用户发送的覆盖写请求,从该覆盖写请求中提取覆盖写内容、覆盖写位置和需要进行覆盖的目标文件的文件标识。Step S302, if an overwrite request sent by the user is received, extract the overwrite content, the overwrite location and the file identifier of the target file to be overwritten from the overwrite request.

在具体实现时,如果用户想要对分布式文件系统中保存的某一文件进行覆盖写,用户可以通过终端设备发送覆盖写请求,该覆盖写请求中通常携带有用户输入的覆盖写内容、覆盖写位置和需要进行覆盖写的目标文件的文件标识(也可以是文件名称)。In the specific implementation, if the user wants to overwrite a certain file saved in the distributed file system, the user can send an overwrite request through the terminal device, and the overwrite request usually carries the overwrite content input by the user, the overwrite The write location and the file identifier (or file name) of the target file to be overwritten.

步骤S304,将上述覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识。Step S304: Write the above-mentioned overwriting content into the distributed file system to obtain a storage location identifier of the overwriting content.

当提取到覆盖写内容时,将该覆盖写内容以临时文件的形式写入分布式文件系统中,得到覆盖写内容的存储位置标识,该存储位置标识也即是分布式文件系统中存储覆盖写内容的临时文件的文件标识,该文件标识可以是文件名称。When the overwritten content is extracted, the overwritten content is written into the distributed file system in the form of a temporary file, and the storage location identifier of the overwritten content is obtained, and the storage location identifier is also the storage location identifier in the distributed file system. The file ID of the temporary file for the content, which can be a file name.

在一些实施例中,上述分布式文件系统中存储有目标文件的覆盖写版本号;将覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识之后,分布式文件系统会返回保存的目标文件的覆盖写版本;然后系统接收分布式文件系统返回的目标文件的覆盖写版本号,并将该覆盖写版本号写入覆盖写指令中。In some embodiments, the overwrite version number of the target file is stored in the above-mentioned distributed file system; after the overwrite content is written into the distributed file system, and the storage location identifier of the overwrite content is obtained, the distributed file system will return Save the overwrite version of the target file; then the system receives the overwrite version number of the target file returned by the distributed file system, and writes the overwrite version number into the overwrite instruction.

步骤S306,拼接目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,得到目标文件的覆盖写指令。Step S306, splicing the file identifier of the target file, the storage location identifier of the overwriting content, and the overwriting location to obtain an overwriting instruction of the target file.

将目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置进行拼接,生成目标文件的覆盖写指令,该覆盖写指令也可以称为覆盖写记录。在一些实施例中,如果接收到分布式文件系统返回的目标文件的覆盖写版本号,即可将目标文件的文件标识、覆盖写内容的存储位置标识、覆盖写位置和目标文件的覆盖写版本号进行拼接,生成覆盖写指令。The file identifier of the target file, the storage location identifier of the overwrite content, and the overwrite location are spliced together to generate an overwrite instruction of the target file, and the overwrite instruction may also be called an overwrite record. In some embodiments, if the overwrite version number of the target file returned by the distributed file system is received, the file identifier of the target file, the storage location identifier of the overwrite content, the overwrite location and the overwrite version of the target file can be stored Numbers are spliced to generate an overwrite instruction.

步骤S308,将上述覆盖写指令保存至指定数据库中。Step S308, save the above-mentioned overwriting instruction into a designated database.

用户发送的每条覆盖写请求,均可对应一条覆盖写指令。在具体实现时,可能会接收到多个用户发送的多个覆盖写请求,也即是得到多条覆盖写指令,为了后续有序处理覆盖写指令,可以按照预设规则将覆盖写指令保存至指定数据库中,该预设规则可以是按照覆盖写指令的生成顺序、按照接收覆盖写请求的接收顺序等。Each overwrite request sent by the user can correspond to an overwrite instruction. During the specific implementation, multiple overwrite requests sent by multiple users may be received, that is, multiple overwrite instructions are obtained. In order to process the overwrite instructions in an orderly manner, the overwrite instructions can be saved to the In the specified database, the preset rule may be according to the generation sequence of the overwrite instructions, according to the reception sequence of the overwrite requests received, and the like.

步骤S310,实时监控指定数据库中是否存在覆盖写指令。Step S310, monitor in real time whether there is an overwrite instruction in the specified database.

通过预设服务,可以不停的扫描指定数据库中的数据,以达到实时监控指定数据库中的数据的目的,从而在指定数据库中包含有覆盖写指令时,可逐条处理指定数据库中的覆盖写指令。Through the preset service, the data in the specified database can be continuously scanned to achieve the purpose of monitoring the data in the specified database in real time, so that when the specified database contains overwrite instructions, the overwrite instructions in the specified database can be processed one by one. .

步骤S312;如果存在,获取上述覆盖写指令。Step S312; if there is, obtain the above-mentioned overwriting instruction.

步骤S314,根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。Step S314, according to the overwriting instruction, write the overwriting content to the overwriting position in the target file.

如果指定数据库中存在覆盖写指令,将逐条读取覆盖写指令,针对每条覆盖写指令,均执行步骤S314,也即是针对每条覆盖写指令进行如下处理:根据覆盖写指令中包含的覆盖写内容的存储位置标识,从分布式文件系统中读取覆盖写内容,调用分布式文件系统的预设接口,将该覆盖写内容覆盖写至目标文件的覆盖写位置上,删除本次覆盖写指令和存储位置标识对应的存储位置处的覆盖写内容(也可以理解为删除保存覆盖写内容的临时文件)。If there is an overwrite instruction in the specified database, the overwrite instruction will be read one by one, and step S314 is executed for each overwrite instruction, that is, the following processing is performed for each overwrite instruction: according to the overwrite instruction included in the overwrite instruction The storage location identifier of the write content, read the overwrite content from the distributed file system, call the preset interface of the distributed file system, overwrite the overwrite content to the overwrite location of the target file, and delete the overwrite The instruction and the storage location identify the overwritten content at the corresponding storage location (it can also be understood as deleting the temporary file storing the overwritten content).

在具体实现时,如果覆盖写指令中包含有目标文件的覆盖写版本号,在根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上之后,将分布式文件系统中的覆盖写版本号,更新为覆盖写指令中的覆盖写版本号与一的加和。也可以理解为在覆盖写内容写入目标文件后,分布式目标文件中保存的目标文件的覆盖写版本号加一,从而可以保证针对同一个文件的任何一次覆盖写,均可用唯一的、严格递增的覆盖写版本号来标识,同时可以根据该覆盖写版本号确定目标文件的覆盖写次数,便于用户后续使用和查询。In specific implementation, if the overwrite instruction contains the overwrite version number of the target file, after the overwrite content is written to the overwrite position in the target file according to the overwrite instruction, the overwrite in the distributed file system will be overwritten. The write version number is updated to the sum of the overwrite version number and one in the overwrite instruction. It can also be understood that after the overwriting content is written to the target file, the overwriting version number of the target file saved in the distributed target file is incremented by one, thereby ensuring that any overwriting to the same file can be written with a unique and strict value. It is identified by the incremental overwriting version number, and the number of overwriting and writing of the target file can be determined according to the overwriting version number, which is convenient for users to use and query later.

在具体实现时,由于分布式文件系统中的文件均是多副本(例如,3副本)存储的,因此上述目标文件包括多个副本文件,也即是分布式文件系统中保存有目标文件的多个副本文件;在对目标文件进行覆盖写时,需要针对目标文件的每个副本文件,根据覆盖写指令,将覆盖写内容写入当前副本文件中的覆盖写位置上;也可以理解为将覆盖写内容覆盖写到目标文件对应的所有副本文件中,从而保证副本之间数据的一致性。During specific implementation, since the files in the distributed file system are stored in multiple copies (for example, three copies), the above-mentioned target file includes multiple copy files, that is, the multiple copies of the target file stored in the distributed file system are A copy file; when overwriting the target file, it is necessary to write the overwriting content to the overwriting position in the current copy file according to the overwriting instruction for each copy file of the target file; it can also be understood as the overwriting The write content is overwritten to all replica files corresponding to the target file, thereby ensuring data consistency between replicas.

为了确保目标文件的每个副本文件均完成覆盖写,在具体实现时,需要针对目标文件的每个副本文件,判断覆盖写内容是否成功写入当前副本文件中的覆盖写位置上;如果未成功写入,自动修复当前副本文件,并将覆盖写内容重新写入当前副本文件中,直到当前副本文件覆盖写成功。In order to ensure that each copy file of the target file is overwritten, in the specific implementation, it is necessary to judge whether the overwrite content is successfully written to the overwrite position in the current copy file for each copy file of the target file; Write, automatically repair the current copy file, and rewrite the overwritten content to the current copy file until the current copy file is successfully overwritten.

例如,分布式文件系统中包含有3个目标文件的副本文件,在对目标文件进行覆盖写时,同时对3个副本文件进行并发覆盖写,以使所有的副本文件均覆盖写成功。如果某个副本文件由于磁盘或机器故障损坏,导致这个副本文件覆盖写失败,系统会监控到这种情况,自动将这个磁盘或机器从集群中剔除,并自动根据剩下的2副本文件恢复出第3个副本文件,然后继续将覆盖写内容覆盖写到这个恢复出来的副本文件中,直到3个副本文件均覆盖写成功。For example, a distributed file system contains three copy files of the target file. When overwriting the target file, concurrently overwriting the three copy files is performed, so that all copy files are successfully overwritten. If a copy file is damaged due to a disk or machine failure, causing the copy file to fail to be overwritten, the system will monitor this situation, automatically remove the disk or machine from the cluster, and automatically restore the file based on the remaining two copy files. The third copy file, and then continue to overwrite the overwritten content to the recovered copy file, until all three copy files are overwritten successfully.

为了便于对本发明实施例进行理解,图4给出了一种文件覆盖写示意图;图4中的存储网关用于接收用户发送的覆盖写请求,该存储网关是基于分布式文件系统之上的分布式文件服务,它可以HTTP(Hyper Text Transfer Protocol,超文本传输协议)接口的形式存在,可为多个用户提供文件存储服务,也可以提供多用户数据隔离、权限校验等功能;存储网关接收到用户发送的覆盖写请求后,提取该覆盖写请求中的覆盖写内容、需要覆盖写的目标文件的文件标识和覆盖写位置,将该覆盖写内容当作临时文件写入分布式文件系统中,该分布式文件系统系统接收到临时文件后,会向存储网关返回覆盖写版本号,然后该存储网关可以将目标文件的文件标识、覆盖写位置、覆盖写内容的存储位置标识和覆盖写版本号进行拼接,得到覆盖写指令,并将该覆盖写指令保存至指定数据库中。In order to facilitate the understanding of the embodiments of the present invention, FIG. 4 shows a schematic diagram of file overwriting; the storage gateway in FIG. 4 is used to receive overwriting requests sent by users, and the storage gateway is based on a distributed file system. It can exist in the form of HTTP (Hyper Text Transfer Protocol) interface, and can provide file storage services for multiple users, as well as multi-user data isolation, permission verification and other functions; the storage gateway receives After the overwrite request sent by the user, extract the overwrite content in the overwrite request, the file identifier and overwrite location of the target file to be overwritten, and write the overwrite content as a temporary file into the distributed file system , after the distributed file system system receives the temporary file, it will return the overwrite version number to the storage gateway, and then the storage gateway can record the file identifier of the target file, the overwrite location, the storage location identifier of the overwrite content, and the overwrite version. Numbers are spliced to obtain an overwrite instruction, and the overwrite instruction is saved in the specified database.

图4中的指令读取服务可以不停扫描指定数据库中的覆盖写指令,并逐条读取指定数据库中的覆盖写指令,针对每条覆盖写指令执行如下操作:读取覆盖写指令指示的临时文件中的覆盖写内容,调用分布式文件系统的预设接口,将覆盖写内容覆盖写到目标文件的多个副本文件中,如果某个副本文件覆盖写失败,则会一直重试覆盖写,直到所有副本文件均在分布式文件系统中覆盖写成功,然后删除临时文件和本条覆盖写指令。The instruction reading service in FIG. 4 can continuously scan the overwrite instructions in the specified database, and read the overwrite instructions in the specified database one by one, and perform the following operations for each overwrite instruction: read the temporary instruction indicated by the overwrite instruction. Overwrite the content in the file, call the preset interface of the distributed file system, and write the overwrite content to multiple copies of the target file. If the overwrite of a copy file fails, the overwrite will be retried all the time. Until all copy files are successfully overwritten in the distributed file system, then delete the temporary file and this overwrite instruction.

在具体实现时,用户会根据自身需求从分布式文件系统中读取文件,对文件的读取操作可以通过下述步骤10-13实现:In the specific implementation, users will read files from the distributed file system according to their own needs, and the reading operation of files can be implemented through the following steps 10-13:

步骤10,接收用户发送的目标文件的读取请求。用户可以通过终端设备发送对分布式文件系统中的任意文件的读取请求。Step 10: Receive a read request of the target file sent by the user. A user can send a read request to any file in the distributed file system through a terminal device.

步骤11,判断指定数据库中是否存在目标文件的覆盖写指令;如果存在,执行步骤12;如果不存在,执行步骤13。Step 11, determine whether there is an overwrite instruction of the target file in the designated database; if it exists, go to step 12; if not, go to step 13.

步骤12,根据目标文件的覆盖写指令,从分布式文件系统中读取覆盖写指令对应的覆盖写内容和目标文件,将覆盖写内容和目标文件进行合并,将合并后的目标文件返回给用户。Step 12, according to the overwriting instruction of the target file, read the overwriting content and the target file corresponding to the overwriting instruction from the distributed file system, merge the overwriting content and the target file, and return the merged target file to the user .

步骤13,从分布式文件系统中读取目标文件,将读取的目标文件返回给用户。Step 13: Read the target file from the distributed file system, and return the read target file to the user.

上述目标文件的读取方式可以保证用户可以读取到与覆盖写内容合并后的目标文件,从而确保用户能够读取到最新的文件,同时也避免了数据的丢失。The above method of reading the target file can ensure that the user can read the target file merged with the overwritten content, thereby ensuring that the user can read the latest file and avoiding data loss.

上述文件覆盖写方法,如果接收到用户发送的覆盖写请求,从该覆盖写请求中提取覆盖写内容、覆盖写位置和需要进行覆盖的目标文件的文件标识;进而将覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识;再拼接目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,得到目标文件的覆盖写指令,并将该覆盖写指令保存至指定数据库中;实时监控和获取指定数据库中的覆盖写指令,根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。该方式相对于读取原文件、本地合并覆盖内容、然后再上传整个文件并删除原文件的方法,本发明没有读、写放大问题,减少了读数据和写数据的数据量,进一步提升了文件覆盖写的性能。In the above-mentioned file overwriting method, if an overwriting request sent by a user is received, the overwriting content, the overwriting location and the file identifier of the target file to be overwritten are extracted from the overwriting request; and then the overwriting content is written into a distributed In the file system, the storage location identifier of the overwritten content is obtained; then the file identifier of the target file, the storage location identifier of the overwritten content and the overwritten location are spliced to obtain the overwritten instruction of the target file, and the overwritten instruction is saved to the specified location. In the database; real-time monitoring and acquisition of the overwrite instruction in the specified database, according to the overwrite instruction, the overwrite content is written to the overwrite position in the target file. Compared with the method of reading the original file, merging the overwritten content locally, uploading the entire file and deleting the original file, the present invention does not have the problem of reading and writing amplification, reduces the amount of data read and written, and further improves the file size. Overwrite performance.

对应于上述方法实施例,本发明实施例提供了一种文件覆盖写装置,如图5所示,该装置包括:Corresponding to the above method embodiments, an embodiment of the present invention provides a file overwriting device, as shown in FIG. 5 , the device includes:

指令获取模块50,用于获取覆盖写指令;其中,该覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置。The instruction acquisition module 50 is configured to acquire an overwrite instruction; wherein, the overwrite instruction at least includes: a file identifier of a target file to be overwritten, a storage location identifier of the overwritten content, and an overwritten location.

覆盖写模块51,用于根据覆盖写指令,将覆盖写内容写入目标文件中的覆盖写位置上。The overwriting module 51 is configured to write the overwriting content to the overwriting position in the target file according to the overwriting instruction.

上述文件覆盖写装置,首先获取覆盖写指令;该覆盖写指令至少包括需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;然后根据覆盖写指令,将该覆盖写内容写入目标文件中的覆盖写位置上。该方式基于覆盖写指令中包含的数据,在需要进行覆盖写的目标文件的存储位置上,将覆盖写内容写入目标文件中,无需将目标文件从存储位置中读取出来后再进行覆盖写,从而减少了读数据和写数据的数据量,提升了覆盖写性能。The above-mentioned file overwriting device, first obtains an overwriting instruction; the overwriting instruction includes at least the file identifier of the target file that needs to be overwritten, the storage location identifier of the overwriting content and the overwriting position; then according to the overwriting instruction, the overwriting instruction Writes are written to the overwrite location in the target file. This method is based on the data contained in the overwrite instruction. In the storage location of the target file that needs to be overwritten, the overwrite content is written into the target file, and there is no need to read the target file from the storage location and then overwrite. , thereby reducing the amount of data read and written, and improving the overwrite performance.

具体地,上述覆盖写位置包括:覆盖写起始地址和覆盖写长度;其中,覆盖写长度与覆盖写内容的长度相同;上述覆盖写模块51,用于:根据目标文件的文件标识和覆盖写内容的存储位置标识,确定出目标文件和覆盖写内容;从目标文件中的覆盖写起始地址开始,将目标文件中覆盖写长度的内容替换为覆盖写内容。Specifically, the above-mentioned overwriting position includes: an overwriting start address and an overwriting length; wherein, the overwriting length is the same as the length of the overwriting content; the overwriting module 51 is used for: according to the file identification of the target file and the overwriting The storage location identifier of the content determines the target file and the overwriting content; starting from the overwriting start address in the target file, replace the overwriting length content in the target file with the overwriting content.

进一步地,上述覆盖写指令保存在指定数据库中;上述指令获取模块50,用于:判断指定数据库中是否存在覆盖写指令;如果存在,获取该覆盖写指令。Further, the above-mentioned overwriting instruction is stored in a designated database; the above-mentioned instruction acquisition module 50 is used for: judging whether there is an overwriting instruction in the designated database; if there is, acquiring the overwriting instruction.

进一步地,上述需要进行覆盖写的目标文件保存在预设的分布式文件系统中;上述装置还包括覆盖写指令保存模块,用于:如果接收到用户发送的覆盖写请求,从覆盖写请求中提取覆盖写内容、覆盖写位置和需要进行覆盖的目标文件的文件标识;将覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识;拼接目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,得到目标文件的覆盖写指令;将覆盖写指令保存至指定数据库中。Further, the above-mentioned target file that needs to be overwritten is stored in a preset distributed file system; the above-mentioned device also includes an overwrite instruction storage module, used for: if an overwrite request sent by a user is received, from the overwrite request Extract the overwrite content, overwrite location and the file identifier of the target file to be overwritten; write the overwrite content into the distributed file system to obtain the storage location identifier of the overwrite content; splicing the file identifier and overwrite content of the target file The storage location identifier and overwrite location of the target file are obtained, and the overwrite instruction of the target file is obtained; the overwrite instruction is saved to the specified database.

进一步地,上述装置还包括信息删除模块,用于:删除覆盖写指令,以及存储位置标识对应的文件中的覆盖写内容。Further, the above-mentioned apparatus further includes an information deletion module, which is used for: deleting the overwriting instruction and overwriting content in the file corresponding to the storage location identifier.

在具体实现时,上述装置还包括文件读取模块,用于:接收用户发送的目标文件的读取请求;判断指定数据库中是否存在目标文件的覆盖写指令;如果存在,根据目标文件的覆盖写指令,从分布式文件系统中读取覆盖写指令对应的覆盖写内容和目标文件,将覆盖写内容与目标文件进行合并,将合并后的目标文件返回给用户;如果不存在,从分布式文件系统中读取目标文件,将读取的目标文件返回给用户。When specifically implemented, the above-mentioned device also includes a file reading module, which is used for: receiving a reading request of a target file sent by a user; judging whether there is an overwriting instruction of the target file in the specified database; if there is, according to the overwriting instruction of the target file instruction, read the overwrite content and target file corresponding to the overwrite instruction from the distributed file system, merge the overwrite content with the target file, and return the merged target file to the user; if it does not exist, from the distributed file The system reads the target file and returns the read target file to the user.

进一步地,上述分布式文件系统中存储有目标文件的覆盖写版本号;上述覆盖写指令保存模块,还用于:将覆盖写内容写入分布式文件系统中,得到覆盖写内容的存储位置标识之后,接收分布式文件系统返回的目标文件的覆盖写版本号;将覆盖写版本号写入覆盖写指令中。Further, the overwriting version number of the target file is stored in the above-mentioned distributed file system; the above-mentioned overwriting instruction preservation module is also used for: writing the overwriting content into the distributed file system, and obtaining the storage location identifier of the overwriting content After that, receive the overwrite version number of the target file returned by the distributed file system; write the overwrite version number into the overwrite instruction.

具体地,上述装置还包括版本号更新模块,用于:将分布式文件系统中的覆盖写版本号,更新为覆盖写指令中的覆盖写版本号与一的加和。Specifically, the above apparatus further includes a version number update module, configured to: update the overwrite version number in the distributed file system to the sum of the overwrite version number and one in the overwrite instruction.

在具体实现时,上述目标文件包括多个副本文件;上述覆盖写模块51,用于:针对目标文件的每个副本文件,根据覆盖写指令,将覆盖写内容写入当前副本文件中的覆盖写位置上。When specifically implemented, the above-mentioned target file includes a plurality of duplicate files; the above-mentioned overwriting module 51 is used for: for each duplicate file of the target file, according to the overwriting instruction, the overwriting content is written into the overwriting in the current duplicate file. position.

进一步地,上述装置还包括覆盖写监控模块,用于:针对目标文件的每个副本文件,判断覆盖写内容是否成功写入当前副本文件中的覆盖写位置上;如果未成功写入,自动修复当前副本文件,并将覆盖写内容重新写入当前副本文件中,直到当前副本文件覆盖写成功。Further, the above-mentioned device also includes an overwriting monitoring module, which is used for: for each copy file of the target file, determine whether the overwriting content is successfully written in the overwriting position in the current copy file; if it is not successfully written, it is automatically repaired The current copy file, and rewrite the overwritten content to the current copy file until the current copy file is successfully overwritten.

本发明实施例所提供的文件覆盖写装置,其实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。The implementation principle and the technical effect of the file overwriting device provided by the embodiments of the present invention are the same as those of the foregoing method embodiments. For brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments. .

本发明实施例还提供了一种电子设备,参见图6所示,该电子设备包括处理器101和存储器100,该存储器100存储有能够被处理器101执行的机器可执行指令,该处理器101执行机器可执行指令以实现上述文件覆盖写方法。An embodiment of the present invention further provides an electronic device, as shown in FIG. 6 , the electronic device includes a processor 101 and a memory 100, where the memory 100 stores machine-executable instructions that can be executed by the processor 101, and the processor 101 Machine-executable instructions are executed to implement the file overwriting method described above.

进一步地,图6所示的电子设备还包括总线102和通信接口103,处理器101、通信接口103和存储器100通过总线102连接。Further, the electronic device shown in FIG. 6 further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected through the bus 102 .

其中,存储器100可能包含高速随机存取存储器(RAM,RandomAccessMemory),也可能还包括非不稳定的存储器(non-volatilememory),例如至少一个磁盘存储器。通过至少一个通信接口103(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。总线102可以是ISA总线、PCI总线或EISA总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图6中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The memory 100 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is implemented through at least one communication interface 103 (which may be wired or wireless), which may use the Internet, a wide area network, a local network, a metropolitan area network, and the like. The bus 102 may be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one bidirectional arrow is shown in FIG. 6, but it does not mean that there is only one bus or one type of bus.

处理器101可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器101中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器101可以是通用处理器,包括中央处理器(CentralProcessingUnit,简称CPU)、网络处理器(NetworkProcessor,简称NP)等;还可以是数字信号处理器(Digital SignalProcessing,简称DSP)、专用集成电路(Application Specific Integrated Circuit,简称ASIC)、现成可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器100,处理器101读取存储器100中的信息,结合其硬件完成前述实施例的方法的步骤。The processor 101 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above-mentioned method may be completed by an integrated logic circuit of hardware in the processor 101 or an instruction in the form of software. The above-mentioned processor 101 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (NetworkProcessor, NP for short), etc. Circuit (Application Specific Integrated Circuit, ASIC for short), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. Various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention can be implemented or executed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in conjunction with the embodiments of the present invention may be directly embodied as executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the methods in the foregoing embodiments in combination with its hardware.

本发明实施例还提供了一种机器可读存储介质,该机器可读存储介质存储有机器可执行指令,该机器可执行指令在被处理器调用和执行时,该机器可执行指令促使处理器实现上述文件覆盖写方法,具体实现可参见方法实施例,在此不再赘述。Embodiments of the present invention further provide a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to For the implementation of the above-mentioned file overwriting method, the specific implementation can be found in the method embodiment, which will not be repeated here.

本发明实施例所提供的文件覆盖写方法、装置和电子设备的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行前面方法实施例中所述的方法,具体实现可参见方法实施例,在此不再赘述。The file overwriting method, apparatus, and computer program product of an electronic device provided by the embodiments of the present invention include a computer-readable storage medium storing program codes, and the instructions included in the program codes can be used to execute the methods described in the foregoing method embodiments. The specific implementation can refer to the method embodiment, which is not repeated here.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,电子设备,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as independent products, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, an electronic device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present invention, and are used to illustrate the technical solutions of the present invention, but not to limit them. The protection scope of the present invention is not limited thereto, although referring to the foregoing The embodiment has been described in detail the present invention, those of ordinary skill in the art should understand: any person skilled in the art who is familiar with the technical field within the technical scope disclosed by the present invention can still modify the technical solutions described in the foregoing embodiments. Or can easily think of changes, or equivalently replace some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be covered in the present invention. within the scope of protection. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims (12)

1.一种文件覆盖写方法,其特征在于,所述方法包括:1. a file overwriting method, characterized in that the method comprises: 获取覆盖写指令;其中,所述覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;Obtain an overwrite instruction; wherein, the overwrite instruction includes at least: a file identifier of a target file that needs to be overwritten, a storage location identifier of the overwritten content, and an overwritten location; 根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上。According to the overwriting instruction, the overwriting content is written to the overwriting position in the target file. 2.根据权利要求1所述的方法,其特征在于,所述覆盖写位置包括:覆盖写起始地址和覆盖写长度;其中,所述覆盖写长度与所述覆盖写内容的长度相同;2. The method according to claim 1, wherein the overwriting position comprises: an overwriting start address and an overwriting length; wherein, the overwriting length is the same as the length of the overwriting content; 所述根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上的步骤,包括:The step of writing the overwriting content to the overwriting position in the target file according to the overwriting instruction includes: 根据所述目标文件的文件标识和所述覆盖写内容的存储位置标识,确定出所述目标文件和所述覆盖写内容;Determine the target file and the overwritten content according to the file identifier of the target file and the storage location identifier of the overwritten content; 从所述目标文件中的所述覆盖写起始地址开始,将所述目标文件中所述覆盖写长度的内容替换为所述覆盖写内容。Starting from the overwriting start address in the target file, the content of the overwriting length in the target file is replaced with the overwriting content. 3.根据权利要求1所述的方法,其特征在于,所述覆盖写指令保存在指定数据库中;所述获取覆盖写指令的步骤,包括:3. The method according to claim 1, wherein the overwriting instruction is stored in a designated database; the step of obtaining the overwriting instruction comprises: 判断所述指定数据库中是否存在所述覆盖写指令;Judging whether the overwrite instruction exists in the specified database; 如果存在,获取所述覆盖写指令。If it exists, get the overwrite instruction. 4.根据权利要求3所述的方法,其特征在于,所述需要进行覆盖写的目标文件保存在预设的分布式文件系统中;所述指定数据库中的所述覆盖写指令通过下述方式获取:4. The method according to claim 3, wherein the target file that needs to be overwritten is stored in a preset distributed file system; the overwritten instruction in the designated database is in the following manner Obtain: 如果接收到用户发送的覆盖写请求,从所述覆盖写请求中提取覆盖写内容、覆盖写位置和需要进行覆盖的目标文件的文件标识;If an overwrite request sent by the user is received, extract the overwrite content, the overwrite location and the file identifier of the target file to be overwritten from the overwrite request; 将所述覆盖写内容写入所述分布式文件系统中,得到所述覆盖写内容的存储位置标识;Writing the overwriting content into the distributed file system to obtain a storage location identifier of the overwriting content; 拼接所述目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置,得到所述目标文件的覆盖写指令;Splicing the file identifier of the target file, the storage location identifier of the overwriting content and the overwriting position, to obtain the overwriting instruction of the target file; 将所述覆盖写指令保存至所述指定数据库中。The overwrite instruction is stored in the designated database. 5.根据权利要求1所述的方法,其特征在于,所述根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上的步骤之后,所述方法还包括:5. The method according to claim 1, wherein after the step of writing the overwriting content to the overwriting position in the target file according to the overwriting instruction, the overwriting Methods also include: 删除所述覆盖写指令,以及所述存储位置标识对应的文件中的覆盖写内容。The overwriting instruction and the overwriting content in the file corresponding to the storage location identifier are deleted. 6.根据权利要求4所述的方法,其特征在于,所述方法还包括:6. The method according to claim 4, wherein the method further comprises: 接收用户发送的目标文件的读取请求;Receive the read request of the target file sent by the user; 判断所述指定数据库中是否存在所述目标文件的覆盖写指令;Judging whether there is an overwrite instruction of the target file in the specified database; 如果存在,根据所述目标文件的覆盖写指令,从所述分布式文件系统中读取所述覆盖写指令对应的覆盖写内容和所述目标文件,将所述覆盖写内容与所述目标文件进行合并,将合并后的目标文件返回给所述用户;If there is, read the overwrite content corresponding to the overwrite instruction and the target file from the distributed file system according to the overwrite instruction of the target file, and compare the overwrite content with the target file Merge, and return the merged target file to the user; 如果不存在,从所述分布式文件系统中读取所述目标文件,将读取的所述目标文件返回给所述用户。If it does not exist, read the target file from the distributed file system, and return the read target file to the user. 7.根据权利要求4所述的方法,其特征在于,所述分布式文件系统中存储有所述目标文件的覆盖写版本号;7. The method according to claim 4, wherein the overwrite version number of the target file is stored in the distributed file system; 所述将所述覆盖写内容写入所述分布式文件系统中,得到所述覆盖写内容的存储位置标识的步骤之后,所述方法还包括:After the step of writing the overwritten content into the distributed file system to obtain the storage location identifier of the overwritten content, the method further includes: 接收所述分布式文件系统返回的所述目标文件的覆盖写版本号;receiving the overwrite version number of the target file returned by the distributed file system; 将所述覆盖写版本号写入所述覆盖写指令中;Writing the overwriting version number into the overwriting instruction; 所述根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上的步骤之后,所述方法还包括:After the step of writing the overwriting content to the overwriting position in the target file according to the overwriting instruction, the method further includes: 将所述分布式文件系统中的覆盖写版本号,更新为所述覆盖写指令中的覆盖写版本号与一的加和。The overwrite version number in the distributed file system is updated to the sum of the overwrite version number and one in the overwrite instruction. 8.根据权利要求1所述的方法,其特征在于,所述目标文件包括多个副本文件;8. The method according to claim 1, wherein the target file comprises a plurality of duplicate files; 根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上的步骤,包括:According to the overwriting instruction, the step of writing the overwriting content to the overwriting position in the target file includes: 针对所述目标文件的每个副本文件,根据所述覆盖写指令,将所述覆盖写内容写入当前副本文件中的所述覆盖写位置上。For each copy file of the target file, according to the overwriting instruction, write the overwriting content to the overwriting position in the current copy file. 9.根据权利要求8所述的方法,其特征在于,所述方法还包括:9. The method according to claim 8, wherein the method further comprises: 针对所述目标文件的每个副本文件,判断所述覆盖写内容是否成功写入当前副本文件中的所述覆盖写位置上;For each copy file of the target file, determine whether the overwrite content is successfully written to the overwrite position in the current copy file; 如果未成功写入,自动修复所述当前副本文件,并将所述覆盖写内容重新写入所述当前副本文件中,直到所述当前副本文件覆盖写成功。If it is not successfully written, the current copy file is automatically repaired, and the overwritten content is rewritten into the current copy file until the current copy file is successfully overwritten. 10.一种文件覆盖写装置,其特征在于,所述装置包括:10. A file overwriting device, wherein the device comprises: 指令获取模块,用于获取覆盖写指令;其中,所述覆盖写指令至少包括:需要进行覆盖写的目标文件的文件标识、覆盖写内容的存储位置标识和覆盖写位置;An instruction acquisition module, used for acquiring an overwriting instruction; wherein, the overwriting instruction at least includes: a file identifier of a target file that needs to be overwritten, a storage location identifier of the overwriting content, and an overwriting location; 覆盖写模块,用于根据所述覆盖写指令,将所述覆盖写内容写入所述目标文件中的所述覆盖写位置上。An overwriting module, configured to write the overwriting content to the overwriting position in the target file according to the overwriting instruction. 11.一种电子设备,其特征在于,所述电子设备包括处理器和存储器,所述存储器存储有能够被所述处理器执行的机器可执行指令,所述处理器执行所述机器可执行指令以实现权利要求1至9任一项所述的文件覆盖写方法。11. An electronic device, characterized in that the electronic device comprises a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions In order to realize the file overwriting method described in any one of claims 1 to 9. 12.一种机器可读存储介质,其特征在于,所述机器可读存储介质存储有机器可执行指令,所述机器可执行指令在被处理器调用和执行时,所述机器可执行指令促使处理器实现权利要求1至9任一项所述的文件覆盖写方法。12. A machine-readable storage medium, characterized in that the machine-readable storage medium stores machine-executable instructions that, when invoked and executed by a processor, cause the machine-executable instructions to The processor implements the file overwriting method according to any one of claims 1 to 9.
CN202110194994.5A 2021-02-19 2021-02-19 File overwriting method, device and electronic device Pending CN114968963A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110194994.5A CN114968963A (en) 2021-02-19 2021-02-19 File overwriting method, device and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110194994.5A CN114968963A (en) 2021-02-19 2021-02-19 File overwriting method, device and electronic device

Publications (1)

Publication Number Publication Date
CN114968963A true CN114968963A (en) 2022-08-30

Family

ID=82954205

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110194994.5A Pending CN114968963A (en) 2021-02-19 2021-02-19 File overwriting method, device and electronic device

Country Status (1)

Country Link
CN (1) CN114968963A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116069685A (en) * 2023-03-07 2023-05-05 浪潮电子信息产业股份有限公司 A storage system writing control method, device, equipment and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103049058A (en) * 2006-12-06 2013-04-17 弗森-艾奥公司 Apparatus, system, and method for storage space recovery in solid-state storage
CN106339473A (en) * 2016-08-29 2017-01-18 北京百度网讯科技有限公司 Method and device for copying file
CN106406770A (en) * 2016-09-28 2017-02-15 乐视控股(北京)有限公司 Data write-in method and system
CN109597818A (en) * 2018-11-28 2019-04-09 优刻得科技股份有限公司 Data-updating method, device, storage medium and equipment
CN109614385A (en) * 2018-12-11 2019-04-12 浪潮电子信息产业股份有限公司 A file updating method, apparatus, device and readable storage medium
CN110990480A (en) * 2018-09-30 2020-04-10 北京国双科技有限公司 Data processing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103049058A (en) * 2006-12-06 2013-04-17 弗森-艾奥公司 Apparatus, system, and method for storage space recovery in solid-state storage
CN106339473A (en) * 2016-08-29 2017-01-18 北京百度网讯科技有限公司 Method and device for copying file
CN106406770A (en) * 2016-09-28 2017-02-15 乐视控股(北京)有限公司 Data write-in method and system
CN110990480A (en) * 2018-09-30 2020-04-10 北京国双科技有限公司 Data processing method and device
CN109597818A (en) * 2018-11-28 2019-04-09 优刻得科技股份有限公司 Data-updating method, device, storage medium and equipment
CN109614385A (en) * 2018-12-11 2019-04-12 浪潮电子信息产业股份有限公司 A file updating method, apparatus, device and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116069685A (en) * 2023-03-07 2023-05-05 浪潮电子信息产业股份有限公司 A storage system writing control method, device, equipment and readable storage medium

Similar Documents

Publication Publication Date Title
US11385830B2 (en) Data storage method, apparatus and system, and server, control node and medium
CN111723056B (en) Small file processing method, device, equipment and storage medium
CN113064885B (en) A data cleaning method and device
US8412684B2 (en) Information creating apparatus, recording medium, method and retrieval method utilizing data structure containing hint and link information
CN113625952B (en) Object storage method, device, equipment and storage medium
CN114489762B (en) A method, system and electronic device for implementing multi-version application
CN113419901A (en) Data disaster recovery method and device and server
WO2025138618A1 (en) Stored data recovery method, apparatus and system, electronic device, and storage medium
CN116708563B (en) Archival data processing method, device, server and readable storage medium
CN113468118B (en) File increment storage method, device and storage medium based on blockchain
CN113806145A (en) Backup and recovery method and device for OpenStack virtualization platform based on Ceph storage
CN112748877A (en) File integration uploading method and device and file downloading method and device
CN110807000B (en) File repair method and device, electronic equipment and storage medium
CN113419897A (en) File processing method and device, electronic equipment and storage medium thereof
CN114968963A (en) File overwriting method, device and electronic device
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN111198885A (en) Data processing method and device
CN113656363B (en) A data deduplication method, system, device and storage medium based on HDFS
CN113448946A (en) Data migration method and device and electronic equipment
CN117971297A (en) Dependency package synchronization method, device, computer equipment and storage medium
CN114675776B (en) Resource storage method and device, storage medium and electronic device
CN113535482B (en) Cloud backup chain data backup method and device, equipment and readable medium
CN106407320B (en) File processing method, device and system
CN114764425A (en) Object updating method and device, storage medium and electronic equipment
CN114826877A (en) Asset alarm processing method and device, computer equipment and storage medium

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